query_name
stringlengths
13
55
code_file_path
stringlengths
14
194
context_blocks
list
answer_spans
list
supporting_fact_spans
list
example_type
int8
0
1
single_hop
bool
2 classes
subtokenized_input_sequence
list
label_sequence
list
Variable defined multiple times
rizar/attention-lvcsr/libs/Theano/theano/sparse/sandbox/test_sp.py
[ { "content": " @attr('slow')\n def test_sparse(self):\n\n# print '\\n\\n*************************************************'\n# print ' TEST SPARSE'\n# print '*************************************************'\n\n # fixed parameters\n bsize = 10 # batch size\n imshp = (8, 8)\n kshp = (5, 5)\n nkern = 1 # per output pixel\n ssizes = ((1, 1), (2, 2))\n convmodes = ('full', 'valid',)\n\n # symbolic stuff\n bias = tensor.dvector()\n kerns = tensor.dvector()\n input = tensor.dmatrix()\n rng = numpy.random.RandomState(3423489)\n\n import theano.gof as gof\n\n for mode in (None,):\n ntot, ttot = 0, 0\n for conv_mode in convmodes:\n for ss in ssizes:\n\n output, outshp = sp.applySparseFilter(kerns, kshp,\\\n nkern, input, imshp, ss, bias=bias, mode=conv_mode)\n f = function([kerns, bias, input], output, mode=mode)\n\n # build actual input images\n img2d = numpy.arange(bsize*numpy.prod(imshp)).reshape((bsize,)+imshp)\n img1d = img2d.reshape(bsize, -1)\n zeropad_img = numpy.zeros((bsize,\\\n img2d.shape[1]+2*(kshp[0]-1),\\\n img2d.shape[2]+2*(kshp[1]-1)))\n zeropad_img[:, kshp[0]-1:kshp[0]-1+img2d.shape[1],\n kshp[1]-1:kshp[1]-1+img2d.shape[2]] = img2d\n\n # build kernel matrix -- flatten it for theano stuff\n filters = numpy.arange(numpy.prod(outshp)*numpy.prod(kshp)).\\\n reshape(nkern, numpy.prod(outshp[1:]), numpy.prod(kshp))\n spfilt = filters.flatten()\n biasvals = numpy.arange(numpy.prod(outshp))\n\n # compute output by hand\n ntime1 = time.time()\n refout = numpy.zeros((bsize, nkern, outshp[1], outshp[2]))\n patch = numpy.zeros((kshp[0], kshp[1]))\n for b in xrange(bsize):\n for k in xrange(nkern):\n pixi = 0 # pixel index in raster order\n for j in xrange(outshp[1]):\n for i in xrange(outshp[2]):\n n = j * ss[0]\n m = i * ss[1]\n patch = zeropad_img[b, n:n+kshp[0], m:m+kshp[1]]\n refout[b, k, j, i] = numpy.dot(filters[k, pixi, :],\\\n patch.flatten())\n pixi += 1\n refout = refout.reshape(bsize, -1) + biasvals\n ntot += time.time() - ntime1\n\n # need to flatten images\n ttime1 = time.time()\n out1 = f(spfilt, biasvals, img1d)\n ttot += time.time() - ttime1\n\n temp = refout - out1\n assert (temp < 1e-10).all()\n\n # test downward propagation\n vis = tensor.grad(0.5*tensor.sqr(output).sum(), input)\n downprop = function([kerns, output], vis)\n temp1 = time.time()\n for zz in range(100):\n visval = downprop(spfilt, out1)\n indices, indptr, spmat_shape, sptype, outshp, kmap = \\\n sp.convolution_indices.sparse_eval(imshp, kshp, nkern, ss, conv_mode)\n spmat = sparse.csc_matrix((spfilt[kmap], indices, indptr), spmat_shape)\n visref = numpy.dot(out1, spmat.todense())\n assert numpy.all(visref == visval), (visref, visval)", "metadata": "root.TestSP.test_sparse", "header": "['class', 'TestSP', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 132 } ]
[ { "span": "patch ", "start_line": 182, "start_column": 20, "end_line": 182, "end_column": 25 } ]
[ { "span": "patch ", "start_line": 190, "start_column": 36, "end_line": 190, "end_column": 41 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Test", "SP_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "attr_", "(_", "'", "slow", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "sparse_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "print", " ", "'\\\\", "n", "\\\\", "n", "***********", "***********", "***********", "***********", "*****", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "print", " ", "'", " ", " ", " ", "TEST", " ", "SPAR", "SE", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "print", " ", "'*******", "***********", "***********", "***********", "********", "*'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fixed", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bsi", "ze_", "=_", "10_", "#", " ", "batch", " ", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ims", "hp_", "=_", "(_", "8_", ",_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ksh", "p_", "=_", "(_", "5_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nke", "rn_", "=_", "1_", "#", " ", "per", " ", "output", " ", "pixel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ssi", "zes", "_", "=_", "(_", "(_", "1_", ",_", "1_", ")_", ",_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conv", "modes_", "=_", "(_", "'", "full", "'_", ",_", "'", "valid", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "symbolic", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "bias_", "=_", "tensor_", "._", "dv", "ector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kern", "s_", "=_", "tensor_", "._", "dv", "ector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input_", "=_", "tensor_", "._", "dma", "trix_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rng_", "=_", "numpy_", "._", "random_", "._", "Random", "State_", "(_", "342", "348", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "theano_", "._", "gof", "_", "as_", "gof", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "mode_", "in_", "(_", "None_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nto", "t_", ",_", "tto", "t_", "=_", "0_", ",_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "conv", "\\u", "mode_", "in_", "conv", "modes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ss_", "in_", "ssi", "zes", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "output_", ",_", "outs", "hp_", "=_", "sp_", "._", "appl", "y", "Spar", "se", "Filter_", "(_", "kern", "s_", ",_", "ksh", "p_", ",_", "nke", "rn_", ",_", "input_", ",_", "ims", "hp_", ",_", "ss_", ",_", "bias_", "=_", "bias_", ",_", "mode_", "=_", "conv", "\\u", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "function_", "(_", "[_", "kern", "s_", ",_", "bias_", ",_", "input_", "]_", ",_", "output_", ",_", "mode_", "=_", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "actual", " ", "input", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "img", "2d_", "=_", "numpy_", "._", "arange_", "(_", "bsi", "ze_", "*_", "numpy_", "._", "prod_", "(_", "ims", "hp_", ")_", ")_", "._", "reshape_", "(_", "(_", "bsi", "ze_", ",_", ")_", "+_", "ims", "hp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img", "1d_", "=_", "img", "2d_", "._", "reshape_", "(_", "bsi", "ze_", ",_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zero", "pad", "\\u", "img_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "bsi", "ze_", ",_", "img", "2d_", "._", "shape_", "[_", "1_", "]_", "+_", "2_", "*_", "(_", "ksh", "p_", "[_", "0_", "]_", "-_", "1_", ")_", ",_", "img", "2d_", "._", "shape_", "[_", "2_", "]_", "+_", "2_", "*_", "(_", "ksh", "p_", "[_", "1_", "]_", "-_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zero", "pad", "\\u", "img_", "[_", ":_", ",_", "ksh", "p_", "[_", "0_", "]_", "-_", "1_", ":_", "ksh", "p_", "[_", "0_", "]_", "-_", "1_", "+_", "img", "2d_", "._", "shape_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ksh", "p_", "[_", "1_", "]_", "-_", "1_", ":_", "ksh", "p_", "[_", "1_", "]_", "-_", "1_", "+_", "img", "2d_", "._", "shape_", "[_", "2_", "]_", "]_", "=_", "img", "2d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "kernel", " ", "matrix", " ", "--", " ", "flat", "ten", " ", "it", " ", "for", " ", "theano", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "filters_", "=_", "numpy_", "._", "arange_", "(_", "numpy_", "._", "prod_", "(_", "outs", "hp_", ")_", "*_", "numpy_", "._", "prod_", "(_", "ksh", "p_", ")_", ")_", "._", "reshape_", "(_", "nke", "rn_", ",_", "numpy_", "._", "prod_", "(_", "outs", "hp_", "[_", "1_", ":_", "]_", ")_", ",_", "numpy_", "._", "prod_", "(_", "ksh", "p_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sp", "filt_", "=_", "filters_", "._", "flatten_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bias", "vals_", "=_", "numpy_", "._", "arange_", "(_", "numpy_", "._", "prod_", "(_", "outs", "hp_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compute", " ", "output", " ", "by", " ", "hand_", "\\u\\u\\uNL\\u\\u\\u_", "ntime", "1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ref", "out_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "bsi", "ze_", ",_", "nke", "rn_", ",_", "outs", "hp_", "[_", "1_", "]_", ",_", "outs", "hp_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "patch_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "ksh", "p_", "[_", "0_", "]_", ",_", "ksh", "p_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "b_", "in_", "xrange_", "(_", "bsi", "ze_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "k_", "in_", "xrange_", "(_", "nke", "rn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pix", "i_", "=_", "0_", "#", " ", "pixel", " ", "index", " ", "in", " ", "rast", "er", " ", "order_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "xrange_", "(_", "outs", "hp_", "[_", "1_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "i_", "in_", "xrange_", "(_", "outs", "hp_", "[_", "2_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "n_", "=_", "j_", "*_", "ss_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "i_", "*_", "ss_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "patch_", "=_", "zero", "pad", "\\u", "img_", "[_", "b_", ",_", "n_", ":_", "n_", "+_", "ksh", "p_", "[_", "0_", "]_", ",_", "m_", ":_", "m_", "+_", "ksh", "p_", "[_", "1_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ref", "out_", "[_", "b_", ",_", "k_", ",_", "j_", ",_", "i_", "]_", "=_", "numpy_", "._", "dot_", "(_", "filters_", "[_", "k_", ",_", "pix", "i_", ",_", ":_", "]_", ",_", "patch_", "._", "flatten_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pix", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ref", "out_", "=_", "ref", "out_", "._", "reshape_", "(_", "bsi", "ze_", ",_", "-_", "1_", ")_", "+_", "bias", "vals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nto", "t_", "+=_", "time_", "._", "time_", "(_", ")_", "-_", "ntime", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "flat", "ten", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "tti", "me", "1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out1_", "=_", "f_", "(_", "sp", "filt_", ",_", "bias", "vals_", ",_", "img", "1d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tto", "t_", "+=_", "time_", "._", "time_", "(_", ")_", "-_", "tti", "me", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "temp_", "=_", "ref", "out_", "-_", "out1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "(_", "temp_", "<_", "1e-10_", ")_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "down", "ward", " ", "propagat", "ion_", "\\u\\u\\uNL\\u\\u\\u_", "vis_", "=_", "tensor_", "._", "grad_", "(_", "0.5_", "*_", "tensor_", "._", "sqr", "_", "(_", "output_", ")_", "._", "sum_", "(_", ")_", ",_", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "down", "prop_", "=_", "function_", "(_", "[_", "kern", "s_", ",_", "output_", "]_", ",_", "vis_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "zz_", "in_", "range_", "(_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "vis", "val_", "=_", "down", "prop_", "(_", "sp", "filt_", ",_", "out1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "indices_", ",_", "indp", "tr_", ",_", "spm", "at", "\\u", "shape_", ",_", "spt", "ype_", ",_", "outs", "hp_", ",_", "kma", "p_", "=_", "sp_", "._", "convolution", "\\u", "indices_", "._", "spars", "e\\u", "eval_", "(_", "ims", "hp_", ",_", "ksh", "p_", ",_", "nke", "rn_", ",_", "ss_", ",_", "conv", "\\u", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "spm", "at_", "=_", "sparse_", "._", "csc", "\\u", "matrix_", "(_", "(_", "sp", "filt_", "[_", "kma", "p_", "]_", ",_", "indices_", ",_", "indp", "tr_", ")_", ",_", "spm", "at", "\\u", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vis", "ref_", "=_", "numpy_", "._", "dot_", "(_", "out1_", ",_", "spm", "at_", "._", "tod", "ense", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "numpy_", "._", "all_", "(_", "vis", "ref_", "==_", "vis", "val_", ")_", ",_", "(_", "vis", "ref_", ",_", "vis", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Comparison using is when operands support `__eq__`
uci-cbcl/tree-hmm/gmtkParam/__init__.py
[ { "content": " def _convertSlices(self, item):\n var = []\n cond = []\n cur = var\n if not issequence(item):\n item = [item]\n for i in item:\n if isinstance(i, slice):\n if cur is cond:\n raise ValueError(\"Malformed probability index\")\n if i.step is not None:\n raise ValueError(\"Malformed probability index\")\n if i.start is not None:\n var.append(i.start)\n if i.stop is None:\n raise ValueError(\"Malformed probability index\")\n else:\n cond.append(i.stop)\n cur = cond\n else:\n cur.append(i)\n return tuple(var), tuple(cond)", "metadata": "root.ProbTable._convertSlices", "header": "['class', 'ProbTable', '(', 'object', ')', ':', '___EOS___']", "index": 104 } ]
[ { "span": "cur is cond:", "start_line": 112, "start_column": 19, "end_line": 112, "end_column": 30 } ]
[]
1
false
[ "[CLS]_", "Compari", "son_", "using_", "is_", "when_", "operands_", "support_", " _", "`_", "\\u\\u", "eq\\u\\u_", "`_", "[SEP]_", "class_", "Prob", "Table_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "convert", "Slice", "s_", "(_", "self_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "var_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cond_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur_", "=_", "var_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isse", "quenc", "e_", "(_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "=_", "[_", "item_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "i_", ",_", "slice_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cur_", "is_", "cond_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Value", "Error_", "(_", "\"", "Mal", "formed", " ", "probabilit", "y", " ", "index", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i_", "._", "step_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Value", "Error_", "(_", "\"", "Mal", "formed", " ", "probabilit", "y", " ", "index", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i_", "._", "start_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "var_", "._", "append_", "(_", "i_", "._", "start_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i_", "._", "stop_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Value", "Error_", "(_", "\"", "Mal", "formed", " ", "probabilit", "y", " ", "index", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "cond_", "._", "append_", "(_", "i_", "._", "stop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cur_", "=_", "cond_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cur_", "._", "append_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "tuple_", "(_", "var_", ")_", ",_", "tuple_", "(_", "cond_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
plamere/spotipy/examples/show_related.py
[ { "content": "\n# shows related artists for the given seed artist\n\nimport spotipy\nimport sys\nimport pprint\n\nif len(sys.argv) > 1:\n artist_name = sys.argv[1]\nelse:\n artist_name = 'weezer'\n\nsp = spotipy.Spotify()\nresult = sp.search(q='artist:' + artist_name, type='artist')\ntry:\n name = result['artists']['items'][0]['name']\n uri = result['artists']['items'][0]['uri']\n\n related = sp.artist_related_artists(uri)\n print('Related artists for', name)\n for artist in related['artists']:\n print(' ', artist['name'])\nexcept:\n print(\"usage show_related.py [artist-name]\")\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import pprint", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "show", "s", " ", "relate", "d", " ", "artist", "s", " ", "for", " ", "the", " ", "give", "n", " ", "seed", " ", "artist_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "spoti", "py_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "sys_", "._", "argv_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist", "\\u", "name_", "=_", "sys_", "._", "argv_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist", "\\u", "name_", "=_", "'", "wee", "zer", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sp_", "=_", "spoti", "py_", "._", "Spot", "ify_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "sp_", "._", "search_", "(_", "q_", "=_", "'", "artist", ":'_", "+_", "artist", "\\u", "name_", ",_", "type_", "=_", "'", "artist", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "result_", "[_", "'", "artist", "s", "'_", "]_", "[_", "'", "items", "'_", "]_", "[_", "0_", "]_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uri_", "=_", "result_", "[_", "'", "artist", "s", "'_", "]_", "[_", "'", "items", "'_", "]_", "[_", "0_", "]_", "[_", "'", "uri", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "related_", "=_", "sp_", "._", "artist", "\\u", "relate", "d\\u", "artists_", "(_", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "Rela", "ted", " ", "artist", "s", " ", "for", "'_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "artist_", "in_", "related_", "[_", "'", "artist", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", " ", " ", "'_", ",_", "artist_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "usage", " ", "show", "\\u", "relate", "d", ".", "py", " ", "[", "artist", "-", "name", "]\"_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
sfu-natlang/Kriya/src/Kriya-Decoder/languageModelManager.py
[ { "content": " def mergeAntecedents(self, anteHyps, anteItems, lm_order, lm_obj):\n\n mgram_beg = 0\n e_new_len = 0\n eTgtLstNew = []\n tgtItems = []\n phrStateTupLst = []\n curr_state = None\n old_e_tgt = ''\n\n for term in self.eTgtLst:\n if term == \"X__1\" or term == \"S__1\":\n tgtItems.append(anteHyps[0])\n tempLst = anteItems[0].eTgtLst\n old_e_tgt = ' '.join(tempLst)\n next_state = anteItems[0].r_lm_state\n elif term == \"X__2\":\n tgtItems.append(anteHyps[1])\n tempLst = anteItems[1].eTgtLst\n next_state = anteItems[1].r_lm_state\n else:\n tgtItems.append(term)\n eTgtLstNew.append(term)\n e_new_len += 1\n continue\n\n eTgtLstNew.extend(tempLst)\n mgram_beg, curr_state = self.handleEdges(lm_order, mgram_beg, e_new_len, curr_state, next_state, tempLst, eTgtLstNew)\n e_new_len += len(tempLst)\n\n self.elideNewTgt(old_e_tgt, lm_obj, lm_order, mgram_beg, e_new_len, curr_state, eTgtLstNew)\n return ' '.join(tgtItems)", "metadata": "root.ConsequentItem.mergeAntecedents", "header": "['class', 'ConsequentItem', '(', 'object', ')', ':', '___EOS___']", "index": 232 } ]
[ { "span": "phrStateTupLst ", "start_line": 238, "start_column": 8, "end_line": 238, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Conse", "que", "nt", "Item_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "merge", "Ant", "ece", "dent", "s_", "(_", "self_", ",_", "ante", "Hyp", "s_", ",_", "ante", "Items_", ",_", "lm", "\\u", "order_", ",_", "lm", "\\u", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mgr", "am", "\\u", "beg_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "new", "\\u", "len_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e", "Tg", "t", "Lst", "New_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tgt", "Items_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "phr", "State", "Tup", "Lst_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "\\u", "state_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "e\\u", "tgt_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "term_", "in_", "self_", "._", "e", "Tg", "t", "Lst_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "term_", "==_", "\"", "X", "\\u\\u", "1", "\"_", "or_", "term_", "==_", "\"", "S", "\\u\\u", "1", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tgt", "Items_", "._", "append_", "(_", "ante", "Hyp", "s_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "Lst_", "=_", "ante", "Items_", "[_", "0_", "]_", "._", "e", "Tg", "t", "Lst_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "e\\u", "tgt_", "=_", "'", " ", "'_", "._", "join_", "(_", "temp", "Lst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next", "\\u", "state_", "=_", "ante", "Items_", "[_", "0_", "]_", "._", "r", "\\u", "lm", "\\u", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "term_", "==_", "\"", "X", "\\u\\u", "2", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tgt", "Items_", "._", "append_", "(_", "ante", "Hyp", "s_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "Lst_", "=_", "ante", "Items_", "[_", "1_", "]_", "._", "e", "Tg", "t", "Lst_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next", "\\u", "state_", "=_", "ante", "Items_", "[_", "1_", "]_", "._", "r", "\\u", "lm", "\\u", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tgt", "Items_", "._", "append_", "(_", "term_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e", "Tg", "t", "Lst", "New_", "._", "append_", "(_", "term_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "new", "\\u", "len_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "e", "Tg", "t", "Lst", "New_", "._", "extend_", "(_", "temp", "Lst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mgr", "am", "\\u", "beg_", ",_", "curr", "\\u", "state_", "=_", "self_", "._", "handle", "Edges_", "(_", "lm", "\\u", "order_", ",_", "mgr", "am", "\\u", "beg_", ",_", "e\\u", "new", "\\u", "len_", ",_", "curr", "\\u", "state_", ",_", "next", "\\u", "state_", ",_", "temp", "Lst_", ",_", "e", "Tg", "t", "Lst", "New_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e\\u", "new", "\\u", "len_", "+=_", "len_", "(_", "temp", "Lst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "eli", "de", "New", "Tg", "t_", "(_", "old", "\\u", "e\\u", "tgt_", ",_", "lm", "\\u", "obj_", ",_", "lm", "\\u", "order_", ",_", "mgr", "am", "\\u", "beg_", ",_", "e\\u", "new", "\\u", "len_", ",_", "curr", "\\u", "state_", ",_", "e", "Tg", "t", "Lst", "New_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'", " ", "'_", "._", "join_", "(_", "tgt", "Items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
gferreira/hTools2/Lib/hTools2/extras/outline.py
[ { "content": "# outline.py\n\n# by Frederik Berlaen/TypeMyType\n# https://github.com/typemytype/RoboFontExtensions/blob/master/outliner/Outliner.roboFontExt/lib/outline.py\n\nfrom vanilla import *\nfrom AppKit import *\n\nfrom fontTools.pens.cocoaPen import CocoaPen\n\ntry:\n from lib.tools.bezierTools import curveConverter\nexcept:\n print 'running outside of RoboFont'\n\nfrom fontTools.pens.basePen import BasePen\nfrom robofab.pens.pointPen import AbstractPointPen\nfrom robofab.pens.reverseContourPointPen import ReverseContourPointPen\nfrom robofab.pens.adapterPens import PointToSegmentPen\n\nfrom robofab.world import CurrentGlyph\n\nfrom defcon import Glyph\nfrom math import sqrt, cos, sin, acos, asin, degrees, radians, tan, pi\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def roundFloat(f):\n error = 1000000.\n return round(f*error)/error", "metadata": "root.roundFloat", "header": "['module', '___EOS___']", "index": 25 }, { "content": "def checkSmooth(firstAngle, lastAngle):\n if firstAngle == None or lastAngle == None:\n return True\n error = 4\n firstAngle = degrees(firstAngle)\n lastAngle = degrees(lastAngle)\n\n if int(firstAngle) + error >= int(lastAngle) >= int(firstAngle) - error:\n return True\n return False", "metadata": "root.checkSmooth", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def checkInnerOuter(firstAngle, lastAngle):\n if firstAngle == None or lastAngle == None:\n return True\n dirAngle = degrees(firstAngle) - degrees(lastAngle)\n\n if dirAngle > 180:\n dirAngle = 180 - dirAngle\n elif dirAngle < -180:\n dirAngle= -180 - dirAngle\n\n if dirAngle > 0:\n return True\n\n if dirAngle <= 0:\n return False", "metadata": "root.checkInnerOuter", "header": "['module', '___EOS___']", "index": 40 }, { "content": "def interSect((seg1s, seg1e), (seg2s, seg2e)):\n denom = (seg2e.y - seg2s.y)*(seg1e.x - seg1s.x) - (seg2e.x - seg2s.x)*(seg1e.y - seg1s.y)\n if roundFloat(denom) == 0:\n #print 'parallel: %s' % denom\n return None\n uanum = (seg2e.x - seg2s.x)*(seg1s.y - seg2s.y) - (seg2e.y - seg2s.y)*(seg1s.x - seg2s.x)\n ubnum = (seg1e.x - seg1s.x)*(seg1s.y - seg2s.y) - (seg1e.y - seg1s.y)*(seg1s.x - seg2s.x)\n ua = uanum/denom\n ub = ubnum/denom\n x = seg1s.x + ua*(seg1e.x - seg1s.x)\n y = seg1s.y + ua*(seg1e.y - seg1s.y)\n return MathPoint(x, y)", "metadata": "root.interSect", "header": "['module', '___EOS___']", "index": 56 }, { "content": "def pointOnACurve((x1, y1), (cx1, cy1), (cx2, cy2), (x2, y2), value):\n #, handle = False , order = False):\n dx = x1\n cx = (cx1 - dx) * 3.0\n bx = (cx2 - cx1) * 3.0 - cx\n ax = x2 - dx - cx - bx\n dy = y1\n cy = (cy1 - dy) * 3.0\n by = (cy2 - cy1) * 3.0 - cy\n ay = y2 - dy - cy - by\n mx = ax*(value)**3 + bx*(value)**2 + cx*(value) + dx\n my = ay*(value)**3 + by*(value)**2 + cy*(value) + dy\n return MathPoint(mx, my)", "metadata": "root.pointOnACurve", "header": "['module', '___EOS___']", "index": 69 }, { "content": "class MathPoint(object):\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.MathPoint", "header": "['module', '___EOS___']", "index": 83 }, { "content": " def __init__(self, x, y=None):\n if y is None:\n x, y = x\n self.x = x\n self.y = y", "metadata": "root.MathPoint.__init__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 85 }, { "content": " def __repr__(self): #### print p\n return \"<MathPoint x:%s y:%s>\" %(self.x, self.y)", "metadata": "root.MathPoint.__repr__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 91 }, { "content": " def __getitem__(self, index):\n if index == 0:\n return self.x\n if index == 1:\n return self.y\n raise IndexError", "metadata": "root.MathPoint.__getitem__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 94 }, { "content": " def __iter__(self):\n for value in [self.x, self.y]:\n yield value", "metadata": "root.MathPoint.__iter__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 101 }, { "content": " def __add__(self, p): # p+ p\n if not isinstance(p, self.__class__):\n return self.__class__(self.x + p, self.y + p)\n return self.__class__(self.x + p.x, self.y + p.y)", "metadata": "root.MathPoint.__add__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 105 }, { "content": " def __sub__(self, p): #p - p\n if not isinstance(p, self.__class__):\n return self.__class__(self.x - p, self.y - p)\n return self.__class__(self.x - p.x, self.y - p.y)", "metadata": "root.MathPoint.__sub__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 110 }, { "content": " def __mul__(self, p): ## p * p\n if not isinstance(p, self.__class__):\n return self.__class__(self.x * p, self.y * p)\n return self.__class__(self.x * p.x, self.y * p.y)", "metadata": "root.MathPoint.__mul__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 115 }, { "content": " def __div__(self, p):\n if not isinstance(p, self.__class__):\n return self.__class__(self.x / p, self.y / p)\n return self.__class__(self.x / p.x, self.y / p.y)", "metadata": "root.MathPoint.__div__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 120 }, { "content": " def __eq__(self, p): ## if p == p\n if not isinstance(p,self.__class__):\n return False\n return roundFloat(self.x) == roundFloat(p.x) and roundFloat(self.y) == roundFloat(p.y)", "metadata": "root.MathPoint.__eq__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 125 }, { "content": " def __ne__(self, p): ## if p != p\n return not self.__eq__(p)", "metadata": "root.MathPoint.__ne__", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 130 }, { "content": " def copy(self):\n return self.__class__(self.x, self.y)", "metadata": "root.MathPoint.copy", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 133 }, { "content": " def round(self):\n self.x = round(self.x)\n self.y = round(self.y)", "metadata": "root.MathPoint.round", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 136 }, { "content": " def distance(self, p):\n return sqrt((p.x - self.x)**2 + (p.y - self.y)**2)", "metadata": "root.MathPoint.distance", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 140 }, { "content": " def angle(self, other, add=90):\n #### returns the angle of the Line in degrees\n b = other.x - self.x\n a = other.y - self.y\n c = sqrt(a**2 + b**2)\n if c == 0:\n return None\n if add is None:\n return b/c\n cosAngle = degrees(acos(b/c))\n sinAngle = degrees(asin(a/c))\n if sinAngle < 0:\n cosAngle = 360 - cosAngle\n return radians(cosAngle + add)", "metadata": "root.MathPoint.angle", "header": "['class', 'MathPoint', '(', 'object', ')', ':', '___EOS___']", "index": 143 }, { "content": "class CleanPointPen(AbstractPointPen):\n\n\n\n\n\n", "metadata": "root.CleanPointPen", "header": "['module', '___EOS___']", "index": 158 }, { "content": " def __init__(self, pointPen):\n self.pointPen = pointPen\n self.currentContour = None", "metadata": "root.CleanPointPen.__init__", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 160 }, { "content": " def processContour(self):\n pointPen = self.pointPen\n contour = self.currentContour\n\n index = 0\n prevAngle = None\n toRemove = []\n for data in contour:\n if data[\"segmentType\"] in [\"line\", \"move\"]:\n prevPoint = contour[index-1]\n if prevPoint[\"segmentType\"] in [\"line\", \"move\"]:\n angle = MathPoint(data[\"point\"]).angle(MathPoint(prevPoint[\"point\"]), None)\n if prevAngle is not None and angle is not None and roundFloat(prevAngle) == roundFloat(angle):\n toRemove.append(prevPoint)\n prevAngle = angle\n else:\n prevAngle = None\n else:\n prevAngle = None\n index += 1\n\n for data in toRemove:\n contour.remove(data)\n\n pointPen.beginPath()\n for data in contour:\n pointPen.addPoint(data[\"point\"], **data)\n pointPen.endPath()", "metadata": "root.CleanPointPen.processContour", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 164 }, { "content": " def beginPath(self):\n assert self.currentContour is None\n self.currentContour = []\n self.onCurve = []", "metadata": "root.CleanPointPen.beginPath", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 193 }, { "content": " def endPath(self):\n assert self.currentContour is not None\n self.processContour()\n self.currentContour = None", "metadata": "root.CleanPointPen.endPath", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 198 }, { "content": " def addPoint(self, pt, segmentType=None, smooth=False, name=None, **kwargs):\n data = dict(point=pt, segmentType=segmentType, smooth=smooth, name=name)\n data.update(kwargs)\n self.currentContour.append(data)", "metadata": "root.CleanPointPen.addPoint", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 203 }, { "content": " def addComponent(self, glyphName, transform):\n assert self.currentContour is None\n self.pointPen.addComponent(glyphName, transform)", "metadata": "root.CleanPointPen.addComponent", "header": "['class', 'CleanPointPen', '(', 'AbstractPointPen', ')', ':', '___EOS___']", "index": 208 }, { "content": "class OutlinePen(BasePen):\n\n pointClass = MathPoint\n magicCurve = 0.5522847498\n\n\n\n\n\n\n\n ## connections\n\n\n\n\n\n\n\n ## caps\n\n\n\n\n\n\n\n", "metadata": "root.OutlinePen", "header": "['module', '___EOS___']", "index": 212 }, { "content": " def __init__(self, glyphSet, offset=10, connection=\"square\", cap=\"round\", miterLimit=None, closeOpenPaths=True):\n BasePen.__init__(self, glyphSet)\n\n self.offset = abs(offset)\n self._inputmiterLimit = miterLimit\n if miterLimit is None:\n miterLimit = self.offset\n self.miterLimit = abs(miterLimit)\n\n self.closeOpenPaths = closeOpenPaths\n\n self.connectionCallback = getattr(self, \"connection%s\" %(connection[0].capitalize() + connection[1:]))\n self.capCallback = getattr(self, \"cap%s\" %(cap[0].capitalize() + cap[1:]))\n\n self.originalGlyph = Glyph()\n self.originalPen = self.originalGlyph.getPen()\n\n self.outerGlyph = Glyph()\n self.outerPen = self.outerGlyph.getPen()\n self.outerCurrentPoint = None\n self.outerFirstPoint = None\n self.outerPrevPoint = None\n\n self.innerGlyph = Glyph()\n self.innerPen = self.innerGlyph.getPen()\n self.innerCurrentPoint = None\n self.innerFirstPoint = None\n self.innerPrevPoint = None\n\n self.prevPoint = None\n self.firstPoint = None\n self.firstAngle = None\n self.prevAngle = None\n\n self.shouldHandleMove = True\n\n self.drawSettings()", "metadata": "root.OutlinePen.__init__", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 217 }, { "content": " def _moveTo(self, (x, y)):\n if self.offset == 0:\n self.outerPen.moveTo((x, y))\n self.innerPen.moveTo((x, y))\n return\n self.originalPen.moveTo((x, y))\n\n p = self.pointClass(x, y)\n self.prevPoint = p\n self.firstPoint = p\n self.shouldHandleMove = True", "metadata": "root.OutlinePen._moveTo", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 255 }, { "content": " def _lineTo(self, (x, y)):\n if self.offset == 0:\n self.outerPen.lineTo((x, y))\n self.innerPen.lineTo((x, y))\n return\n self.originalPen.lineTo((x, y))\n\n currentPoint = self.pointClass(x, y)\n if currentPoint == self.prevPoint:\n return\n\n self.currentAngle = self.prevPoint.angle(currentPoint)\n\n self.innerCurrentPoint = self.prevPoint - self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * self.offset\n self.outerCurrentPoint = self.prevPoint + self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * self.offset\n\n if self.shouldHandleMove:\n self.shouldHandleMove = False\n\n self.innerPen.moveTo(self.innerCurrentPoint)\n self.innerFirstPoint = self.innerCurrentPoint\n\n self.outerPen.moveTo(self.outerCurrentPoint)\n self.outerFirstPoint = self.outerCurrentPoint\n\n self.firstAngle = self.currentAngle\n else:\n self.buildConnection()\n\n self.innerCurrentPoint = currentPoint - self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * self.offset\n self.innerPen.lineTo(self.innerCurrentPoint)\n self.innerPrevPoint = self.innerCurrentPoint\n\n self.outerCurrentPoint = currentPoint + self.pointClass(cos(self.currentAngle), sin(self.currentAngle)) * self.offset\n self.outerPen.lineTo(self.outerCurrentPoint)\n self.outerPrevPoint = self.outerCurrentPoint\n\n self.prevPoint = currentPoint\n self.prevAngle = self.currentAngle", "metadata": "root.OutlinePen._lineTo", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 267 }, { "content": " def _curveToOne(self, (x1, y1), (x2, y2), (x3, y3)):\n if self.offset == 0:\n self.outerPen.curveTo((x1, y1), (x2, y2), (x3, y3))\n self.innerPen.curveTo((x1, y1), (x2, y2), (x3, y3))\n return\n self.originalPen.curveTo((x1, y1), (x2, y2), (x3, y3))\n\n p1 = self.pointClass(x1, y1)\n p2 = self.pointClass(x2, y2)\n p3 = self.pointClass(x3, y3)\n\n if p1 == self.prevPoint:\n p1 = pointOnACurve(self.prevPoint, p1, p2, p3, 0.01)\n if p2 == p3:\n p2 = pointOnACurve(self.prevPoint, p1, p2, p3, 0.99)\n\n a1 = self.prevPoint.angle(p1)\n a2 = p2.angle(p3)\n\n self.currentAngle = a1\n\n a1bis = self.prevPoint.angle(p1, 0)\n a2bis = p3.angle(p2, 0)\n intersectPoint = interSect((self. prevPoint, self.prevPoint + self.pointClass(cos(a1), sin(a1)) * 100),\n (p3, p3 + self.pointClass(cos(a2), sin(a2)) * 100))\n self.innerCurrentPoint = self.prevPoint - self.pointClass(cos(a1), sin(a1)) * self.offset\n self.outerCurrentPoint = self.prevPoint + self.pointClass(cos(a1), sin(a1)) * self.offset\n\n if self.shouldHandleMove:\n self.shouldHandleMove = False\n\n self.innerPen.moveTo(self.innerCurrentPoint)\n self.innerFirstPoint = self.innerCurrentPoint\n\n self.outerPen.moveTo(self.outerCurrentPoint)\n self.outerFirstPoint = self.outerCurrentPoint\n\n self.firstAngle = a1\n else:\n self.buildConnection()\n h1 = None\n if intersectPoint is not None:\n h1 = interSect((self.innerCurrentPoint, self.innerCurrentPoint + self.pointClass(cos(a1bis), sin(a1bis)) * self.offset), (intersectPoint, p1))\n if h1 is None:\n h1 = p1 - self.pointClass(cos(a1), sin(a1)) * self.offset\n\n self.innerCurrentPoint = p3 - self.pointClass(cos(a2), sin(a2)) * self.offset\n\n h2 = None\n if intersectPoint is not None:\n h2 = interSect((self.innerCurrentPoint, self.innerCurrentPoint + self.pointClass(cos(a2bis), sin(a2bis)) * self.offset), (intersectPoint, p2))\n if h2 is None:\n h2 = p2 - self.pointClass(cos(a1), sin(a1)) * self.offset\n\n self.innerPen.curveTo(h1, h2, self.innerCurrentPoint)\n self.innerPrevPoint = self.innerCurrentPoint\n\n ########\n h1 = None\n if intersectPoint is not None:\n h1 = interSect((self.outerCurrentPoint, self.outerCurrentPoint + self.pointClass(cos(a1bis), sin(a1bis)) * self.offset), (intersectPoint, p1))\n if h1 is None:\n h1 = p1 + self.pointClass(cos(a1), sin(a1)) * self.offset\n\n self.outerCurrentPoint = p3 + self.pointClass(cos(a2), sin(a2)) * self.offset\n\n h2 = None\n if intersectPoint is not None:\n h2 = interSect((self.outerCurrentPoint, self.outerCurrentPoint + self.pointClass(cos(a2bis), sin(a2bis)) * self.offset), (intersectPoint, p2))\n if h2 is None:\n h2 = p2 + self.pointClass(cos(a1), sin(a1)) * self.offset\n self.outerPen.curveTo(h1, h2, self.outerCurrentPoint)\n self.outerPrevPoint = self.outerCurrentPoint\n\n self.prevPoint = p3\n self.currentAngle = a2\n self.prevAngle = a2", "metadata": "root.OutlinePen._curveToOne", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 307 }, { "content": " def _closePath(self):\n if self.shouldHandleMove:\n return\n if self.offset == 0:\n self.outerPen.closePath()\n self.innerPen.closePath()\n return\n\n if not self.prevPoint == self.firstPoint:\n self._lineTo(self.firstPoint)\n\n self.originalPen.closePath()\n\n self.innerPrevPoint = self.innerCurrentPoint\n self.innerCurrentPoint = self.innerFirstPoint\n\n self.outerPrevPoint = self.outerCurrentPoint\n self.outerCurrentPoint = self.outerFirstPoint\n\n self.prevAngle = self.currentAngle\n self.currentAngle = self.firstAngle\n\n self.buildConnection(close=True)\n\n self.innerPen.closePath()\n self.outerPen.closePath()", "metadata": "root.OutlinePen._closePath", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 385 }, { "content": " def _endPath(self):\n if self.shouldHandleMove:\n return\n\n self.originalPen.endPath()\n self.innerPen.endPath()\n self.outerPen.endPath()\n\n if self.closeOpenPaths:\n\n innerContour = self.innerGlyph[-1]\n outerContour = self.outerGlyph[-1]\n\n innerContour.reverse()\n\n innerContour[0].segmentType = \"line\"\n outerContour[0].segmentType = \"line\"\n\n self.buildCap(outerContour, innerContour)\n\n for point in innerContour:\n outerContour.addPoint((point.x, point.y), segmentType=point.segmentType, smooth=point.smooth)\n\n self.innerGlyph.removeContour(innerContour)", "metadata": "root.OutlinePen._endPath", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 412 }, { "content": " def buildConnection(self, close=False):\n if not checkSmooth(self.prevAngle, self.currentAngle):\n if checkInnerOuter(self.prevAngle, self.currentAngle):\n self.connectionCallback(self.outerPrevPoint, self.outerCurrentPoint, self.outerPen, close)\n self.connectionInnerCorner(self.innerPrevPoint, self.innerCurrentPoint, self.innerPen, close)\n else:\n self.connectionCallback(self.innerPrevPoint, self.innerCurrentPoint, self.innerPen, close)\n self.connectionInnerCorner(self.outerPrevPoint, self.outerCurrentPoint, self.outerPen, close)", "metadata": "root.OutlinePen.buildConnection", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 439 }, { "content": " def connectionSquare(self, first, last, pen, close):\n angle_1 = radians(degrees(self.prevAngle)+90)\n angle_2 = radians(degrees(self.currentAngle)+90)\n\n tempFirst = first - self.pointClass(cos(angle_1), sin(angle_1)) * self.miterLimit\n tempLast = last + self.pointClass(cos(angle_2), sin(angle_2)) * self.miterLimit\n\n newPoint = interSect((first, tempFirst), (last, tempLast))\n if newPoint is not None:\n\n if self._inputmiterLimit is not None and roundFloat(newPoint.distance(first)) > self._inputmiterLimit:\n pen.lineTo(tempFirst)\n pen.lineTo(tempLast)\n else:\n pen.lineTo(newPoint)\n\n if not close:\n pen.lineTo(last)", "metadata": "root.OutlinePen.connectionSquare", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 448 }, { "content": " def connectionRound(self, first, last, pen, close):\n angle_1 = radians(degrees(self.prevAngle)+90)\n angle_2 = radians(degrees(self.currentAngle)+90)\n\n tempFirst = first - self.pointClass(cos(angle_1), sin(angle_1)) * self.miterLimit\n tempLast = last + self.pointClass(cos(angle_2), sin(angle_2)) * self.miterLimit\n\n newPoint = interSect((first, tempFirst), (last, tempLast))\n if newPoint is None:\n pen.lineTo(last)\n return\n distance = newPoint.distance(first)\n\n if roundFloat(distance) > self.miterLimit:\n distance = self.miterLimit + tempFirst.distance(tempLast) * .7\n\n distance *= self.magicCurve\n\n bcp1 = first - self.pointClass(cos(angle_1), sin(angle_1)) * distance\n bcp2 = last + self.pointClass(cos(angle_2), sin(angle_2)) * distance\n pen.curveTo(bcp1, bcp2, last)", "metadata": "root.OutlinePen.connectionRound", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 467 }, { "content": " def connectionButt(self, first, last, pen, close):\n if not close:\n pen.lineTo(last)", "metadata": "root.OutlinePen.connectionButt", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 489 }, { "content": " def connectionInnerCorner(self, first, last, pen, close):\n if not close:\n pen.lineTo(last)", "metadata": "root.OutlinePen.connectionInnerCorner", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 493 }, { "content": " def buildCap(self, firstContour, lastContour):\n first = firstContour[-1]\n last = lastContour[0]\n first = self.pointClass(first.x, first.y)\n last = self.pointClass(last.x, last.y)\n\n self.capCallback(firstContour, lastContour, first, last, self.prevAngle)\n\n first = lastContour[-1]\n last = firstContour[0]\n first = self.pointClass(first.x, first.y)\n last = self.pointClass(last.x, last.y)\n\n angle = radians(degrees(self.firstAngle)+180)\n self.capCallback(lastContour, firstContour, first, last, angle)", "metadata": "root.OutlinePen.buildCap", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 500 }, { "content": " def capButt(self, firstContour, lastContour, first, last, angle):\n ## not nothing\n pass", "metadata": "root.OutlinePen.capButt", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 516 }, { "content": " def capRound(self, firstContour, lastContour, first, last, angle):\n hookedAngle = radians(degrees(angle)+90)\n\n p1 = first - self.pointClass(cos(hookedAngle), sin(hookedAngle)) * self.offset\n\n p2 = last - self.pointClass(cos(hookedAngle), sin(hookedAngle)) * self.offset\n\n oncurve = p1 + (p2-p1)*.5\n\n roundness = .54\n\n h1 = first - self.pointClass(cos(hookedAngle), sin(hookedAngle)) * self.offset * roundness\n h2 = oncurve + self.pointClass(cos(angle), sin(angle)) * self.offset * roundness\n\n firstContour[-1].smooth = True\n\n firstContour.addPoint((h1.x, h1.y))\n firstContour.addPoint((h2.x, h2.y))\n firstContour.addPoint((oncurve.x, oncurve.y), smooth=True, segmentType=\"curve\")\n\n h1 = oncurve - self.pointClass(cos(angle), sin(angle)) * self.offset * roundness\n h2 = last - self.pointClass(cos(hookedAngle), sin(hookedAngle)) * self.offset * roundness\n\n firstContour.addPoint((h1.x, h1.y))\n firstContour.addPoint((h2.x, h2.y))\n\n lastContour[0].segmentType = \"curve\"\n lastContour[0].smooth = True", "metadata": "root.OutlinePen.capRound", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 520 }, { "content": " def capSquare(self, firstContour, lastContour, first, last, angle):\n angle = radians(degrees(angle)+90)\n\n firstContour[-1].smooth = True\n lastContour[0].smooth = True\n\n p1 = first - self.pointClass(cos(angle), sin(angle)) * self.offset\n firstContour.addPoint((p1.x, p1.y), smooth=False, segmentType=\"line\")\n\n p2 = last - self.pointClass(cos(angle), sin(angle)) * self.offset\n firstContour.addPoint((p2.x, p2.y), smooth=False, segmentType=\"line\")", "metadata": "root.OutlinePen.capSquare", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 549 }, { "content": " def drawSettings(self, drawOriginal=False, drawInner=False, drawOuter=True):\n self.drawOriginal = drawOriginal\n self.drawInner = drawInner\n self.drawOuter = drawOuter", "metadata": "root.OutlinePen.drawSettings", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 561 }, { "content": " def drawPoints(self, pointPen):\n if self.drawInner:\n reversePen = ReverseContourPointPen(pointPen)\n self.innerGlyph.drawPoints(CleanPointPen(reversePen))\n if self.drawOuter:\n self.outerGlyph.drawPoints(CleanPointPen(pointPen))\n\n if self.drawOriginal:\n if self.drawOuter:\n pointPen = ReverseContourPointPen(pointPen)\n self.originalGlyph.drawPoints(CleanPointPen(pointPen))", "metadata": "root.OutlinePen.drawPoints", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 566 }, { "content": " def draw(self, pen):\n pointPen = PointToSegmentPen(pen)\n self.drawPoints(pointPen)", "metadata": "root.OutlinePen.draw", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 578 }, { "content": " def getGlyph(self):\n glyph = Glyph()\n pointPen = glyph.getPointPen()\n self.drawPoints(pointPen)\n return glyph", "metadata": "root.OutlinePen.getGlyph", "header": "['class', 'OutlinePen', '(', 'BasePen', ')', ':', '___EOS___']", "index": 582 } ]
[ { "span": "from fontTools.pens.cocoaPen import CocoaPen", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 44 }, { "span": "from lib.tools.bezierTools import curveConverter", "start_line": 11, "start_column": 4, "end_line": 11, "end_column": 52 }, { "span": "from robofab.world import CurrentGlyph", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 38 }, { "span": "from math import sqrt, cos, sin, acos, asin, degrees, radians, tan, pi", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 70 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "outline", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "by", " ", "Fre", "der", "ik", " ", "Ber", "la", "en", "/", "Type", "My", "Type_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "git", "hub", ".", "com", "/", "type", "myt", "ype", "/", "Rob", "o", "Font", "Ext", "ensi", "ons", "/", "blob", "/", "master", "/", "outline", "r", "/", "Outline", "r", ".", "robo", "Font", "Ext", "/", "lib", "/", "outline", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "vanilla", "_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "App", "Kit_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "font", "Tools_", "._", "pens", "_", "._", "coco", "a", "Pen_", "import_", "Coc", "oa", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "lib_", "._", "tools_", "._", "bezier", "Tools_", "import_", "curve", "Converter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "runn", "ing", " ", "outsi", "de", " ", "of", " ", "Rob", "o", "Font", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "font", "Tools_", "._", "pens", "_", "._", "base", "Pen_", "import_", "Base", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "robo", "fab", "_", "._", "pens", "_", "._", "point", "Pen_", "import_", "Abstract", "Point", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "robo", "fab", "_", "._", "pens", "_", "._", "reverse", "Contour", "Point", "Pen_", "import_", "Revers", "e", "Contour", "Point", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "robo", "fab", "_", "._", "pens", "_", "._", "adapter", "Pen", "s_", "import_", "Point", "To", "Segme", "nt", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "robo", "fab", "_", "._", "world_", "import_", "Curr", "ent", "Glyph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "def", "con_", "import_", "Glyph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "math_", "import_", "sqrt_", ",_", "cos_", ",_", "sin_", ",_", "acos", "_", ",_", "asin", "_", ",_", "degrees_", ",_", "radians_", ",_", "tan_", ",_", "pi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "round", "Float_", "(_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "=_", "1000000", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "round_", "(_", "f_", "*_", "error_", ")_", "/_", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Smooth", "_", "(_", "first", "Angle_", ",_", "last", "Angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "first", "Angle_", "==_", "None_", "or_", "last", "Angle_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "error_", "=_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Angle_", "=_", "degrees_", "(_", "first", "Angle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "Angle_", "=_", "degrees_", "(_", "last", "Angle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "int_", "(_", "first", "Angle_", ")_", "+_", "error_", ">=_", "int_", "(_", "last", "Angle_", ")_", ">=_", "int_", "(_", "first", "Angle_", ")_", "-_", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "In", "ner", "Out", "er_", "(_", "first", "Angle_", ",_", "last", "Angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "first", "Angle_", "==_", "None_", "or_", "last", "Angle_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dir", "Angle_", "=_", "degrees_", "(_", "first", "Angle_", ")_", "-_", "degrees_", "(_", "last", "Angle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "dir", "Angle_", ">_", "180_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir", "Angle_", "=_", "180_", "-_", "dir", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "dir", "Angle_", "<_", "-_", "180_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir", "Angle_", "=_", "-_", "180_", "-_", "dir", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dir", "Angle_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dir", "Angle_", "<=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "inter", "Sect", "_", "(_", "(_", "seg", "1s", "_", ",_", "seg", "1e", "_", ")_", ",_", "(_", "seg", "2s", "_", ",_", "seg", "2e", "_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "denom_", "=_", "(_", "seg", "2e", "_", "._", "y_", "-_", "seg", "2s", "_", "._", "y_", ")_", "*_", "(_", "seg", "1e", "_", "._", "x_", "-_", "seg", "1s", "_", "._", "x_", ")_", "-_", "(_", "seg", "2e", "_", "._", "x_", "-_", "seg", "2s", "_", "._", "x_", ")_", "*_", "(_", "seg", "1e", "_", "._", "y_", "-_", "seg", "1s", "_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "round", "Float_", "(_", "denom_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "'", "parall", "el", ":", " ", "%", "s", "'", " ", "%", " ", "denom_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "uan", "um_", "=_", "(_", "seg", "2e", "_", "._", "x_", "-_", "seg", "2s", "_", "._", "x_", ")_", "*_", "(_", "seg", "1s", "_", "._", "y_", "-_", "seg", "2s", "_", "._", "y_", ")_", "-_", "(_", "seg", "2e", "_", "._", "y_", "-_", "seg", "2s", "_", "._", "y_", ")_", "*_", "(_", "seg", "1s", "_", "._", "x_", "-_", "seg", "2s", "_", "._", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ub", "num_", "=_", "(_", "seg", "1e", "_", "._", "x_", "-_", "seg", "1s", "_", "._", "x_", ")_", "*_", "(_", "seg", "1s", "_", "._", "y_", "-_", "seg", "2s", "_", "._", "y_", ")_", "-_", "(_", "seg", "1e", "_", "._", "y_", "-_", "seg", "1s", "_", "._", "y_", ")_", "*_", "(_", "seg", "1s", "_", "._", "x_", "-_", "seg", "2s", "_", "._", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ua_", "=_", "uan", "um_", "/_", "denom_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ub_", "=_", "ub", "num_", "/_", "denom_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "seg", "1s", "_", "._", "x_", "+_", "ua_", "*_", "(_", "seg", "1e", "_", "._", "x_", "-_", "seg", "1s", "_", "._", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "seg", "1s", "_", "._", "y_", "+_", "ua_", "*_", "(_", "seg", "1e", "_", "._", "y_", "-_", "seg", "1s", "_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Math", "Point_", "(_", "x_", ",_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "point", "On", "AC", "urve", "_", "(_", "(_", "x1_", ",_", "y1_", ")_", ",_", "(_", "cx", "1_", ",_", "cy", "1_", ")_", ",_", "(_", "cx", "2_", ",_", "cy", "2_", ")_", ",_", "(_", "x2_", ",_", "y2_", ")_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", ",", " ", "handle", " ", "=", " ", "Fal", "se", " ", ",", " ", "order", " ", "=", " ", "Fal", "se", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dx_", "=_", "x1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cx_", "=_", "(_", "cx", "1_", "-_", "dx_", ")_", "*_", "3.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bx_", "=_", "(_", "cx", "2_", "-_", "cx", "1_", ")_", "*_", "3.0_", "-_", "cx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "x2_", "-_", "dx_", "-_", "cx_", "-_", "bx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dy_", "=_", "y1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cy_", "=_", "(_", "cy", "1_", "-_", "dy_", ")_", "*_", "3.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "by_", "=_", "(_", "cy", "2_", "-_", "cy", "1_", ")_", "*_", "3.0_", "-_", "cy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ay_", "=_", "y2_", "-_", "dy_", "-_", "cy_", "-_", "by_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mx_", "=_", "ax_", "*_", "(_", "value_", ")_", "**_", "3_", "+_", "bx_", "*_", "(_", "value_", ")_", "**_", "2_", "+_", "cx_", "*_", "(_", "value_", ")_", "+_", "dx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "my_", "=_", "ay_", "*_", "(_", "value_", ")_", "**_", "3_", "+_", "by_", "*_", "(_", "value_", ")_", "**_", "2_", "+_", "cy_", "*_", "(_", "value_", ")_", "+_", "dy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Math", "Point_", "(_", "mx_", ",_", "my_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "x_", ",_", "y_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "y_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", ",_", "y_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "x_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "y_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "###", "#", " ", "print", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"<", "Math", "Point", " ", "x", ":", "%", "s", " ", "y", ":", "%", "s", ">\"_", "%_", "(_", "self_", "._", "x_", ",_", "self_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getitem\\u\\u_", "(_", "self_", ",_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "index_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "index_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Index", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "value_", "in_", "[_", "self_", "._", "x_", ",_", "self_", "._", "y_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "add\\u\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "#", " ", "p", "+", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "p_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "+_", "p_", ",_", "self_", "._", "y_", "+_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "+_", "p_", "._", "x_", ",_", "self_", "._", "y_", "+_", "p_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "sub\\u", "\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "#", "p", " ", "-", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "p_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "-_", "p_", ",_", "self_", "._", "y_", "-_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "-_", "p_", "._", "x_", ",_", "self_", "._", "y_", "-_", "p_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "mul\\u\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "##", " ", "p", " ", "*", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "p_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "*_", "p_", ",_", "self_", "._", "y_", "*_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "*_", "p_", "._", "x_", ",_", "self_", "._", "y_", "*_", "p_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "div\\u\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "p_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "/_", "p_", ",_", "self_", "._", "y_", "/_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", "/_", "p_", "._", "x_", ",_", "self_", "._", "y_", "/_", "p_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "##", " ", "if", " ", "p", " ", "==", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "p_", ",_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "round", "Float_", "(_", "self_", "._", "x_", ")_", "==_", "round", "Float_", "(_", "p_", "._", "x_", ")_", "and_", "round", "Float_", "(_", "self_", "._", "y_", ")_", "==_", "round", "Float_", "(_", "p_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "ne\\u\\u_", "(_", "self_", ",_", "p_", ")_", ":_", "##", " ", "if", " ", "p", " ", "!=", " ", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "not_", "self_", "._", "\\u\\u", "eq\\u\\u_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "x_", ",_", "self_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "round_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "x_", "=_", "round_", "(_", "self_", "._", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "y_", "=_", "round_", "(_", "self_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "distance_", "(_", "self_", ",_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "sqrt_", "(_", "(_", "p_", "._", "x_", "-_", "self_", "._", "x_", ")_", "**_", "2_", "+_", "(_", "p_", "._", "y_", "-_", "self_", "._", "y_", ")_", "**_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Math", "Point_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "angle_", "(_", "self_", ",_", "other_", ",_", "add_", "=_", "90_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", "#", " ", "return", "s", " ", "the", " ", "angle", " ", "of", " ", "the", " ", "Line", " ", "in", " ", "degrees_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "b_", "=_", "other_", "._", "x_", "-_", "self_", "._", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "other_", "._", "y_", "-_", "self_", "._", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "sqrt_", "(_", "a_", "**_", "2_", "+_", "b_", "**_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "c_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "add_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "b_", "/_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cos", "Angle_", "=_", "degrees_", "(_", "acos", "_", "(_", "b_", "/_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sin", "Angle_", "=_", "degrees_", "(_", "asin", "_", "(_", "a_", "/_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sin", "Angle_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cos", "Angle_", "=_", "360_", "-_", "cos", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "radians_", "(_", "cos", "Angle_", "+_", "add_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "point", "Pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "point", "Pen_", "=_", "point", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Contour", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "Contour", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "Pen_", "=_", "self_", "._", "point", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contour_", "=_", "self_", "._", "current", "Contour", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "Angle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to", "Remove_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "data_", "in_", "contour_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "data_", "[_", "\"", "segment", "Type", "\"_", "]_", "in_", "[_", "\"", "line", "\"_", ",_", "\"", "move", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prev", "Point_", "=_", "contour_", "[_", "index_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prev", "Point_", "[_", "\"", "segment", "Type", "\"_", "]_", "in_", "[_", "\"", "line", "\"_", ",_", "\"", "move", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "angle_", "=_", "Math", "Point_", "(_", "data_", "[_", "\"", "point", "\"_", "]_", ")_", "._", "angle_", "(_", "Math", "Point_", "(_", "prev", "Point_", "[_", "\"", "point", "\"_", "]_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prev", "Angle_", "is_", "not_", "None_", "and_", "angle_", "is_", "not_", "None_", "and_", "round", "Float_", "(_", "prev", "Angle_", ")_", "==_", "round", "Float_", "(_", "angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "to", "Remove_", "._", "append_", "(_", "prev", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prev", "Angle_", "=_", "angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "prev", "Angle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prev", "Angle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "data_", "in_", "to", "Remove_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "contour_", "._", "remove_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "point", "Pen_", "._", "begin", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "data_", "in_", "contour_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "Pen_", "._", "add", "Point_", "(_", "data_", "[_", "\"", "point", "\"_", "]_", ",_", "**_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "point", "Pen_", "._", "end", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "begin", "Path_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "current", "Contour", "_", "is_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Contour", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "on", "Curve_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "end", "Path_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "current", "Contour", "_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "process", "Contour", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Contour", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Point_", "(_", "self_", ",_", "pt_", ",_", "segment", "Type_", "=_", "None_", ",_", "smooth_", "=_", "False_", ",_", "name_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "dict_", "(_", "point_", "=_", "pt_", ",_", "segment", "Type_", "=_", "segment", "Type_", ",_", "smooth_", "=_", "smooth_", ",_", "name_", "=_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "._", "update_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Contour", "_", "._", "append_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Clean", "Point", "Pen_", "(_", "Abstract", "Point", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Component_", "(_", "self_", ",_", "glyph", "Name_", ",_", "transform_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "current", "Contour", "_", "is_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "point", "Pen_", "._", "add", "Component_", "(_", "glyph", "Name_", ",_", "transform_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "Class_", "=_", "Math", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "magic", "Curve_", "=_", "0.55", "228", "474", "98_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "connections_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "caps_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "glyph", "Set_", ",_", "offset_", "=_", "10_", ",_", "connection_", "=_", "\"", "square", "\"_", ",_", "cap_", "=_", "\"", "round", "\"_", ",_", "mite", "r", "Limit_", "=_", "None_", ",_", "close", "Open", "Paths_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Base", "Pen_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "glyph", "Set_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "offset_", "=_", "abs_", "(_", "offset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "input", "mite", "r", "Limit_", "=_", "mite", "r", "Limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mite", "r", "Limit_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mite", "r", "Limit_", "=_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "mite", "r", "Limit_", "=_", "abs_", "(_", "mite", "r", "Limit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "close", "Open", "Paths_", "=_", "close", "Open", "Paths_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "connecti", "on", "Callback_", "=_", "getattr_", "(_", "self_", ",_", "\"", "connecti", "on", "%", "s", "\"_", "%_", "(_", "connection_", "[_", "0_", "]_", "._", "capitalize_", "(_", ")_", "+_", "connection_", "[_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cap", "Callback_", "=_", "getattr_", "(_", "self_", ",_", "\"", "cap", "%", "s", "\"_", "%_", "(_", "cap_", "[_", "0_", "]_", "._", "capitalize_", "(_", ")_", "+_", "cap_", "[_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "original", "Glyph_", "=_", "Glyph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "original", "Pen_", "=_", "self_", "._", "original", "Glyph_", "._", "get", "Pen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "outer", "Glyph_", "=_", "Glyph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Pen_", "=_", "self_", "._", "outer", "Glyph_", "._", "get", "Pen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Fi", "rst", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Prev", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Glyph_", "=_", "Glyph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "=_", "self_", "._", "inner", "Glyph_", "._", "get", "Pen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Fi", "rst", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Prev", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "prev", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "first", "Point_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "first", "Angle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prev", "Angle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "shou", "ld", "Handle", "Move_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "draw", "Settings_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "move", "To_", "(_", "self_", ",_", "(_", "x_", ",_", "y_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "offset_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "outer", "Pen_", "._", "move", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "move", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Pen_", "._", "move", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p_", "=_", "self_", "._", "point", "Class_", "(_", "x_", ",_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prev", "Point_", "=_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "first", "Point_", "=_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shou", "ld", "Handle", "Move_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "line", "To_", "(_", "self_", ",_", "(_", "x_", ",_", "y_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "offset_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "outer", "Pen_", "._", "line", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "line", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Pen_", "._", "line", "To_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current", "Point_", "=_", "self_", "._", "point", "Class_", "(_", "x_", ",_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "Point_", "==_", "self_", "._", "prev", "Point_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "current", "Angle_", "=_", "self_", "._", "prev", "Point_", "._", "angle_", "(_", "current", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "self_", "._", "prev", "Point_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "self_", "._", "current", "Angle_", ")_", ",_", "sin_", "(_", "self_", "._", "current", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "self_", "._", "prev", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "self_", "._", "current", "Angle_", ")_", ",_", "sin_", "(_", "self_", "._", "current", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "shou", "ld", "Handle", "Move_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "shou", "ld", "Handle", "Move_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "move", "To_", "(_", "self_", "._", "inner", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Fi", "rst", "Point_", "=_", "self_", "._", "inner", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "move", "To_", "(_", "self_", "._", "outer", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Fi", "rst", "Point_", "=_", "self_", "._", "outer", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "first", "Angle_", "=_", "self_", "._", "current", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "build", "Connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "current", "Point_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "self_", "._", "current", "Angle_", ")_", ",_", "sin_", "(_", "self_", "._", "current", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "line", "To_", "(_", "self_", "._", "inner", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Prev", "Point_", "=_", "self_", "._", "inner", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "current", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "self_", "._", "current", "Angle_", ")_", ",_", "sin_", "(_", "self_", "._", "current", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "line", "To_", "(_", "self_", "._", "outer", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Prev", "Point_", "=_", "self_", "._", "outer", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "prev", "Point_", "=_", "current", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prev", "Angle_", "=_", "self_", "._", "current", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "curve", "To", "One_", "(_", "self_", ",_", "(_", "x1_", ",_", "y1_", ")_", ",_", "(_", "x2_", ",_", "y2_", ")_", ",_", "(_", "x3_", ",_", "y3_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "offset_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "outer", "Pen_", "._", "curve", "To_", "(_", "(_", "x1_", ",_", "y1_", ")_", ",_", "(_", "x2_", ",_", "y2_", ")_", ",_", "(_", "x3_", ",_", "y3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "curve", "To_", "(_", "(_", "x1_", ",_", "y1_", ")_", ",_", "(_", "x2_", ",_", "y2_", ")_", ",_", "(_", "x3_", ",_", "y3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Pen_", "._", "curve", "To_", "(_", "(_", "x1_", ",_", "y1_", ")_", ",_", "(_", "x2_", ",_", "y2_", ")_", ",_", "(_", "x3_", ",_", "y3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p1_", "=_", "self_", "._", "point", "Class_", "(_", "x1_", ",_", "y1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p2_", "=_", "self_", "._", "point", "Class_", "(_", "x2_", ",_", "y2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p3_", "=_", "self_", "._", "point", "Class_", "(_", "x3_", ",_", "y3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "p1_", "==_", "self_", "._", "prev", "Point_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p1_", "=_", "point", "On", "AC", "urve", "_", "(_", "self_", "._", "prev", "Point_", ",_", "p1_", ",_", "p2_", ",_", "p3_", ",_", "0.01_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p2_", "==_", "p3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p2_", "=_", "point", "On", "AC", "urve", "_", "(_", "self_", "._", "prev", "Point_", ",_", "p1_", ",_", "p2_", ",_", "p3_", ",_", "0.99_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a1_", "=_", "self_", "._", "prev", "Point_", "._", "angle_", "(_", "p1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "p2_", "._", "angle_", "(_", "p3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "current", "Angle_", "=_", "a1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a1", "bis", "_", "=_", "self_", "._", "prev", "Point_", "._", "angle_", "(_", "p1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2", "bis", "_", "=_", "p3_", "._", "angle_", "(_", "p2_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "intersect", "Point_", "=_", "inter", "Sect", "_", "(_", "(_", "self_", "._", "prev", "Point_", ",_", "self_", "._", "prev", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "100_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "p3_", ",_", "p3_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a2_", ")_", ",_", "sin_", "(_", "a2_", ")_", ")_", "*_", "100_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "self_", "._", "prev", "Point_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "self_", "._", "prev", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "shou", "ld", "Handle", "Move_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "shou", "ld", "Handle", "Move_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "move", "To_", "(_", "self_", "._", "inner", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Fi", "rst", "Point_", "=_", "self_", "._", "inner", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "move", "To_", "(_", "self_", "._", "outer", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Fi", "rst", "Point_", "=_", "self_", "._", "outer", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "first", "Angle_", "=_", "a1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "build", "Connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "h1_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "intersect", "Point_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h1_", "=_", "inter", "Sect", "_", "(_", "(_", "self_", "._", "inner", "Curr", "ent", "Point_", ",_", "self_", "._", "inner", "Curr", "ent", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1", "bis", "_", ")_", ",_", "sin_", "(_", "a1", "bis", "_", ")_", ")_", "*_", "self_", "._", "offset_", ")_", ",_", "(_", "intersect", "Point_", ",_", "p1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "h1_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h1_", "=_", "p1_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "p3_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a2_", ")_", ",_", "sin_", "(_", "a2_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h2_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "intersect", "Point_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h2_", "=_", "inter", "Sect", "_", "(_", "(_", "self_", "._", "inner", "Curr", "ent", "Point_", ",_", "self_", "._", "inner", "Curr", "ent", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a2", "bis", "_", ")_", ",_", "sin_", "(_", "a2", "bis", "_", ")_", ")_", "*_", "self_", "._", "offset_", ")_", ",_", "(_", "intersect", "Point_", ",_", "p2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "h2_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h2_", "=_", "p2_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "curve", "To_", "(_", "h1_", ",_", "h2_", ",_", "self_", "._", "inner", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Prev", "Point_", "=_", "self_", "._", "inner", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "h1_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "intersect", "Point_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h1_", "=_", "inter", "Sect", "_", "(_", "(_", "self_", "._", "outer", "Curr", "ent", "Point_", ",_", "self_", "._", "outer", "Curr", "ent", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1", "bis", "_", ")_", ",_", "sin_", "(_", "a1", "bis", "_", ")_", ")_", "*_", "self_", "._", "offset_", ")_", ",_", "(_", "intersect", "Point_", ",_", "p1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "h1_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h1_", "=_", "p1_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "p3_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a2_", ")_", ",_", "sin_", "(_", "a2_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h2_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "intersect", "Point_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h2_", "=_", "inter", "Sect", "_", "(_", "(_", "self_", "._", "outer", "Curr", "ent", "Point_", ",_", "self_", "._", "outer", "Curr", "ent", "Point_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a2", "bis", "_", ")_", ",_", "sin_", "(_", "a2", "bis", "_", ")_", ")_", "*_", "self_", "._", "offset_", ")_", ",_", "(_", "intersect", "Point_", ",_", "p2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "h2_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h2_", "=_", "p2_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "a1_", ")_", ",_", "sin_", "(_", "a1_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "curve", "To_", "(_", "h1_", ",_", "h2_", ",_", "self_", "._", "outer", "Curr", "ent", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Prev", "Point_", "=_", "self_", "._", "outer", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "prev", "Point_", "=_", "p3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Angle_", "=_", "a2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prev", "Angle_", "=_", "a2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "close", "Path_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "shou", "ld", "Handle", "Move_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "offset_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "outer", "Pen_", "._", "close", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "close", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "prev", "Point_", "==_", "self_", "._", "first", "Point_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "line", "To_", "(_", "self_", "._", "first", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Pen_", "._", "close", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Prev", "Point_", "=_", "self_", "._", "inner", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Curr", "ent", "Point_", "=_", "self_", "._", "inner", "Fi", "rst", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "outer", "Prev", "Point_", "=_", "self_", "._", "outer", "Curr", "ent", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Curr", "ent", "Point_", "=_", "self_", "._", "outer", "Fi", "rst", "Point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "prev", "Angle_", "=_", "self_", "._", "current", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Angle_", "=_", "self_", "._", "first", "Angle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "build", "Connection_", "(_", "close_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "close", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "close", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "end", "Path_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "shou", "ld", "Handle", "Move_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Pen_", "._", "end", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Pen_", "._", "end", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outer", "Pen_", "._", "end", "Path_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "close", "Open", "Paths_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "inner", "Contour", "_", "=_", "self_", "._", "inner", "Glyph_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "outer", "Contour", "_", "=_", "self_", "._", "outer", "Glyph_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "inner", "Contour", "_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "inner", "Contour", "_", "[_", "0_", "]_", "._", "segment", "Type_", "=_", "\"", "line", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "outer", "Contour", "_", "[_", "0_", "]_", "._", "segment", "Type_", "=_", "\"", "line", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "build", "Cap", "_", "(_", "outer", "Contour", "_", ",_", "inner", "Contour", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "point_", "in_", "inner", "Contour", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "outer", "Contour", "_", "._", "add", "Point_", "(_", "(_", "point_", "._", "x_", ",_", "point_", "._", "y_", ")_", ",_", "segment", "Type_", "=_", "point_", "._", "segment", "Type_", ",_", "smooth_", "=_", "point_", "._", "smooth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "inner", "Glyph_", "._", "remove", "Contour", "_", "(_", "inner", "Contour", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "build", "Connection_", "(_", "self_", ",_", "close_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "check", "Smooth", "_", "(_", "self_", "._", "prev", "Angle_", ",_", "self_", "._", "current", "Angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "check", "In", "ner", "Out", "er_", "(_", "self_", "._", "prev", "Angle_", ",_", "self_", "._", "current", "Angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "connecti", "on", "Callback_", "(_", "self_", "._", "outer", "Prev", "Point_", ",_", "self_", "._", "outer", "Curr", "ent", "Point_", ",_", "self_", "._", "outer", "Pen_", ",_", "close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connecti", "on", "In", "ner", "Corner", "_", "(_", "self_", "._", "inner", "Prev", "Point_", ",_", "self_", "._", "inner", "Curr", "ent", "Point_", ",_", "self_", "._", "inner", "Pen_", ",_", "close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "connecti", "on", "Callback_", "(_", "self_", "._", "inner", "Prev", "Point_", ",_", "self_", "._", "inner", "Curr", "ent", "Point_", ",_", "self_", "._", "inner", "Pen_", ",_", "close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connecti", "on", "In", "ner", "Corner", "_", "(_", "self_", "._", "outer", "Prev", "Point_", ",_", "self_", "._", "outer", "Curr", "ent", "Point_", ",_", "self_", "._", "outer", "Pen_", ",_", "close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "Square_", "(_", "self_", ",_", "first_", ",_", "last_", ",_", "pen_", ",_", "close_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "angle", "\\u", "1_", "=_", "radians_", "(_", "degrees_", "(_", "self_", "._", "prev", "Angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "angle", "\\u", "2_", "=_", "radians_", "(_", "degrees_", "(_", "self_", "._", "current", "Angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "temp", "First_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "1_", ")_", ",_", "sin_", "(_", "angle", "\\u", "1_", ")_", ")_", "*_", "self_", "._", "mite", "r", "Limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "Last_", "=_", "last_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "2_", ")_", ",_", "sin_", "(_", "angle", "\\u", "2_", ")_", ")_", "*_", "self_", "._", "mite", "r", "Limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "Point_", "=_", "inter", "Sect", "_", "(_", "(_", "first_", ",_", "temp", "First_", ")_", ",_", "(_", "last_", ",_", "temp", "Last_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "new", "Point_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "input", "mite", "r", "Limit_", "is_", "not_", "None_", "and_", "round", "Float_", "(_", "new", "Point_", "._", "distance_", "(_", "first_", ")_", ")_", ">_", "self_", "._", "\\u", "input", "mite", "r", "Limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "temp", "First_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pen_", "._", "line", "To_", "(_", "temp", "Last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "new", "Point_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "close_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "Round", "_", "(_", "self_", ",_", "first_", ",_", "last_", ",_", "pen_", ",_", "close_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "angle", "\\u", "1_", "=_", "radians_", "(_", "degrees_", "(_", "self_", "._", "prev", "Angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "angle", "\\u", "2_", "=_", "radians_", "(_", "degrees_", "(_", "self_", "._", "current", "Angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "temp", "First_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "1_", ")_", ",_", "sin_", "(_", "angle", "\\u", "1_", ")_", ")_", "*_", "self_", "._", "mite", "r", "Limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "Last_", "=_", "last_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "2_", ")_", ",_", "sin_", "(_", "angle", "\\u", "2_", ")_", ")_", "*_", "self_", "._", "mite", "r", "Limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "Point_", "=_", "inter", "Sect", "_", "(_", "(_", "first_", ",_", "temp", "First_", ")_", ",_", "(_", "last_", ",_", "temp", "Last_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "new", "Point_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "distance_", "=_", "new", "Point_", "._", "distance_", "(_", "first_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "round", "Float_", "(_", "distance_", ")_", ">_", "self_", "._", "mite", "r", "Limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "distance_", "=_", "self_", "._", "mite", "r", "Limit_", "+_", "temp", "First_", "._", "distance_", "(_", "temp", "Last_", ")_", "*_", ".7_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "distance_", "*=_", "self_", "._", "magic", "Curve_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bc", "p1_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "1_", ")_", ",_", "sin_", "(_", "angle", "\\u", "1_", ")_", ")_", "*_", "distance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bc", "p2_", "=_", "last_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle", "\\u", "2_", ")_", ",_", "sin_", "(_", "angle", "\\u", "2_", ")_", ")_", "*_", "distance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pen_", "._", "curve", "To_", "(_", "bc", "p1_", ",_", "bc", "p2_", ",_", "last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "Butt", "_", "(_", "self_", ",_", "first_", ",_", "last_", ",_", "pen_", ",_", "close_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "close_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "In", "ner", "Corner", "_", "(_", "self_", ",_", "first_", ",_", "last_", ",_", "pen_", ",_", "close_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "close_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pen_", "._", "line", "To_", "(_", "last_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "build", "Cap", "_", "(_", "self_", ",_", "first", "Contour", "_", ",_", "last", "Contour", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "first_", "=_", "first", "Contour", "_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last_", "=_", "last", "Contour", "_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", "=_", "self_", "._", "point", "Class_", "(_", "first_", "._", "x_", ",_", "first_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last_", "=_", "self_", "._", "point", "Class_", "(_", "last_", "._", "x_", ",_", "last_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cap", "Callback_", "(_", "first", "Contour", "_", ",_", "last", "Contour", "_", ",_", "first_", ",_", "last_", ",_", "self_", "._", "prev", "Angle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first_", "=_", "last", "Contour", "_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last_", "=_", "first", "Contour", "_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", "=_", "self_", "._", "point", "Class_", "(_", "first_", "._", "x_", ",_", "first_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last_", "=_", "self_", "._", "point", "Class_", "(_", "last_", "._", "x_", ",_", "last_", "._", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "angle_", "=_", "radians_", "(_", "degrees_", "(_", "self_", "._", "first", "Angle_", ")_", "+_", "180_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cap", "Callback_", "(_", "last", "Contour", "_", ",_", "first", "Contour", "_", ",_", "first_", ",_", "last_", ",_", "angle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cap", "Butt", "_", "(_", "self_", ",_", "first", "Contour", "_", ",_", "last", "Contour", "_", ",_", "first_", ",_", "last_", ",_", "angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "not", " ", "nothing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cap", "Round", "_", "(_", "self_", ",_", "first", "Contour", "_", ",_", "last", "Contour", "_", ",_", "first_", ",_", "last_", ",_", "angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hooke", "d", "Angle_", "=_", "radians_", "(_", "degrees_", "(_", "angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p1_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "hooke", "d", "Angle_", ")_", ",_", "sin_", "(_", "hooke", "d", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p2_", "=_", "last_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "hooke", "d", "Angle_", ")_", ",_", "sin_", "(_", "hooke", "d", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "onc", "urve", "_", "=_", "p1_", "+_", "(_", "p2_", "-_", "p1_", ")_", "*_", ".5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "round", "ness_", "=_", ".5", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h1_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "hooke", "d", "Angle_", ")_", ",_", "sin_", "(_", "hooke", "d", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "*_", "round", "ness_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h2_", "=_", "onc", "urve", "_", "+_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle_", ")_", ",_", "sin_", "(_", "angle_", ")_", ")_", "*_", "self_", "._", "offset_", "*_", "round", "ness_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first", "Contour", "_", "[_", "-_", "1_", "]_", "._", "smooth_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "h1_", "._", "x_", ",_", "h1_", "._", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "h2_", "._", "x_", ",_", "h2_", "._", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "onc", "urve", "_", "._", "x_", ",_", "onc", "urve", "_", "._", "y_", ")_", ",_", "smooth_", "=_", "True_", ",_", "segment", "Type_", "=_", "\"", "curve", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h1_", "=_", "onc", "urve", "_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle_", ")_", ",_", "sin_", "(_", "angle_", ")_", ")_", "*_", "self_", "._", "offset_", "*_", "round", "ness_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h2_", "=_", "last_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "hooke", "d", "Angle_", ")_", ",_", "sin_", "(_", "hooke", "d", "Angle_", ")_", ")_", "*_", "self_", "._", "offset_", "*_", "round", "ness_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "h1_", "._", "x_", ",_", "h1_", "._", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "h2_", "._", "x_", ",_", "h2_", "._", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "last", "Contour", "_", "[_", "0_", "]_", "._", "segment", "Type_", "=_", "\"", "curve", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "Contour", "_", "[_", "0_", "]_", "._", "smooth_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cap", "Square_", "(_", "self_", ",_", "first", "Contour", "_", ",_", "last", "Contour", "_", ",_", "first_", ",_", "last_", ",_", "angle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "angle_", "=_", "radians_", "(_", "degrees_", "(_", "angle_", ")_", "+_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first", "Contour", "_", "[_", "-_", "1_", "]_", "._", "smooth_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "Contour", "_", "[_", "0_", "]_", "._", "smooth_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p1_", "=_", "first_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle_", ")_", ",_", "sin_", "(_", "angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "p1_", "._", "x_", ",_", "p1_", "._", "y_", ")_", ",_", "smooth_", "=_", "False_", ",_", "segment", "Type_", "=_", "\"", "line", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p2_", "=_", "last_", "-_", "self_", "._", "point", "Class_", "(_", "cos_", "(_", "angle_", ")_", ",_", "sin_", "(_", "angle_", ")_", ")_", "*_", "self_", "._", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Contour", "_", "._", "add", "Point_", "(_", "(_", "p2_", "._", "x_", ",_", "p2_", "._", "y_", ")_", ",_", "smooth_", "=_", "False_", ",_", "segment", "Type_", "=_", "\"", "line", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw", "Settings_", "(_", "self_", ",_", "draw", "Origina", "l_", "=_", "False_", ",_", "draw", "In", "ner_", "=_", "False_", ",_", "draw", "Out", "er_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "draw", "Origina", "l_", "=_", "draw", "Origina", "l_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "draw", "In", "ner_", "=_", "draw", "In", "ner_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "draw", "Out", "er_", "=_", "draw", "Out", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw", "Points_", "(_", "self_", ",_", "point", "Pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "draw", "In", "ner_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reverse", "Pen_", "=_", "Revers", "e", "Contour", "Point", "Pen_", "(_", "point", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "inner", "Glyph_", "._", "draw", "Points_", "(_", "Clean", "Point", "Pen_", "(_", "reverse", "Pen_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "draw", "Out", "er_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "outer", "Glyph_", "._", "draw", "Points_", "(_", "Clean", "Point", "Pen_", "(_", "point", "Pen_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "draw", "Origina", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "draw", "Out", "er_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "Pen_", "=_", "Revers", "e", "Contour", "Point", "Pen_", "(_", "point", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "original", "Glyph_", "._", "draw", "Points_", "(_", "Clean", "Point", "Pen_", "(_", "point", "Pen_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw_", "(_", "self_", ",_", "pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "Pen_", "=_", "Point", "To", "Segme", "nt", "Pen_", "(_", "pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "draw", "Points_", "(_", "point", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Outline", "Pen_", "(_", "Base", "Pen_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Glyph_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "glyph_", "=_", "Glyph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "point", "Pen_", "=_", "glyph_", "._", "get", "Point", "Pen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "draw", "Points_", "(_", "point", "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 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Nested loops with same variable
binaryage/firelogger.py/gprof2dot.py
[ { "content": " def build_profile(self, results):\n assert results.name == 'Routines'\n profile = Profile()\n profile[TIME] = 0.0\n for fields, tables in results:\n function = self.build_function(fields)\n children = tables['Children']\n for fields, _ in children:\n call = self.build_call(fields)\n function.add_call(call)\n profile.add_function(function)\n profile[TIME] = profile[TIME] + function[TIME]\n profile[TOTAL_TIME] = profile[TIME]\n profile.ratio(TOTAL_TIME_RATIO, TOTAL_TIME)\n return profile", "metadata": "root.AQtimeParser.build_profile", "header": "['class', 'AQtimeParser', '(', 'XmlParser', ')', ':', '___EOS___']", "index": 1411 }, { "content": " def parse(self):\n self.profile[TIME] = 0.0\n self.profile[TOTAL_TIME] = self.stats.total_tt\n for fn, (cc, nc, tt, ct, callers) in self.stats.stats.iteritems():\n callee = self.get_function(fn)\n callee[CALLS] = nc\n callee[TOTAL_TIME] = ct\n callee[TIME] = tt\n self.profile[TIME] += tt\n self.profile[TOTAL_TIME] = max(self.profile[TOTAL_TIME], ct)\n for fn, value in callers.iteritems():\n caller = self.get_function(fn)\n call = Call(callee.id)\n if isinstance(value, tuple):\n for i in xrange(0, len(value), 4):\n nc, cc, tt, ct = value[i:i+4]\n if CALLS in call:\n call[CALLS] += cc\n else:\n call[CALLS] = cc\n\n if TOTAL_TIME in call:\n call[TOTAL_TIME] += ct\n else:\n call[TOTAL_TIME] = ct\n\n else:\n call[CALLS] = value\n call[TOTAL_TIME] = ratio(value, nc)*ct\n\n caller.add_call(call)\n #self.stats.print_stats()\n #self.stats.print_callees()\n\n # Compute derived events\n self.profile.validate()\n self.profile.ratio(TIME_RATIO, TIME)\n self.profile.ratio(TOTAL_TIME_RATIO, TOTAL_TIME)\n\n return self.profile", "metadata": "root.PstatsParser.parse", "header": "['class', 'PstatsParser', ':', '___EOS___']", "index": 1482 } ]
[ { "span": "for fields, _ in children:", "start_line": 1418, "start_column": 12, "end_line": 1418, "end_column": 38 }, { "span": "for fn, value in callers.iteritems():", "start_line": 1492, "start_column": 12, "end_line": 1492, "end_column": 49 } ]
[ { "span": "for fields, tables in results:", "start_line": 1415, "start_column": 8, "end_line": 1415, "end_column": 38 }, { "span": "for fn, (cc, nc, tt, ct, callers) in self.stats.stats.iteritems():", "start_line": 1485, "start_column": 8, "end_line": 1485, "end_column": 74 } ]
1
true
[ "[CLS]_", "Nest", "ed_", "loops_", "with_", "same_", "variable_", "[SEP]_", "class_", "AQ", "time", "Parser_", "(_", "Xm", "l", "Parser_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "build", "\\u", "profile_", "(_", "self_", ",_", "results_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "results_", "._", "name_", "==_", "'", "Routine", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "=_", "Profile_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "[_", "TIME_", "]_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fields_", ",_", "tables_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "function_", "=_", "self_", "._", "build", "\\u", "function_", "(_", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "children_", "=_", "tables_", "[_", "'", "Chil", "dre", "n", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fields_", ",_", "\\u_", "in_", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "call_", "=_", "self_", "._", "build", "\\u", "call_", "(_", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "function_", "._", "add", "\\u", "call_", "(_", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "profile_", "._", "add", "\\u", "function_", "(_", "function_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "[_", "TIME_", "]_", "=_", "profile_", "[_", "TIME_", "]_", "+_", "function_", "[_", "TIME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "profile_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "profile_", "[_", "TIME_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "ratio_", "(_", "TOTAL", "\\u", "TIME", "\\u", "RATIO", "_", ",_", "TOTAL", "\\u", "TIME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ps", "tats", "Parser_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "profile_", "[_", "TIME_", "]_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "profile_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "self_", "._", "stats_", "._", "total", "\\u", "tt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fn_", ",_", "(_", "cc_", ",_", "nc_", ",_", "tt_", ",_", "ct_", ",_", "caller", "s_", ")_", "in_", "self_", "._", "stats_", "._", "stats_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callee", "_", "=_", "self_", "._", "get", "\\u", "function_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callee", "_", "[_", "CALL", "S_", "]_", "=_", "nc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callee", "_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "ct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callee", "_", "[_", "TIME_", "]_", "=_", "tt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "profile_", "[_", "TIME_", "]_", "+=_", "tt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "profile_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "max_", "(_", "self_", "._", "profile_", "[_", "TOTAL", "\\u", "TIME_", "]_", ",_", "ct_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fn_", ",_", "value_", "in_", "caller", "s_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "caller_", "=_", "self_", "._", "get", "\\u", "function_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "=_", "Call_", "(_", "callee", "_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "i_", "in_", "xrange_", "(_", "0_", ",_", "len_", "(_", "value_", ")_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "nc_", ",_", "cc_", ",_", "tt_", ",_", "ct_", "=_", "value_", "[_", "i_", ":_", "i_", "+_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "CALL", "S_", "in_", "call_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "call_", "[_", "CALL", "S_", "]_", "+=_", "cc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "call_", "[_", "CALL", "S_", "]_", "=_", "cc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "TOTAL", "\\u", "TIME_", "in_", "call_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "call_", "[_", "TOTAL", "\\u", "TIME_", "]_", "+=_", "ct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "call_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "ct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "call_", "[_", "CALL", "S_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call_", "[_", "TOTAL", "\\u", "TIME_", "]_", "=_", "ratio_", "(_", "value_", ",_", "nc_", ")_", "*_", "ct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "caller_", "._", "add", "\\u", "call_", "(_", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "stats", ".", "print", "\\u", "stats", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "stats", ".", "print", "\\u", "callee", "s", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "derive", "d", " ", "events_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "profile_", "._", "validate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "profile_", "._", "ratio_", "(_", "TIME", "\\u", "RATIO", "_", ",_", "TIME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "profile_", "._", "ratio_", "(_", "TOTAL", "\\u", "TIME", "\\u", "RATIO", "_", ",_", "TOTAL", "\\u", "TIME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Signature mismatch in overriding method
mikrosimage/OpenRenderManagement/src/octopus/dispatcher/model/node.py
[ { "content": "class BaseNode(models.Model):\n\n dispatcher = None\n\n name = models.StringField()\n parent = models.ModelField(allow_null=True)\n user = models.StringField()\n priority = models.IntegerField()\n dispatchKey = models.FloatField()\n maxRN = models.IntegerField()\n updateTime = models.FloatField()\n poolShares = PoolShareDictField()\n additionnalPoolShares = AdditionnalPoolShareDictField()\n completion = models.FloatField()\n status = models.IntegerField()\n creationTime = models.FloatField()\n startTime = models.FloatField(allow_null=True)\n updateTime = models.FloatField(allow_null=True)\n endTime = models.FloatField(allow_null=True)\n dependencies = DependencyListField()\n averageTimeByFrame = models.FloatField(allow_null=True)\n minTimeByFrame = models.FloatField(allow_null=True)\n maxTimeByFrame = models.FloatField(allow_null=True)\n timer = models.FloatField(allow_null=True)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n parent_value = property(lambda self: self._parent_value, setParentValue)\n", "metadata": "root.BaseNode", "header": "['module', '___EOS___']", "index": 41 }, { "content": " @property\n def tags(self):\n return {}", "metadata": "root.BaseNode.tags", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 66 }, { "content": " def __init__(self, id, name, parent, user, priority, dispatchKey, maxRN,\n creationTime=None, startTime=None,\n updateTime=None, endTime=None,\n status=NODE_READY):\n '''\n Base class for each node in dispatcher tree structure. Holds main model\n fields.\n\n :param id int: unique id for this node\n :param name str: a short string describing this node\n :param parent: a FolderNode or None if this node is a root node\n :param priority int: priority value\n :param dispatchKey int: dispatchKey value\n :param maxRN int: maximum number of render nodes that can be allocated to this tree node\n :param creationTime: timestamp indicating when the node was created\n :param startTime: timestamp indicating when the node was started\n :param updateTime: timestamp indicating when the node was updated\n :param endTime: timestamp indicating when the node was ended\n :param status int: current node's status\n '''\n if not self.dispatcher:\n from octopus.dispatcher.dispatcher import Dispatcher\n self.dispatcher = Dispatcher(None)\n self.__dict__['parent'] = None\n models.Model.__init__(self)\n self.id = int(id) if id is not None else None\n self.name = str(name)\n self.parent = parent\n self.user = str(user)\n self.priority = int(priority)\n self.dispatchKey = int(dispatchKey)\n self.maxRN = int(maxRN)\n self.optimalMaxRN = 0\n self.allocatedRN = 0\n self.poolShares = WeakKeyDictionary()\n self.additionnalPoolShares = WeakKeyDictionary()\n self.completion = 1.0\n self.status = status\n self.creationTime = time() if not creationTime else creationTime\n self.startTime = startTime\n self.updateTime = updateTime\n self.endTime = endTime\n\n self.dependencies = []\n self.reverseDependencies = []\n self.lastDependenciesSatisfaction = False\n self.lastDependenciesSatisfactionDispatchCycle = -1\n self.readyCommandCount = 0\n self.doneCommandCount = 0\n self.commandCount = 0\n self.averageTimeByFrameList = []\n self.averageTimeByFrame = 0.0\n self.minTimeByFrame = 0.0\n self.maxTimeByFrame = 0.0\n self.timer = None", "metadata": "root.BaseNode.__init__", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 70 }, { "content": " def mainPoolShare(self):\n return self.poolShares.values()[0]", "metadata": "root.BaseNode.mainPoolShare", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 126 }, { "content": " def mainPool(self):\n return self.poolShares.keys()[0]", "metadata": "root.BaseNode.mainPool", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 129 }, { "content": " def to_json(self):\n base = super(BaseNode, self).to_json()\n base[\"allocatedRN\"] = self.allocatedRN\n base[\"optimalMaxRN\"] = self.optimalMaxRN\n base[\"tags\"] = self.tags.copy()\n base[\"readyCommandCount\"] = self.readyCommandCount\n base[\"doneCommandCount\"] = self.doneCommandCount\n base[\"commandCount\"] = self.commandCount\n return base", "metadata": "root.BaseNode.to_json", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 132 }, { "content": " def addDependency(self, node, acceptedStatus):\n # TODO dependencies should be set for restricted node statutes only: DONE, ERROR and CANCELED\n\n if not acceptedStatus:\n return\n if self is node:\n # skip dependencies on oneself\n return\n self.status = NODE_BLOCKED\n val = [node, acceptedStatus]\n if not val in self.dependencies:\n self.dependencies.append(val)\n if self not in node.reverseDependencies:\n node.reverseDependencies.append(self)", "metadata": "root.BaseNode.addDependency", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 142 }, { "content": " def checkDependenciesSatisfaction(self):\n # TODO dependencies should be set for restricted node statutes only: DONE, ERROR and CANCELED\n\n if self.dispatcher.cycle == self.lastDependenciesSatisfactionDispatchCycle:\n return self.lastDependenciesSatisfaction\n\n self.lastDependenciesSatisfaction = True\n self.lastDependenciesSatisfactionDispatchCycle = self.dispatcher.cycle\n for node, acceptedStatus in self.dependencies:\n if node.status not in acceptedStatus:\n self.lastDependenciesSatisfaction = False\n break\n else:\n if self.parent is not None:\n self.lastDependenciesSatisfaction = self.parent.checkDependenciesSatisfaction()\n\n return self.lastDependenciesSatisfaction", "metadata": "root.BaseNode.checkDependenciesSatisfaction", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 157 }, { "content": " def __new__(cls, *args, **kwargs):\n\n # Remove optional attributes for __new__ call, not supported, but the attributes are still transmitter via super hierarchy\n obj = super(BaseNode, cls).__new__(cls)\n obj._parent_value = None\n obj.invalidated = True\n return obj", "metadata": "root.BaseNode.__new__", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 175 }, { "content": " def __setattr__(self, name, value):\n if name == 'parent':\n self.setParentValue(value)\n super(BaseNode, self).__setattr__(name, value)", "metadata": "root.BaseNode.__setattr__", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 183 }, { "content": " def setParentValue(self, parent):\n if self.parent is parent:\n return\n if self.parent:\n self.parent.removeChild(self, False)\n if parent:\n parent.addChild(self, False)\n self.__dict__['parent'] = parent", "metadata": "root.BaseNode.setParentValue", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 188 }, { "content": " def dispatchIterator(self):\n raise NotImplementedError", "metadata": "root.BaseNode.dispatchIterator", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 197 }, { "content": " def updateAllocation(self):\n '''\n Called by subclasses during updateCompletion process to store maxRN and allocatedRN in the node.\n maxRN is also updated during webservice on user requests, this is a bit of a redefinition since it shouldn't change programmatically.\n '''\n\n # Need to iterate over all poolshares concerning the current node.\n # Otherwise we only update the allocatedRN of current pool (node the right value when user has changed pool during render)\n # nodeSharesList = [poolshare for poolshare in self.dispatcher.dispatchTree.poolShares.values() if poolshare.node.id == self.id and poolshare.node.status in [NODE_RUNNING, NODE_ERROR, NODE_PAUSED] ]\n # self.allocatedRN = 0\n # for currPoolShare in nodeSharesList:\n # self.maxRN = currPoolShare.maxRN\n # self.allocatedRN += currPoolShare.allocatedRN\n\n # Correct way, iterate over active poolshare and additionnal poolshares only\n self.allocatedRN = 0\n for currPoolShare in self.poolShares.values():\n self.maxRN = currPoolShare.maxRN\n self.allocatedRN += currPoolShare.allocatedRN\n\n for ps in self.additionnalPoolShares.values():\n self.allocatedRN += ps.allocatedRN", "metadata": "root.BaseNode.updateAllocation", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 200 }, { "content": " def updateCompletionAndStatus(self):\n raise NotImplementedError", "metadata": "root.BaseNode.updateCompletionAndStatus", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 223 }, { "content": " def __repr__(self):\n nodes = [self]\n parent = self.parent\n while parent is not None:\n nodes.insert(0, parent)\n parent = parent.parent\n names = [node.name for node in nodes]\n return \"<Node name='%s' path='/%s'>\" % (self.name, \"/\".join(names))", "metadata": "root.BaseNode.__repr__", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 226 }, { "content": " def __str__(self):\n return \"%s: maxRN=%d allocatedRN=%d\" % (self.name, self.maxRN, self.allocatedRN)", "metadata": "root.BaseNode.__str__", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 235 }, { "content": " def invalidate(self):\n self.invalidated = True\n while self.parent and not self.parent.invalidated:\n self.parent.invalidated = True\n self = self.parent", "metadata": "root.BaseNode.invalidate", "header": "['class', 'BaseNode', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 240 }, { "content": "class FolderNode(BaseNode):\n\n strategy = models.StrategyField()\n taskGroup = models.ModelField(allow_null=True)\n children = FolderNodeChildrenField()\n\n\n ##\n # @param id an integer, unique for this node\n # @param name a short string describing this folder\n # @param parent a FolderNode or None if this node is a root node\n # @param priority an integer priority value\n # @param dispatchKey a floating-point dispatchKey value\n # @param maxRN an integer value representing the maximum number of render\n # nodes that can be allocated to this tree node.\n # @param allocator a DispatchStrategy object\n #\n\n\n\n\n\n\n ##\n # @return yields (node, command) tuples\n #\n\n\n\n\n", "metadata": "root.FolderNode", "header": "['module', '___EOS___']", "index": 247 }, { "content": " @property\n def tags(self):\n return self.taskGroup.tags if self.taskGroup else {}", "metadata": "root.FolderNode.tags", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 253 }, { "content": " def __init__(self, id, name, parent, user, priority, dispatchKey, maxRN, strategy, creationTime=None, startTime=None, updateTime=None, endTime=None, status=NODE_DONE, taskGroup=None):\n BaseNode.__init__(self, id, name, parent, user, priority, dispatchKey, maxRN, creationTime, startTime, updateTime, endTime, status)\n self.children = []\n self.strategy = strategy\n self.taskGroup = taskGroup\n if taskGroup is not None:\n self.timer = taskGroup.timer", "metadata": "root.FolderNode.__init__", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 267 }, { "content": " def addChild(self, child, setParent=True):\n if child.parent is not self and setParent:\n child.parent = self\n else:\n self.children.append(child)\n self.fireChildAddedEvent(child)", "metadata": "root.FolderNode.addChild", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 275 }, { "content": " def removeChild(self, child, setParent=True):\n if child.parent is self and setParent:\n child.parent = None\n else:\n self.children.remove(child)\n self.fireChildRemovedEvent(child)", "metadata": "root.FolderNode.removeChild", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 282 }, { "content": " def fireChildAddedEvent(self, child):\n self.invalidate()\n for l in self.changeListeners:\n try:\n l.onChildAddedEvent(self, child)\n except AttributeError:\n pass", "metadata": "root.FolderNode.fireChildAddedEvent", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 289 }, { "content": " def fireChildRemovedEvent(self, child):\n self.invalidate()\n for l in self.changeListeners:\n try:\n l.onChildRemovedEvent(self, child)\n except AttributeError:\n pass", "metadata": "root.FolderNode.fireChildRemovedEvent", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 297 }, { "content": " def cmdIterator(self):\n for child in self.children:\n for command in child.cmdIterator():\n yield command\n # if pCascadeUpdate:\n # for dependingNode in self.reverseDependencies:\n # dependingNode.setStatus( pStatus, pCascadeUpdate )\n\n # for child in self.children:\n # child.setStatus(pStatus, pCascadeUpdate)\n\n # self.status = pStatus\n # return True", "metadata": "root.FolderNode.cmdIterator", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 305 }, { "content": " def dispatchIterator(self, stopFunc, ep=None):\n if ep is None:\n ep = self\n\n if self.readyCommandCount == 0:\n return\n self.strategy.update(self, ep)\n\n for child in self.children:\n try:\n # PRA: only the TaskNode.dispatchIterator() may raise NoRenderNodeAvailable or NoLicenseAvailableForTask\n for assignment in child.dispatchIterator(stopFunc, ep):\n node, command = assignment\n self.strategy.on_assignment(self, child, node)\n yield assignment\n # If no render node available for a command, all the commands of the parent tasks will not find a RN\n except NoRenderNodeAvailable:\n return\n # Lack of licence is specific to a command, so we continue to iterate through the graph\n except NoLicenseAvailableForTask:\n LOGGER.info(\"Missing license for node \\\"%s\\\" (other commands can start anyway).\" % self.name)\n continue\n # We should stop if stopFunction is reached\n if stopFunc():\n return", "metadata": "root.FolderNode.dispatchIterator", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 322 }, { "content": " def updateCompletionAndStatus(self):\n \"\"\"\n Evaluate new value for completion and status of a particular FolderNode\n \"\"\"\n\n self.updateAllocation()\n\n if not self.invalidated:\n return\n if not self.children:\n completion = 1.0\n status = NODE_DONE\n else:\n\n # Getting completion info\n self.readyCommandCount = 0\n self.doneCommandCount = 0\n self.commandCount = 0\n completion = 0.0\n status = defaultdict(int)\n for child in self.children:\n child.updateCompletionAndStatus()\n completion += child.completion\n status[child.status] += 1\n self.readyCommandCount += child.readyCommandCount\n self.doneCommandCount += child.doneCommandCount\n self.commandCount += child.commandCount\n\n if hasattr(self, \"commandCount\") and int(self.commandCount) != 0:\n self.completion = self.doneCommandCount / float(self.commandCount)\n else:\n # LOGGER.warning(\"Warning: a folder node without \\\"commandCount\\\" value was found -> %s\" % self.name )\n self.completion = completion / len(self.children)\n\n # Updating node's overall status\n if NODE_PAUSED in status:\n self.status = NODE_PAUSED\n elif NODE_ERROR in status:\n self.status = NODE_ERROR\n elif NODE_RUNNING in status:\n self.status = NODE_RUNNING\n elif NODE_READY in status:\n self.status = NODE_READY\n elif NODE_BLOCKED in status:\n self.status = NODE_BLOCKED\n elif NODE_CANCELED in status:\n self.status = NODE_CANCELED\n else:\n # all commands are DONE, ensure the completion is at 1.0 (in case of failed completion update from some workers)\n self.completion = 1.0\n self.status = NODE_DONE\n\n # Updating timers\n times = [childNode.creationTime for childNode in self.children if childNode.creationTime is not None]\n if times:\n self.creationTime = min(times)\n if self.taskGroup and (self.taskGroup.creationTime is None or self.taskGroup.creationTime > self.creationTime):\n self.taskGroup.creationTime = self.creationTime\n\n times = [childNode.startTime for childNode in self.children if childNode.startTime is not None]\n if times:\n self.startTime = min(times)\n if self.taskGroup and (self.taskGroup.startTime is None or self.taskGroup.startTime > self.startTime):\n self.taskGroup.startTime = self.startTime\n\n times = [childNode.updateTime for childNode in self.children if childNode.updateTime is not None]\n if times:\n self.updateTime = max(times)\n if self.taskGroup and (self.taskGroup.updateTime is None or self.taskGroup.updateTime > self.updateTime):\n self.taskGroup.updateTime = self.updateTime\n\n if isFinalNodeStatus(self.status):\n times = [childNode.endTime for childNode in self.children if childNode.endTime is not None]\n if times:\n self.endTime = max(times)\n if self.taskGroup and (self.taskGroup.endTime is None or\n self.taskGroup.endTime > self.taskGroup.endTime):\n self.taskGroup.endTime = self.endTime\n else:\n self.endTime = None\n if self.taskGroup:\n self.taskGroup.endTime = None\n self.invalidated = False\n if self.taskGroup:\n self.timer = self.taskGroup.timer\n # FIXME: suboptimal... lazy update someday ?\n self.taskGroup.updateStatusAndCompletion()", "metadata": "root.FolderNode.updateCompletionAndStatus", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 348 }, { "content": " def setPaused(self, paused):\n for child in self.children:\n child.setPaused(paused)", "metadata": "root.FolderNode.setPaused", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 436 }, { "content": " def resetCompletion(self):\n self.completion = 0\n for child in self.children:\n child.resetCompletion()", "metadata": "root.FolderNode.resetCompletion", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 440 }, { "content": " def setStatus(self, pStatus, pCascadeUpdate=False):\n '''\n | Propagates a target status update request.\n | @see doc/design/node-status-update.txt\n\n :param pStatus: New status value to assign to the current node\n :param pCascadeUpdate: Flag indicating if the depending nodes need to be updated in cascade\n '''\n if pCascadeUpdate:\n for dependingNode in self.reverseDependencies:\n dependingNode.setStatus(pStatus, pCascadeUpdate)\n\n for child in self.children:\n child.setStatus(pStatus, pCascadeUpdate)\n\n self.status = pStatus\n return True", "metadata": "root.FolderNode.setStatus", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 445 }, { "content": " def setMaxAttempt(self, maxAttempt):\n '''\n '''\n globalResult = True\n\n for child in self.children:\n res = child.setMaxAttempt(maxAttempt)\n if res is False:\n globalResult = False\n\n self.dispatcher.dispatchTree.toModifyElements.append(self)\n return globalResult", "metadata": "root.FolderNode.setMaxAttempt", "header": "['class', 'FolderNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 463 }, { "content": "class TaskNode(BaseNode):\n\n task = models.ModelField()\n paused = models.BooleanField()\n maxAttempt = models.IntegerField()\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TaskNode", "header": "['module', '___EOS___']", "index": 477 }, { "content": " @property\n def tags(self):\n if self.task is not None:\n return self.task.tags\n return None", "metadata": "root.TaskNode.tags", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 483 }, { "content": " def __init__(self, id, name, parent, user, priority, dispatchKey, maxRN, task, creationTime=None, startTime=None, updateTime=None, endTime=None, status=NODE_BLOCKED, paused=False, maxAttempt=1):\n '''\n :param id: an integer, unique for this node\n :param name: a short string describing this folder\n :param parent: a FolderNode or None if this node is a root node\n :param priority: an integer priority value\n :param dispatchKey: a floating-point dispatchKey value\n :param maxRN: an integer value representing the maximum number of render\n nodes that can be allocated to this tree node.\n :param task: a Task object\n '''\n BaseNode.__init__(self, id, name, parent, user, priority, dispatchKey, maxRN, creationTime, startTime, updateTime, endTime, status)\n self.task = task\n self.paused = paused\n self.maxAttempt = int(maxAttempt)\n\n self.commmandCount = 0\n\n if task is not None:\n self.timer = task.timer\n self.maxAttempt = int(task.maxAttempt)\n self.commandCount = len(task.commands)", "metadata": "root.TaskNode.__init__", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 489 }, { "content": " def cmdIterator(self):\n for command in self.task.commands:\n yield command", "metadata": "root.TaskNode.cmdIterator", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 512 }, { "content": " def dispatchIterator(self, stopFunc, ep=None):\n # PRA : we don't use the stop function here ...\n\n if ep is None:\n ep = self\n\n # Return if no readyCommand or job in pause\n if self.readyCommandCount == 0:\n return\n if self.paused:\n return\n\n # ensure we are treating the commands in the order they arrived\n sorted(self.task.commands, key=lambda x: x.id)\n for command in self.task.commands:\n if command.status != CMD_READY:\n continue\n # PRA : search a render node to assign command\n renderNode = self.reserve_rendernode(command, ep)\n # PRA : renderNode is None if we did not found a RN that match job contraints\n if not renderNode:\n # PRA : Requirements depends on the task (and not the command)\n # So if we don't find a RN for a command, we would not find one for the command related to the same task\n return\n\n # Decrease the number of ready commands through the hierarchy\n self.readyCommandCount -= 1\n tmp_ep = ep\n while tmp_ep:\n tmp_ep.readyCommandCount -= 1\n tmp_ep = tmp_ep.parent\n\n yield (renderNode, command)", "metadata": "root.TaskNode.dispatchIterator", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 516 }, { "content": " def reserve_rendernode(self, command, ep):\n '''\n :param command:\n :returns: renderNode assigned to command\n None if no RNs found due to constraints\n '''\n if ep is None:\n ep = self\n\n for poolshare in [poolShare for poolShare in ep.poolShares.values() if poolShare.hasRenderNodesAvailable()]:\n # first, sort the rendernodes according their performance value\n rnList = sorted(poolshare.pool.renderNodes, key=lambda rn: rn.performance, reverse=True)\n for rendernode in rnList:\n if rendernode.isAvailable() and rendernode.canRun(command):\n if rendernode.reserveLicense(command, self.dispatcher.licenseManager):\n rendernode.addAssignment(command)\n return rendernode\n else:\n raise NoLicenseAvailableForTask\n\n # Might not be necessary anymore because first loop is based on poolShare's hasRNSavailable method\n # It was not taking into account the tests before assignment: RN.canRun()\n if not [poolShare for poolShare in ep.poolShares.values() if poolShare.hasRenderNodesAvailable()]:\n raise NoRenderNodeAvailable\n return None", "metadata": "root.TaskNode.reserve_rendernode", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 550 }, { "content": " def updateCompletionAndStatus(self):\n '''\n Evaluate new value for completion and status of a particular TaskNode\n '''\n self.updateAllocation()\n\n if not self.invalidated:\n return\n if self.task is None:\n self.status = NODE_CANCELED\n return\n completion = 0.0\n status = defaultdict(int)\n self.readyCommandCount = 0\n self.doneCommandCount = 0\n self.commandCount = len(self.task.commands)\n\n for command in self.task.commands:\n completion += command.completion\n status[command.status] += 1\n if command.status == CMD_READY:\n self.readyCommandCount += 1\n if command.status == CMD_DONE:\n self.doneCommandCount += 1\n\n if self.task.commands:\n self.completion = completion / len(self.task.commands)\n else:\n self.completion = 1.0\n\n if CMD_CANCELED in status:\n self.status = NODE_CANCELED\n elif self.paused:\n self.status = NODE_PAUSED\n elif CMD_ERROR in status:\n self.status = NODE_ERROR\n elif CMD_TIMEOUT in status:\n self.status = NODE_ERROR\n elif CMD_RUNNING in status:\n self.status = NODE_RUNNING\n elif CMD_ASSIGNED in status:\n self.status = NODE_READY\n elif CMD_FINISHING in status:\n self.status = NODE_RUNNING\n elif CMD_READY in status:\n self.status = NODE_READY\n elif CMD_BLOCKED in status:\n self.status = NODE_BLOCKED\n else:\n # all commands are DONE, ensure the completion is at 1.0 (in case of failed completion update from some workers)\n self.completion = 1.0\n self.status = NODE_DONE\n\n times = [command.creationTime for command in self.task.commands if command.creationTime is not None]\n if times:\n self.creationTime = min(times)\n\n times = [command.startTime for command in self.task.commands if command.startTime is not None]\n if times:\n self.startTime = min(times)\n\n times = [command.updateTime for command in self.task.commands if command.updateTime is not None]\n if times:\n self.updateTime = max(times)\n\n # only set the endTime on the node if it's done\n if self.status == NODE_DONE:\n times = [command.endTime for command in self.task.commands if command.endTime is not None]\n if times:\n self.endTime = max(times)\n else:\n self.endTime = None\n\n self.task.status = self.status\n self.task.completion = self.completion\n self.task.creationTime = self.creationTime\n self.task.startTime = self.startTime\n self.task.updateTime = self.updateTime\n self.task.endTime = self.endTime\n\n self.timer = self.task.timer\n\n self.invalidated = False", "metadata": "root.TaskNode.updateCompletionAndStatus", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 576 }, { "content": " def checkDependenciesSatisfaction(self):\n # TODO dependencies should be set for restricted node statutes only: DONE, ERROR and CANCELED\n taskNodes = [taskNode\n for taskNode in self.dispatcher.dispatchTree.nodes.values()\n if isinstance(taskNode, TaskNode) and taskNode.task == self.task]\n return all(BaseNode.checkDependenciesSatisfaction(taskNode) for taskNode in taskNodes)", "metadata": "root.TaskNode.checkDependenciesSatisfaction", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 660 }, { "content": " def setPaused(self, paused):\n # pause every job not done\n if self.status != NODE_DONE:\n self.paused = paused\n if self.status == NODE_PAUSED and not paused:\n self.status = NODE_READY\n self.invalidate()", "metadata": "root.TaskNode.setPaused", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 667 }, { "content": " def setMaxAttempt(self, maxAttempt):\n '''\n '''\n if not isinstance(self.task, Task):\n return False\n\n # Update node's task if exists\n self.task.maxAttempt = maxAttempt\n\n # Update node\n self.maxAttempt = maxAttempt\n\n self.dispatcher.dispatchTree.toModifyElements.append(self.task)\n self.dispatcher.dispatchTree.toModifyElements.append(self)\n\n return True", "metadata": "root.TaskNode.setMaxAttempt", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 675 }, { "content": " def resetCompletion(self):\n\n self.completion = 0\n for command in self.task.commands:\n command.completion = 0", "metadata": "root.TaskNode.resetCompletion", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 692 }, { "content": " def setStatus(self, pStatus, pCascadeUpdate=False):\n '''\n | Update commands in order to reach the required status.\n | If proper param is given, depending node will receive the same status.\n\n :param pStatus: New status value to assign to the current node\n :param pCascadeUpdate: Flag indicating if the depending node need to be updated in cascade\n '''\n\n if pCascadeUpdate:\n for dependingNode in self.reverseDependencies:\n dependingNode.setStatus(pStatus, pCascadeUpdate)\n\n if pStatus == NODE_CANCELED and self.status != NODE_DONE:\n for command in self.task.commands:\n command.cancel()\n elif pStatus == NODE_READY and self.status != NODE_RUNNING:\n if any(isRunningStatus(command.status) for command in self.task.commands):\n return False\n for command in self.task.commands:\n command.setReadyStatus()\n elif pStatus in (NODE_DONE, NODE_ERROR, NODE_BLOCKED, NODE_RUNNING):\n return False\n return True", "metadata": "root.TaskNode.setStatus", "header": "['class', 'TaskNode', '(', 'BaseNode', ')', ':', '___EOS___']", "index": 698 } ]
[ { "span": "def dispatchIterator(self, stopFunc, ep=None):", "start_line": 322, "start_column": 4, "end_line": 322, "end_column": 50 }, { "span": "def dispatchIterator(self, stopFunc, ep=None):", "start_line": 516, "start_column": 4, "end_line": 516, "end_column": 50 } ]
[ { "span": "def dispatchIterator(self):", "start_line": 197, "start_column": 4, "end_line": 197, "end_column": 31 } ]
1
false
[ "[CLS]_", "Signature_", "mismatch_", "in_", "overrid", "ing_", "method_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dispatcher_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "models_", "._", "String", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "models_", "._", "Model", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "models_", "._", "String", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priority_", "=_", "models_", "._", "Integer", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dispatch", "Key_", "=_", "models_", "._", "Float", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "RN", "_", "=_", "models_", "._", "Integer", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "Time_", "=_", "models_", "._", "Float", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool", "Share", "s_", "=_", "Poo", "l", "Share", "Dict", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addition", "nal", "Poo", "l", "Share", "s_", "=_", "Addition", "nal", "Poo", "l", "Share", "Dict", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completion_", "=_", "models_", "._", "Float", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "models_", "._", "Integer", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "creati", "on", "Time_", "=_", "models_", "._", "Float", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "Time_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "Time_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "Time_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dependencies_", "=_", "Dependenc", "y", "List", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "averag", "e", "Time", "By", "Frame_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "min", "Time", "By", "Frame_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "Time", "By", "Frame_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timer_", "=_", "models_", "._", "Float", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parent", "\\u", "value_", "=_", "property_", "(_", "lambda_", "self_", ":_", "self_", "._", "\\u", "parent", "\\u", "value_", ",_", "set", "Parent", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "tags_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "parent_", ",_", "user_", ",_", "priority_", ",_", "dispatch", "Key_", ",_", "max", "RN", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "creati", "on", "Time_", "=_", "None_", ",_", "start", "Time_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "update", "Time_", "=_", "None_", ",_", "end", "Time_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "NODE", "\\u", "READY", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Base", " ", "class", " ", "for", " ", "each", " ", "node", " ", "in", " ", "dispatcher", " ", "tree", " ", "structure", ".", " ", "Hold", "s", " ", "main", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "fields", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "id", " ", "int", ":", " ", "unique", " ", "id", " ", "for", " ", "this", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "name", " ", "str", ":", " ", " ", "a", " ", "short", " ", "string", " ", "descri", "bing", " ", "this", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "parent", ":", " ", "a", " ", "Fold", "er", "Node", " ", "or", " ", "Non", "e", " ", "if", " ", "this", " ", "node", " ", "is", " ", "a", " ", "root", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "priorit", "y", " ", "int", ":", " ", "priorit", "y", " ", "value", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "dispatch", "Key", " ", "int", ":", " ", "dispatch", "Key", " ", "value", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "max", "RN", " ", "int", ":", " ", "maxim", "um", " ", "number", " ", "of", " ", "render", " ", "nodes", " ", "tha", "t", " ", "can", " ", "be", " ", "allocated", " ", "to", " ", "this", " ", "tree", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "creati", "on", "Time", ":", " ", "timestamp", " ", "indicati", "ng", " ", "whe", "n", " ", "the", " ", "node", " ", "was", " ", "created", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "start", "Time", ":", " ", "timestamp", " ", "indicati", "ng", " ", "whe", "n", " ", "the", " ", "node", " ", "was", " ", "start", "ed", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "update", "Time", ":", " ", "timestamp", " ", "indicati", "ng", " ", "whe", "n", " ", "the", " ", "node", " ", "was", " ", "update", "d", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "end", "Time", ":", " ", "timestamp", " ", "indicati", "ng", " ", "whe", "n", " ", "the", " ", "node", " ", "was", " ", "ende", "d", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "status", " ", "int", ":", " ", "current", " ", "node", "'", "s", " ", "status", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "dispatcher_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "octop", "us_", "._", "dispatcher_", "._", "dispatcher_", "import_", "Dispatcher_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dispatcher_", "=_", "Dispatcher_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u\\u", "dict\\u\\u_", "[_", "'", "parent", "'_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "models_", "._", "Model_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "id_", "=_", "int_", "(_", "id_", ")_", "if_", "id_", "is_", "not_", "None_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "str_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "=_", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "user_", "=_", "str_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "priority_", "=_", "int_", "(_", "priority_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dispatch", "Key_", "=_", "int_", "(_", "dispatch", "Key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "RN", "_", "=_", "int_", "(_", "max", "RN", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "optim", "al", "Max", "RN", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "allocated", "RN", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pool", "Share", "s_", "=_", "Wea", "k", "Key", "Dictionary_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "addition", "nal", "Poo", "l", "Share", "s_", "=_", "Wea", "k", "Key", "Dictionary_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "completion_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "status_", "=_", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "creati", "on", "Time_", "=_", "time_", "(_", ")_", "if_", "not_", "creati", "on", "Time_", "else_", "creati", "on", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "Time_", "=_", "start", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "Time_", "=_", "update", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "Time_", "=_", "end", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "dependencies_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reverse", "Dependenc", "ies_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action", "Dispa", "tch", "Cycle_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "read", "y", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "don", "e", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "averag", "e", "Time", "By", "Frame", "List_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "averag", "e", "Time", "By", "Frame_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "min", "Time", "By", "Frame_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "Time", "By", "Frame_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main", "Poo", "l", "Share", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "pool", "Share", "s_", "._", "values_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main", "Pool_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "pool", "Share", "s_", "._", "keys_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "to", "\\u", "json_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "base_", "=_", "super_", "(_", "Base", "Node_", ",_", "self_", ")_", "._", "to", "\\u", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "allocated", "RN", "\"_", "]_", "=_", "self_", "._", "allocated", "RN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "optim", "al", "Max", "RN", "\"_", "]_", "=_", "self_", "._", "optim", "al", "Max", "RN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "tags", "\"_", "]_", "=_", "self_", "._", "tags_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "read", "y", "Command", "Count", "\"_", "]_", "=_", "self_", "._", "read", "y", "Command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "don", "e", "Command", "Count", "\"_", "]_", "=_", "self_", "._", "don", "e", "Command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base_", "[_", "\"", "command", "Count", "\"_", "]_", "=_", "self_", "._", "command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "base_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Dependency_", "(_", "self_", ",_", "node_", ",_", "accept", "ed", "Status_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "dependen", "cies", " ", "shou", "ld", " ", "be", " ", "set", " ", "for", " ", "restrict", "ed", " ", "node", " ", "stat", "ute", "s", " ", "only", ":", " ", "DON", "E", ",", " ", "ERROR", " ", "and", " ", "CANCEL", "ED_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "accept", "ed", "Status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "is_", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", " ", "dependen", "cies", " ", "on", " ", "ones", "elf_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "status_", "=_", "NODE", "\\u", "BLOCK", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "val_", "=_", "[_", "node_", ",_", "accept", "ed", "Status_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "val_", "in_", "self_", "._", "dependencies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "dependencies_", "._", "append_", "(_", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "not_", "in_", "node_", "._", "reverse", "Dependenc", "ies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "._", "reverse", "Dependenc", "ies_", "._", "append_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Dependenc", "ies", "Sat", "isf", "action_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "dependen", "cies", " ", "shou", "ld", " ", "be", " ", "set", " ", "for", " ", "restrict", "ed", " ", "node", " ", "stat", "ute", "s", " ", "only", ":", " ", "DON", "E", ",", " ", "ERROR", " ", "and", " ", "CANCEL", "ED_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "dispatcher_", "._", "cycle_", "==_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action", "Dispa", "tch", "Cycle_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action", "Dispa", "tch", "Cycle_", "=_", "self_", "._", "dispatcher_", "._", "cycle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", ",_", "accept", "ed", "Status_", "in_", "self_", "._", "dependencies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node_", "._", "status_", "not_", "in_", "accept", "ed", "Status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "parent_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "=_", "self_", "._", "parent_", "._", "check", "Dependenc", "ies", "Sat", "isf", "action_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "last", "Dependenc", "ies", "Sat", "isf", "action_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Remove", " ", "option", "al", " ", "attribute", "s", " ", "for", " ", "\\u\\u", "new", "\\u\\u", " ", "call", ",", " ", "not", " ", "support", "ed", ",", " ", "but", " ", "the", " ", "attribute", "s", " ", "are", " ", "still", " ", "transmitte", "r", " ", "via", " ", "super", " ", "hierarchy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "super_", "(_", "Base", "Node_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "cls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "._", "\\u", "parent", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "._", "invalidate", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "setattr\\u\\u_", "(_", "self_", ",_", "name_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "name_", "==_", "'", "parent", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Parent", "Value_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "Base", "Node_", ",_", "self_", ")_", "._", "\\u\\u", "setattr\\u\\u_", "(_", "name_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Parent", "Value_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "parent_", "is_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parent_", "._", "remove", "Child_", "(_", "self_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "._", "add", "Child_", "(_", "self_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u\\u", "dict\\u\\u_", "[_", "'", "parent", "'_", "]_", "=_", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dispatch", "Iterator_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Allocati", "on_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Call", "ed", " ", "by", " ", "subclasses", " ", "dur", "ing", " ", "update", "Completi", "on", " ", "process", " ", "to", " ", "store", " ", "max", "RN", " ", "and", " ", "allocated", "RN", " ", "in", " ", "the", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", "max", "RN", " ", "is", " ", "als", "o", " ", "update", "d", " ", "dur", "ing", " ", "webservice", " ", "on", " ", "user", " ", "request", "s", ",", " ", "this", " ", "is", " ", "a", " ", "bit", " ", "of", " ", "a", " ", "rede", "fini", "tion", " ", "sinc", "e", " ", "it", " ", "shou", "ld", "n", "'", "t", " ", "change", " ", "program", "matical", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ne", "ed", " ", "to", " ", "iterate", " ", "over", " ", "all", " ", "pools", "hare", "s", " ", "concern", "ing", " ", "the", " ", "current", " ", "node", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ot", "her", "wis", "e", " ", "we", " ", "only", " ", "update", " ", "the", " ", "allocated", "RN", " ", "of", " ", "current", " ", "pool", " ", "(", "node", " ", "the", " ", "right", " ", "value", " ", "whe", "n", " ", "user", " ", "has", " ", "change", "d", " ", "pool", " ", "dur", "ing", " ", "render", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "node", "Share", "s", "List", " ", "=", " ", "[", "pools", "hare", " ", "for", " ", "pools", "hare", " ", "in", " ", "self", ".", "dispatcher", ".", "dispatch", "Tree", ".", "pool", "Share", "s", ".", "values", "()", " ", "if", " ", "pools", "hare", ".", "node", ".", "id", " ", "==", " ", "self", ".", "id", " ", "and", " ", "pools", "hare", ".", "node", ".", "status", " ", "in", " ", "[", "NODE", "\\u", "RUNN", "ING", ",", " ", "NODE", "\\u", "ERROR", ",", " ", "NODE", "\\u", "PAUSE", "D", "]", " ", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "allocated", "RN", " ", "=", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "curr", "Poo", "l", "Share", " ", "in", " ", "node", "Share", "s", "List", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "max", "RN", " ", "=", " ", "curr", "Poo", "l", "Share", ".", "max", "RN", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "allocated", "RN", " ", "+=", " ", "curr", "Poo", "l", "Share", ".", "allocated", "RN", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Correct", " ", "way", ",", " ", "iterate", " ", "over", " ", "active", " ", "pools", "hare", " ", "and", " ", "addition", "nal", " ", "pools", "hare", "s", " ", "only_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "allocated", "RN", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "curr", "Poo", "l", "Share", "_", "in_", "self_", "._", "pool", "Share", "s_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "max", "RN", "_", "=_", "curr", "Poo", "l", "Share", "_", "._", "max", "RN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "allocated", "RN", "_", "+=_", "curr", "Poo", "l", "Share", "_", "._", "allocated", "RN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "ps_", "in_", "self_", "._", "addition", "nal", "Poo", "l", "Share", "s_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "allocated", "RN", "_", "+=_", "ps_", "._", "allocated", "RN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Completi", "on", "And", "Status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "=_", "[_", "self_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "parent_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "._", "insert_", "(_", "0_", ",_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "parent_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "names_", "=_", "[_", "node_", "._", "name_", "for_", "node_", "in_", "nodes_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"<", "Node", " ", "name", "='", "%", "s", "'", " ", "path", "='", "/", "%", "s", "'>\"_", "%_", "(_", "self_", "._", "name_", ",_", "\"/\"_", "._", "join_", "(_", "names_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", ":", " ", "max", "RN", "=", "%", "d", " ", "allocated", "RN", "=", "%", "d", "\"_", "%_", "(_", "self_", "._", "name_", ",_", "self_", "._", "max", "RN", "_", ",_", "self_", "._", "allocated", "RN", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Node_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "invalidate", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "invalidate", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "self_", "._", "parent_", "and_", "not_", "self_", "._", "parent_", "._", "invalidate", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parent_", "._", "invalidate", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "strategy_", "=_", "models_", "._", "Strat", "eg", "y", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "task", "Group_", "=_", "models_", "._", "Model", "Field_", "(_", "allow", "\\u", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "children_", "=_", "Fold", "er", "Node", "Chil", "dre", "n", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "id", " ", "an", " ", "integ", "er", ",", " ", "unique", " ", "for", " ", "this", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "name", " ", "a", " ", "short", " ", "string", " ", "descri", "bing", " ", "this", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "parent", " ", "a", " ", "Fold", "er", "Node", " ", "or", " ", "Non", "e", " ", "if", " ", "this", " ", "node", " ", "is", " ", "a", " ", "root", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "priorit", "y", " ", "an", " ", "integ", "er", " ", "priorit", "y", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "dispatch", "Key", " ", "a", " ", "float", "ing", "-", "point", " ", "dispatch", "Key", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "max", "RN", " ", "an", " ", "integ", "er", " ", "value", " ", "represent", "ing", " ", "the", " ", "maxim", "um", " ", "number", " ", "of", " ", "render_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", "nodes", " ", "tha", "t", " ", "can", " ", "be", " ", "allocated", " ", "to", " ", "this", " ", "tree", " ", "node", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "allocat", "or", " ", "a", " ", "Dispa", "tch", "Strat", "eg", "y", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "return", " ", "yield", "s", " ", "(", "node", ",", " ", "command", ")", " ", "tuples_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "tags_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "task", "Group_", "._", "tags_", "if_", "self_", "._", "task", "Group_", "else_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "parent_", ",_", "user_", ",_", "priority_", ",_", "dispatch", "Key_", ",_", "max", "RN", "_", ",_", "strategy_", ",_", "creati", "on", "Time_", "=_", "None_", ",_", "start", "Time_", "=_", "None_", ",_", "update", "Time_", "=_", "None_", ",_", "end", "Time_", "=_", "None_", ",_", "status_", "=_", "NODE", "\\u", "DONE_", ",_", "task", "Group_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Base", "Node_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "parent_", ",_", "user_", ",_", "priority_", ",_", "dispatch", "Key_", ",_", "max", "RN", "_", ",_", "creati", "on", "Time_", ",_", "start", "Time_", ",_", "update", "Time_", ",_", "end", "Time_", ",_", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "children_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "strategy_", "=_", "strategy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task", "Group_", "=_", "task", "Group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "task", "Group_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "=_", "task", "Group_", "._", "timer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Child_", "(_", "self_", ",_", "child_", ",_", "set", "Parent_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "child_", "._", "parent_", "is_", "not_", "self_", "and_", "set", "Parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "parent_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "children_", "._", "append_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fire", "Chil", "d", "Added", "Event_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "Child_", "(_", "self_", ",_", "child_", ",_", "set", "Parent_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "child_", "._", "parent_", "is_", "self_", "and_", "set", "Parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "parent_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "children_", "._", "remove_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fire", "Chil", "d", "Remove", "d", "Event_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fire", "Chil", "d", "Added", "Event_", "(_", "self_", ",_", "child_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "invalidate", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "self_", "._", "change", "Listen", "ers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "._", "on", "Chil", "d", "Added", "Event_", "(_", "self_", ",_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Attribute", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fire", "Chil", "d", "Remove", "d", "Event_", "(_", "self_", ",_", "child_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "invalidate", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "self_", "._", "change", "Listen", "ers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "._", "on", "Chil", "d", "Remove", "d", "Event_", "(_", "self_", ",_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Attribute", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "Iterator_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "command_", "in_", "child_", "._", "cmd", "Iterator_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "p", "Casca", "de", "Update", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "depend", "ing", "Node", " ", "in", " ", "self", ".", "reverse", "Dependenc", "ies", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "depend", "ing", "Node", ".", "set", "Status", "(", " ", "p", "Status", ",", " ", "p", "Casca", "de", "Update", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "child", " ", "in", " ", "self", ".", "child", "ren", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "child", ".", "set", "Status", "(", "p", "Status", ",", " ", "p", "Casca", "de", "Update", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "status", " ", "=", " ", "p", "Status_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dispatch", "Iterator_", "(_", "self_", ",_", "stop", "Func_", ",_", "ep_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ep_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ep_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "read", "y", "Command", "Count_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "strategy_", "._", "update_", "(_", "self_", ",_", "ep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PRA", ":", " ", "only", " ", "the", " ", "Task", "Node", ".", "dispatch", "Iterat", "or", "()", " ", "may", " ", "raise", " ", "No", "Render", "Node", "Avail", "able", " ", "or", " ", "No", "License", "Avail", "able", "For", "Task_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "assignment_", "in_", "child_", "._", "dispatch", "Iterator_", "(_", "stop", "Func_", ",_", "ep_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "node_", ",_", "command_", "=_", "assignment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "strategy_", "._", "on", "\\u", "assignment_", "(_", "self_", ",_", "child_", ",_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "assignment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "no", " ", "render", " ", "node", " ", "avail", "able", " ", "for", " ", "a", " ", "command", ",", " ", "all", " ", "the", " ", "command", "s", " ", "of", " ", "the", " ", "parent", " ", "task", "s", " ", "will", " ", "not", " ", "find", " ", "a", " ", "RN", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Render", "Node", "Available_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Lac", "k", " ", "of", " ", "licence", " ", "is", " ", "specific", " ", "to", " ", "a", " ", "command", ",", " ", "so", " ", "we", " ", "continue", " ", "to", " ", "iterate", " ", "through", " ", "the", " ", "graph_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "License", "Avail", "able", "For", "Task_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "LOGGER_", "._", "info_", "(_", "\"", "Missing", " ", "license", " ", "for", " ", "node", " ", "\\\\\"", "%", "s", "\\\\\"", " ", "(", "other", " ", "command", "s", " ", "can", " ", "start", " ", "anyway", ").\"_", "%_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "shou", "ld", " ", "stop", " ", "if", " ", "stop", "Function", " ", "is", " ", "reache", "d_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "stop", "Func_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Completi", "on", "And", "Status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Evaluate", " ", "new", " ", "value", " ", "for", " ", "completion", " ", "and", " ", "status", " ", "of", " ", "a", " ", "partic", "ular", " ", "Fold", "er", "Node", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "update", "Allocati", "on_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "invalidate", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "completion_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "NODE", "\\u", "DONE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", "ting", " ", "completion", " ", "info_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "read", "y", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "don", "e", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completion_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "defaultdict_", "(_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "update", "Completi", "on", "And", "Status_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completion_", "+=_", "child_", "._", "completion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "child_", "._", "status_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "read", "y", "Command", "Count_", "+=_", "child_", "._", "read", "y", "Command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "don", "e", "Command", "Count_", "+=_", "child_", "._", "don", "e", "Command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "Count_", "+=_", "child_", "._", "command", "Count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "self_", ",_", "\"", "command", "Count", "\"_", ")_", "and_", "int_", "(_", "self_", "._", "command", "Count_", ")_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "self_", "._", "don", "e", "Command", "Count_", "/_", "float_", "(_", "self_", "._", "command", "Count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "LOGGE", "R", ".", "warn", "ing", "(\"", "Warn", "ing", ":", " ", "a", " ", "folder", " ", "node", " ", "with", "out", " ", "\\\\\"", "command", "Count", "\\\\\"", " ", "value", " ", "was", " ", "found", " ", "->", " ", "%", "s", "\"", " ", "%", " ", "self", ".", "name", " ", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "completion_", "/_", "len_", "(_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Up", "dati", "ng", " ", "node", "'", "s", " ", "over", "all", " ", "status_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "NODE", "\\u", "PAUSE", "D_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "PAUSE", "D_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "NODE", "\\u", "ERROR_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "NODE", "\\u", "RUNNING_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "RUNNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "NODE", "\\u", "READY", "_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "READY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "NODE", "\\u", "BLOCK", "ED_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "BLOCK", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "NODE", "\\u", "CANCEL", "ED_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "CANCEL", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "all", " ", "command", "s", " ", "are", " ", "DON", "E", ",", " ", "ensure", " ", "the", " ", "completion", " ", "is", " ", "at", " ", "1.0", " ", "(", "in", " ", "case", " ", "of", " ", "fail", "ed", " ", "completion", " ", "update", " ", "from", " ", "some", " ", "worker", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "status_", "=_", "NODE", "\\u", "DONE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Up", "dati", "ng", " ", "timers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "child", "Node_", "._", "creati", "on", "Time_", "for_", "child", "Node_", "in_", "self_", "._", "children_", "if_", "child", "Node_", "._", "creati", "on", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "creati", "on", "Time_", "=_", "min_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", "and_", "(_", "self_", "._", "task", "Group_", "._", "creati", "on", "Time_", "is_", "None_", "or_", "self_", "._", "task", "Group_", "._", "creati", "on", "Time_", ">_", "self_", "._", "creati", "on", "Time_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "task", "Group_", "._", "creati", "on", "Time_", "=_", "self_", "._", "creati", "on", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "child", "Node_", "._", "start", "Time_", "for_", "child", "Node_", "in_", "self_", "._", "children_", "if_", "child", "Node_", "._", "start", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "Time_", "=_", "min_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", "and_", "(_", "self_", "._", "task", "Group_", "._", "start", "Time_", "is_", "None_", "or_", "self_", "._", "task", "Group_", "._", "start", "Time_", ">_", "self_", "._", "start", "Time_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "task", "Group_", "._", "start", "Time_", "=_", "self_", "._", "start", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "child", "Node_", "._", "update", "Time_", "for_", "child", "Node_", "in_", "self_", "._", "children_", "if_", "child", "Node_", "._", "update", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "update", "Time_", "=_", "max_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", "and_", "(_", "self_", "._", "task", "Group_", "._", "update", "Time_", "is_", "None_", "or_", "self_", "._", "task", "Group_", "._", "update", "Time_", ">_", "self_", "._", "update", "Time_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "task", "Group_", "._", "update", "Time_", "=_", "self_", "._", "update", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "Final", "Node", "Status_", "(_", "self_", "._", "status_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "times_", "=_", "[_", "child", "Node_", "._", "end", "Time_", "for_", "child", "Node_", "in_", "self_", "._", "children_", "if_", "child", "Node_", "._", "end", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "end", "Time_", "=_", "max_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", "and_", "(_", "self_", "._", "task", "Group_", "._", "end", "Time_", "is_", "None_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "task", "Group_", "._", "end", "Time_", ">_", "self_", "._", "task", "Group_", "._", "end", "Time_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "task", "Group_", "._", "end", "Time_", "=_", "self_", "._", "end", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "end", "Time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "task", "Group_", "._", "end", "Time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "invalidate", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "task", "Group_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "=_", "self_", "._", "task", "Group_", "._", "timer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "subo", "pti", "mal", "...", " ", "lazy", " ", "update", " ", "some", "day", " ", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "task", "Group_", "._", "update", "Status", "And", "Completi", "on_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Pause", "d_", "(_", "self_", ",_", "paused_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "set", "Pause", "d_", "(_", "paused_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset", "Completi", "on_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "reset", "Completi", "on_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Status_", "(_", "self_", ",_", "p", "Status_", ",_", "p", "Casca", "de", "Update_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "Propag", "ates", " ", "a", " ", "target", " ", "status", " ", "update", " ", "request", ".", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "@", "see", " ", "doc", "/", "design", "/", "node", "-", "status", "-", "update", ".", "txt", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "p", "Status", ":", " ", "New", " ", "status", " ", "value", " ", "to", " ", "assign", " ", "to", " ", "the", " ", "current", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "p", "Casca", "de", "Update", ":", " ", "Fla", "g", " ", "indicati", "ng", " ", "if", " ", "the", " ", "depend", "ing", " ", "nodes", " ", "need", " ", "to", " ", "be", " ", "update", "d", " ", "in", " ", "cascade", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "p", "Casca", "de", "Update_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "depend", "ing", "Node_", "in_", "self_", "._", "reverse", "Dependenc", "ies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "depend", "ing", "Node_", "._", "set", "Status_", "(_", "p", "Status_", ",_", "p", "Casca", "de", "Update_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "set", "Status_", "(_", "p", "Status_", ",_", "p", "Casca", "de", "Update_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "status_", "=_", "p", "Status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fold", "er", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Max", "Atte", "mpt", "_", "(_", "self_", ",_", "max", "Atte", "mpt", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global", "Result_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "child_", "._", "set", "Max", "Atte", "mpt", "_", "(_", "max", "Atte", "mpt", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "res_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global", "Result_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "dispatcher_", "._", "dispatch", "Tree_", "._", "to", "Modif", "y", "Elements_", "._", "append_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "global", "Result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "task_", "=_", "models_", "._", "Model", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "paused_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "Atte", "mpt", "_", "=_", "models_", "._", "Integer", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "tags_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "task_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "task_", "._", "tags_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "parent_", ",_", "user_", ",_", "priority_", ",_", "dispatch", "Key_", ",_", "max", "RN", "_", ",_", "task_", ",_", "creati", "on", "Time_", "=_", "None_", ",_", "start", "Time_", "=_", "None_", ",_", "update", "Time_", "=_", "None_", ",_", "end", "Time_", "=_", "None_", ",_", "status_", "=_", "NODE", "\\u", "BLOCK", "ED_", ",_", "paused_", "=_", "False_", ",_", "max", "Atte", "mpt", "_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "id", ":", " ", "an", " ", "integ", "er", ",", " ", "unique", " ", "for", " ", "this", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "name", ":", " ", "a", " ", "short", " ", "string", " ", "descri", "bing", " ", "this", " ", "folder", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "parent", ":", " ", "a", " ", "Fold", "er", "Node", " ", "or", " ", "Non", "e", " ", "if", " ", "this", " ", "node", " ", "is", " ", "a", " ", "root", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "priorit", "y", ":", " ", "an", " ", "integ", "er", " ", "priorit", "y", " ", "value", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "dispatch", "Key", ":", " ", "a", " ", "float", "ing", "-", "point", " ", "dispatch", "Key", " ", "value", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "max", "RN", ":", " ", "an", " ", "integ", "er", " ", "value", " ", "represent", "ing", " ", "the", " ", "maxim", "um", " ", "number", " ", "of", " ", "render", "\\", "10", ";", " ", " ", " ", " ", "nodes", " ", "tha", "t", " ", "can", " ", "be", " ", "allocated", " ", "to", " ", "this", " ", "tree", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "task", ":", " ", "a", " ", "Task", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Base", "Node_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "parent_", ",_", "user_", ",_", "priority_", ",_", "dispatch", "Key_", ",_", "max", "RN", "_", ",_", "creati", "on", "Time_", ",_", "start", "Time_", ",_", "update", "Time_", ",_", "end", "Time_", ",_", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "=_", "task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "paused_", "=_", "paused_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "Atte", "mpt", "_", "=_", "int_", "(_", "max", "Atte", "mpt", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "comm", "mand", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "task_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "=_", "task_", "._", "timer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "Atte", "mpt", "_", "=_", "int_", "(_", "task_", "._", "max", "Atte", "mpt", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "Count_", "=_", "len_", "(_", "task_", "._", "commands_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "Iterator_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dispatch", "Iterator_", "(_", "self_", ",_", "stop", "Func_", ",_", "ep_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PRA", " ", ":", " ", "we", " ", "don", "'", "t", " ", "use", " ", "the", " ", "stop", " ", "function", " ", "here", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ep_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ep_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "if", " ", "no", " ", "read", "y", "Command", " ", "or", " ", "job", " ", "in", " ", "pause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "read", "y", "Command", "Count_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "paused_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ensure", " ", "we", " ", "are", " ", "treat", "ing", " ", "the", " ", "command", "s", " ", "in", " ", "the", " ", "order", " ", "the", "y", " ", "arrive", "d_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sorted_", "(_", "self_", "._", "task_", "._", "commands_", ",_", "key_", "=_", "lambda_", "x_", ":_", "x_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "command_", "._", "status_", "!=_", "CMD", "\\u", "READY", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PRA", " ", ":", " ", "search", " ", "a", " ", "render", " ", "node", " ", "to", " ", "assign", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "render", "Node_", "=_", "self_", "._", "reserve", "\\u", "render", "node_", "(_", "command_", ",_", "ep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PRA", " ", ":", " ", "render", "Node", " ", "is", " ", "Non", "e", " ", "if", " ", "we", " ", "did", " ", "not", " ", "found", " ", "a", " ", "RN", " ", "tha", "t", " ", "match", " ", "job", " ", "contra", "ints_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "render", "Node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PRA", " ", ":", " ", "Requirements", " ", "depend", "s", " ", "on", " ", "the", " ", "task", " ", "(", "and", " ", "not", " ", "the", " ", "command", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "So", " ", "if", " ", "we", " ", "don", "'", "t", " ", "find", " ", "a", " ", "RN", " ", "for", " ", "a", " ", "command", ",", " ", "we", " ", "wou", "ld", " ", "not", " ", "find", " ", "one", " ", "for", " ", "the", " ", "command", " ", "relate", "d", " ", "to", " ", "the", " ", "same", " ", "task_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Decre", "ase", " ", "the", " ", "number", " ", "of", " ", "read", "y", " ", "command", "s", " ", "through", " ", "the", " ", "hierarchy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "read", "y", "Command", "Count_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "\\u", "ep_", "=_", "ep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "tmp", "\\u", "ep_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmp", "\\u", "ep_", "._", "read", "y", "Command", "Count_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "\\u", "ep_", "=_", "tmp", "\\u", "ep_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "(_", "render", "Node_", ",_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reserve", "\\u", "render", "node_", "(_", "self_", ",_", "command_", ",_", "ep_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "command", ":", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "render", "Node", " ", "assign", "ed", " ", "to", " ", "command", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "Non", "e", " ", "if", " ", "no", " ", "RN", "s", " ", "found", " ", "due", " ", "to", " ", "constraint", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ep_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ep_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "pools", "hare", "_", "in_", "[_", "pool", "Share", "_", "for_", "pool", "Share", "_", "in_", "ep_", "._", "pool", "Share", "s_", "._", "values_", "(_", ")_", "if_", "pool", "Share", "_", "._", "has", "Render", "Node", "s", "Available_", "(_", ")_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "first", ",", " ", "sort", " ", "the", " ", "render", "nodes", " ", "according", " ", "thei", "r", " ", "perform", "anc", "e", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rn", "List_", "=_", "sorted_", "(_", "pools", "hare", "_", "._", "pool_", "._", "render", "Nodes_", ",_", "key_", "=_", "lambda_", "rn_", ":_", "rn_", "._", "performance_", ",_", "reverse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "render", "node_", "in_", "rn", "List_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "render", "node_", "._", "is", "Available_", "(_", ")_", "and_", "render", "node_", "._", "can", "Run_", "(_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "render", "node_", "._", "reserve", "License", "_", "(_", "command_", ",_", "self_", "._", "dispatcher_", "._", "license", "Manager_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "render", "node_", "._", "add", "Assignment_", "(_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "No", "License", "Avail", "able", "For", "Task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mi", "ght", " ", "not", " ", "be", " ", "necessar", "y", " ", "any", "more", " ", "bec", "aus", "e", " ", "first", " ", "loop", " ", "is", " ", "based", " ", "on", " ", "pool", "Share", "'", "s", " ", "has", "RN", "Sav", "ail", "able", " ", "method_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", " ", "was", " ", "not", " ", "tak", "ing", " ", "int", "o", " ", "account", " ", "the", " ", "tests", " ", "bef", "ore", " ", "assign", "ment", ":", " ", "RN", ".", "can", "Run", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "[_", "pool", "Share", "_", "for_", "pool", "Share", "_", "in_", "ep_", "._", "pool", "Share", "s_", "._", "values_", "(_", ")_", "if_", "pool", "Share", "_", "._", "has", "Render", "Node", "s", "Available_", "(_", ")_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "No", "Render", "Node", "Available_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Completi", "on", "And", "Status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Evaluate", " ", "new", " ", "value", " ", "for", " ", "completion", " ", "and", " ", "status", " ", "of", " ", "a", " ", "partic", "ular", " ", "Task", "Node", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "Allocati", "on_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "invalidate", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "task_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "CANCEL", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "completion_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "defaultdict_", "(_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "read", "y", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "don", "e", "Command", "Count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "Count_", "=_", "len_", "(_", "self_", "._", "task_", "._", "commands_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "completion_", "+=_", "command_", "._", "completion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "command_", "._", "status_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "command_", "._", "status_", "==_", "CMD", "\\u", "READY", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "read", "y", "Command", "Count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "command_", "._", "status_", "==_", "CMD", "\\u", "DONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "don", "e", "Command", "Count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "completion_", "/_", "len_", "(_", "self_", "._", "task_", "._", "commands_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "CMD", "\\u", "CANCEL", "ED_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "CANCEL", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "paused_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "PAUSE", "D_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "ERROR_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "TIMEOUT_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "RUNNING_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "RUNNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "ASSIGN", "ED_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "READY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "FINISH", "ING_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "RUNNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "READY", "_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "READY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "CMD", "\\u", "BLOCK", "ED_", "in_", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "BLOCK", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "all", " ", "command", "s", " ", "are", " ", "DON", "E", ",", " ", "ensure", " ", "the", " ", "completion", " ", "is", " ", "at", " ", "1.0", " ", "(", "in", " ", "case", " ", "of", " ", "fail", "ed", " ", "completion", " ", "update", " ", "from", " ", "some", " ", "worker", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "status_", "=_", "NODE", "\\u", "DONE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "command_", "._", "creati", "on", "Time_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", "if_", "command_", "._", "creati", "on", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "creati", "on", "Time_", "=_", "min_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "command_", "._", "start", "Time_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", "if_", "command_", "._", "start", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "Time_", "=_", "min_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "times_", "=_", "[_", "command_", "._", "update", "Time_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", "if_", "command_", "._", "update", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "update", "Time_", "=_", "max_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "only", " ", "set", " ", "the", " ", "end", "Time", " ", "on", " ", "the", " ", "node", " ", "if", " ", "it", "'", "s", " ", "done_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "status_", "==_", "NODE", "\\u", "DONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "times_", "=_", "[_", "command_", "._", "end", "Time_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", "if_", "command_", "._", "end", "Time_", "is_", "not_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "end", "Time_", "=_", "max_", "(_", "times_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "end", "Time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "task_", "._", "status_", "=_", "self_", "._", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "._", "completion_", "=_", "self_", "._", "completion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "._", "creati", "on", "Time_", "=_", "self_", "._", "creati", "on", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "._", "start", "Time_", "=_", "self_", "._", "start", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "._", "update", "Time_", "=_", "self_", "._", "update", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "task_", "._", "end", "Time_", "=_", "self_", "._", "end", "Time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "timer_", "=_", "self_", "._", "task_", "._", "timer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "invalidate", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Dependenc", "ies", "Sat", "isf", "action_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "dependen", "cies", " ", "shou", "ld", " ", "be", " ", "set", " ", "for", " ", "restrict", "ed", " ", "node", " ", "stat", "ute", "s", " ", "only", ":", " ", "DON", "E", ",", " ", "ERROR", " ", "and", " ", "CANCEL", "ED_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "task", "Nodes_", "=_", "[_", "task", "Node_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "task", "Node_", "in_", "self_", "._", "dispatcher_", "._", "dispatch", "Tree_", "._", "nodes_", "._", "values_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "task", "Node_", ",_", "Task", "Node_", ")_", "and_", "task", "Node_", "._", "task_", "==_", "self_", "._", "task_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "all_", "(_", "Base", "Node_", "._", "check", "Dependenc", "ies", "Sat", "isf", "action_", "(_", "task", "Node_", ")_", "for_", "task", "Node_", "in_", "task", "Nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Pause", "d_", "(_", "self_", ",_", "paused_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "paus", "e", " ", "every", " ", "job", " ", "not", " ", "done_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "status_", "!=_", "NODE", "\\u", "DONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "paused_", "=_", "paused_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "status_", "==_", "NODE", "\\u", "PAUSE", "D_", "and_", "not_", "paused_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "status_", "=_", "NODE", "\\u", "READY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "invalidate", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Max", "Atte", "mpt", "_", "(_", "self_", ",_", "max", "Atte", "mpt", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "self_", "._", "task_", ",_", "Task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "node", "'", "s", " ", "task", " ", "if", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "task_", "._", "max", "Atte", "mpt", "_", "=_", "max", "Atte", "mpt", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "max", "Atte", "mpt", "_", "=_", "max", "Atte", "mpt", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "dispatcher_", "._", "dispatch", "Tree_", "._", "to", "Modif", "y", "Elements_", "._", "append_", "(_", "self_", "._", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dispatcher_", "._", "dispatch", "Tree_", "._", "to", "Modif", "y", "Elements_", "._", "append_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset", "Completi", "on_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "completion_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "._", "completion_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Task", "Node_", "(_", "Base", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Status_", "(_", "self_", ",_", "p", "Status_", ",_", "p", "Casca", "de", "Update_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "Update", " ", "command", "s", " ", "in", " ", "order", " ", "to", " ", "reach", " ", "the", " ", "require", "d", " ", "status", ".", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "If", " ", "proper", " ", "param", " ", "is", " ", "give", "n", ",", " ", "depend", "ing", " ", "node", " ", "will", " ", "receive", " ", "the", " ", "same", " ", "status", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "p", "Status", ":", " ", "New", " ", "status", " ", "value", " ", "to", " ", "assign", " ", "to", " ", "the", " ", "current", " ", "node", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "p", "Casca", "de", "Update", ":", " ", "Fla", "g", " ", "indicati", "ng", " ", "if", " ", "the", " ", "depend", "ing", " ", "node", " ", "need", " ", "to", " ", "be", " ", "update", "d", " ", "in", " ", "cascade", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "p", "Casca", "de", "Update_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "depend", "ing", "Node_", "in_", "self_", "._", "reverse", "Dependenc", "ies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "depend", "ing", "Node_", "._", "set", "Status_", "(_", "p", "Status_", ",_", "p", "Casca", "de", "Update_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p", "Status_", "==_", "NODE", "\\u", "CANCEL", "ED_", "and_", "self_", "._", "status_", "!=_", "NODE", "\\u", "DONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "._", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "p", "Status_", "==_", "NODE", "\\u", "READY", "_", "and_", "self_", "._", "status_", "!=_", "NODE", "\\u", "RUNNING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "any_", "(_", "is", "Run", "ning", "Status_", "(_", "command_", "._", "status_", ")_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "command_", "in_", "self_", "._", "task_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "._", "set", "Read", "y", "Status_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "p", "Status_", "in_", "(_", "NODE", "\\u", "DONE_", ",_", "NODE", "\\u", "ERROR_", ",_", "NODE", "\\u", "BLOCK", "ED_", ",_", "NODE", "\\u", "RUNNING_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
anandology/pyjamas/pgen/astgen.py
[ { "content": "\"\"\"Generate ast module from specification\n\nThis script generates the ast module from a simple specification,\nwhich makes it easy to accomodate changes in the grammar. This\napproach would be quite reasonable if the grammar changed often.\nInstead, it is rather complex to generate the appropriate code. And\nthe Node interface has changed more often than the grammar.\n\"\"\"\n\nimport fileinput\nimport re\nimport sys\nfrom StringIO import StringIO\n\nSPEC = \"ast.txt\"\nCOMMA = \", \"\n\n\n\nP_NODE = 1\nP_OTHER = 2\nP_NESTED = 3\nP_NONE = 4\n\n\nrx_init = re.compile('init\\((.*)\\):')\n\n\n\nif __name__ == \"__main__\":\n main()\n sys.exit(0)\n\n### PROLOGUE\n\"\"\"Python abstract syntax node definitions\n\nThis file is automatically generated by Tools/compiler/astgen.py\n\"\"\"\nfrom consts import CO_VARARGS, CO_VARKEYWORDS\n\n\n\nnodes = {}\n\n\n\n\n### EPILOGUE\nfor name, obj in globals().items():\n if isinstance(obj, type) and issubclass(obj, Node):\n nodes[name.lower()] = obj\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def load_boilerplate(file):\n f = open(file)\n buf = f.read()\n f.close()\n i = buf.find('### ''PROLOGUE')\n j = buf.find('### ''EPILOGUE')\n pro = buf[i+12:j].strip()\n epi = buf[j+12:].strip()\n return pro, epi", "metadata": "root.load_boilerplate", "header": "['module', '___EOS___']", "index": 17 }, { "content": "def strip_default(arg):\n \"\"\"Return the argname from an 'arg = default' string\"\"\"\n i = arg.find('=')\n if i == -1:\n return arg\n t = arg[:i].strip()\n return t", "metadata": "root.strip_default", "header": "['module', '___EOS___']", "index": 27 }, { "content": "class NodeInfo:\n \"\"\"Each instance describes a specific AST node\"\"\"\n\n\n\n\n\n\n", "metadata": "root.NodeInfo", "header": "['module', '___EOS___']", "index": 40 }, { "content": " def __init__(self, name, args):\n self.name = name\n self.args = args.strip()\n self.argnames = self.get_argnames()\n self.argprops = self.get_argprops()\n self.nargs = len(self.argnames)\n self.init = []", "metadata": "root.NodeInfo.__init__", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 42 }, { "content": " def get_argnames(self):\n if '(' in self.args:\n i = self.args.find('(')\n j = self.args.rfind(')')\n args = self.args[i+1:j]\n else:\n args = self.args\n return [strip_default(arg.strip())\n for arg in args.split(',') if arg]", "metadata": "root.NodeInfo.get_argnames", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 50 }, { "content": " def get_argprops(self):\n \"\"\"Each argument can have a property like '*' or '!'\n\n XXX This method modifies the argnames in place!\n \"\"\"\n d = {}\n hardest_arg = P_NODE\n for i in range(len(self.argnames)):\n arg = self.argnames[i]\n if arg.endswith('*'):\n arg = self.argnames[i] = arg[:-1]\n d[arg] = P_OTHER\n hardest_arg = max(hardest_arg, P_OTHER)\n elif arg.endswith('!'):\n arg = self.argnames[i] = arg[:-1]\n d[arg] = P_NESTED\n hardest_arg = max(hardest_arg, P_NESTED)\n elif arg.endswith('&'):\n arg = self.argnames[i] = arg[:-1]\n d[arg] = P_NONE\n hardest_arg = max(hardest_arg, P_NONE)\n else:\n d[arg] = P_NODE\n self.hardest_arg = hardest_arg\n\n if hardest_arg > P_NODE:\n self.args = self.args.replace('*', '')\n self.args = self.args.replace('!', '')\n self.args = self.args.replace('&', '')\n\n return d", "metadata": "root.NodeInfo.get_argprops", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 60 }, { "content": " def gen_source(self):\n buf = StringIO()\n print >> buf, \"class %s(Node):\" % self.name\n self._gen_init(buf)\n print >> buf\n self._gen_getChildren(buf)\n print >> buf\n self._gen_getChildNodes(buf)\n print >> buf\n self._gen_repr(buf)\n buf.seek(0, 0)\n return buf.read()", "metadata": "root.NodeInfo.gen_source", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 92 }, { "content": " def _gen_init(self, buf):\n if self.args:\n print >> buf, \" def __init__(self, %s, lineno=None):\" % self.args\n else:\n print >> buf, \" def __init__(self, lineno=None):\"\n if self.argnames:\n for name in self.argnames:\n print >> buf, \" self.%s = %s\" % (name, name)\n print >> buf, \" self.lineno = lineno\"\n # Copy the lines in self.init, indented four spaces. The rstrip()\n # business is to get rid of the four spaces if line happens to be\n # empty, so that reindent.py is happy with the output.\n for line in self.init:\n print >> buf, (\" \" + line).rstrip()", "metadata": "root.NodeInfo._gen_init", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 105 }, { "content": " def _gen_getChildren(self, buf):\n print >> buf, \" def getChildren(self):\"\n if len(self.argnames) == 0:\n print >> buf, \" return ()\"\n else:\n if self.hardest_arg < P_NESTED:\n clist = COMMA.join([\"self.%s\" % c\n for c in self.argnames])\n if self.nargs == 1:\n print >> buf, \" return %s,\" % clist\n else:\n print >> buf, \" return %s\" % clist\n else:\n if len(self.argnames) == 1:\n print >> buf, \" return tuple(flatten(self.%s))\" % self.argnames[0]\n else:\n print >> buf, \" children = []\"\n template = \" children.%s(%sself.%s%s)\"\n for name in self.argnames:\n if self.argprops[name] == P_NESTED:\n print >> buf, template % (\"extend\", \"flatten(\",\n name, \")\")\n else:\n print >> buf, template % (\"append\", \"\", name, \"\")\n print >> buf, \" return tuple(children)\"", "metadata": "root.NodeInfo._gen_getChildren", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 120 }, { "content": " def _gen_getChildNodes(self, buf):\n print >> buf, \" def getChildNodes(self):\"\n if len(self.argnames) == 0:\n print >> buf, \" return ()\"\n else:\n if self.hardest_arg < P_NESTED:\n clist = [\"self.%s\" % c\n for c in self.argnames\n if self.argprops[c] == P_NODE]\n if len(clist) == 0:\n print >> buf, \" return ()\"\n elif len(clist) == 1:\n print >> buf, \" return %s,\" % clist[0]\n else:\n print >> buf, \" return %s\" % COMMA.join(clist)\n else:\n print >> buf, \" nodelist = []\"\n template = \" nodelist.%s(%sself.%s%s)\"\n for name in self.argnames:\n if self.argprops[name] == P_NONE:\n tmp = (\" if self.%s is not None:\\n\"\n \" nodelist.append(self.%s)\")\n print >> buf, tmp % (name, name)\n elif self.argprops[name] == P_NESTED:\n print >> buf, template % (\"extend\", \"flatten_nodes(\",\n name, \")\")\n elif self.argprops[name] == P_NODE:\n print >> buf, template % (\"append\", \"\", name, \"\")\n print >> buf, \" return tuple(nodelist)\"", "metadata": "root.NodeInfo._gen_getChildNodes", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 146 }, { "content": " def _gen_repr(self, buf):\n print >> buf, \" def __repr__(self):\"\n if self.argnames:\n fmt = COMMA.join([\"%s\"] * self.nargs)\n if '(' in self.args:\n fmt = '(%s)' % fmt\n vals = [\"repr(self.%s)\" % name for name in self.argnames]\n vals = COMMA.join(vals)\n if self.nargs == 1:\n vals = vals + \",\"\n print >> buf, ' return \"%s(%s)\" %% (%s)' % \\\n (self.name, fmt, vals)\n else:\n print >> buf, ' return \"%s()\"' % self.name", "metadata": "root.NodeInfo._gen_repr", "header": "['class', 'NodeInfo', ':', '___EOS___']", "index": 176 }, { "content": "def parse_spec(file):\n classes = {}\n cur = None\n for line in fileinput.input(file):\n if line.strip().startswith('#'):\n continue\n mo = rx_init.search(line)\n if mo is None:\n if cur is None:\n # a normal entry\n try:\n name, args = line.split(':')\n except ValueError:\n continue\n classes[name] = NodeInfo(name, args)\n cur = None\n else:\n # some code for the __init__ method\n cur.init.append(line)\n else:\n # some extra code for a Node's __init__ method\n name = mo.group(1)\n cur = classes[name]\n return sorted(classes.values(), key=lambda n: n.name)", "metadata": "root.parse_spec", "header": "['module', '___EOS___']", "index": 193 }, { "content": "def main():\n prologue, epilogue = load_boilerplate(sys.argv[-1])\n print prologue\n print\n classes = parse_spec(SPEC)\n for info in classes:\n print info.gen_source()\n print epilogue", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 218 }, { "content": "def flatten(seq):\n l = []\n for elt in seq:\n t = type(elt)\n if t is tuple or t is list:\n for elt2 in flatten(elt):\n l.append(elt2)\n else:\n l.append(elt)\n return l", "metadata": "root.flatten", "header": "['module', '___EOS___']", "index": 238 }, { "content": "def flatten_nodes(seq):\n return [n for n in flatten(seq) if isinstance(n, Node)]", "metadata": "root.flatten_nodes", "header": "['module', '___EOS___']", "index": 249 }, { "content": "class Node(object):\n \"\"\"Abstract base class for ast nodes.\"\"\"\n lineno = property(_get_lineno, _set_lineno)", "metadata": "root.Node", "header": "['module', '___EOS___']", "index": 254 }, { "content": " def getChildren(self):\n pass # implemented by subclasses", "metadata": "root.Node.getChildren", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 256 }, { "content": " def __iter__(self):\n for n in self.getChildren():\n yield n", "metadata": "root.Node.__iter__", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 258 }, { "content": " def asList(self): # for backwards compatibility\n return self.getChildren()", "metadata": "root.Node.asList", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 261 }, { "content": " def getChildNodes(self):\n pass # implemented by subclasses", "metadata": "root.Node.getChildNodes", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 263 }, { "content": " def _get_lineno(self):\n return self._lineno", "metadata": "root.Node._get_lineno", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 265 }, { "content": " def _set_lineno(self, lineno):\n if lineno is not None and not isinstance(lineno, int):\n self._context = lineno\n self._lineno = lineno[1][0]\n else:\n self._lineno = lineno\n self._context = None", "metadata": "root.Node._set_lineno", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 267 }, { "content": "class EmptyNode(Node):\n pass", "metadata": "root.EmptyNode", "header": "['module', '___EOS___']", "index": 276 }, { "content": "class Expression(Node):\n # Expression is an artificial node class to support \"eval\"\n nodes[\"expression\"] = \"Expression\"\n\n\n", "metadata": "root.Expression", "header": "['module', '___EOS___']", "index": 279 }, { "content": " def __init__(self, node):\n Node.__init__(self)\n self.node = node", "metadata": "root.Expression.__init__", "header": "['class', 'Expression', '(', 'Node', ')', ':', '___NEWLINE___', '# Expression is an artificial node class to support \"eval\"', '___NL___', '___EOS___']", "index": 282 }, { "content": " def getChildren(self):\n return self.node,", "metadata": "root.Expression.getChildren", "header": "['class', 'Expression', '(', 'Node', ')', ':', '___NEWLINE___', '# Expression is an artificial node class to support \"eval\"', '___NL___', '___EOS___']", "index": 286 }, { "content": " def getChildNodes(self):\n return self.node,", "metadata": "root.Expression.getChildNodes", "header": "['class', 'Expression', '(', 'Node', ')', ':', '___NEWLINE___', '# Expression is an artificial node class to support \"eval\"', '___NL___', '___EOS___']", "index": 289 }, { "content": " def __repr__(self):\n return \"Expression(%s)\" % (repr(self.node))", "metadata": "root.Expression.__repr__", "header": "['class', 'Expression', '(', 'Node', ')', ':', '___NEWLINE___', '# Expression is an artificial node class to support \"eval\"', '___NL___', '___EOS___']", "index": 292 } ]
[ { "span": "from consts import CO_VARARGS, CO_VARKEYWORDS", "start_line": 236, "start_column": 0, "end_line": 236, "end_column": 45 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Generate", " ", "ast", " ", "module", " ", "from", " ", "specifica", "tion", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "script", " ", "generat", "es", " ", "the", " ", "ast", " ", "module", " ", "from", " ", "a", " ", "simple", " ", "specifica", "tion", ",", "\\", "10", ";", "whi", "ch", " ", "make", "s", " ", "it", " ", "easy", " ", "to", " ", "accom", "oda", "te", " ", "change", "s", " ", "in", " ", "the", " ", "grammar", ".", " ", " ", "Thi", "s", "\\", "10", ";", "appro", "ach", " ", "wou", "ld", " ", "be", " ", "quite", " ", "reason", "able", " ", "if", " ", "the", " ", "grammar", " ", "change", "d", " ", "oft", "en", ".", "\\", "10", ";", "Ins", "tea", "d", ",", " ", "it", " ", "is", " ", "rat", "her", " ", "complex", " ", "to", " ", "generat", "e", " ", "the", " ", "appropr", "iate", " ", "code", ".", " ", " ", "And", "\\", "10", ";", "the", " ", "Node", " ", "interface", " ", "has", " ", "change", "d", " ", "more", " ", "oft", "en", " ", "than", " ", "the", " ", "grammar", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "fileinput_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SPEC", "_", "=_", "\"", "ast", ".", "txt", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "COMMA", "_", "=_", "\",", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "P", "\\u", "NODE_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P", "\\u", "OTHER", "_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P", "\\u", "NEST", "ED_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P", "\\u", "NONE_", "=_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rx", "\\u", "init_", "=_", "re_", "._", "compile_", "(_", "'", "init", "\\\\((", ".*)", "\\\\)", ":'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###", " ", "PRO", "LOG", "UE", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "Pyth", "on", " ", "abstract", " ", "synta", "x", " ", "node", " ", "definit", "ion", "s", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "file", " ", "is", " ", "automati", "call", "y", " ", "generat", "ed", " ", "by", " ", "Tool", "s", "/", "compiler", "/", "ast", "gen", ".", "py", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "consts_", "import_", "CO", "\\u", "VAR", "ARGS_", ",_", "CO", "\\u", "VAR", "KEYWORDS", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "nodes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###", " ", "EPI", "LOG", "UE", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "name_", ",_", "obj_", "in_", "globals_", "(_", ")_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "obj_", ",_", "type_", ")_", "and_", "issubclass_", "(_", "obj_", ",_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "[_", "name_", "._", "lower_", "(_", ")_", "]_", "=_", "obj_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "load", "\\u", "boiler", "plate_", "(_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "buf_", "._", "find_", "(_", "'###", " ", "'_", "'", "PRO", "LOG", "UE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "j_", "=_", "buf_", "._", "find_", "(_", "'###", " ", "'_", "'", "EPI", "LOG", "UE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pro_", "=_", "buf_", "[_", "i_", "+_", "12_", ":_", "j_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "epi", "_", "=_", "buf_", "[_", "j_", "+_", "12_", ":_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "pro_", ",_", "epi", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "strip", "\\u", "default_", "(_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "the", " ", "argname", " ", "from", " ", "an", " ", "'", "arg", " ", "=", " ", "default", "'", " ", "string", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "arg_", "._", "find_", "(_", "'='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "arg_", "[_", ":_", "i_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Node", "Info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ea", "ch", " ", "instance", " ", "descri", "bes", " ", "a", " ", "specific", " ", "AST", " ", "node", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "args_", "=_", "args_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "argname", "s_", "=_", "self_", "._", "get", "\\u", "argname", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "argp", "rop", "s_", "=_", "self_", "._", "get", "\\u", "argp", "rop", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "nargs_", "=_", "len_", "(_", "self_", "._", "argname", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "init_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "argname", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'('_", "in_", "self_", "._", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "self_", "._", "args_", "._", "find_", "(_", "'('_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "j_", "=_", "self_", "._", "args_", "._", "rfind_", "(_", "')'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "self_", "._", "args_", "[_", "i_", "+_", "1_", ":_", "j_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "self_", "._", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "strip", "\\u", "default_", "(_", "arg_", "._", "strip_", "(_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "arg_", "in_", "args_", "._", "split_", "(_", "','_", ")_", "if_", "arg_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "argp", "rop", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ea", "ch", " ", "argu", "ment", " ", "can", " ", "have", " ", "a", " ", "property", " ", "like", " ", "'*", "'", " ", "or", " ", "'!", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "XX", "X", " ", "Thi", "s", " ", "method", " ", "modifi", "es", " ", "the", " ", "argname", "s", " ", "in", " ", "place", "!", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hard", "est", "\\u", "arg_", "=_", "P", "\\u", "NODE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "self_", "._", "argname", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arg_", "=_", "self_", "._", "argname", "s_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "arg_", "._", "endswith_", "(_", "'*'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arg_", "=_", "self_", "._", "argname", "s_", "[_", "i_", "]_", "=_", "arg_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "[_", "arg_", "]_", "=_", "P", "\\u", "OTHER", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hard", "est", "\\u", "arg_", "=_", "max_", "(_", "hard", "est", "\\u", "arg_", ",_", "P", "\\u", "OTHER", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "arg_", "._", "endswith_", "(_", "'!'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arg_", "=_", "self_", "._", "argname", "s_", "[_", "i_", "]_", "=_", "arg_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "[_", "arg_", "]_", "=_", "P", "\\u", "NEST", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hard", "est", "\\u", "arg_", "=_", "max_", "(_", "hard", "est", "\\u", "arg_", ",_", "P", "\\u", "NEST", "ED_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "arg_", "._", "endswith_", "(_", "'&'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arg_", "=_", "self_", "._", "argname", "s_", "[_", "i_", "]_", "=_", "arg_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "[_", "arg_", "]_", "=_", "P", "\\u", "NONE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hard", "est", "\\u", "arg_", "=_", "max_", "(_", "hard", "est", "\\u", "arg_", ",_", "P", "\\u", "NONE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "[_", "arg_", "]_", "=_", "P", "\\u", "NODE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "hard", "est", "\\u", "arg_", "=_", "hard", "est", "\\u", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hard", "est", "\\u", "arg_", ">_", "P", "\\u", "NODE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "args_", "=_", "self_", "._", "args_", "._", "replace_", "(_", "'*'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "args_", "=_", "self_", "._", "args_", "._", "replace_", "(_", "'!'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "args_", "=_", "self_", "._", "args_", "._", "replace_", "(_", "'&'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gen", "\\u", "source_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "buf_", "=_", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "\"", "class", " ", "%", "s", "(", "Node", "):\"_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "gen", "\\u", "init_", "(_", "buf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "buf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "gen", "\\u", "get", "Children_", "(_", "buf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "buf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "gen", "\\u", "get", "Chil", "d", "Nodes_", "(_", "buf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "buf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "gen", "\\u", "repr_", "(_", "buf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf_", "._", "seek_", "(_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "buf_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gen", "\\u", "init_", "(_", "self_", ",_", "buf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "def", " ", "\\u\\u", "init", "\\u\\u", "(", "self", ",", " ", "%", "s", ",", " ", "linen", "o", "=", "Non", "e", "):\"_", "%_", "self_", "._", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "def", " ", "\\u\\u", "init", "\\u\\u", "(", "self", ",", " ", "linen", "o", "=", "Non", "e", "):\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "argname", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "name_", "in_", "self_", "._", "argname", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "self", ".", "%", "s", " ", "=", " ", "%", "s", "\"_", "%_", "(_", "name_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "self", ".", "linen", "o", " ", "=", " ", "linen", "o", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Copy", " ", "the", " ", "lines", " ", "in", " ", "self", ".", "init", ",", " ", "indented", " ", "four", " ", "space", "s", ".", " ", " ", "The", " ", "rstr", "ip", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "business", " ", "is", " ", "to", " ", "get", " ", "rid", " ", "of", " ", "the", " ", "four", " ", "space", "s", " ", "if", " ", "line", " ", "happ", "ens", " ", "to", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "empty", ",", " ", "so", " ", "tha", "t", " ", "rein", "dent", ".", "py", " ", "is", " ", "happy", " ", "with", " ", "the", " ", "output", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "line_", "in_", "self_", "._", "init_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "(_", "\"", " ", " ", " ", " ", "\"_", "+_", "line_", ")_", "._", "rstrip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gen", "\\u", "get", "Children_", "(_", "self_", ",_", "buf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "def", " ", "get", "Chil", "dre", "n", "(", "self", "):\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "argname", "s_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "()\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "hard", "est", "\\u", "arg_", "<_", "P", "\\u", "NEST", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clist", "_", "=_", "COMMA", "_", "._", "join_", "(_", "[_", "\"", "self", ".", "%", "s", "\"_", "%_", "c_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "c_", "in_", "self_", "._", "argname", "s_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "nargs_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "%", "s", ",\"_", "%_", "clist", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "%", "s", "\"_", "%_", "clist", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "self_", "._", "argname", "s_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "tuple", "(", "flat", "ten", "(", "self", ".", "%", "s", "))\"_", "%_", "self_", "._", "argname", "s_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "child", "ren", " ", "=", " ", "[]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "\"", " ", " ", " ", " ", "child", "ren", ".", "%", "s", "(%", "sse", "lf", ".", "%", "s", "%", "s", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "name_", "in_", "self_", "._", "argname", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "argp", "rop", "s_", "[_", "name_", "]_", "==_", "P", "\\u", "NEST", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", ">>_", "buf_", ",_", "template_", "%_", "(_", "\"", "extend", "\"_", ",_", "\"", "flat", "ten", "(\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", ",_", "\")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", ">>_", "buf_", ",_", "template_", "%_", "(_", "\"", "append", "\"_", ",_", "\"\"_", ",_", "name_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "tuple", "(", "child", "ren", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gen", "\\u", "get", "Chil", "d", "Nodes_", "(_", "self_", ",_", "buf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "def", " ", "get", "Chil", "d", "Node", "s", "(", "self", "):\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "argname", "s_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "()\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "hard", "est", "\\u", "arg_", "<_", "P", "\\u", "NEST", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clist", "_", "=_", "[_", "\"", "self", ".", "%", "s", "\"_", "%_", "c_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "c_", "in_", "self_", "._", "argname", "s_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "argp", "rop", "s_", "[_", "c_", "]_", "==_", "P", "\\u", "NODE_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "clist", "_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "()\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "clist", "_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "%", "s", ",\"_", "%_", "clist", "_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "%", "s", "\"_", "%_", "COMMA", "_", "._", "join_", "(_", "clist", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "nodel", "ist", " ", "=", " ", "[]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "\"", " ", " ", " ", " ", "nodel", "ist", ".", "%", "s", "(%", "sse", "lf", ".", "%", "s", "%", "s", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "name_", "in_", "self_", "._", "argname", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "argp", "rop", "s_", "[_", "name_", "]_", "==_", "P", "\\u", "NONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tmp_", "=_", "(_", "\"", " ", " ", " ", " ", "if", " ", "self", ".", "%", "s", " ", "is", " ", "not", " ", "Non", "e", ":\\\\", "n", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", " ", " ", " ", " ", "nodel", "ist", ".", "append", "(", "self", ".", "%", "s", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "tmp_", "%_", "(_", "name_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "argp", "rop", "s_", "[_", "name_", "]_", "==_", "P", "\\u", "NEST", "ED_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", ">>_", "buf_", ",_", "template_", "%_", "(_", "\"", "extend", "\"_", ",_", "\"", "flat", "ten", "\\u", "nodes", "(\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", ",_", "\")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "argp", "rop", "s_", "[_", "name_", "]_", "==_", "P", "\\u", "NODE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", ">>_", "buf_", ",_", "template_", "%_", "(_", "\"", "append", "\"_", ",_", "\"\"_", ",_", "name_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "return", " ", "tuple", "(", "nodel", "ist", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Info_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gen", "\\u", "repr_", "(_", "self_", ",_", "buf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "\"", " ", " ", " ", " ", "def", " ", "\\u\\u", "repr", "\\u\\u", "(", "self", "):\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "argname", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fmt_", "=_", "COMMA", "_", "._", "join_", "(_", "[_", "\"%", "s", "\"_", "]_", "*_", "self_", "._", "nargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'('_", "in_", "self_", "._", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fmt_", "=_", "'(", "%", "s", ")'_", "%_", "fmt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vals_", "=_", "[_", "\"", "repr", "(", "self", ".", "%", "s", ")\"_", "%_", "name_", "for_", "name_", "in_", "self_", "._", "argname", "s_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "COMMA", "_", "._", "join_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "nargs_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "vals_", "+_", "\",\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "buf_", ",_", "'", " ", " ", " ", " ", "return", " ", "\"%", "s", "(%", "s", ")\"", " ", "%%", " ", "(%", "s", ")'_", "%_", "(_", "self_", "._", "name_", ",_", "fmt_", ",_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "buf_", ",_", "'", " ", " ", " ", " ", "return", " ", "\"%", "s", "()\"", "'_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "parse", "\\u", "spec_", "(_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "classes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "fileinput_", "._", "input_", "(_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "line_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'#'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mo_", "=_", "rx", "\\u", "init_", "._", "search_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mo_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cur_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "a", " ", "normal", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "name_", ",_", "args_", "=_", "line_", "._", "split_", "(_", "':'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "classes_", "[_", "name_", "]_", "=_", "Node", "Info_", "(_", "name_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "some", " ", "code", " ", "for", " ", "the", " ", "\\u\\u", "init", "\\u\\u", " ", "method_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cur_", "._", "init_", "._", "append_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "some", " ", "extra", " ", "code", " ", "for", " ", "a", " ", "Node", "'", "s", " ", "\\u\\u", "init", "\\u\\u", " ", "method_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "mo_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur_", "=_", "classes_", "[_", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "sorted_", "(_", "classes_", "._", "values_", "(_", ")_", ",_", "key_", "=_", "lambda_", "n_", ":_", "n_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prolog", "ue_", ",_", "epi", "logu", "e_", "=_", "load", "\\u", "boiler", "plate_", "(_", "sys_", "._", "argv_", "[_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prolog", "ue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "classes_", "=_", "parse", "\\u", "spec_", "(_", "SPEC", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "info_", "in_", "classes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "info_", "._", "gen", "\\u", "source_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "epi", "logu", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "flatten_", "(_", "seq_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "elt_", "in_", "seq_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "type_", "(_", "elt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "t_", "is_", "tuple_", "or_", "t_", "is_", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "elt", "2_", "in_", "flatten_", "(_", "elt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "._", "append_", "(_", "elt", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "._", "append_", "(_", "elt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "l_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "flat", "ten", "\\u", "nodes_", "(_", "seq_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "n_", "for_", "n_", "in_", "flatten_", "(_", "seq_", ")_", "if_", "isinstance_", "(_", "n_", ",_", "Node_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Abstract", " ", "base", " ", "class", " ", "for", " ", "ast", " ", "nodes", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lineno_", "=_", "property_", "(_", "\\u", "get", "\\u", "lineno_", ",_", "\\u", "set\\u", "lineno_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "Children_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", " ", "implemented", " ", "by", " ", "subclasses", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "n_", "in_", "self_", "._", "get", "Children_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "as", "List_", "(_", "self_", ")_", ":_", "#", " ", "for", " ", "back", "ward", "s", " ", "compatibility", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "get", "Children_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Chil", "d", "Nodes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", " ", "implemented", " ", "by", " ", "subclasses", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "lineno_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "lineno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "lineno_", "(_", "self_", ",_", "lineno_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "lineno_", "is_", "not_", "None_", "and_", "not_", "isinstance_", "(_", "lineno_", ",_", "int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "context_", "=_", "lineno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "lineno_", "=_", "lineno_", "[_", "1_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "lineno_", "=_", "lineno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "context_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Emp", "ty", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Expression_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Expression", " ", "is", " ", "an", " ", "arti", "ficia", "l", " ", "node", " ", "class", " ", "to", " ", "support", " ", "\"", "eval", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "[_", "\"", "express", "ion", "\"_", "]_", "=_", "\"", "Expression", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Expression_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Expression", " ", "is", " ", "an", " ", "arti", "ficia", "l", " ", "node", " ", "class", " ", "to", " ", "support", " ", "\"", "eval", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Node_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "node_", "=_", "node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Expression_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Expression", " ", "is", " ", "an", " ", "arti", "ficia", "l", " ", "node", " ", "class", " ", "to", " ", "support", " ", "\"", "eval", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Children_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "node_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Expression_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Expression", " ", "is", " ", "an", " ", "arti", "ficia", "l", " ", "node", " ", "class", " ", "to", " ", "support", " ", "\"", "eval", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Chil", "d", "Nodes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "node_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Expression_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Expression", " ", "is", " ", "an", " ", "arti", "ficia", "l", " ", "node", " ", "class", " ", "to", " ", "support", " ", "\"", "eval", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Expression", "(%", "s", ")\"_", "%_", "(_", "repr_", "(_", "self_", "._", "node_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Comparison using is when operands support `__eq__`
azoft-dev-team/imagrium/env/Lib/optparse.py
[ { "content": " def expand_default(self, option):\n if self.parser is None or not self.default_tag:\n return option.help\n\n default_value = self.parser.defaults.get(option.dest)\n if default_value is NO_DEFAULT or default_value is None:\n default_value = self.NO_DEFAULT_VALUE\n\n return option.help.replace(self.default_tag, str(default_value))", "metadata": "root.HelpFormatter.expand_default", "header": "['class', 'HelpFormatter', ':', '___EOS___']", "index": 278 }, { "content": " def add_option(self, *args, **kwargs):\n \"\"\"add_option(Option)\n add_option(opt_str, ..., kwarg=val, ...)\n \"\"\"\n if type(args[0]) in types.StringTypes:\n option = self.option_class(*args, **kwargs)\n elif len(args) == 1 and not kwargs:\n option = args[0]\n if not isinstance(option, Option):\n raise TypeError, \"not an Option instance: %r\" % option\n else:\n raise TypeError, \"invalid arguments\"\n\n self._check_conflict(option)\n\n self.option_list.append(option)\n option.container = self\n for opt in option._short_opts:\n self._short_opt[opt] = option\n for opt in option._long_opts:\n self._long_opt[opt] = option\n\n if option.dest is not None: # option has a dest, we need a default\n if option.default is not NO_DEFAULT:\n self.defaults[option.dest] = option.default\n elif option.dest not in self.defaults:\n self.defaults[option.dest] = None\n\n return option", "metadata": "root.OptionContainer.add_option", "header": "['class', 'OptionContainer', ':', '___EOS___']", "index": 1006 }, { "content": " def format_option_help(self, formatter):\n if not self.option_list:\n return \"\"\n result = []\n for option in self.option_list:\n if not option.help is SUPPRESS_HELP:\n result.append(formatter.format_option(option))\n return \"\".join(result)", "metadata": "root.OptionContainer.format_option_help", "header": "['class', 'OptionContainer', ':', '___EOS___']", "index": 1066 }, { "content": " def set_usage(self, usage):\n if usage is None:\n self.usage = _(\"%prog [options]\")\n elif usage is SUPPRESS_USAGE:\n self.usage = None\n # For backwards compatibility with Optik 1.3 and earlier.\n elif usage.lower().startswith(\"usage: \"):\n self.usage = usage[7:]\n else:\n self.usage = usage", "metadata": "root.OptionParser.set_usage", "header": "['class', 'OptionParser', '(', 'OptionContainer', ')', ':', '___EOS___']", "index": 1275 } ]
[ { "span": "default_value is NO_DEFAULT ", "start_line": 283, "start_column": 11, "end_line": 283, "end_column": 38 }, { "span": "option.default is not NO_DEFAULT:", "start_line": 1029, "start_column": 15, "end_line": 1029, "end_column": 47 }, { "span": "option.help is SUPPRESS_HELP:", "start_line": 1071, "start_column": 19, "end_line": 1071, "end_column": 47 }, { "span": "usage is SUPPRESS_USAGE:", "start_line": 1278, "start_column": 13, "end_line": 1278, "end_column": 36 } ]
[]
1
false
[ "[CLS]_", "Compari", "son_", "using_", "is_", "when_", "operands_", "support_", " _", "`_", "\\u\\u", "eq\\u\\u_", "`_", "[SEP]_", "class_", "Help", "Formatter_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "expand", "\\u", "default_", "(_", "self_", ",_", "option_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "parser_", "is_", "None_", "or_", "not_", "self_", "._", "default", "\\u", "tag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "option_", "._", "help_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "default", "\\u", "value_", "=_", "self_", "._", "parser_", "._", "defaults_", "._", "get_", "(_", "option_", "._", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "default", "\\u", "value_", "is_", "NO", "\\u", "DEFAULT_", "or_", "default", "\\u", "value_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "default", "\\u", "value_", "=_", "self_", "._", "NO", "\\u", "DEF", "AUL", "T", "\\u", "VALUE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "option_", "._", "help_", "._", "replace_", "(_", "self_", "._", "default", "\\u", "tag_", ",_", "str_", "(_", "default", "\\u", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Optio", "n", "Container_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "option_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "add", "\\u", "option", "(", "Optio", "n", ")", "\\", "10", ";", " ", " ", " ", "add", "\\u", "option", "(", "opt", "\\u", "str", ",", " ", "...", ",", " ", "kwarg", "=", "val", ",", " ", "...)", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "args_", "[_", "0_", "]_", ")_", "in_", "types_", "._", "String", "Types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "option_", "=_", "self_", "._", "option", "\\u", "class_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "args_", ")_", "==_", "1_", "and_", "not_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "option_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "option_", ",_", "Option_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", ",_", "\"", "not", " ", "an", " ", "Optio", "n", " ", "instance", ":", " ", "%", "r", "\"_", "%_", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", ",_", "\"", "invalid", " ", "argu", "ment", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "check", "\\u", "conflict_", "(_", "option_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "option", "\\u", "list_", "._", "append_", "(_", "option_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "option_", "._", "container_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "opt_", "in_", "option_", "._", "\\u", "short", "\\u", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "short", "\\u", "opt_", "[_", "opt_", "]_", "=_", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "opt_", "in_", "option_", "._", "\\u", "long", "\\u", "opts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "long", "\\u", "opt_", "[_", "opt_", "]_", "=_", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "option_", "._", "dest_", "is_", "not_", "None_", ":_", "#", " ", "option", " ", "has", " ", "a", " ", "dest", ",", " ", "we", " ", "need", " ", "a", " ", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "option_", "._", "default_", "is_", "not_", "NO", "\\u", "DEFAULT_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "defaults_", "[_", "option_", "._", "dest_", "]_", "=_", "option_", "._", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "option_", "._", "dest_", "not_", "in_", "self_", "._", "defaults_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "defaults_", "[_", "option_", "._", "dest_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Optio", "n", "Container_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "format\\u", "option", "\\u", "help_", "(_", "self_", ",_", "formatter_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "option", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "option_", "in_", "self_", "._", "option", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "option_", "._", "help_", "is_", "SUPPRESS", "\\u", "HELP_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "append_", "(_", "formatter_", "._", "format\\u", "option_", "(_", "option_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Optio", "n", "Parser_", "(_", "Optio", "n", "Container_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "usage_", "(_", "self_", ",_", "usage_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "usage_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "usage_", "=_", "\\u_", "(_", "\"%", "prog", " ", "[", "options", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "usage_", "is_", "SUPPRESS", "\\u", "USAGE", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "usage_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "For", " ", "back", "ward", "s", " ", "compatibility", " ", "with", " ", "Opt", "ik", " ", "1.3", " ", "and", " ", "ear", "lie", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "usage_", "._", "lower_", "(_", ")_", "._", "startswith_", "(_", "\"", "usage", ":", " ", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "usage_", "=_", "usage_", "[_", "7_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "usage_", "=_", "usage_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2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 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
formencode/formencode/formencode/tests/test_htmlfill_control.py
[ { "content": "def test_error_attr_ignore():\n html = \"\"\"\n<input type=\"text\" name=\"foo\" value=\"bar\" data-formencode-form=\"a\" />\n<input type=\"text\" name=\"foo\" value=\"biz\" data-formencode-form=\"b\" />\n<input type=\"text\" name=\"foo\" value=\"bash\" data-formencode-form=\"c\" />\n\"\"\"\n expected_html = \"\"\"\n<input type=\"text\" name=\"foo\" value=\"bar\" data-formencode-form=\"a\" />\n<!-- for: foo -->\n<span class=\"error-message\">bang</span><br />\n<input type=\"text\" name=\"foo\" value=\"\" data-formencode-form=\"b\" class=\"error\" />\n<input type=\"text\" name=\"foo\" value=\"bash\" data-formencode-form=\"c\" />\n\"\"\"\n rendered_html = htmlfill.render(html, errors={\"foo\": \"bang\"},\n force_defaults=True,\n data_formencode_form=\"b\",)", "metadata": "root.test_error_attr_ignore", "header": "['module', '___EOS___']", "index": 81 } ]
[ { "span": "expected_html ", "start_line": 87, "start_column": 4, "end_line": 87, "end_column": 17 }, { "span": "rendered_html ", "start_line": 94, "start_column": 4, "end_line": 94, "end_column": 17 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "error", "\\u", "attr", "\\u", "ignore_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "html_", "=_", "\"\"\"", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "bar", "\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "a", "\"", " ", "/>", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "biz", "\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "b", "\"", " ", "/>", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "bash", "\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "c", "\"", " ", "/>", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "html_", "=_", "\"\"\"", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "bar", "\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "a", "\"", " ", "/>", "\\", "10", ";<", "!-", "-", " ", "for", ":", " ", "foo", " ", "-->", "\\", "10", ";<", "span", " ", "class", "=\"", "error", "-", "message", "\">", "bang", "</", "span", "><", "br", " ", "/>", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "b", "\"", " ", "class", "=\"", "error", "\"", " ", "/>", "\\", "10", ";<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "bash", "\"", " ", "data", "-", "form", "encode", "-", "form", "=\"", "c", "\"", " ", "/>", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "render", "ed", "\\u", "html_", "=_", "html", "fill_", "._", "render_", "(_", "html_", ",_", "errors_", "=_", "{_", "\"", "foo", "\"_", ":_", "\"", "bang", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "force", "\\u", "defaults_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data\\u", "form", "encode", "\\u", "form_", "=_", "\"", "b", "\"_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
googlefonts/fontbakery/tools/fontbakery-metadata-vs-api.py
[ { "content": "# -*- coding: utf-8 -*-\n#!/usr/bin/env python\nfrom __future__ import print_function\n\nimport argparse\nimport collections\nimport io\nimport os\nimport sys\nfrom bakery_cli.fonts_public_pb2 import FontProto, FamilyProto\nfrom google.protobuf import text_format\n\nargs = argparse.ArgumentParser()\nargs.add_argument('key', help='Key from Google Fonts Developer API')\nargs.add_argument('repo', help='Directory tree that contains directories with METADATA.pb files')\nargs.add_argument('--cache', help='Directory to store a copy of the files in the fonts developer api',\n default=\"/tmp/fontbakery-compare-git-api\")\nargs.add_argument('--verbose', help='Print additional information', action=\"store_true\")\nargs.add_argument('--ignore-copy-existing-ttf', action=\"store_true\")\nargs.add_argument('--autofix', help='Apply automatic fixes to files', action=\"store_true\")\nargs.add_argument('--api', help='Domain string to use to request', default=\"fonts.googleapis.com\")\nargv = args.parse_args()\n\n\n\n\nif __name__ == '__main__':\n import urllib\n import urlparse\n import json\n response = urllib.urlopen('https://www.googleapis.com/webfonts/v1/webfonts?key={}'.format(argv.key))\n try:\n webfontList = json.loads(response.read())['items']\n webfontListFamilyNames = [item['family'] for item in webfontList]\n except (ValueError, KeyError):\n sys.exit(1)\n\n for dirpath, dirnames, filenames in os.walk(argv.repo):\n metadataProtoFile = os.path.join(dirpath, 'METADATA.pb')\n if not os.path.exists(metadataProtoFile):\n continue\n\n metadata = FamilyProto()\n text_data = open(metadataProtoFile, \"rb\").read()\n text_format.Merge(text_data, metadata)\n try:\n family = metadata.name\n except KeyError:\n print('ER: \"{}\" does not contain FamilyName'.format(metadataProtoFile), file=sys.stderr)\n continue\n\n try:\n index = webfontListFamilyNames.index(family)\n webfontsItem = webfontList[index]\n except ValueError:\n print('ER: Family \"{}\" could not be found in API'.format(family))\n continue\n\n webfontVariants = []\n log_messages = []\n for variant, fonturl in webfontsItem['files'].items():\n cache_font_path = get_cache_font_path(argv.cache, fonturl)\n webfontVariants.append(variant)\n\n if argv.ignore_copy_existing_ttf and os.path.exists(cache_font_path):\n continue\n\n with open(cache_font_path, 'w') as fp:\n filenameWeightStyleIndex = [getVariantName(item) for item in metadata.fonts].index(variant)\n filename = metadata.fonts[filenameWeightStyleIndex].filename\n if argv.verbose:\n print('Downloading \"{}\" as \"{}\"'.format(fonturl, filename))\n\n #Saving:\n fp.write(urllib.urlopen(fonturl).read())\n\n #Symlinking:\n src = cache_font_path\n dst_dir = os.path.dirname(cache_font_path)\n dst = os.path.join(dst_dir, filename)\n if not os.path.exists(dst):\n os.symlink(src, dst)\n\n for subset in webfontsItem['subsets']:\n if subset == \"menu\":\n # note about Google Web Fonts:\n # Menu subsets are no longer generated offline.\n continue\n\n if subset not in metadata.subsets:\n print('ER: \"{}\" lacks subset \"{}\" in git'.format(family, subset), file=sys.stderr)\n else:\n if argv.verbose:\n print('OK: \"{}\" subset \"{}\" in sync'.format(family, subset))\n\n for subset in metadata.subsets:\n if subset != \"menu\" and subset not in webfontsItem['subsets']:\n print('ER: \"{}\" lacks subset \"{}\" in API'.format(family, subset), file=sys.stderr)\n\n if metadata.category.lower() != webfontsItem['category']:\n print('ER: \"{}\" category \"{}\" in git does not match category \"{}\" in API'.format(family, metadata.category, webfontsItem['category']))\n else:\n if argv.verbose:\n print('OK: \"{}\" category \"{}\" in sync'.format(family, metadata.category))\n\n\n for variant in webfontVariants:\n try:\n filenameWeightStyleIndex = [getVariantName(item) for item in metadata.fonts].index(variant)\n repoFileName = metadata.fonts[filenameWeightStyleIndex].filename\n\n fonturl = webfontsItem['files'][variant]\n fontpath = get_cache_font_path(argv.cache, fonturl)\n\n import hashlib\n google_md5 = hashlib.md5(open(fontpath, 'rb').read()).hexdigest()\n repo_md5 = hashlib.md5(open(os.path.join(dirpath, repoFileName), 'rb').read()).hexdigest()\n\n if repo_md5 == google_md5:\n log_messages.append([variant, 'OK', '\"{}\" in sync'.format(repoFileName)])\n else:\n log_messages.append([variant, 'ER', '\"{}\" checksum mismatch, file in API does not match file in git'.format(repoFileName)])\n\n except ValueError:\n log_messages.append([variant, 'ER', '\"{}\" available in API but not in git'.format(font.filename)])\n\n for font in metadata.fonts:\n variant = getVariantName(font)\n try:\n webfontVariants.index(variant)\n except ValueError:\n log_messages.append([variant, 'ER', '\"{}\" available in git but not in API'.format(font.filename)])\n\n #sort all the messages by their respective metadataFileName and print them:\n for message in sorted(log_messages, key=lambda x: x[0].lower()):\n variant, status, text = message\n if status == \"OK\":\n if argv.verbose:\n print('{}: {}'.format(status, text))\n else:\n print('{}: {}'.format(status, text), file=sys.stderr)\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_cache_font_path(cache_dir, fonturl):\n urlparts = urlparse.urlparse(fonturl)\n cache_dir = os.path.join(cache_dir, urlparts.netloc, os.path.dirname(urlparts.path).strip('/'))\n if not os.path.exists(cache_dir):\n os.makedirs(cache_dir)\n fontname = os.path.basename(fonturl)\n return os.path.join(cache_dir, fontname)", "metadata": "root.get_cache_font_path", "header": "['module', '___EOS___']", "index": 24 }, { "content": "def getVariantName(item):\n if item.style == \"normal\" and item.weight == 400:\n return \"regular\"\n\n name = \"\"\n if item.weight != 400:\n name = str(item.weight)\n\n if item.style != \"normal\":\n name += item.style\n\n return name", "metadata": "root.getVariantName", "header": "['module', '___EOS___']", "index": 32 } ]
[ { "span": "import collections", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 18 }, { "span": "import io", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 9 }, { "span": "from bakery_cli.fonts_public_pb2 import FontProto, FamilyProto", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 62 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "collections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bake", "ry", "\\u", "cli_", "._", "font", "s", "\\u", "public", "\\u", "pb2_", "import_", "Font", "Proto_", ",_", "Famil", "y", "Proto_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "google_", "._", "protobuf_", "import_", "text", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'", "key", "'_", ",_", "help_", "=_", "'", "Key", " ", "from", " ", "Goo", "gle", " ", "Font", "s", " ", "Dev", "elope", "r", " ", "API", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'", "repo", "'_", ",_", "help_", "=_", "'", "Director", "y", " ", "tree", " ", "tha", "t", " ", "contain", "s", " ", "director", "ies", " ", "with", " ", "METAD", "ATA", ".", "pb", " ", "files", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'--", "cache", "'_", ",_", "help_", "=_", "'", "Director", "y", " ", "to", " ", "store", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "files", " ", "in", " ", "the", " ", "font", "s", " ", "developer", " ", "api", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "\"/", "tmp", "/", "font", "bake", "ry", "-", "compare", "-", "git", "-", "api", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'--", "verbo", "se", "'_", ",_", "help_", "=_", "'", "Print", " ", "addition", "al", " ", "informati", "on", "'_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'--", "ignore", "-", "copy", "-", "exist", "ing", "-", "tt", "f", "'_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'--", "autof", "ix", "'_", ",_", "help_", "=_", "'", "Apply", " ", "automati", "c", " ", "fixes", " ", "to", " ", "files", "'_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "add", "\\u", "argument_", "(_", "'--", "api", "'_", ",_", "help_", "=_", "'", "Doma", "in", " ", "string", " ", "to", " ", "use", " ", "to", " ", "request", "'_", ",_", "default_", "=_", "\"", "font", "s", ".", "google", "apis", ".", "com", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argv_", "=_", "args_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "urllib_", "._", "urlopen_", "(_", "'", "https", "://", "www", ".", "google", "apis", ".", "com", "/", "web", "font", "s", "/", "v1", "/", "web", "font", "s", "?", "key", "={}'_", "._", "format_", "(_", "argv_", "._", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "web", "font", "List_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "read_", "(_", ")_", ")_", "[_", "'", "items", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "web", "font", "List", "Famil", "y", "Names_", "=_", "[_", "item_", "[_", "'", "famil", "y", "'_", "]_", "for_", "item_", "in_", "web", "font", "List_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Value", "Error_", ",_", "Key", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "dirpath_", ",_", "dirnames_", ",_", "filenames_", "in_", "os_", "._", "walk_", "(_", "argv_", "._", "repo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metadata", "Proto", "File_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dirpath_", ",_", "'", "METAD", "ATA", ".", "pb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "metadata", "Proto", "File_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "metadata_", "=_", "Famil", "y", "Proto_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "data_", "=_", "open_", "(_", "metadata", "Proto", "File_", ",_", "\"", "rb", "\"_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "format_", "._", "Merge_", "(_", "text", "\\u", "data_", ",_", "metadata_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "family_", "=_", "metadata_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "ER", ":", " ", "\"{}\"", " ", "doe", "s", " ", "not", " ", "contain", " ", "Famil", "y", "Name", "'_", "._", "format_", "(_", "metadata", "Proto", "File_", ")_", ",_", "file_", "=_", "sys_", "._", "stderr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index_", "=_", "web", "font", "List", "Famil", "y", "Names_", "._", "index_", "(_", "family_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "web", "font", "s", "Item_", "=_", "web", "font", "List_", "[_", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "ER", ":", " ", "Famil", "y", " ", "\"{}\"", " ", "coul", "d", " ", "not", " ", "be", " ", "found", " ", "in", " ", "API", "'_", "._", "format_", "(_", "family_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "web", "font", "Varia", "nts_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log", "\\u", "messages_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "variant_", ",_", "font", "url_", "in_", "web", "font", "s", "Item_", "[_", "'", "files", "'_", "]_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache", "\\u", "font", "\\u", "path_", "=_", "get", "\\u", "cache", "\\u", "font", "\\u", "path_", "(_", "argv_", "._", "cache_", ",_", "font", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "web", "font", "Varia", "nts_", "._", "append_", "(_", "variant_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "argv_", "._", "ignore", "\\u", "copy", "\\u", "exist", "ing", "\\u", "tt", "f_", "and_", "os_", "._", "path_", "._", "exists_", "(_", "cache", "\\u", "font", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "open_", "(_", "cache", "\\u", "font", "\\u", "path_", ",_", "'", "w", "'_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename", "Weig", "ht", "Style", "Index_", "=_", "[_", "get", "Varia", "nt", "Name_", "(_", "item_", ")_", "for_", "item_", "in_", "metadata_", "._", "fonts_", "]_", "._", "index_", "(_", "variant_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "metadata_", "._", "fonts_", "[_", "filename", "Weig", "ht", "Style", "Index_", "]_", "._", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "argv_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "'", "Down", "load", "ing", " ", "\"{}\"", " ", "as", " ", "\"{}\"'_", "._", "format_", "(_", "font", "url_", ",_", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Sav", "ing", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fp_", "._", "write_", "(_", "urllib_", "._", "urlopen_", "(_", "font", "url_", ")_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Sym", "linking", ":_", "\\u\\u\\uNL\\u\\u\\u_", "src_", "=_", "cache", "\\u", "font", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dst", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "cache", "\\u", "font", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dst_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dst", "\\u", "dir_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "dst_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "symlink_", "(_", "src_", ",_", "dst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "subset_", "in_", "web", "font", "s", "Item_", "[_", "'", "subsets", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "subset_", "==_", "\"", "menu", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "note", " ", "abo", "ut", " ", "Goo", "gle", " ", "Web", " ", "Font", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Menu", " ", "subsets", " ", "are", " ", "no", " ", "long", "er", " ", "generat", "ed", " ", "offline", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "subset_", "not_", "in_", "metadata_", "._", "subsets", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "ER", ":", " ", "\"{}\"", " ", "lack", "s", " ", "subse", "t", " ", "\"{}\"", " ", "in", " ", "git", "'_", "._", "format_", "(_", "family_", ",_", "subset_", ")_", ",_", "file_", "=_", "sys_", "._", "stderr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "argv_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "'", "OK", ":", " ", "\"{}\"", " ", "subse", "t", " ", "\"{}\"", " ", "in", " ", "sync", "'_", "._", "format_", "(_", "family_", ",_", "subset_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "subset_", "in_", "metadata_", "._", "subsets", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "subset_", "!=_", "\"", "menu", "\"_", "and_", "subset_", "not_", "in_", "web", "font", "s", "Item_", "[_", "'", "subsets", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "ER", ":", " ", "\"{}\"", " ", "lack", "s", " ", "subse", "t", " ", "\"{}\"", " ", "in", " ", "API", "'_", "._", "format_", "(_", "family_", ",_", "subset_", ")_", ",_", "file_", "=_", "sys_", "._", "stderr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "metadata_", "._", "category_", "._", "lower_", "(_", ")_", "!=_", "web", "font", "s", "Item_", "[_", "'", "category", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "ER", ":", " ", "\"{}\"", " ", "category", " ", "\"{}\"", " ", "in", " ", "git", " ", "doe", "s", " ", "not", " ", "match", " ", "category", " ", "\"{}\"", " ", "in", " ", "API", "'_", "._", "format_", "(_", "family_", ",_", "metadata_", "._", "category_", ",_", "web", "font", "s", "Item_", "[_", "'", "category", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "argv_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "OK", ":", " ", "\"{}\"", " ", "category", " ", "\"{}\"", " ", "in", " ", "sync", "'_", "._", "format_", "(_", "family_", ",_", "metadata_", "._", "category_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "variant_", "in_", "web", "font", "Varia", "nts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename", "Weig", "ht", "Style", "Index_", "=_", "[_", "get", "Varia", "nt", "Name_", "(_", "item_", ")_", "for_", "item_", "in_", "metadata_", "._", "fonts_", "]_", "._", "index_", "(_", "variant_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repo", "File", "Name_", "=_", "metadata_", "._", "fonts_", "[_", "filename", "Weig", "ht", "Style", "Index_", "]_", "._", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "font", "url_", "=_", "web", "font", "s", "Item_", "[_", "'", "files", "'_", "]_", "[_", "variant_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "font", "path_", "=_", "get", "\\u", "cache", "\\u", "font", "\\u", "path_", "(_", "argv_", "._", "cache_", ",_", "font", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "google", "\\u", "md5_", "=_", "hashlib_", "._", "md5_", "(_", "open_", "(_", "font", "path_", ",_", "'", "rb", "'_", ")_", "._", "read_", "(_", ")_", ")_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repo", "\\u", "md5_", "=_", "hashlib_", "._", "md5_", "(_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dirpath_", ",_", "repo", "File", "Name_", ")_", ",_", "'", "rb", "'_", ")_", "._", "read_", "(_", ")_", ")_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "repo", "\\u", "md5_", "==_", "google", "\\u", "md5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "log", "\\u", "messages_", "._", "append_", "(_", "[_", "variant_", ",_", "'", "OK", "'_", ",_", "'\"{", "}\"", " ", "in", " ", "sync", "'_", "._", "format_", "(_", "repo", "File", "Name_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "log", "\\u", "messages_", "._", "append_", "(_", "[_", "variant_", ",_", "'", "ER", "'_", ",_", "'\"{", "}\"", " ", "checks", "um", " ", "mism", "atch", ",", " ", "file", " ", "in", " ", "API", " ", "doe", "s", " ", "not", " ", "match", " ", "file", " ", "in", " ", "git", "'_", "._", "format_", "(_", "repo", "File", "Name_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log", "\\u", "messages_", "._", "append_", "(_", "[_", "variant_", ",_", "'", "ER", "'_", ",_", "'\"{", "}\"", " ", "avail", "able", " ", "in", " ", "API", " ", "but", " ", "not", " ", "in", " ", "git", "'_", "._", "format_", "(_", "font_", "._", "filename_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "font_", "in_", "metadata_", "._", "fonts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "variant_", "=_", "get", "Varia", "nt", "Name_", "(_", "font_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "web", "font", "Varia", "nts_", "._", "index_", "(_", "variant_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log", "\\u", "messages_", "._", "append_", "(_", "[_", "variant_", ",_", "'", "ER", "'_", ",_", "'\"{", "}\"", " ", "avail", "able", " ", "in", " ", "git", " ", "but", " ", "not", " ", "in", " ", "API", "'_", "._", "format_", "(_", "font_", "._", "filename_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sort", " ", "all", " ", "the", " ", "message", "s", " ", "by", " ", "thei", "r", " ", "respec", "tiv", "e", " ", "metadata", "File", "Name", " ", "and", " ", "print", " ", "them", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "message_", "in_", "sorted_", "(_", "log", "\\u", "messages_", ",_", "key_", "=_", "lambda_", "x_", ":_", "x_", "[_", "0_", "]_", "._", "lower_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "variant_", ",_", "status_", ",_", "text_", "=_", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "status_", "==_", "\"", "OK", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "argv_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "'{}", ":", " ", "{}'_", "._", "format_", "(_", "status_", ",_", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'{}", ":", " ", "{}'_", "._", "format_", "(_", "status_", ",_", "text_", ")_", ",_", "file_", "=_", "sys_", "._", "stderr_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "cache", "\\u", "font", "\\u", "path_", "(_", "cache", "\\u", "dir_", ",_", "font", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urlpa", "rts_", "=_", "urlparse_", "._", "urlparse_", "(_", "font", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "cache", "\\u", "dir_", ",_", "urlpa", "rts_", "._", "netloc_", ",_", "os_", "._", "path_", "._", "dirname_", "(_", "urlpa", "rts_", "._", "path_", ")_", "._", "strip_", "(_", "'/'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "cache", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "cache", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "font", "name_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "font", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "os_", "._", "path_", "._", "join_", "(_", "cache", "\\u", "dir_", ",_", "font", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Varia", "nt", "Name_", "(_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "item_", "._", "style_", "==_", "\"", "normal", "\"_", "and_", "item_", "._", "weight_", "==_", "400_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "regular", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "name_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "item_", "._", "weight_", "!=_", "400_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "str_", "(_", "item_", "._", "weight_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "item_", "._", "style_", "!=_", "\"", "normal", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "+=_", "item_", "._", "style_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
coleifer/micawber/micawber/test_utils.py
[ { "content": " def assertCached(self, url, data, **params):\n key = make_key(url, params)\n self.assertTrue(key in test_cache._cache)\n self.assertEqual(test_cache._cache[key], data)", "metadata": "root.BaseTestCase.assertCached", "header": "['class', 'BaseTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 81 } ]
[ { "span": "self.assertTrue(key in test_cache._cache)", "start_line": 83, "start_column": 8, "end_line": 83, "end_column": 49 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Base", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "assert", "Cache", "d_", "(_", "self_", ",_", "url_", ",_", "data_", ",_", "**_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "make", "\\u", "key_", "(_", "url_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "key_", "in_", "test\\u", "cache_", "._", "\\u", "cache_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "test\\u", "cache_", "._", "\\u", "cache_", "[_", "key_", "]_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
bolme/pyvision/src/pyvision/ml/opencv_ml.py
[ { "content": "'''\nThis module includes some helper functions for training OpenCV's machine learning algorithms.\nCreated on Mar 25, 2013\n\n@author: David S. Bolme\nOak Ridge National Laboratory\n'''\nimport pyvision as pv\nimport cv2\nimport numpy as np\nimport tempfile\nimport shutil\nimport os\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \nif __name__ == '__main__':\n #print \"IRIS_DATA:\",pv.IRIS_DATA\n #print pv.IRIS_LABELS\n labels = np.float32((pv.IRIS_LABELS=='versicolor') + 2*(pv.IRIS_LABELS=='virginica'))\n \n model = svc_rbf(pv.IRIS_DATA[0::2,:],labels[0::2])\n \n import cPickle as pkl\n buf = pkl.dumps(model)\n model = pkl.loads(buf)\n print \"Prediction:\",np.float32([model.predict(s) for s in pv.IRIS_DATA[1::2,:]])\n print \"Prediction:\",model.predict_all(pv.IRIS_DATA[1::2,:])\n assert 0\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class StatsModelWrapper(object):\n '''\n This class wraps an opencv stats model to support pickling and other \n pythonic features, etc.\n '''\n \n \n\n \n \n \n \n ", "metadata": "root.StatsModelWrapper", "header": "['module', '___EOS___']", "index": 14 }, { "content": " def __init__(self,model):\n '''\n Init the wrapper with the model.\n '''\n self.model = model", "metadata": "root.StatsModelWrapper.__init__", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 20 }, { "content": " def predict(self,*args,**kwarg):\n '''\n Wrapper for the predict function.\n '''\n return self.model.predict(*args,**kwarg)", "metadata": "root.StatsModelWrapper.predict", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 26 }, { "content": " def predict_prob(self,*args,**kwarg):\n '''\n Wrapper for the predict function.\n '''\n return self.model.predict_prob(*args,**kwarg)", "metadata": "root.StatsModelWrapper.predict_prob", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 32 }, { "content": " def predict_all(self,*args,**kwarg):\n '''\n Wrapper for the predict function.\n '''\n return self.model.predict_all(*args,**kwarg)", "metadata": "root.StatsModelWrapper.predict_all", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 38 }, { "content": " def __getstate__(self):\n ''' Save the state for pickling '''\n state = {}\n state['model_class'] = str(self.model.__class__).split(\"'\")[-2]\n filename = tempfile.mktemp(suffix='.mod', prefix='tmp')\n self.model.save(filename)\n data = open(filename,'rb').read()\n state['model_data'] = data\n \n for key,value in self.__dict__.iteritems():\n if key != 'model':\n state[key] = value\n \n return state", "metadata": "root.StatsModelWrapper.__getstate__", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 44 }, { "content": " def __setstate__(self,state):\n ''' Load the state for pickling. '''\n self.model = eval(state['model_class']+\"()\")\n filename = tempfile.mktemp(suffix='.mod', prefix='tmp')\n open(filename,'wb').write(state['model_data'])\n self.model.load(filename)\n os.remove(filename)\n for key,value in state.iteritems():\n if key not in ('model_data','model_class'):\n setattr(self,key,value)", "metadata": "root.StatsModelWrapper.__setstate__", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 60 }, { "content": " def save(self,*args,**kwargs):\n self.model.save(*args,**kwargs)", "metadata": "root.StatsModelWrapper.save", "header": "['class', 'StatsModelWrapper', '(', 'object', ')', ':', '___EOS___']", "index": 71 }, { "content": "def svc_rbf(data,responses):\n '''\n Auto trains an OpenCV SVM.\n '''\n data = np.float32(data)\n responses = np.float32(responses) \n params = dict( kernel_type = cv2.SVM_RBF, svm_type = cv2.SVM_C_SVC )\n model = cv2.SVM()\n model.train_auto(data,responses,None,None,params)\n return StatsModelWrapper(model)", "metadata": "root.svc_rbf", "header": "['module', '___EOS___']", "index": 75 }, { "content": "def svc_linear(data,responses):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict( kernel_type = cv2.SVM_LINEAR, svm_type = cv2.SVM_C_SVC)\n model = cv2.SVM()\n model.train_auto(data,responses,None,None,params)\n return StatsModelWrapper(model)", "metadata": "root.svc_linear", "header": "['module', '___EOS___']", "index": 87 }, { "content": "def svr_rbf(data,responses):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict( kernel_type = cv2.SVM_RBF, svm_type = cv2.SVM_EPS_SVR , p=1.0)\n model = cv2.SVM()\n model.train_auto(data,responses,None,None,params)\n return StatsModelWrapper(model)", "metadata": "root.svr_rbf", "header": "['module', '___EOS___']", "index": 99 }, { "content": "def svr_linear(data,responses):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict( kernel_type = cv2.SVM_LINEAR, svm_type = cv2.SVM_EPS_SVR , p=1.0 )\n model = cv2.SVM()\n model.train_auto(data,responses,None,None,params)\n return StatsModelWrapper(model)", "metadata": "root.svr_linear", "header": "['module', '___EOS___']", "index": 110 }, { "content": "def random_forest(data,responses,n_trees=100):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict(max_num_of_trees_in_the_forest=n_trees,termcrit_type=cv2.TERM_CRITERIA_MAX_ITER)\n #params = dict( kernel_type = cv2.SVM_LINEAR, svm_type = cv2.SVM_EPS_SVR , p=1.0 )\n model = cv2.RTrees()\n model.train(data,cv2.CV_ROW_SAMPLE,responses,params=params)\n return StatsModelWrapper(model)", "metadata": "root.random_forest", "header": "['module', '___EOS___']", "index": 122 }, { "content": "def boost(data,responses,weak_count=100,max_depth=20,boost_type=cv2.BOOST_DISCRETE):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict(boost_type=boost_type,weak_count=weak_count,max_depth=max_depth)\n model = cv2.Boost()\n model.train(data,cv2.CV_ROW_SAMPLE,responses,params=params)\n return StatsModelWrapper(model)", "metadata": "root.boost", "header": "['module', '___EOS___']", "index": 135 }, { "content": "def gbtrees(data,responses,n_trees=100):\n '''\n Auto trains an OpenCV SVM.\n '''\n np.float32(data)\n np.float32(responses) \n params = dict(max_num_of_trees_in_the_forest=n_trees,termcrit_type=cv2.TERM_CRITERIA_MAX_ITER)\n #params = dict( kernel_type = cv2.SVM_LINEAR, svm_type = cv2.SVM_EPS_SVR , p=1.0 )\n model = cv2.GBTrees()\n model.train(data,cv2.CV_ROW_SAMPLE,responses,params=params)\n return StatsModelWrapper(model)", "metadata": "root.gbtrees", "header": "['module', '___EOS___']", "index": 146 } ]
[ { "span": "import shutil", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "Thi", "s", " ", "module", " ", "include", "s", " ", "some", " ", "help", "er", " ", "function", "s", " ", "for", " ", "train", "ing", " ", "Open", "CV", "'", "s", " ", "machine", " ", "learn", "ing", " ", "algo", "rit", "hms", ".", "\\", "10", ";", "Creat", "ed", " ", "on", " ", "Mar", " ", "25", ",", " ", "2013", "\\", "10", ";", "\\", "10", ";", "@", "author", ":", " ", "Dav", "id", " ", "S", ".", " ", "Bol", "me", "\\", "10", ";", "Oa", "k", " ", "Rid", "ge", " ", "Nat", "ional", " ", "Labo", "rator", "y", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyv", "isi", "on_", "as_", "pv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cv2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "\"", "IRI", "S", "\\u", "DATA", ":\"", ",", "pv", ".", "IRI", "S", "\\u", "DATA_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "pv", ".", "IRI", "S", "\\u", "LABELS_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labels_", "=_", "np_", "._", "float32_", "(_", "(_", "pv_", "._", "IRI", "S", "\\u", "LABELS_", "==_", "'", "versi", "color", "'_", ")_", "+_", "2_", "*_", "(_", "pv_", "._", "IRI", "S", "\\u", "LABELS_", "==_", "'", "virg", "ini", "ca", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "svc", "\\u", "rbf", "_", "(_", "pv_", "._", "IRI", "S", "\\u", "DATA_", "[_", "0_", ":_", ":_", "2_", ",_", ":_", "]_", ",_", "labels_", "[_", "0_", ":_", ":_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "c", "Pickle_", "as_", "pkl", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf_", "=_", "pkl", "_", "._", "dumps_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "pkl", "_", "._", "loads_", "(_", "buf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Prediction", ":\"_", ",_", "np_", "._", "float32_", "(_", "[_", "model_", "._", "predict_", "(_", "s_", ")_", "for_", "s_", "in_", "pv_", "._", "IRI", "S", "\\u", "DATA_", "[_", "1_", ":_", ":_", "2_", ",_", ":_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Prediction", ":\"_", ",_", "model_", "._", "predi", "ct", "\\u", "all_", "(_", "pv_", "._", "IRI", "S", "\\u", "DATA_", "[_", "1_", ":_", ":_", "2_", ",_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "0_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "class", " ", "wrap", "s", " ", "an", " ", "opencv", " ", "stats", " ", "model", " ", "to", " ", "support", " ", "pick", "ling", " ", "and", " ", "other", " ", "\\", "10", ";", " ", " ", " ", " ", "python", "ic", " ", "features", ",", " ", "etc", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Ini", "t", " ", "the", " ", "wrapp", "er", " ", "with", " ", "the", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "model_", "=_", "model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "predict_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwarg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Wrapper", " ", "for", " ", "the", " ", "predi", "ct", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "model_", "._", "predict_", "(_", "*_", "args_", ",_", "**_", "kwarg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "predi", "ct", "\\u", "prob_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwarg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Wrapper", " ", "for", " ", "the", " ", "predi", "ct", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "model_", "._", "predi", "ct", "\\u", "prob_", "(_", "*_", "args_", ",_", "**_", "kwarg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "predi", "ct", "\\u", "all_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwarg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Wrapper", " ", "for", " ", "the", " ", "predi", "ct", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "model_", "._", "predi", "ct", "\\u", "all_", "(_", "*_", "args_", ",_", "**_", "kwarg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getstate", "\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Save", " ", "the", " ", "state", " ", "for", " ", "pick", "ling", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "[_", "'", "model", "\\u", "class", "'_", "]_", "=_", "str_", "(_", "self_", "._", "model_", "._", "\\u\\u", "class\\u\\u_", ")_", "._", "split_", "(_", "\"'\"_", ")_", "[_", "-_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "tempfile_", "._", "mktemp_", "(_", "suffix_", "=_", "'.", "mod", "'_", ",_", "prefix_", "=_", "'", "tmp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "model_", "._", "save_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "open_", "(_", "filename_", ",_", "'", "rb", "'_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "[_", "'", "model", "\\u", "data", "'_", "]_", "=_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "!=_", "'", "model", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "state_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "setstate", "\\u\\u_", "(_", "self_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Load", " ", "the", " ", "state", " ", "for", " ", "pick", "ling", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "model_", "=_", "eval_", "(_", "state_", "[_", "'", "model", "\\u", "class", "'_", "]_", "+_", "\"(", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "tempfile_", "._", "mktemp_", "(_", "suffix_", "=_", "'.", "mod", "'_", ",_", "prefix_", "=_", "'", "tmp", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open_", "(_", "filename_", ",_", "'", "wb", "'_", ")_", "._", "write_", "(_", "state_", "[_", "'", "model", "\\u", "data", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "model_", "._", "load_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "state_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "not_", "in_", "(_", "'", "model", "\\u", "data", "'_", ",_", "'", "model", "\\u", "class", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Model", "Wrapper_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "model_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "svc", "\\u", "rbf", "_", "(_", "data_", ",_", "responses_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "responses_", "=_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "kernel", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "RB", "F_", ",_", "svm", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "C", "\\u", "SVC_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "cv2_", "._", "SV", "M_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train", "\\u", "auto_", "(_", "data_", ",_", "responses_", ",_", "None_", ",_", "None_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "svc", "\\u", "linear_", "(_", "data_", ",_", "responses_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "kernel", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "LINEAR", "_", ",_", "svm", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "C", "\\u", "SVC_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "cv2_", "._", "SV", "M_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train", "\\u", "auto_", "(_", "data_", ",_", "responses_", ",_", "None_", ",_", "None_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sv", "r", "\\u", "rbf", "_", "(_", "data_", ",_", "responses_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "kernel", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "RB", "F_", ",_", "svm", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "EPS", "\\u", "SV", "R_", ",_", "p_", "=_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "cv2_", "._", "SV", "M_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train", "\\u", "auto_", "(_", "data_", ",_", "responses_", ",_", "None_", ",_", "None_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sv", "r", "\\u", "linear_", "(_", "data_", ",_", "responses_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "kernel", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "LINEAR", "_", ",_", "svm", "\\u", "type_", "=_", "cv2_", "._", "SV", "M", "\\u", "EPS", "\\u", "SV", "R_", ",_", "p_", "=_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "cv2_", "._", "SV", "M_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train", "\\u", "auto_", "(_", "data_", ",_", "responses_", ",_", "None_", ",_", "None_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "random", "\\u", "forest_", "(_", "data_", ",_", "responses_", ",_", "n", "\\u", "trees_", "=_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "max", "\\u", "num", "\\u", "of", "\\u", "trees", "\\u", "in", "\\u", "the", "\\u", "forest_", "=_", "n", "\\u", "trees_", ",_", "term", "crit", "\\u", "type_", "=_", "cv2_", "._", "TERM", "\\u", "CRIT", "ERI", "A", "\\u", "MAX", "\\u", "ITER", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "params", " ", "=", " ", "dict", "(", " ", "kernel", "\\u", "type", " ", "=", " ", "cv", "2", ".", "SV", "M", "\\u", "LINEAR", ",", " ", "svm", "\\u", "type", " ", "=", " ", "cv", "2", ".", "SV", "M", "\\u", "EPS", "\\u", "SV", "R", " ", ",", " ", "p", "=", "1.0", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "cv2_", "._", "RT", "ree", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train_", "(_", "data_", ",_", "cv2_", "._", "CV", "\\u", "ROW", "\\u", "SAMPLE", "_", ",_", "responses_", ",_", "params_", "=_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "boost", "_", "(_", "data_", ",_", "responses_", ",_", "weak", "\\u", "count_", "=_", "100_", ",_", "max", "\\u", "depth_", "=_", "20_", ",_", "boost", "\\u", "type_", "=_", "cv2_", "._", "BOO", "ST", "\\u", "DISC", "RET", "E_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "boost", "\\u", "type_", "=_", "boost", "\\u", "type_", ",_", "weak", "\\u", "count_", "=_", "weak", "\\u", "count_", ",_", "max", "\\u", "depth_", "=_", "max", "\\u", "depth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "cv2_", "._", "Boost", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train_", "(_", "data_", ",_", "cv2_", "._", "CV", "\\u", "ROW", "\\u", "SAMPLE", "_", ",_", "responses_", ",_", "params_", "=_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gb", "trees_", "(_", "data_", ",_", "responses_", ",_", "n", "\\u", "trees_", "=_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Auto", " ", "trains", " ", "an", " ", "Open", "CV", " ", "SV", "M", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "float32_", "(_", "responses_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "dict_", "(_", "max", "\\u", "num", "\\u", "of", "\\u", "trees", "\\u", "in", "\\u", "the", "\\u", "forest_", "=_", "n", "\\u", "trees_", ",_", "term", "crit", "\\u", "type_", "=_", "cv2_", "._", "TERM", "\\u", "CRIT", "ERI", "A", "\\u", "MAX", "\\u", "ITER", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "params", " ", "=", " ", "dict", "(", " ", "kernel", "\\u", "type", " ", "=", " ", "cv", "2", ".", "SV", "M", "\\u", "LINEAR", ",", " ", "svm", "\\u", "type", " ", "=", " ", "cv", "2", ".", "SV", "M", "\\u", "EPS", "\\u", "SV", "R", " ", ",", " ", "p", "=", "1.0", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "cv2_", "._", "GB", "Trees", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "train_", "(_", "data_", ",_", "cv2_", "._", "CV", "\\u", "ROW", "\\u", "SAMPLE", "_", ",_", "responses_", ",_", "params_", "=_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Stat", "s", "Model", "Wrapper_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
Keeper-Security/Commander/keepercommander/api.py
[ { "content": "def decrypt_data_key(params):\n \"\"\" Decrypt the data key returned by the server \n Format:\n 1 byte: Version number (currently only 1)\n 3 bytes: Iterations, unsigned integer, big endian\n 16 bytes: salt\n 80 bytes: encrypted data key (broken down further below)\n 16 bytes: IV\n 64 bytes: ciphertextIn\n Key for encrypting the data key: \n PBKDF2_with_HMAC_SHA256(iterations, salt, master password, 256-bit)\n Encryption method: 256-bit AES, CBC mode, no padding\n Verification: the decrypted ciphertext should contain two 32 byte values, \n identical to each other.\n \"\"\"\n if not params.encryption_params:\n raise CryptoError('Invalid encryption params: empty')\n\n decoded_encryption_params = base64.urlsafe_b64decode(\n params.encryption_params+'==')\n\n if len(decoded_encryption_params) != 100:\n raise CryptoError('Invalid encryption params: bad params length')\n\n version = int.from_bytes(decoded_encryption_params[0:1], \n byteorder='big', signed=False)\n iterations = int.from_bytes(decoded_encryption_params[1:4], \n byteorder='big', signed=False)\n salt = decoded_encryption_params[4:20]\n encrypted_data_key = decoded_encryption_params[20:100]\n iv = encrypted_data_key[0:16]\n ciphertext = encrypted_data_key[16:80]\n\n if iterations < 1000:\n raise CryptoError('Invalid encryption parameters: iterations too low')\n\n # generate cipher key from master password and encryption params\n prf = lambda p,s: HMAC.new(p,s,SHA256).digest()\n key = PBKDF2(params.password, salt, 32, iterations, prf)\n\n # decrypt the <encrypted data key>\n cipher = AES.new(key, AES.MODE_CBC, iv)\n decrypted_data_key = cipher.decrypt(ciphertext)\n\n # validate the key is formatted correctly\n if len(decrypted_data_key) != 64:\n raise CryptoError('Invalid data key length')\n\n if decrypted_data_key[:32] != decrypted_data_key[32:]:\n raise CryptoError('Invalid data key: failed mirror verification')\n\n if params.debug: print('Decrypted data key with success.')\n\n # save the encryption params \n params.data_key = decrypted_data_key[:32] ", "metadata": "root.decrypt_data_key", "header": "['module', '___EOS___']", "index": 565 }, { "content": "def rotate_password(params, record_uid):\n \"\"\" Rotate the password for the specified record UID \"\"\"\n\n record_uid = record_uid.strip()\n\n if not record_uid:\n print('No record UID provided')\n return False\n\n if not params.record_cache:\n print('No record cache. Sync down first.')\n return False\n\n if not record_uid in params.record_cache:\n print('Record UID not found.')\n return False\n\n # get the record object\n cached_rec = params.record_cache[record_uid]\n\n # extract data and extra from record\n if 'data' in cached_rec:\n data = json.loads(cached_rec['data'].decode('utf-8')) \n else: data = {}\n\n if 'extra' in cached_rec:\n extra = json.loads(cached_rec['extra'].decode('utf-8')) \n else: extra = {}\n\n # check for edit permissions\n can_edit = False\n if 'can_edit' in cached_rec:\n if params.debug: print('Edit permissions found in record')\n can_edit = True\n\n # If record permission not there, check shared folders\n found_shared_folder_uid = ''\n if can_edit == False:\n for shared_folder_uid in params.shared_folder_cache:\n shared_folder = params.shared_folder_cache[shared_folder_uid]\n sf_key = shared_folder['shared_folder_key']\n if 'records' in shared_folder:\n sf_records = shared_folder['records']\n for sf_record in sf_records:\n if 'record_uid' in sf_record:\n if sf_record['record_uid'] == record_uid:\n found_shared_folder_uid = shared_folder_uid\n if 'can_edit' in sf_record:\n can_edit = True\n if params.debug: \n print('Edit permissions found in folder')\n break\n\n if not can_edit:\n print('You do not have permissions to edit this record.')\n return False\n\n if not params.server:\n raise CommunicationError('No server provided')\n\n if not params.user:\n raise CommunicationError('No username provided')\n\n # save previous password\n if params.debug: print('Data: ' + str(data))\n if params.debug: print('Extra: ' + str(extra))\n\n # generate friendly datestamp\n modified_time = int(round(time.time()))\n modified_time_milli = modified_time * 1000 \n datestamp = datetime.datetime.fromtimestamp(\n modified_time).strftime('%Y-%m-%d %H:%M:%S')\n\n # Backup old password in a custom field\n custom_dict = {}\n custom_dict['name'] = 'cmdr:Rotation @ '+str(datestamp)\n custom_dict['value'] = data['secret2']\n custom_dict['type'] = 'text' \n\n # serialize this dict\n serialized = json.dumps(custom_dict)\n\n # load as json\n custom_dict_json = json.loads(serialized)\n\n # Append to the current structure\n data['custom'].append(custom_dict_json)\n \n if params.debug: \n print('Old password: ' + str(data['secret2']))\n\n # load the data into a record object for convenience\n record_object = Record()\n record_object.load(data)\n\n # generate a new password with any specified rules\n rules = record_object.get(\"cmdr:rules\")\n if rules:\n new_password = generator.generateFromRules(rules)\n else:\n new_password = generator.generate()\n\n # execute rotation plugin associated with this record\n plugin_name = record_object.get(\"cmdr:plugin\")\n if plugin_name:\n # Some plugins might need to change the password in the process of rotation\n # f.e. windows plugin gets rid of certain characters.\n plugin = plugin_manager.get_plugin(plugin_name)\n if plugin:\n if hasattr(plugin, \"adjust\"):\n new_password = plugin.adjust(new_password)\n\n print(\"Rotating with plugin \" + str(plugin_name))\n success = plugin.rotate(record_object, new_password)\n if success:\n if params.debug:\n print(\"Password rotation is successful for \\\"{0}\\\".\".format(plugin_name))\n else:\n print(\"Password rotation failed for \\\"{0}\\\".\".format(plugin_name))\n return False\n else:\n return False\n else:\n return False\n\n data['secret2'] = record_object.password\n\n if params.debug: \n print('New password: ' + str(data['secret2']))\n\n if params.debug: \n print('New record data: ' + str(data))\n\n # Update the record cache with the cleartext data\n if params.debug: print('data is ' + str(isinstance(data, dict)))\n if params.debug: print('params.record_cache is ' + \\\n str(isinstance(params.record_cache, dict)))\n\n # convert dict back to json then encode it \n params.record_cache[record_uid]['data'] = json.dumps(data).encode()\n\n if params.debug: \n print('New record: ' + str(params.record_cache[record_uid]))\n print('Data: ' + str(data))\n print('Extra: ' + str(extra))\n\n # Convert the data and extra dictionary to string object\n # with double quotes instead of single quotes\n data_serialized = json.dumps(data)\n extra_serialized = json.dumps(extra)\n\n if params.debug: print('data_serialized: ' + str(data_serialized))\n if params.debug: print('extra_serialized: ' + str(extra_serialized))\n\n # encrypt data and extra\n if not 'record_key_unencrypted' in params.record_cache[record_uid]:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise CryptoError('No record_key_unencrypted found for ' + record_uid)\n\n if not 'record_key' in params.record_cache[record_uid]:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise CryptoError('No record_key found for ' + record_uid)\n\n record_key_unencrypted = \\\n params.record_cache[record_uid]['record_key_unencrypted']\n iv = os.urandom(16)\n cipher = AES.new(record_key_unencrypted, AES.MODE_CBC, iv)\n encrypted_data = iv + cipher.encrypt(pad(data_serialized))\n\n iv = os.urandom(16)\n cipher = AES.new(record_key_unencrypted, AES.MODE_CBC, iv)\n encrypted_extra = iv + cipher.encrypt(pad(extra_serialized))\n\n if params.debug: print('encrypted_data: ' + str(encrypted_data))\n if params.debug: print('encrypted_extra: ' + str(encrypted_extra))\n\n # note: decode() converts bytestream (b') to string\n encoded_data = base64.urlsafe_b64encode(encrypted_data).decode()\n encoded_extra = base64.urlsafe_b64encode(encrypted_extra).decode()\n\n if params.debug: print('encoded_data: ' + str(encoded_data))\n if params.debug: print('encoded_extra: ' + str(encoded_extra))\n\n # build a record object\n new_record = {}\n new_record['record_uid'] = record_uid\n new_record['version'] = 2 \n new_record['data'] = encoded_data\n new_record['extra'] = encoded_extra\n new_record['client_modified_time'] = modified_time_milli\n new_record['revision'] = params.record_cache[record_uid]['revision']\n if found_shared_folder_uid:\n new_record['shared_folder_uid'] = found_shared_folder_uid\n\n if 'udata' in params.record_cache[record_uid]:\n new_record['udata'] = params.record_cache[record_uid]['udata']\n \n if params.debug: print('new_record: ' + str(new_record))\n\n # create updated records\n update_records = []\n update_records.append(new_record)\n\n def make_json(params, update_records):\n return {\n 'client_time':current_milli_time(),\n 'device_id':'Commander', \n 'device_name':'Commander', \n 'command':'record_update', \n 'update_records':update_records,\n 'protocol_version':1, \n 'client_version':CLIENT_VERSION,\n '2fa_token':params.mfa_token,\n '2fa_type':params.mfa_type, \n 'session_token':params.session_token, \n 'username':params.user\n }\n \n if not params.session_token:\n try:\n login(params)\n except:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise\n \n payload = make_json(params, update_records)\n\n if params.debug: print('payload: ' + str(payload))\n \n try:\n r = requests.post(params.server, json=payload)\n except:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise CommunicationError(sys.exc_info()[0])\n\n response_json = r.json()\n\n if params.debug:\n debug_response(params, payload, r)\n\n if response_json['result_code'] == 'auth_failed':\n if params.debug: print('Re-authorizing.')\n\n try:\n login(params)\n except:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise\n\n payload = make_json(params, update_records)\n\n try:\n r = requests.post(params.server, json=payload)\n except:\n print('Comm error during re-auth')\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise CommunicationError(sys.exc_info()[0])\n \n response_json = r.json()\n \n if params.debug:\n debug_response(params, payload, r)\n\n if response_json['result'] == 'success':\n new_revision = 0\n if 'update_records' in response_json:\n for info in response_json['update_records']:\n if info['record_uid'] == record_uid:\n if info['status'] == 'success':\n # all records in the transaction get the \n # same revision. this just checks 100% success\n new_revision = response_json['revision']\n \n if new_revision == 0:\n print('Error: Revision not updated')\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n return False\n\n if new_revision == new_record['revision']:\n print('Error: Revision did not change')\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n return False\n\n print('Rotation successful for record_uid=' + \\\n str(new_record['record_uid']) + ', revision=' + \\\n str(new_record['revision']), ', new_revision=' + \\\n str(new_revision))\n\n # update local cache\n params.record_cache[record_uid]['revision'] = new_revision\n\n else :\n if response_json['result_code']:\n if plugin_name: \n print('Plugin updated password to: ' + new_password)\n raise CommunicationError('Unexpected problem: ' + \\\n response_json['result_code'])\n\n return True", "metadata": "root.rotate_password", "header": "['module', '___EOS___']", "index": 654 }, { "content": "def prepare_record(params, record, shared_folder_uid=''):\n ''' Prepares the record to be sent to the Keeper server\n :return: record encrypted and ready to be included into record_update json\n '''\n if not record.record_uid:\n record.record_uid = generate_record_uid()\n\n if params.debug: print('record UID: ' + record.record_uid)\n\n if record.record_uid in params.record_cache:\n raise Exception('Record UID already exists.')\n\n # generate friendly datestamp\n modified_time = int(round(time.time()))\n modified_time_milli = modified_time * 1000\n datestamp = datetime.datetime.fromtimestamp(\n modified_time).strftime('%Y-%m-%d %H:%M:%S')\n\n # initialize data and extra\n data = {}\n extra = {}\n udata = []\n\n data['title'] = record.title\n data['folder'] = record.folder\n data['secret1'] = record.login\n data['secret2'] = record.password\n data['link'] = record.login_url\n data['notes'] = record.notes\n data['custom'] = record.custom_fields\n\n # Convert the data and extra dictionary to string object\n # with double quotes instead of single quotes\n data_serialized = json.dumps(data)\n extra_serialized = json.dumps(extra)\n\n if params.debug: print('Dictionary: ' + str(data))\n if params.debug: print('Serialized: : ' + str(data_serialized))\n\n # generate a record key\n unencrypted_key = os.urandom(32)\n iv = os.urandom(16)\n cipher = AES.new(params.data_key, AES.MODE_CBC, iv)\n type1key = iv + cipher.encrypt(pad_binary(unencrypted_key))\n encoded_type1key = (base64.urlsafe_b64encode(\n type1key).decode()).rstrip('==')\n\n if params.debug: print('generated key=' + str(type1key))\n if params.debug: print('encoded=' + str(encoded_type1key))\n\n # encrypt data with record key\n iv = os.urandom(16)\n cipher = AES.new(unencrypted_key, AES.MODE_CBC, iv)\n encrypted_data = iv + cipher.encrypt(pad(data_serialized))\n\n # encrypt extra with record key\n iv = os.urandom(16)\n cipher = AES.new(unencrypted_key, AES.MODE_CBC, iv)\n encrypted_extra = iv + cipher.encrypt(pad(extra_serialized))\n\n if params.debug: print('encrypted_data: ' + str(encrypted_data))\n if params.debug: print('encrypted_extra: ' + str(encrypted_extra))\n\n # note: decode() converts bytestream (b') to string\n encoded_data = base64.urlsafe_b64encode(encrypted_data).decode()\n encoded_extra = base64.urlsafe_b64encode(encrypted_extra).decode()\n\n if params.debug: print('encoded_data: ' + str(encoded_data))\n if params.debug: print('encoded_extra: ' + str(encoded_extra))\n\n # build a record object\n new_record = {}\n new_record['record_uid'] = record.record_uid\n new_record['version'] = 2\n new_record['data'] = encoded_data\n new_record['extra'] = encoded_extra\n new_record['udata'] = udata\n new_record['client_modified_time'] = modified_time_milli\n new_record['revision'] = 0\n new_record['record_key'] = encoded_type1key\n if shared_folder_uid:\n new_record['shared_folder_uid'] = shared_folder_uid\n\n if params.debug: print('new_record: ' + str(new_record))\n\n return new_record", "metadata": "root.prepare_record", "header": "['module', '___EOS___']", "index": 1011 } ]
[ { "span": "version ", "start_line": 589, "start_column": 4, "end_line": 589, "end_column": 11 }, { "span": "sf_key ", "start_line": 694, "start_column": 12, "end_line": 694, "end_column": 18 }, { "span": "datestamp ", "start_line": 1026, "start_column": 4, "end_line": 1026, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "decrypt", "\\u", "data\\u", "key_", "(_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Decrypt", " ", "the", " ", "data", " ", "key", " ", "return", "ed", " ", "by", " ", "the", " ", "server", " ", "\\", "10", ";", " ", " ", " ", " ", "Format", ":", "\\", "10", ";", " ", " ", " ", " ", "1", " ", "byte", ":", " ", "Version", " ", "number", " ", "(", "currentl", "y", " ", "only", " ", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "3", " ", "bytes", ":", " ", "Iterations", ",", " ", "unsigned", " ", "integ", "er", ",", " ", "big", " ", "endian", "\\", "10", ";", " ", " ", " ", " ", "16", " ", "bytes", ":", " ", "salt", "\\", "10", ";", " ", " ", " ", " ", "80", " ", "bytes", ":", " ", "encrypt", "ed", " ", "data", " ", "key", " ", "(", "broken", " ", "down", " ", "fur", "ther", " ", "belo", "w", ")", "\\", "10", ";", " ", " ", " ", " ", "16", " ", "bytes", ":", " ", "IV", "\\", "10", ";", " ", " ", " ", " ", "64", " ", "bytes", ":", " ", "cipher", "text", "In", "\\", "10", ";", " ", " ", " ", " ", "Key", " ", "for", " ", "encrypt", "ing", " ", "the", " ", "data", " ", "key", ":", " ", "\\", "10", ";", " ", " ", " ", " ", "PB", "KD", "F2", "\\u", "with", "\\u", "HMAC", "\\u", "SHA", "256", "(", "iterati", "ons", ",", " ", "salt", ",", " ", "master", " ", "password", ",", " ", "256", "-", "bit", ")", "\\", "10", ";", " ", " ", " ", " ", "Encrypt", "ion", " ", "method", ":", " ", "256", "-", "bit", " ", "AE", "S", ",", " ", "CBC", " ", "mode", ",", " ", "no", " ", "padd", "ing", "\\", "10", ";", " ", " ", " ", " ", "Veri", "fication", ":", " ", "the", " ", "decrypted", " ", "cipher", "text", " ", "shou", "ld", " ", "contain", " ", "two", " ", "32", " ", "byte", " ", "values", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "identi", "cal", " ", "to", " ", "each", " ", "other", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "params_", "._", "encrypt", "ion", "\\u", "params_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Crypto", "Error_", "(_", "'", "Inva", "lid", " ", "encrypt", "ion", " ", "params", ":", " ", "empty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", "=_", "base64_", "._", "urlsafe", "\\u", "b64decode_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "._", "encrypt", "ion", "\\u", "params_", "+_", "'=='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", ")_", "!=_", "100_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Crypto", "Error_", "(_", "'", "Inva", "lid", " ", "encrypt", "ion", " ", "params", ":", " ", "bad", " ", "params", " ", "length", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "int_", "._", "from", "\\u", "bytes_", "(_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", "[_", "0_", ":_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "byteorder_", "=_", "'", "big", "'_", ",_", "signed_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iterations_", "=_", "int_", "._", "from", "\\u", "bytes_", "(_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", "[_", "1_", ":_", "4_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "byteorder_", "=_", "'", "big", "'_", ",_", "signed_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "salt_", "=_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", "[_", "4_", ":_", "20_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encrypt", "ed", "\\u", "data\\u", "key_", "=_", "decode", "d\\u", "encrypt", "ion", "\\u", "params_", "[_", "20_", ":_", "100_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iv_", "=_", "encrypt", "ed", "\\u", "data\\u", "key_", "[_", "0_", ":_", "16_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ciphertext_", "=_", "encrypt", "ed", "\\u", "data\\u", "key_", "[_", "16_", ":_", "80_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "iterations_", "<_", "1000_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Crypto", "Error_", "(_", "'", "Inva", "lid", " ", "encrypt", "ion", " ", "parameter", "s", ":", " ", "iterati", "ons", " ", "too", " ", "low", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "cipher", " ", "key", " ", "from", " ", "master", " ", "password", " ", "and", " ", "encrypt", "ion", " ", "params_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prf", "_", "=_", "lambda_", "p_", ",_", "s_", ":_", "HMAC", "_", "._", "new_", "(_", "p_", ",_", "s_", ",_", "SHA", "256_", ")_", "._", "digest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "PB", "KD", "F2_", "(_", "params_", "._", "password_", ",_", "salt_", ",_", "32_", ",_", "iterations_", ",_", "prf", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "decrypt", " ", "the", " ", "<", "encrypt", "ed", " ", "data", " ", "key", ">_", "\\u\\u\\uNL\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "key_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "decrypted", "\\u", "data\\u", "key_", "=_", "cipher_", "._", "decrypt_", "(_", "ciphertext_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "validat", "e", " ", "the", " ", "key", " ", "is", " ", "format", "ted", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "decrypted", "\\u", "data\\u", "key_", ")_", "!=_", "64_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Crypto", "Error_", "(_", "'", "Inva", "lid", " ", "data", " ", "key", " ", "length", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "decrypted", "\\u", "data\\u", "key_", "[_", ":_", "32_", "]_", "!=_", "decrypted", "\\u", "data\\u", "key_", "[_", "32_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Crypto", "Error_", "(_", "'", "Inva", "lid", " ", "data", " ", "key", ":", " ", "fail", "ed", " ", "mirror", " ", "verification", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Decrypt", "ed", " ", "data", " ", "key", " ", "with", " ", "success", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "save", " ", "the", " ", "encrypt", "ion", " ", "params", " _", "\\u\\u\\uNL\\u\\u\\u_", "params_", "._", "data\\u", "key_", "=_", "decrypted", "\\u", "data\\u", "key_", "[_", ":_", "32_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rota", "te", "\\u", "password_", "(_", "params_", ",_", "record", "\\u", "uid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Rotate", " ", "the", " ", "password", " ", "for", " ", "the", " ", "specified", " ", "record", " ", "UI", "D", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "record", "\\u", "uid_", "=_", "record", "\\u", "uid_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "record", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "No", " ", "record", " ", "UI", "D", " ", "provided", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "params_", "._", "record", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "No", " ", "record", " ", "cache", ".", " ", " ", "Sync", " ", "down", " ", "first", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "record", "\\u", "uid_", "in_", "params_", "._", "record", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Record", " ", "UI", "D", " ", "not", " ", "found", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "record", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cache", "d\\u", "rec_", "=_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "extract", " ", "data", " ", "and", " ", "extra", " ", "from", " ", "record_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "data", "'_", "in_", "cache", "d\\u", "rec_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "json_", "._", "loads_", "(_", "cache", "d\\u", "rec_", "[_", "'", "data", "'_", "]_", "._", "decode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "extra", "'_", "in_", "cache", "d\\u", "rec_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra_", "=_", "json_", "._", "loads_", "(_", "cache", "d\\u", "rec_", "[_", "'", "extra", "'_", "]_", "._", "decode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "extra_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "for", " ", "edit", " ", "permissions_", "\\u\\u\\uNL\\u\\u\\u_", "can", "\\u", "edit_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "can", "\\u", "edit", "'_", "in_", "cache", "d\\u", "rec_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Edit", " ", "permissi", "ons", " ", "found", " ", "in", " ", "record", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "can", "\\u", "edit_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "record", " ", "permissi", "on", " ", "not", " ", "there", ",", " ", "check", " ", "shared", " ", "folders_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "found", "\\u", "shared", "\\u", "folder", "\\u", "uid_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "can", "\\u", "edit_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "shared", "\\u", "folder", "\\u", "uid_", "in_", "params_", "._", "shared", "\\u", "folder", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "shared", "\\u", "folder_", "=_", "params_", "._", "shared", "\\u", "folder", "\\u", "cache_", "[_", "shared", "\\u", "folder", "\\u", "uid_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sf", "\\u", "key_", "=_", "shared", "\\u", "folder_", "[_", "'", "shared", "\\u", "folder", "\\u", "key", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "record", "s", "'_", "in_", "shared", "\\u", "folder_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sf", "\\u", "records_", "=_", "shared", "\\u", "folder_", "[_", "'", "record", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "sf", "\\u", "record_", "in_", "sf", "\\u", "records_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "'", "record", "\\u", "uid", "'_", "in_", "sf", "\\u", "record_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "sf", "\\u", "record_", "[_", "'", "record", "\\u", "uid", "'_", "]_", "==_", "record", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "found", "\\u", "shared", "\\u", "folder", "\\u", "uid_", "=_", "shared", "\\u", "folder", "\\u", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "can", "\\u", "edit", "'_", "in_", "sf", "\\u", "record_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "can", "\\u", "edit_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", "(_", "'", "Edit", " ", "permissi", "ons", " ", "found", " ", "in", " ", "folder", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "edit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "You", " ", "do", " ", "not", " ", "have", " ", "permissi", "ons", " ", "to", " ", "edit", " ", "this", " ", "record", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "params_", "._", "server_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Communication", "Error_", "(_", "'", "No", " ", "server", " ", "provided", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "params_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Communication", "Error_", "(_", "'", "No", " ", "user", "name", " ", "provided", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "save", " ", "previ", "ous", " ", "password_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Data", ":", " ", "'_", "+_", "str_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Extra", ":", " ", "'_", "+_", "str_", "(_", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "frie", "ndl", "y", " ", "dates", "tamp", "_", "\\u\\u\\uNL\\u\\u\\u_", "modifi", "ed", "\\u", "time_", "=_", "int_", "(_", "round_", "(_", "time_", "._", "time_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modifi", "ed", "\\u", "time", "\\u", "milli", "_", "=_", "modifi", "ed", "\\u", "time_", "*_", "1000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dates", "tamp", "_", "=_", "datetime_", "._", "datetime_", "._", "fromtimestamp_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "modifi", "ed", "\\u", "time_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Back", "up", " ", "old", " ", "password", " ", "in", " ", "a", " ", "custom", " ", "field_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "dict_", "[_", "'", "name", "'_", "]_", "=_", "'", "cmd", "r", ":", "Rot", "ation", " ", "@", " ", "'_", "+_", "str_", "(_", "dates", "tamp", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "dict_", "[_", "'", "value", "'_", "]_", "=_", "data_", "[_", "'", "secret", "2", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "dict_", "[_", "'", "type", "'_", "]_", "=_", "'", "text", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "serialize", " ", "this", " ", "dict_", "\\u\\u\\uNL\\u\\u\\u_", "serialized_", "=_", "json_", "._", "dumps_", "(_", "custom", "\\u", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "load", " ", "as", " ", "json_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "dict", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "serialized_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Append", " ", "to", " ", "the", " ", "current", " ", "structure_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "custom", "'_", "]_", "._", "append_", "(_", "custom", "\\u", "dict", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Old", " ", "password", ":", " ", "'_", "+_", "str_", "(_", "data_", "[_", "'", "secret", "2", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "load", " ", "the", " ", "data", " ", "int", "o", " ", "a", " ", "record", " ", "object", " ", "for", " ", "convenien", "ce_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "record", "\\u", "object_", "=_", "Record_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "record", "\\u", "object_", "._", "load_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "a", " ", "new", " ", "password", " ", "with", " ", "any", " ", "specified", " ", "rules_", "\\u\\u\\uNL\\u\\u\\u_", "rules_", "=_", "record", "\\u", "object_", "._", "get_", "(_", "\"", "cmd", "r", ":", "rule", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rules_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "password_", "=_", "generator_", "._", "generat", "e", "Fro", "m", "Rules_", "(_", "rules_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "password_", "=_", "generator_", "._", "generate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "execute", " ", "rotati", "on", " ", "plugin", " ", "associate", "d", " ", "with", " ", "this", " ", "record_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plugin", "\\u", "name_", "=_", "record", "\\u", "object_", "._", "get_", "(_", "\"", "cmd", "r", ":", "plugin", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Some", " ", "plugin", "s", " ", "mig", "ht", " ", "need", " ", "to", " ", "change", " ", "the", " ", "password", " ", "in", " ", "the", " ", "process", " ", "of", " ", "rotation_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "f", ".", "e", ".", " ", "windows", " ", "plugin", " ", "gets", " ", "rid", " ", "of", " ", "cert", "ain", " ", "character", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plugin_", "=_", "plugin", "\\u", "manager_", "._", "get", "\\u", "plugin_", "(_", "plugin", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plugin_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "plugin_", ",_", "\"", "adjust", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "password_", "=_", "plugin_", "._", "adjust_", "(_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Rot", "ati", "ng", " ", "with", " ", "plugin", " ", "\"_", "+_", "str_", "(_", "plugin", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "plugin_", "._", "rotate_", "(_", "record", "\\u", "object_", ",_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "\"", "Passw", "ord", " ", "rotati", "on", " ", "is", " ", "success", "ful", " ", "for", " ", "\\\\\"{", "0", "}\\\\\"", ".\"_", "._", "format_", "(_", "plugin", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Passw", "ord", " ", "rotati", "on", " ", "fail", "ed", " ", "for", " ", "\\\\\"{", "0", "}\\\\\"", ".\"_", "._", "format_", "(_", "plugin", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "[_", "'", "secret", "2", "'_", "]_", "=_", "record", "\\u", "object_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "New", " ", "password", ":", " ", "'_", "+_", "str_", "(_", "data_", "[_", "'", "secret", "2", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "New", " ", "record", " ", "data", ":", " ", "'_", "+_", "str_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "the", " ", "record", " ", "cache", " ", "with", " ", "the", " ", "clear", "text", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "data", " ", "is", " ", "'_", "+_", "str_", "(_", "isinstance_", "(_", "data_", ",_", "dict_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "params", ".", "record", "\\u", "cache", " ", "is", " ", "'_", "+_", "str_", "(_", "isinstance_", "(_", "params_", "._", "record", "\\u", "cache_", ",_", "dict_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "convert", " ", "dict", " ", "back", " ", "to", " ", "json", " ", "then", " ", "encode", " ", "it", " _", "\\u\\u\\uNL\\u\\u\\u_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "[_", "'", "data", "'_", "]_", "=_", "json_", "._", "dumps_", "(_", "data_", ")_", "._", "encode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "New", " ", "record", ":", " ", "'_", "+_", "str_", "(_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "Data", ":", " ", "'_", "+_", "str_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "Extra", ":", " ", "'_", "+_", "str_", "(_", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "data", " ", "and", " ", "extra", " ", "dictionar", "y", " ", "to", " ", "string", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "double", " ", "quote", "s", " ", "inst", "ead", " ", "of", " ", "single", " ", "quotes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data\\u", "serialized_", "=_", "json_", "._", "dumps_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "serialized_", "=_", "json_", "._", "dumps_", "(_", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "data\\u", "serialize", "d", ":", " ", "'_", "+_", "str_", "(_", "data\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "extra", "\\u", "serialize", "d", ":", " ", "'_", "+_", "str_", "(_", "extra", "\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encrypt", " ", "data", " ", "and", " ", "extra_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "'", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed", "'_", "in_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Crypto", "Error_", "(_", "'", "No", " ", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed", " ", "found", " ", "for", " ", "'_", "+_", "record", "\\u", "uid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "'", "record", "\\u", "key", "'_", "in_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Crypto", "Error_", "(_", "'", "No", " ", "record", "\\u", "key", " ", "found", " ", "for", " ", "'_", "+_", "record", "\\u", "uid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed_", "=_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "[_", "'", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iv_", "=_", "os_", "._", "urandom_", "(_", "16_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encrypt", "ed", "\\u", "data_", "=_", "iv_", "+_", "cipher_", "._", "encrypt_", "(_", "pad_", "(_", "data\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "iv_", "=_", "os_", "._", "urandom_", "(_", "16_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "record", "\\u", "key", "\\u", "une", "ncr", "ypt", "ed_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encrypt", "ed", "\\u", "extra_", "=_", "iv_", "+_", "cipher_", "._", "encrypt_", "(_", "pad_", "(_", "extra", "\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encrypt", "ed", "\\u", "data", ":", " ", "'_", "+_", "str_", "(_", "encrypt", "ed", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encrypt", "ed", "\\u", "extra", ":", " ", "'_", "+_", "str_", "(_", "encrypt", "ed", "\\u", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "note", ":", " ", "decode", "()", " ", "convert", "s", " ", "bytestr", "eam", " ", "(", "b", "')", " ", "to", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "encode", "d\\u", "data_", "=_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "encrypt", "ed", "\\u", "data_", ")_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encode", "d\\u", "extra_", "=_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "encrypt", "ed", "\\u", "extra_", ")_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encode", "d\\u", "data", ":", " ", "'_", "+_", "str_", "(_", "encode", "d\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encode", "d\\u", "extra", ":", " ", "'_", "+_", "str_", "(_", "encode", "d\\u", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "a", " ", "record", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "record_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "record", "\\u", "uid", "'_", "]_", "=_", "record", "\\u", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "version", "'_", "]_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "data", "'_", "]_", "=_", "encode", "d\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "extra", "'_", "]_", "=_", "encode", "d\\u", "extra_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "client", "\\u", "modifi", "ed", "\\u", "time", "'_", "]_", "=_", "modifi", "ed", "\\u", "time", "\\u", "milli", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "revis", "ion", "'_", "]_", "=_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "[_", "'", "revis", "ion", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "found", "\\u", "shared", "\\u", "folder", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "record_", "[_", "'", "shared", "\\u", "folder", "\\u", "uid", "'_", "]_", "=_", "found", "\\u", "shared", "\\u", "folder", "\\u", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "uda", "ta", "'_", "in_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "record_", "[_", "'", "uda", "ta", "'_", "]_", "=_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "[_", "'", "uda", "ta", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "new", "\\u", "record", ":", " ", "'_", "+_", "str_", "(_", "new", "\\u", "record_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "update", "d", " ", "records_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "records_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "\\u", "records_", "._", "append_", "(_", "new", "\\u", "record_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "make", "\\u", "json_", "(_", "params_", ",_", "update", "\\u", "records_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "client", "\\u", "time", "'_", ":_", "current", "\\u", "milli", "\\u", "time_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "device", "\\u", "id", "'_", ":_", "'", "Command", "er", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "device", "\\u", "name", "'_", ":_", "'", "Command", "er", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "command", "'_", ":_", "'", "record", "\\u", "update", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "update", "\\u", "record", "s", "'_", ":_", "update", "\\u", "records_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "protoc", "ol", "\\u", "version", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "client", "\\u", "version", "'_", ":_", "CLIENT", "\\u", "VERSION_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "2f", "a", "\\u", "token", "'_", ":_", "params_", "._", "mf", "a", "\\u", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "2f", "a", "\\u", "type", "'_", ":_", "params_", "._", "mf", "a", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "session", "\\u", "token", "'_", ":_", "params_", "._", "session", "\\u", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "params_", "._", "user_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "params_", "._", "session", "\\u", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "login_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "payload_", "=_", "make", "\\u", "json_", "(_", "params_", ",_", "update", "\\u", "records_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "payload", ":", " ", "'_", "+_", "str_", "(_", "payload_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "requests_", "._", "post_", "(_", "params_", "._", "server_", ",_", "json_", "=_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Communication", "Error_", "(_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "json_", "=_", "r_", "._", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "debug", "\\u", "response_", "(_", "params_", ",_", "payload_", ",_", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "response", "\\u", "json_", "[_", "'", "result", "\\u", "code", "'_", "]_", "==_", "'", "auth", "\\u", "fail", "ed", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Re", "-", "authoriz", "ing", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "login_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "payload_", "=_", "make", "\\u", "json_", "(_", "params_", ",_", "update", "\\u", "records_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "requests_", "._", "post_", "(_", "params_", "._", "server_", ",_", "json_", "=_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Comm", " ", "error", " ", "dur", "ing", " ", "re", "-", "auth", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Communication", "Error_", "(_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "json_", "=_", "r_", "._", "json_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "debug", "\\u", "response_", "(_", "params_", ",_", "payload_", ",_", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "response", "\\u", "json_", "[_", "'", "result", "'_", "]_", "==_", "'", "success", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "revision_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "update", "\\u", "record", "s", "'_", "in_", "response", "\\u", "json_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "info_", "in_", "response", "\\u", "json_", "[_", "'", "update", "\\u", "record", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "info_", "[_", "'", "record", "\\u", "uid", "'_", "]_", "==_", "record", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "info_", "[_", "'", "status", "'_", "]_", "==_", "'", "success", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "all", " ", "record", "s", " ", "in", " ", "the", " ", "transaction", " ", "get", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "same", " ", "revis", "ion", ".", " ", " ", "this", " ", "just", " ", "checks", " ", "100", "%", " ", "success_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "new", "\\u", "revision_", "=_", "response", "\\u", "json_", "[_", "'", "revis", "ion", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "new", "\\u", "revision_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Error", ":", " ", "Revi", "sion", " ", "not", " ", "update", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "new", "\\u", "revision_", "==_", "new", "\\u", "record_", "[_", "'", "revis", "ion", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Error", ":", " ", "Revi", "sion", " ", "did", " ", "not", " ", "change", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "'", "Rot", "ation", " ", "success", "ful", " ", "for", " ", "record", "\\u", "uid", "='_", "+_", "str_", "(_", "new", "\\u", "record_", "[_", "'", "record", "\\u", "uid", "'_", "]_", ")_", "+_", "',", " ", "revis", "ion", "='_", "+_", "str_", "(_", "new", "\\u", "record_", "[_", "'", "revis", "ion", "'_", "]_", ")_", ",_", "',", " ", "new", "\\u", "revis", "ion", "='_", "+_", "str_", "(_", "new", "\\u", "revision_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "local", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "._", "record", "\\u", "cache_", "[_", "record", "\\u", "uid_", "]_", "[_", "'", "revis", "ion", "'_", "]_", "=_", "new", "\\u", "revision_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "response", "\\u", "json_", "[_", "'", "result", "\\u", "code", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "plugin", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Plug", "in", " ", "update", "d", " ", "password", " ", "to", ":", " ", "'_", "+_", "new", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Communication", "Error_", "(_", "'", "Une", "xpe", "cte", "d", " ", "problem", ":", " ", "'_", "+_", "response", "\\u", "json_", "[_", "'", "result", "\\u", "code", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "prepar", "e\\u", "record_", "(_", "params_", ",_", "record_", ",_", "shared", "\\u", "folder", "\\u", "uid_", "=_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Prepare", "s", " ", "the", " ", "record", " ", "to", " ", "be", " ", "sent", " ", "to", " ", "the", " ", "Keep", "er", " ", "server", "\\", "10", ";", " ", " ", " ", " ", ":", "return", ":", " ", "record", " ", "encrypt", "ed", " ", "and", " ", "read", "y", " ", "to", " ", "be", " ", "include", "d", " ", "int", "o", " ", "record", "\\u", "update", " ", "json", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "record_", "._", "record", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "record_", "._", "record", "\\u", "uid_", "=_", "generat", "e\\u", "record", "\\u", "uid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "record", " ", "UI", "D", ":", " ", "'_", "+_", "record_", "._", "record", "\\u", "uid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "record_", "._", "record", "\\u", "uid_", "in_", "params_", "._", "record", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Record", " ", "UI", "D", " ", "alr", "ead", "y", " ", "exist", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "frie", "ndl", "y", " ", "dates", "tamp", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "modifi", "ed", "\\u", "time_", "=_", "int_", "(_", "round_", "(_", "time_", "._", "time_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modifi", "ed", "\\u", "time", "\\u", "milli", "_", "=_", "modifi", "ed", "\\u", "time_", "*_", "1000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dates", "tamp", "_", "=_", "datetime_", "._", "datetime_", "._", "fromtimestamp_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "modifi", "ed", "\\u", "time_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "initialize", " ", "data", " ", "and", " ", "extra_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uda", "ta_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "title", "'_", "]_", "=_", "record_", "._", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "folder", "'_", "]_", "=_", "record_", "._", "folder_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "secret", "1", "'_", "]_", "=_", "record_", "._", "login_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "secret", "2", "'_", "]_", "=_", "record_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "link", "'_", "]_", "=_", "record_", "._", "login", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "note", "s", "'_", "]_", "=_", "record_", "._", "notes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "custom", "'_", "]_", "=_", "record_", "._", "custom", "\\u", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "data", " ", "and", " ", "extra", " ", "dictionar", "y", " ", "to", " ", "string", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "double", " ", "quote", "s", " ", "inst", "ead", " ", "of", " ", "single", " ", "quotes_", "\\u\\u\\uNL\\u\\u\\u_", "data\\u", "serialized_", "=_", "json_", "._", "dumps_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "serialized_", "=_", "json_", "._", "dumps_", "(_", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Dict", "ionar", "y", ":", " ", "'_", "+_", "str_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "Seriali", "zed", ":", " ", ":", " ", "'_", "+_", "str_", "(_", "data\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "a", " ", "record", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "une", "ncr", "ypt", "ed", "\\u", "key_", "=_", "os_", "._", "urandom_", "(_", "32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iv_", "=_", "os_", "._", "urandom_", "(_", "16_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "params_", "._", "data\\u", "key_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type", "1", "key_", "=_", "iv_", "+_", "cipher_", "._", "encrypt_", "(_", "pad", "\\u", "binary_", "(_", "une", "ncr", "ypt", "ed", "\\u", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encode", "d\\u", "type", "1", "key_", "=_", "(_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "type", "1", "key_", ")_", "._", "decode_", "(_", ")_", ")_", "._", "rstrip_", "(_", "'=='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "generat", "ed", " ", "key", "='_", "+_", "str_", "(_", "type", "1", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encode", "d", "='_", "+_", "str_", "(_", "encode", "d\\u", "type", "1", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encrypt", " ", "data", " ", "with", " ", "record", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "iv_", "=_", "os_", "._", "urandom_", "(_", "16_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "une", "ncr", "ypt", "ed", "\\u", "key_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encrypt", "ed", "\\u", "data_", "=_", "iv_", "+_", "cipher_", "._", "encrypt_", "(_", "pad_", "(_", "data\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encrypt", " ", "extra", " ", "with", " ", "record", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "iv_", "=_", "os_", "._", "urandom_", "(_", "16_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "AES_", "._", "new_", "(_", "une", "ncr", "ypt", "ed", "\\u", "key_", ",_", "AES_", "._", "MODE", "\\u", "CBC", "_", ",_", "iv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encrypt", "ed", "\\u", "extra_", "=_", "iv_", "+_", "cipher_", "._", "encrypt_", "(_", "pad_", "(_", "extra", "\\u", "serialized_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encrypt", "ed", "\\u", "data", ":", " ", "'_", "+_", "str_", "(_", "encrypt", "ed", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encrypt", "ed", "\\u", "extra", ":", " ", "'_", "+_", "str_", "(_", "encrypt", "ed", "\\u", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "note", ":", " ", "decode", "()", " ", "convert", "s", " ", "bytestr", "eam", " ", "(", "b", "')", " ", "to", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "encode", "d\\u", "data_", "=_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "encrypt", "ed", "\\u", "data_", ")_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encode", "d\\u", "extra_", "=_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "encrypt", "ed", "\\u", "extra_", ")_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encode", "d\\u", "data", ":", " ", "'_", "+_", "str_", "(_", "encode", "d\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "encode", "d\\u", "extra", ":", " ", "'_", "+_", "str_", "(_", "encode", "d\\u", "extra_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "a", " ", "record", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "record_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "record", "\\u", "uid", "'_", "]_", "=_", "record_", "._", "record", "\\u", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "version", "'_", "]_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "data", "'_", "]_", "=_", "encode", "d\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "extra", "'_", "]_", "=_", "encode", "d\\u", "extra_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "uda", "ta", "'_", "]_", "=_", "uda", "ta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "client", "\\u", "modifi", "ed", "\\u", "time", "'_", "]_", "=_", "modifi", "ed", "\\u", "time", "\\u", "milli", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "revis", "ion", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "record_", "[_", "'", "record", "\\u", "key", "'_", "]_", "=_", "encode", "d\\u", "type", "1", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "shared", "\\u", "folder", "\\u", "uid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "record_", "[_", "'", "shared", "\\u", "folder", "\\u", "uid", "'_", "]_", "=_", "shared", "\\u", "folder", "\\u", "uid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "params_", "._", "debug_", ":_", "print_", "(_", "'", "new", "\\u", "record", ":", " ", "'_", "+_", "str_", "(_", "new", "\\u", "record_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "new", "\\u", "record_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
scrapy/scrapy/scrapy/core/spidermw.py
[ { "content": " def scrape_response(self, scrape_func, response, request, spider):\n fname = lambda f:'%s.%s' % (\n six.get_method_self(f).__class__.__name__,\n six.get_method_function(f).__name__)\n\n def process_spider_input(response):\n for method in self.methods['process_spider_input']:\n try:\n result = method(response=response, spider=spider)\n assert result is None, \\\n 'Middleware %s must returns None or ' \\\n 'raise an exception, got %s ' \\\n % (fname(method), type(result))\n except:\n return scrape_func(Failure(), request, spider)\n return scrape_func(response, request, spider)\n\n def process_spider_exception(_failure):\n exception = _failure.value\n for method in self.methods['process_spider_exception']:\n result = method(response=response, exception=exception, spider=spider)\n assert result is None or _isiterable(result), \\\n 'Middleware %s must returns None, or an iterable object, got %s ' % \\\n (fname(method), type(result))\n if result is not None:\n return result\n return _failure\n\n def process_spider_output(result):\n for method in self.methods['process_spider_output']:\n result = method(response=response, result=result, spider=spider)\n assert _isiterable(result), \\\n 'Middleware %s must returns an iterable object, got %s ' % \\\n (fname(method), type(result))\n return result\n\n dfd = mustbe_deferred(process_spider_input, response)\n dfd.addErrback(process_spider_exception)\n dfd.addCallback(process_spider_output)\n return dfd", "metadata": "root.SpiderMiddlewareManager.scrape_response", "header": "['class', 'SpiderMiddlewareManager', '(', 'MiddlewareManager', ')', ':', '___EOS___']", "index": 33 } ]
[ { "span": "except:", "start_line": 46, "start_column": 16, "end_line": 46, "end_column": 23 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Spi", "der", "Mid", "dle", "ware", "Manager_", "(_", "Mid", "dle", "ware", "Manager_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "scrape", "\\u", "response_", "(_", "self_", ",_", "scrape", "\\u", "func_", ",_", "response_", ",_", "request_", ",_", "spider_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fname_", "=_", "lambda_", "f_", ":_", "'%", "s", ".", "%", "s", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "six_", "._", "get", "\\u", "method", "\\u", "self_", "(_", "f_", ")_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "six_", "._", "get", "\\u", "method", "\\u", "function_", "(_", "f_", ")_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "process", "\\u", "spider", "\\u", "input_", "(_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "method_", "in_", "self_", "._", "methods_", "[_", "'", "process", "\\u", "spider", "\\u", "input", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "=_", "method_", "(_", "response_", "=_", "response_", ",_", "spider_", "=_", "spider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "result_", "is_", "None_", ",_", "'", "Mid", "dle", "ware", " ", "%", "s", " ", "must", " ", "return", "s", " ", "Non", "e", " ", "or", " ", "'_", "'", "raise", " ", "an", " ", "exception", ",", " ", "got", " ", "%", "s", " ", "'_", "%_", "(_", "fname_", "(_", "method_", ")_", ",_", "type_", "(_", "result_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "scrape", "\\u", "func_", "(_", "Failure_", "(_", ")_", ",_", "request_", ",_", "spider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "scrape", "\\u", "func_", "(_", "response_", ",_", "request_", ",_", "spider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "spider", "\\u", "exception_", "(_", "\\u", "failure_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exception_", "=_", "\\u", "failure_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "method_", "in_", "self_", "._", "methods_", "[_", "'", "process", "\\u", "spider", "\\u", "exception", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "method_", "(_", "response_", "=_", "response_", ",_", "exception_", "=_", "exception_", ",_", "spider_", "=_", "spider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "result_", "is_", "None_", "or_", "\\u", "isi", "tera", "ble_", "(_", "result_", ")_", ",_", "'", "Mid", "dle", "ware", " ", "%", "s", " ", "must", " ", "return", "s", " ", "Non", "e", ",", " ", "or", " ", "an", " ", "iterable", " ", "object", ",", " ", "got", " ", "%", "s", " ", "'_", "%_", "(_", "fname_", "(_", "method_", ")_", ",_", "type_", "(_", "result_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u", "failure_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "spider", "\\u", "output_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "method_", "in_", "self_", "._", "methods_", "[_", "'", "process", "\\u", "spider", "\\u", "output", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "method_", "(_", "response_", "=_", "response_", ",_", "result_", "=_", "result_", ",_", "spider_", "=_", "spider_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\\u", "isi", "tera", "ble_", "(_", "result_", ")_", ",_", "'", "Mid", "dle", "ware", " ", "%", "s", " ", "must", " ", "return", "s", " ", "an", " ", "iterable", " ", "object", ",", " ", "got", " ", "%", "s", " ", "'_", "%_", "(_", "fname_", "(_", "method_", ")_", ",_", "type_", "(_", "result_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dfd", "_", "=_", "must", "be", "\\u", "deferred_", "(_", "process", "\\u", "spider", "\\u", "input_", ",_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dfd", "_", "._", "add", "Errback_", "(_", "process", "\\u", "spider", "\\u", "exception_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dfd", "_", "._", "add", "Callback_", "(_", "process", "\\u", "spider", "\\u", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dfd", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
uwdata/termite-data-server/web2py/gluon/globals.py
[ { "content": " def parse_post_vars(self):\n \"\"\"Takes the body of the request and unpacks it into\n post_vars. application/json is also automatically parsed\n \"\"\"\n env = self.env\n post_vars = self._post_vars = Storage()\n body = self.body\n #if content-type is application/json, we must read the body\n is_json = env.get('content_type', '')[:16] == 'application/json'\n\n if is_json:\n try:\n json_vars = sj.load(body)\n except:\n # incoherent request bodies can still be parsed \"ad-hoc\"\n json_vars = {}\n pass\n # update vars and get_vars with what was posted as json\n if isinstance(json_vars, dict):\n post_vars.update(json_vars)\n\n body.seek(0)\n\n # parse POST variables on POST, PUT, BOTH only in post_vars\n if (body and not is_json\n and env.request_method in ('POST', 'PUT', 'DELETE', 'BOTH')):\n query_string = env.pop('QUERY_STRING',None)\n dpost = cgi.FieldStorage(fp=body, environ=env, keep_blank_values=1)\n try:\n post_vars.update(dpost)\n except: pass\n if query_string is not None:\n env['QUERY_STRING'] = query_string\n # The same detection used by FieldStorage to detect multipart POSTs\n body.seek(0)\n\n def listify(a):\n return (not isinstance(a, list) and [a]) or a\n try:\n keys = sorted(dpost)\n except TypeError:\n keys = []\n for key in keys:\n if key is None:\n continue # not sure why cgi.FieldStorage returns None key\n dpk = dpost[key]\n # if an element is not a file replace it with\n # its value else leave it alone\n\n pvalue = listify([(_dpk if _dpk.filename else _dpk.value)\n for _dpk in dpk] \n if isinstance(dpk, list) else\n (dpk if dpk.filename else dpk.value))\n if len(pvalue):\n post_vars[key] = (len(pvalue) > 1 and pvalue) or pvalue[0]", "metadata": "root.Request.parse_post_vars", "header": "['class', 'Request', '(', 'Storage', ')', ':', '___EOS___']", "index": 197 } ]
[ { "span": "pass", "start_line": 213, "start_column": 16, "end_line": 213, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "class_", "Request_", "(_", "Storage_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "\\u", "post", "\\u", "vars_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Tak", "es", " ", "the", " ", "body", " ", "of", " ", "the", " ", "request", " ", "and", " ", "unpack", "s", " ", "it", " ", "int", "o", "\\", "10", ";", " ", " ", " ", " ", "post", "\\u", "vars", ".", " ", "applica", "tion", "/", "json", " ", "is", " ", "als", "o", " ", "automati", "call", "y", " ", "parsed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "=_", "self_", "._", "env_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post", "\\u", "vars_", "=_", "self_", "._", "\\u", "post", "\\u", "vars_", "=_", "Storage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "self_", "._", "body_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "content", "-", "type", " ", "is", " ", "applica", "tion", "/", "json", ",", " ", "we", " ", "must", " ", "read", " ", "the", " ", "body_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "json_", "=_", "env_", "._", "get_", "(_", "'", "content", "\\u", "type", "'_", ",_", "''_", ")_", "[_", ":_", "16_", "]_", "==_", "'", "applica", "tion", "/", "json", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "is", "\\u", "json_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json", "\\u", "vars_", "=_", "sj", "_", "._", "load_", "(_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "inco", "here", "nt", " ", "request", " ", "bodi", "es", " ", "can", " ", "still", " ", "be", " ", "parsed", " ", "\"", "ad", "-", "hoc", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json", "\\u", "vars_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "vars", " ", "and", " ", "get", "\\u", "vars", " ", "with", " ", "what", " ", "was", " ", "poste", "d", " ", "as", " ", "json_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "json", "\\u", "vars_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "post", "\\u", "vars_", "._", "update_", "(_", "json", "\\u", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "body_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "parse", " ", "POST", " ", "variab", "les", " ", "on", " ", "POST", ",", " ", "PU", "T", ",", " ", "BOT", "H", " ", "only", " ", "in", " ", "post", "\\u", "vars_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "body_", "and_", "not_", "is", "\\u", "json_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "env_", "._", "request", "\\u", "method_", "in_", "(_", "'", "POST", "'_", ",_", "'", "PU", "T", "'_", ",_", "'", "DELET", "E", "'_", ",_", "'", "BOT", "H", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query", "\\u", "string_", "=_", "env_", "._", "pop_", "(_", "'", "QUE", "RY", "\\u", "STRING", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dpo", "st_", "=_", "cgi_", "._", "Field", "Storage_", "(_", "fp_", "=_", "body_", ",_", "environ_", "=_", "env_", ",_", "keep", "\\u", "blank", "\\u", "values_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "post", "\\u", "vars_", "._", "update_", "(_", "dpo", "st_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "query", "\\u", "string_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "env_", "[_", "'", "QUE", "RY", "\\u", "STRING", "'_", "]_", "=_", "query", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "same", " ", "detect", "ion", " ", "used", " ", "by", " ", "Field", "Stor", "age", " ", "to", " ", "detect", " ", "multip", "art", " ", "POST", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "body_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "listi", "fy_", "(_", "a_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "not_", "isinstance_", "(_", "a_", ",_", "list_", ")_", "and_", "[_", "a_", "]_", ")_", "or_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "=_", "sorted_", "(_", "dpo", "st_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "key_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "#", " ", "not", " ", "sure", " ", "wh", "y", " ", "cgi", ".", "Field", "Stor", "age", " ", "return", "s", " ", "Non", "e", " ", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dp", "k_", "=_", "dpo", "st_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "an", " ", "element", " ", "is", " ", "not", " ", "a", " ", "file", " ", "replace", " ", "it", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "its", " ", "value", " ", "else", " ", "lea", "ve", " ", "it", " ", "alo", "ne_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pvalue_", "=_", "listi", "fy_", "(_", "[_", "(_", "\\u", "dp", "k_", "if_", "\\u", "dp", "k_", "._", "filename_", "else_", "\\u", "dp", "k_", "._", "value_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u", "dp", "k_", "in_", "dp", "k_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "dp", "k_", ",_", "list_", ")_", "else_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "dp", "k_", "if_", "dp", "k_", "._", "filename_", "else_", "dp", "k_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "pvalue_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "post", "\\u", "vars_", "[_", "key_", "]_", "=_", "(_", "len_", "(_", "pvalue_", ")_", ">_", "1_", "and_", "pvalue_", ")_", "or_", "pvalue_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
scikit-learn/scikit-learn/sklearn/linear_model/tests/test_logistic.py
[ { "content": "def test_sparsify():\n # Test sparsify and densify members.\n n_samples, n_features = iris.data.shape\n target = iris.target_names[iris.target]\n clf = LogisticRegression(random_state=0).fit(iris.data, target)\n\n pred_d_d = clf.decision_function(iris.data)\n\n clf.sparsify()\n assert_true(sp.issparse(clf.coef_))\n pred_s_d = clf.decision_function(iris.data)\n\n sp_data = sp.coo_matrix(iris.data)\n pred_s_s = clf.decision_function(sp_data)\n\n clf.densify()\n pred_d_s = clf.decision_function(sp_data)\n\n assert_array_almost_equal(pred_d_d, pred_s_d)\n assert_array_almost_equal(pred_d_d, pred_s_s)\n assert_array_almost_equal(pred_d_d, pred_d_s)", "metadata": "root.test_sparsify", "header": "['module', '___EOS___']", "index": 182 } ]
[ { "span": "n_samples,", "start_line": 184, "start_column": 4, "end_line": 184, "end_column": 13 }, { "span": "n_features ", "start_line": 184, "start_column": 15, "end_line": 184, "end_column": 25 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "spars", "ify_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Test", " ", "spars", "if", "y", " ", "and", " ", "dens", "if", "y", " ", "member", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n", "\\u", "samples_", ",_", "n", "\\u", "features_", "=_", "iris_", "._", "data_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", "=_", "iris_", "._", "target", "\\u", "names_", "[_", "iris_", "._", "target_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clf_", "=_", "Logi", "stic", "Regression_", "(_", "random", "\\u", "state_", "=_", "0_", ")_", "._", "fit_", "(_", "iris_", "._", "data_", ",_", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pred", "\\u", "d\\u", "d_", "=_", "clf_", "._", "decision", "\\u", "function_", "(_", "iris_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "clf_", "._", "spars", "ify_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "true_", "(_", "sp_", "._", "iss", "parse_", "(_", "clf_", "._", "coef\\u", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pred", "\\u", "s", "\\u", "d_", "=_", "clf_", "._", "decision", "\\u", "function_", "(_", "iris_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sp", "\\u", "data_", "=_", "sp_", "._", "coo", "\\u", "matrix_", "(_", "iris_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pred", "\\u", "s", "\\u", "s_", "=_", "clf_", "._", "decision", "\\u", "function_", "(_", "sp", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "clf_", "._", "dens", "ify_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pred", "\\u", "d\\u", "s_", "=_", "clf_", "._", "decision", "\\u", "function_", "(_", "sp", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "array", "\\u", "alm", "ost", "\\u", "equal_", "(_", "pred", "\\u", "d\\u", "d_", ",_", "pred", "\\u", "s", "\\u", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "array", "\\u", "alm", "ost", "\\u", "equal_", "(_", "pred", "\\u", "d\\u", "d_", ",_", "pred", "\\u", "s", "\\u", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "array", "\\u", "alm", "ost", "\\u", "equal_", "(_", "pred", "\\u", "d\\u", "d_", ",_", "pred", "\\u", "d\\u", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
dimagi/commcare-hq/corehq/apps/hqmedia/utils.py
[ { "content": "from corehq.apps.app_manager.xform import XFormValidationError, XFormException\nfrom corehq.apps.domain.models import LICENSES\n\nMULTIMEDIA_PREFIX = \"jr://file/\"\nIMAGE_MIMETYPES = [\"image/jpeg\", \"image/gif\", \"image/png\"]\nAUDIO_MIMETYPES = [\"audio/mpeg\", \"audio/mpeg3\", \"audio/wav\", \"audio/x-wav\"]\nZIP_MIMETYPES = [\"application/zip\"]\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def most_restrictive(licenses):\n \"\"\"\n given a list of licenses, this function returns the list of licenses that are as restrictive or more restrictive\n than each of the input licenses\n '<' == less restrictive\n cc < cc-nd, cc-nc, cc-sa\n cc-nd < cc-nc-nd\n cc-nc < cc-nc-sa\n cc-sa < cc-nd, cc-nc-sa\n cc-nc-sa < cc-nc-nd\n \"\"\"\n licenses = set(licenses)\n for license in licenses:\n if license not in LICENSES:\n raise Exception(\"Not a valid license type\")\n\n if 'cc-nc-nd' in licenses:\n return ['cc-nc-nd']\n if 'cc-nd' in licenses:\n if 'cc-nc-sa' in licenses or 'cc-nc' in licenses:\n return ['cc-nc-nd']\n else:\n return ['cc-nc-nd', 'cc-nd']\n if 'cc-nc-sa' in licenses or ('cc-sa' in licenses and 'cc-nc' in licenses):\n return ['cc-nc-nd', 'cc-nc-sa']\n if 'cc-nc' in licenses:\n return ['cc-nc-nd', 'cc-nc-sa', 'cc-nc']\n if 'cc-sa' in licenses:\n return ['cc-nc-nd', 'cc-nc-sa', 'cc-nd', 'cc-sa']\n if 'cc' in licenses:\n return ['cc-nc-nd', 'cc-nc-sa', 'cc-nd', 'cc-nc', 'cc-sa', 'cc']\n return ['cc-nc-nd', 'cc-nc-sa', 'cc-nd', 'cc-nc', 'cc-sa', 'cc']", "metadata": "root.most_restrictive", "header": "['module', '___EOS___']", "index": 9 } ]
[ { "span": "from corehq.apps.app_manager.xform import XFormValidationError, XFormException", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 78 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "app", "\\u", "manager_", "._", "xform_", "import_", "XF", "orm", "Validat", "ion", "Error_", ",_", "XF", "orm", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core", "hq", "_", "._", "apps_", "._", "domain_", "._", "models_", "import_", "LICENSE", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MULTI", "MEDIA", "\\u", "PREFIX_", "=_", "\"", "jr", "://", "file", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "IMA", "GE", "\\u", "MIME", "TYPES_", "=_", "[_", "\"", "image", "/", "jpeg", "\"_", ",_", "\"", "image", "/", "gif", "\"_", ",_", "\"", "image", "/", "png", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "AUDIO", "\\u", "MIME", "TYPES_", "=_", "[_", "\"", "audio", "/", "mpeg", "\"_", ",_", "\"", "audio", "/", "mpeg", "3", "\"_", ",_", "\"", "audio", "/", "wav", "\"_", ",_", "\"", "audio", "/", "x", "-", "wav", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ZI", "P", "\\u", "MIME", "TYPES_", "=_", "[_", "\"", "applica", "tion", "/", "zip", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "most", "\\u", "restrict", "ive_", "(_", "license", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "a", " ", "list", " ", "of", " ", "license", "s", ",", " ", "this", " ", "function", " ", "return", "s", " ", "the", " ", "list", " ", "of", " ", "license", "s", " ", "tha", "t", " ", "are", " ", "as", " ", "restrict", "ive", " ", "or", " ", "more", " ", "restrict", "ive", "\\", "10", ";", " ", " ", " ", " ", "than", " ", "each", " ", "of", " ", "the", " ", "input", " ", "license", "s", "\\", "10", ";", " ", " ", " ", " ", "'<", "'", " ", "==", " ", "less", " ", "restrict", "ive", "\\", "10", ";", " ", " ", " ", " ", "cc", " ", "<", " ", "cc", "-", "nd", ",", " ", "cc", "-", "nc", ",", " ", "cc", "-", "sa", "\\", "10", ";", " ", " ", " ", " ", "cc", "-", "nd", " ", "<", " ", "cc", "-", "nc", "-", "nd", "\\", "10", ";", " ", " ", " ", " ", "cc", "-", "nc", " ", "<", " ", "cc", "-", "nc", "-", "sa", "\\", "10", ";", " ", " ", " ", " ", "cc", "-", "sa", " ", "<", " ", "cc", "-", "nd", ",", " ", "cc", "-", "nc", "-", "sa", "\\", "10", ";", " ", " ", " ", " ", "cc", "-", "nc", "-", "sa", " ", "<", " ", "cc", "-", "nc", "-", "nd", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "license", "s_", "=_", "set_", "(_", "license", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "license_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "license_", "not_", "in_", "LICENSE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "Not", " ", "a", " ", "valid", " ", "license", " ", "type", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "-", "nc", "-", "nd", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "-", "nd", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "cc", "-", "nc", "-", "sa", "'_", "in_", "license", "s_", "or_", "'", "cc", "-", "nc", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "-", "nc", "-", "sa", "'_", "in_", "license", "s_", "or_", "(_", "'", "cc", "-", "sa", "'_", "in_", "license", "s_", "and_", "'", "cc", "-", "nc", "'_", "in_", "license", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "-", "sa", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "-", "nc", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "-", "sa", "'_", ",_", "'", "cc", "-", "nc", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "-", "sa", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "-", "sa", "'_", ",_", "'", "cc", "-", "nd", "'_", ",_", "'", "cc", "-", "sa", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "cc", "'_", "in_", "license", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "-", "sa", "'_", ",_", "'", "cc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "'_", ",_", "'", "cc", "-", "sa", "'_", ",_", "'", "cc", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "'", "cc", "-", "nc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "-", "sa", "'_", ",_", "'", "cc", "-", "nd", "'_", ",_", "'", "cc", "-", "nc", "'_", ",_", "'", "cc", "-", "sa", "'_", ",_", "'", "cc", "'_", "]_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
nii-cloud/dodai-compute/nova/tests/test_compute.py
[ { "content": " def test_run_instance_usage_notification(self):\n \"\"\"Ensure run instance generates apropriate usage notification\"\"\"\n instance_id = self._create_instance()\n self.compute.run_instance(self.context, instance_id)\n self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)\n msg = test_notifier.NOTIFICATIONS[0]\n self.assertEquals(msg['priority'], 'INFO')\n self.assertEquals(msg['event_type'], 'compute.instance.create')\n payload = msg['payload']\n self.assertEquals(payload['project_id'], self.project_id)\n self.assertEquals(payload['user_id'], self.user_id)\n self.assertEquals(payload['instance_id'], instance_id)\n self.assertEquals(payload['instance_type'], 'm1.tiny')\n type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']\n self.assertEquals(str(payload['instance_type_id']), str(type_id))\n self.assertTrue('display_name' in payload)\n self.assertTrue('created_at' in payload)\n self.assertTrue('launched_at' in payload)\n self.assertEquals(payload['image_ref'], '1')\n self.compute.terminate_instance(self.context, instance_id)", "metadata": "root.ComputeTestCase.test_run_instance_usage_notification", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 415 }, { "content": " def test_terminate_usage_notification(self):\n \"\"\"Ensure terminate_instance generates apropriate usage notification\"\"\"\n instance_id = self._create_instance()\n self.compute.run_instance(self.context, instance_id)\n test_notifier.NOTIFICATIONS = []\n self.compute.terminate_instance(self.context, instance_id)\n\n self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)\n msg = test_notifier.NOTIFICATIONS[0]\n self.assertEquals(msg['priority'], 'INFO')\n self.assertEquals(msg['event_type'], 'compute.instance.delete')\n payload = msg['payload']\n self.assertEquals(payload['project_id'], self.project_id)\n self.assertEquals(payload['user_id'], self.user_id)\n self.assertEquals(payload['instance_id'], instance_id)\n self.assertEquals(payload['instance_type'], 'm1.tiny')\n type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']\n self.assertEquals(str(payload['instance_type_id']), str(type_id))\n self.assertTrue('display_name' in payload)\n self.assertTrue('created_at' in payload)\n self.assertTrue('launched_at' in payload)\n self.assertEquals(payload['image_ref'], '1')", "metadata": "root.ComputeTestCase.test_terminate_usage_notification", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 436 }, { "content": " def test_resize_instance_notification(self):\n \"\"\"Ensure notifications on instance migrate/resize\"\"\"\n instance_id = self._create_instance()\n context = self.context.elevated()\n inst_ref = db.instance_get(context, instance_id)\n\n self.compute.run_instance(self.context, instance_id)\n test_notifier.NOTIFICATIONS = []\n\n db.instance_update(self.context, instance_id, {'host': 'foo'})\n self.compute.prep_resize(context, inst_ref['uuid'], 1)\n migration_ref = db.migration_get_by_instance_and_status(context,\n inst_ref['uuid'], 'pre-migrating')\n\n self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)\n msg = test_notifier.NOTIFICATIONS[0]\n self.assertEquals(msg['priority'], 'INFO')\n self.assertEquals(msg['event_type'], 'compute.instance.resize.prep')\n payload = msg['payload']\n self.assertEquals(payload['project_id'], self.project_id)\n self.assertEquals(payload['user_id'], self.user_id)\n self.assertEquals(payload['instance_id'], instance_id)\n self.assertEquals(payload['instance_type'], 'm1.tiny')\n type_id = instance_types.get_instance_type_by_name('m1.tiny')['id']\n self.assertEquals(str(payload['instance_type_id']), str(type_id))\n self.assertTrue('display_name' in payload)\n self.assertTrue('created_at' in payload)\n self.assertTrue('launched_at' in payload)\n self.assertEquals(payload['image_ref'], '1')\n self.compute.terminate_instance(context, instance_id)", "metadata": "root.ComputeTestCase.test_resize_instance_notification", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 512 }, { "content": " def test_get_all_by_name_regexp(self):\n \"\"\"Test searching instances by name (display_name)\"\"\"\n c = context.get_admin_context()\n instance_id1 = self._create_instance({'display_name': 'woot'})\n instance_id2 = self._create_instance({\n 'display_name': 'woo',\n 'id': 20})\n instance_id3 = self._create_instance({\n 'display_name': 'not-woot',\n 'id': 30})\n\n instances = self.compute_api.get_all(c,\n search_opts={'name': 'woo.*'})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id1 in instance_ids)\n self.assertTrue(instance_id2 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'name': 'woot.*'})\n instance_ids = [instance.id for instance in instances]\n self.assertEqual(len(instances), 1)\n self.assertTrue(instance_id1 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'name': '.*oot.*'})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id1 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'name': 'n.*'})\n self.assertEqual(len(instances), 1)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id3 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'name': 'noth.*'})\n self.assertEqual(len(instances), 0)\n\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_name_regexp", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 966 }, { "content": " def test_get_all_by_instance_name_regexp(self):\n \"\"\"Test searching instances by name\"\"\"\n self.flags(instance_name_template='instance-%d')\n\n c = context.get_admin_context()\n instance_id1 = self._create_instance()\n instance_id2 = self._create_instance({'id': 2})\n instance_id3 = self._create_instance({'id': 10})\n\n instances = self.compute_api.get_all(c,\n search_opts={'instance_name': 'instance.*'})\n self.assertEqual(len(instances), 3)\n\n instances = self.compute_api.get_all(c,\n search_opts={'instance_name': '.*\\-\\d$'})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id1 in instance_ids)\n self.assertTrue(instance_id2 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'instance_name': 'i.*2'})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id2)\n\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_instance_name_regexp", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1011 }, { "content": " def test_get_all_by_ip_regexp(self):\n \"\"\"Test searching by Floating and Fixed IP\"\"\"\n c = context.get_admin_context()\n instance_id1 = self._create_instance({'display_name': 'woot'})\n instance_id2 = self._create_instance({\n 'display_name': 'woo',\n 'id': 20})\n instance_id3 = self._create_instance({\n 'display_name': 'not-woot',\n 'id': 30})\n\n vif_ref1 = db.virtual_interface_create(c,\n {'address': '12:34:56:78:90:12',\n 'instance_id': instance_id1,\n 'network_id': 1})\n vif_ref2 = db.virtual_interface_create(c,\n {'address': '90:12:34:56:78:90',\n 'instance_id': instance_id2,\n 'network_id': 1})\n vif_ref3 = db.virtual_interface_create(c,\n {'address': '34:56:78:90:12:34',\n 'instance_id': instance_id3,\n 'network_id': 1})\n\n db.fixed_ip_create(c,\n {'address': '1.1.1.1',\n 'instance_id': instance_id1,\n 'virtual_interface_id': vif_ref1['id']})\n db.fixed_ip_create(c,\n {'address': '1.1.2.1',\n 'instance_id': instance_id2,\n 'virtual_interface_id': vif_ref2['id']})\n fix_addr = db.fixed_ip_create(c,\n {'address': '1.1.3.1',\n 'instance_id': instance_id3,\n 'virtual_interface_id': vif_ref3['id']})\n fix_ref = db.fixed_ip_get_by_address(c, fix_addr)\n flo_ref = db.floating_ip_create(c,\n {'address': '10.0.0.2',\n 'fixed_ip_id': fix_ref['id']})\n\n # ends up matching 2nd octet here.. so all 3 match\n instances = self.compute_api.get_all(c,\n search_opts={'ip': '.*\\.1'})\n self.assertEqual(len(instances), 3)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip': '1.*'})\n self.assertEqual(len(instances), 3)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip': '.*\\.1.\\d+$'})\n self.assertEqual(len(instances), 1)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id1 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip': '.*\\.2.+'})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id2)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip': '10.*'})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id3)\n\n db.virtual_interface_delete(c, vif_ref1['id'])\n db.virtual_interface_delete(c, vif_ref2['id'])\n db.virtual_interface_delete(c, vif_ref3['id'])\n db.floating_ip_destroy(c, '10.0.0.2')\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_ip_regexp", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1089 }, { "content": " def test_get_all_by_ipv6_regexp(self):\n \"\"\"Test searching by IPv6 address\"\"\"\n\n c = context.get_admin_context()\n instance_id1 = self._create_instance({'display_name': 'woot'})\n instance_id2 = self._create_instance({\n 'display_name': 'woo',\n 'id': 20})\n instance_id3 = self._create_instance({\n 'display_name': 'not-woot',\n 'id': 30})\n\n vif_ref1 = db.virtual_interface_create(c,\n {'address': '12:34:56:78:90:12',\n 'instance_id': instance_id1,\n 'network_id': 1})\n vif_ref2 = db.virtual_interface_create(c,\n {'address': '90:12:34:56:78:90',\n 'instance_id': instance_id2,\n 'network_id': 1})\n vif_ref3 = db.virtual_interface_create(c,\n {'address': '34:56:78:90:12:34',\n 'instance_id': instance_id3,\n 'network_id': 1})\n\n # This will create IPv6 addresses of:\n # 1: fd00::1034:56ff:fe78:9012\n # 20: fd00::9212:34ff:fe56:7890\n # 30: fd00::3656:78ff:fe90:1234\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip6': '.*1034.*'})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id1)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip6': '^fd00.*'})\n self.assertEqual(len(instances), 3)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id1 in instance_ids)\n self.assertTrue(instance_id2 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n instances = self.compute_api.get_all(c,\n search_opts={'ip6': '^.*12.*34.*'})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id2 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n db.virtual_interface_delete(c, vif_ref1['id'])\n db.virtual_interface_delete(c, vif_ref2['id'])\n db.virtual_interface_delete(c, vif_ref3['id'])\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_ipv6_regexp", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1163 }, { "content": " def test_get_all_by_image(self):\n \"\"\"Test searching instances by image\"\"\"\n\n c = context.get_admin_context()\n instance_id1 = self._create_instance({'image_ref': '1234'})\n instance_id2 = self._create_instance({\n 'id': 2,\n 'image_ref': '4567'})\n instance_id3 = self._create_instance({\n 'id': 10,\n 'image_ref': '4567'})\n\n instances = self.compute_api.get_all(c,\n search_opts={'image': '123'})\n self.assertEqual(len(instances), 0)\n\n instances = self.compute_api.get_all(c,\n search_opts={'image': '1234'})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id1)\n\n instances = self.compute_api.get_all(c,\n search_opts={'image': '4567'})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id2 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n # Test passing a list as search arg\n instances = self.compute_api.get_all(c,\n search_opts={'image': ['1234', '4567']})\n self.assertEqual(len(instances), 3)\n\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_image", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1298 }, { "content": " def test_get_all_by_flavor(self):\n \"\"\"Test searching instances by image\"\"\"\n\n c = context.get_admin_context()\n instance_id1 = self._create_instance({'instance_type_id': 1})\n instance_id2 = self._create_instance({\n 'id': 2,\n 'instance_type_id': 2})\n instance_id3 = self._create_instance({\n 'id': 10,\n 'instance_type_id': 2})\n\n # NOTE(comstud): Migrations set up the instance_types table\n # for us. Therefore, we assume the following is true for\n # these tests:\n # instance_type_id 1 == flavor 3\n # instance_type_id 2 == flavor 1\n # instance_type_id 3 == flavor 4\n # instance_type_id 4 == flavor 5\n # instance_type_id 5 == flavor 2\n\n instances = self.compute_api.get_all(c,\n search_opts={'flavor': 5})\n self.assertEqual(len(instances), 0)\n\n self.assertRaises(exception.FlavorNotFound,\n self.compute_api.get_all,\n c, search_opts={'flavor': 99})\n\n instances = self.compute_api.get_all(c,\n search_opts={'flavor': 3})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id1)\n\n instances = self.compute_api.get_all(c,\n search_opts={'flavor': 1})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id2 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_flavor", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1335 }, { "content": " def test_get_all_by_state(self):\n \"\"\"Test searching instances by state\"\"\"\n\n c = context.get_admin_context()\n instance_id1 = self._create_instance({\n 'power_state': power_state.SHUTDOWN,\n })\n instance_id2 = self._create_instance({\n 'id': 2,\n 'power_state': power_state.RUNNING,\n })\n instance_id3 = self._create_instance({\n 'id': 10,\n 'power_state': power_state.RUNNING,\n })\n instances = self.compute_api.get_all(c,\n search_opts={'power_state': power_state.SUSPENDED})\n self.assertEqual(len(instances), 0)\n\n instances = self.compute_api.get_all(c,\n search_opts={'power_state': power_state.SHUTDOWN})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id1)\n\n instances = self.compute_api.get_all(c,\n search_opts={'power_state': power_state.RUNNING})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id2 in instance_ids)\n self.assertTrue(instance_id3 in instance_ids)\n\n # Test passing a list as search arg\n instances = self.compute_api.get_all(c,\n search_opts={'power_state': [power_state.SHUTDOWN,\n power_state.RUNNING]})\n self.assertEqual(len(instances), 3)\n\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)", "metadata": "root.ComputeTestCase.test_get_all_by_state", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1380 }, { "content": " def test_get_all_by_metadata(self):\n \"\"\"Test searching instances by metadata\"\"\"\n\n c = context.get_admin_context()\n instance_id0 = self._create_instance()\n instance_id1 = self._create_instance({\n 'metadata': {'key1': 'value1'}})\n instance_id2 = self._create_instance({\n 'metadata': {'key2': 'value2'}})\n instance_id3 = self._create_instance({\n 'metadata': {'key3': 'value3'}})\n instance_id4 = self._create_instance({\n 'metadata': {'key3': 'value3',\n 'key4': 'value4'}})\n\n # get all instances\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {}})\n self.assertEqual(len(instances), 5)\n\n # wrong key/value combination\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {'key1': 'value3'}})\n self.assertEqual(len(instances), 0)\n\n # non-existing keys\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {'key5': 'value1'}})\n self.assertEqual(len(instances), 0)\n\n # find existing instance\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {'key2': 'value2'}})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id2)\n\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {'key3': 'value3'}})\n self.assertEqual(len(instances), 2)\n instance_ids = [instance.id for instance in instances]\n self.assertTrue(instance_id3 in instance_ids)\n self.assertTrue(instance_id4 in instance_ids)\n\n # multiple criterias as a dict\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': {'key3': 'value3',\n 'key4': 'value4'}})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id4)\n\n # multiple criterias as a list\n instances = self.compute_api.get_all(c,\n search_opts={'metadata': [{'key4': 'value4'},\n {'key3': 'value3'}]})\n self.assertEqual(len(instances), 1)\n self.assertEqual(instances[0].id, instance_id4)\n\n db.instance_destroy(c, instance_id0)\n db.instance_destroy(c, instance_id1)\n db.instance_destroy(c, instance_id2)\n db.instance_destroy(c, instance_id3)\n db.instance_destroy(c, instance_id4)", "metadata": "root.ComputeTestCase.test_get_all_by_metadata", "header": "['class', 'ComputeTestCase', '(', 'test', '.', 'TestCase', ')', ':', '___EOS___']", "index": 1421 } ]
[ { "span": "self.assertTrue('display_name' in payload)", "start_line": 430, "start_column": 8, "end_line": 430, "end_column": 50 }, { "span": "self.assertTrue('created_at' in payload)", "start_line": 431, "start_column": 8, "end_line": 431, "end_column": 48 }, { "span": "self.assertTrue('launched_at' in payload)", "start_line": 432, "start_column": 8, "end_line": 432, "end_column": 49 }, { "span": "self.assertTrue('display_name' in payload)", "start_line": 454, "start_column": 8, "end_line": 454, "end_column": 50 }, { "span": "self.assertTrue('created_at' in payload)", "start_line": 455, "start_column": 8, "end_line": 455, "end_column": 48 }, { "span": "self.assertTrue('launched_at' in payload)", "start_line": 456, "start_column": 8, "end_line": 456, "end_column": 49 }, { "span": "self.assertTrue('display_name' in payload)", "start_line": 537, "start_column": 8, "end_line": 537, "end_column": 50 }, { "span": "self.assertTrue('created_at' in payload)", "start_line": 538, "start_column": 8, "end_line": 538, "end_column": 48 }, { "span": "self.assertTrue('launched_at' in payload)", "start_line": 539, "start_column": 8, "end_line": 539, "end_column": 49 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 981, "start_column": 8, "end_line": 981, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 982, "start_column": 8, "end_line": 982, "end_column": 53 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 988, "start_column": 8, "end_line": 988, "end_column": 53 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 994, "start_column": 8, "end_line": 994, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 995, "start_column": 8, "end_line": 995, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1001, "start_column": 8, "end_line": 1001, "end_column": 53 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 1028, "start_column": 8, "end_line": 1028, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1029, "start_column": 8, "end_line": 1029, "end_column": 53 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 1143, "start_column": 8, "end_line": 1143, "end_column": 53 }, { "span": "self.assertTrue(instance_id1 in instance_ids)", "start_line": 1202, "start_column": 8, "end_line": 1202, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1203, "start_column": 8, "end_line": 1203, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1204, "start_column": 8, "end_line": 1204, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1210, "start_column": 8, "end_line": 1210, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1211, "start_column": 8, "end_line": 1211, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1323, "start_column": 8, "end_line": 1323, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1324, "start_column": 8, "end_line": 1324, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1373, "start_column": 8, "end_line": 1373, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1374, "start_column": 8, "end_line": 1374, "end_column": 53 }, { "span": "self.assertTrue(instance_id2 in instance_ids)", "start_line": 1408, "start_column": 8, "end_line": 1408, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1409, "start_column": 8, "end_line": 1409, "end_column": 53 }, { "span": "self.assertTrue(instance_id3 in instance_ids)", "start_line": 1461, "start_column": 8, "end_line": 1461, "end_column": 53 }, { "span": "self.assertTrue(instance_id4 in instance_ids)", "start_line": 1462, "start_column": 8, "end_line": 1462, "end_column": 53 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "run", "\\u", "instance", "\\u", "usage", "\\u", "notification_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ensur", "e", " ", "run", " ", "instance", " ", "generat", "es", " ", "apro", "pri", "ate", " ", "usage", " ", "notification", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "run", "\\u", "instance_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "len_", "(_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "priorit", "y", "'_", "]_", ",_", "'", "INFO", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "event", "\\u", "type", "'_", "]_", ",_", "'", "compute", ".", "instance", ".", "create", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "msg_", "[_", "'", "payload", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "project", "\\u", "id", "'_", "]_", ",_", "self_", "._", "project", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "user", "\\u", "id", "'_", "]_", ",_", "self_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "id", "'_", "]_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "'_", "]_", ",_", "'", "m1", ".", "tiny", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type", "\\u", "id_", "=_", "instance", "\\u", "types_", "._", "get", "\\u", "instance", "\\u", "type", "\\u", "by", "\\u", "name_", "(_", "'", "m1", ".", "tiny", "'_", ")_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "str_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "\\u", "id", "'_", "]_", ")_", ",_", "str_", "(_", "type", "\\u", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "display", "\\u", "name", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "created", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "launched", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "image", "\\u", "ref", "'_", "]_", ",_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "terminate", "\\u", "instance_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "terminate", "\\u", "usage", "\\u", "notification_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ensur", "e", " ", "terminate", "\\u", "instance", " ", "generat", "es", " ", "apro", "pri", "ate", " ", "usage", " ", "notification", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "run", "\\u", "instance_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "terminate", "\\u", "instance_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "len_", "(_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "priorit", "y", "'_", "]_", ",_", "'", "INFO", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "event", "\\u", "type", "'_", "]_", ",_", "'", "compute", ".", "instance", ".", "delete", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "msg_", "[_", "'", "payload", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "project", "\\u", "id", "'_", "]_", ",_", "self_", "._", "project", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "user", "\\u", "id", "'_", "]_", ",_", "self_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "id", "'_", "]_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "'_", "]_", ",_", "'", "m1", ".", "tiny", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type", "\\u", "id_", "=_", "instance", "\\u", "types_", "._", "get", "\\u", "instance", "\\u", "type", "\\u", "by", "\\u", "name_", "(_", "'", "m1", ".", "tiny", "'_", ")_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "str_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "\\u", "id", "'_", "]_", ")_", ",_", "str_", "(_", "type", "\\u", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "display", "\\u", "name", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "created", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "launched", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "image", "\\u", "ref", "'_", "]_", ",_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "resiz", "e\\u", "instance", "\\u", "notification_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ensur", "e", " ", "notification", "s", " ", "on", " ", "instance", " ", "migr", "ate", "/", "resiz", "e", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "=_", "self_", "._", "context_", "._", "elevat", "ed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst", "\\u", "ref_", "=_", "db_", "._", "instance", "\\u", "get_", "(_", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "compute_", "._", "run", "\\u", "instance_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "update_", "(_", "self_", "._", "context_", ",_", "instance", "\\u", "id_", ",_", "{_", "'", "host", "'_", ":_", "'", "foo", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "prep", "\\u", "resize_", "(_", "context_", ",_", "inst", "\\u", "ref_", "[_", "'", "uuid", "'_", "]_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "migrati", "on", "\\u", "ref_", "=_", "db_", "._", "migrati", "on", "\\u", "get", "\\u", "by", "\\u", "instance", "\\u", "and", "\\u", "status_", "(_", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "inst", "\\u", "ref_", "[_", "'", "uuid", "'_", "]_", ",_", "'", "pre", "-", "migrati", "ng", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "len_", "(_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "test\\u", "notifier_", "._", "NOTIFICATION", "S_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "priorit", "y", "'_", "]_", ",_", "'", "INFO", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "msg_", "[_", "'", "event", "\\u", "type", "'_", "]_", ",_", "'", "compute", ".", "instance", ".", "resiz", "e", ".", "prep", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "msg_", "[_", "'", "payload", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "project", "\\u", "id", "'_", "]_", ",_", "self_", "._", "project", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "user", "\\u", "id", "'_", "]_", ",_", "self_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "id", "'_", "]_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "'_", "]_", ",_", "'", "m1", ".", "tiny", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type", "\\u", "id_", "=_", "instance", "\\u", "types_", "._", "get", "\\u", "instance", "\\u", "type", "\\u", "by", "\\u", "name_", "(_", "'", "m1", ".", "tiny", "'_", ")_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "str_", "(_", "payload_", "[_", "'", "instance", "\\u", "type", "\\u", "id", "'_", "]_", ")_", ",_", "str_", "(_", "type", "\\u", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "display", "\\u", "name", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "created", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "launched", "\\u", "at", "'_", "in_", "payload_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "payload_", "[_", "'", "image", "\\u", "ref", "'_", "]_", ",_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "compute_", "._", "terminate", "\\u", "instance_", "(_", "context_", ",_", "instance", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "name", "\\u", "regexp_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "name", " ", "(", "display", "\\u", "name", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "t", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "20_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "not", "-", "woo", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "30_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "name", "'_", ":_", "'", "woo", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "name", "'_", ":_", "'", "woo", "t", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "name", "'_", ":_", "'.*", "oot", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "name", "'_", ":_", "'", "n", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "name", "'_", ":_", "'", "not", "h", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "instance", "\\u", "name", "\\u", "regexp_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "name", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "flags_", "(_", "instance", "\\u", "name", "\\u", "template_", "=_", "'", "instance", "-%", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "id", "'_", ":_", "2_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "id", "'_", ":_", "10_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "instance", "\\u", "name", "'_", ":_", "'", "instance", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "instance", "\\u", "name", "'_", ":_", "'.*", "\\\\-\\", "\\", "d", "$'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "instance", "\\u", "name", "'_", ":_", "'", "i", ".*", "2", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "ip", "\\u", "regexp_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "by", " ", "Float", "ing", " ", "and", " ", "Fix", "ed", " ", "IP", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "t", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "20_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "not", "-", "woo", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "30_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vi", "f", "\\u", "ref", "1_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "1", "2", ":", "3", "4", ":", "56", ":", "7", "8", ":", "90", ":", "1", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi", "f", "\\u", "ref", "2_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "90", ":", "1", "2", ":", "3", "4", ":", "56", ":", "7", "8", ":", "90", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi", "f", "\\u", "ref", "3_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "3", "4", ":", "56", ":", "7", "8", ":", "90", ":", "1", "2", ":", "3", "4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "fixed", "\\u", "ip", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "1.1", ".1", ".1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "virtual", "\\u", "interface", "\\u", "id", "'_", ":_", "vi", "f", "\\u", "ref", "1_", "[_", "'", "id", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "fixed", "\\u", "ip", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "1.1", ".2", ".1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "virtual", "\\u", "interface", "\\u", "id", "'_", ":_", "vi", "f", "\\u", "ref", "2_", "[_", "'", "id", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fix", "\\u", "addr_", "=_", "db_", "._", "fixed", "\\u", "ip", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "1.1", ".3", ".1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "virtual", "\\u", "interface", "\\u", "id", "'_", ":_", "vi", "f", "\\u", "ref", "3_", "[_", "'", "id", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fix", "\\u", "ref_", "=_", "db_", "._", "fixed", "\\u", "ip", "\\u", "get", "\\u", "by", "\\u", "address_", "(_", "c_", ",_", "fix", "\\u", "addr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flo", "\\u", "ref_", "=_", "db_", "._", "float", "ing", "\\u", "ip", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "10.", "0.", "0.", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fixed", "\\u", "ip", "\\u", "id", "'_", ":_", "fix", "\\u", "ref_", "[_", "'", "id", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ends", " ", "up", " ", "matchi", "ng", " ", "2n", "d", " ", "oct", "et", " ", "here", "..", " ", "so", " ", "all", " ", "3", " ", "match_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip", "'_", ":_", "'.*", "\\\\.", "1", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip", "'_", ":_", "'", "1", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip", "'_", ":_", "'.*", "\\\\.", "1", ".\\\\", "d", "+$", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip", "'_", ":_", "'.*", "\\\\.", "2", ".+", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip", "'_", ":_", "'", "10.", "*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "1_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "2_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "3_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "float", "ing", "\\u", "ip", "\\u", "destroy_", "(_", "c_", ",_", "'", "10.", "0.", "0.", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "ipv", "6", "\\u", "regexp_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "by", " ", "IP", "v6", " ", "address", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "t", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "woo", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "20_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "display", "\\u", "name", "'_", ":_", "'", "not", "-", "woo", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "30_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vi", "f", "\\u", "ref", "1_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "1", "2", ":", "3", "4", ":", "56", ":", "7", "8", ":", "90", ":", "1", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi", "f", "\\u", "ref", "2_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "90", ":", "1", "2", ":", "3", "4", ":", "56", ":", "7", "8", ":", "90", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vi", "f", "\\u", "ref", "3_", "=_", "db_", "._", "virtual", "\\u", "interface", "\\u", "create_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "address", "'_", ":_", "'", "3", "4", ":", "56", ":", "7", "8", ":", "90", ":", "1", "2", ":", "3", "4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "id", "'_", ":_", "instance", "\\u", "id3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "network", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "create", " ", "IP", "v6", " ", "addresse", "s", " ", "of", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ":", " ", "fd", "00", "::", "103", "4", ":", "56", "ff", ":", "fe", "7", "8", ":", "901", "2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "20", ":", " ", "fd", "00", "::", "921", "2", ":", "3", "4f", "f", ":", "fe", "56", ":", "7890", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "30", ":", " ", "fd", "00", "::", "365", "6", ":", "7", "8f", "f", ":", "fe", "90", ":", "1234_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip6", "'_", ":_", "'.*", "103", "4", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip6", "'_", ":_", "'", "^", "fd", "00", ".*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id1_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "ip6", "'_", ":_", "'", "^", ".*", "12.", "*", "34.", "*'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "1_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "2_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "virtual", "\\u", "interface", "\\u", "delete_", "(_", "c_", ",_", "vi", "f", "\\u", "ref", "3_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "image_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "image", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "image", "\\u", "ref", "'_", ":_", "'", "1234", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "image", "\\u", "ref", "'_", ":_", "'", "4567", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "image", "\\u", "ref", "'_", ":_", "'", "4567", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "image", "'_", ":_", "'", "123", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "image", "'_", ":_", "'", "1234", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "image", "'_", ":_", "'", "4567", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "passi", "ng", " ", "a", " ", "list", " ", "as", " ", "search", " ", "arg_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "image", "'_", ":_", "[_", "'", "1234", "'_", ",_", "'", "4567", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "flavor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "image", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "'", "instance", "\\u", "type", "\\u", "id", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "type", "\\u", "id", "'_", ":_", "2_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "instance", "\\u", "type", "\\u", "id", "'_", ":_", "2_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", "(", "com", "stud", "):", " ", "Migrat", "ion", "s", " ", "set", " ", "up", " ", "the", " ", "instance", "\\u", "types", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "us", ".", " ", " ", "There", "fore", ",", " ", "we", " ", "assume", " ", "the", " ", "follow", "ing", " ", "is", " ", "true", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "these", " ", "tests", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "instance", "\\u", "type", "\\u", "id", " ", "1", " ", "==", " ", "flavor", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "instance", "\\u", "type", "\\u", "id", " ", "2", " ", "==", " ", "flavor", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "instance", "\\u", "type", "\\u", "id", " ", "3", " ", "==", " ", "flavor", " ", "4_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "instance", "\\u", "type", "\\u", "id", " ", "4", " ", "==", " ", "flavor", " ", "5_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "instance", "\\u", "type", "\\u", "id", " ", "5", " ", "==", " ", "flavor", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "flavor", "'_", ":_", "5_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "exception_", "._", "Fla", "vor", "Not", "Found_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "c_", ",_", "search", "\\u", "opts_", "=_", "{_", "'", "flavor", "'_", ":_", "99_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "flavor", "'_", ":_", "3_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "flavor", "'_", ":_", "1_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "state_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "state", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "SHUTDOWN", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "RUNNING_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "RUNNING_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "SUS", "PEND", "ED_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "SHUTDOWN", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "power", "\\u", "state", "'_", ":_", "power", "\\u", "state_", "._", "RUNNING_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id2_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "passi", "ng", " ", "a", " ", "list", " ", "as", " ", "search", " ", "arg_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "power", "\\u", "state", "'_", ":_", "[_", "power", "\\u", "state_", "._", "SHUTDOWN", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "power", "\\u", "state_", "._", "RUNNING_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Compute", "Test", "Case_", "(_", "test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "all", "\\u", "by", "\\u", "metadata_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Test", " ", "search", "ing", " ", "instance", "s", " ", "by", " ", "metadata", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "context_", "._", "get", "\\u", "admin", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id", "0_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id1_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "metadata", "'_", ":_", "{_", "'", "key", "1", "'_", ":_", "'", "value", "1", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id2_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "metadata", "'_", ":_", "{_", "'", "key", "2", "'_", ":_", "'", "value", "2", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id3_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "metadata", "'_", ":_", "{_", "'", "key", "3", "'_", ":_", "'", "value", "3", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "id", "4_", "=_", "self_", "._", "\\u", "create", "\\u", "instance_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "metadata", "'_", ":_", "{_", "'", "key", "3", "'_", ":_", "'", "value", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "4", "'_", ":_", "'", "value", "4", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "all", " ", "instances_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wrong", " ", "key", "/", "value", " ", "combination_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "'", "key", "1", "'_", ":_", "'", "value", "3", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "non", "-", "exist", "ing", " ", "keys_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "'", "key", "5", "'_", ":_", "'", "value", "1", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "find", " ", "exist", "ing", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "'", "key", "2", "'_", ":_", "'", "value", "2", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "'", "key", "3", "'_", ":_", "'", "value", "3", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance", "\\u", "ids_", "=_", "[_", "instance_", "._", "id_", "for_", "instance_", "in_", "instances_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id3_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "instance", "\\u", "id", "4_", "in_", "instance", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "multiple", " ", "crite", "ria", "s", " ", "as", " ", "a", " ", "dict_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "{_", "'", "key", "3", "'_", ":_", "'", "value", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "4", "'_", ":_", "'", "value", "4", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "multiple", " ", "crite", "ria", "s", " ", "as", " ", "a", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "instances_", "=_", "self_", "._", "compute", "\\u", "api_", "._", "get", "\\u", "all_", "(_", "c_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "search", "\\u", "opts_", "=_", "{_", "'", "metadata", "'_", ":_", "[_", "{_", "'", "key", "4", "'_", ":_", "'", "value", "4", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "3", "'_", ":_", "'", "value", "3", "'_", "}_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "instances_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "instances_", "[_", "0_", "]_", "._", "id_", ",_", "instance", "\\u", "id", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\\u", "destroy_", "(_", "c_", ",_", "instance", "\\u", "id2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "instance", "\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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
hyperion-rt/hyperion/hyperion/conftest.py
[ { "content": "import os\nfrom astropy.tests.helper import pytest\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def pytest_addoption(parser):\n parser.addoption('--generate-reference', help=\"generate reference results for bit-level tests\", type=\"string\")\n parser.addoption('--enable-bit-level-tests', help=\"enable bit-level tests\", action=\"store_true\")", "metadata": "root.pytest_addoption", "header": "['module', '___EOS___']", "index": 4 } ]
[ { "span": "import os", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 }, { "span": "from astropy.tests.helper import pytest", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 39 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "astropy_", "._", "tests_", "._", "helper_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "pytest", "\\u", "addop", "tion_", "(_", "parser_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "._", "addop", "tion_", "(_", "'--", "generat", "e-", "reference", "'_", ",_", "help_", "=_", "\"", "generat", "e", " ", "reference", " ", "results", " ", "for", " ", "bit", "-", "level", " ", "tests", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "addop", "tion_", "(_", "'--", "enable", "-", "bit", "-", "level", "-", "tests", "'_", ",_", "help_", "=_", "\"", "enable", " ", "bit", "-", "level", " ", "tests", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
amrdraz/kodr/app/brython/www/src/Lib/time.py
[ { "content": "def _get_tzname():\n \"check if timezone is available, if not return a tuple of empty str\"\n d = date()\n d = d.toTimeString()\n try:\n d = d.split('(')[1].split(')')[0]\n return (d, 'NotAvailable')\n except:\n return ('', '')", "metadata": "root._get_tzname", "header": "['module', '___EOS___']", "index": 108 } ]
[ { "span": "except:", "start_line": 115, "start_column": 4, "end_line": 115, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "tz", "name_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "check", " ", "if", " ", "timezon", "e", " ", "is", " ", "avail", "able", ",", " ", "if", " ", "not", " ", "return", " ", "a", " ", "tuple", " ", "of", " ", "empty", " ", "str", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "date_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "d_", "._", "to", "Time", "String_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "d_", "._", "split_", "(_", "'('_", ")_", "[_", "1_", "]_", "._", "split_", "(_", "')'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "d_", ",_", "'", "Not", "Avail", "able", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "''_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
zoofIO/flexx/flexx/pyscript/tests/test_commonast.py
[ { "content": "def test_Node_creation():\n \n Node = commonast.Node\n \n class MyNodeWithoutSlots(Node):\n pass\n \n class MyStubNode(Node):\n __slots__ = ()\n \n class MyNode(Node):\n __slots__ = 'name', 'op', 'foo_node', 'foo_nodes', 'bar'\n \n stubnode = MyStubNode()\n stubnodes = [MyStubNode(), MyStubNode(), MyStubNode()]\n \n # Node is an abstract class\n raises(AssertionError, Node)\n # Nodes must have slots (and no __dict__ to preserve memory)\n raises(AssertionError, MyNodeWithoutSlots)\n # number of names must match\n raises(AssertionError, MyNode, )\n raises(AssertionError, MyStubNode, 1)\n raises(AssertionError, MyNode, 'a', 'Add', stubnode, stubnodes, 1, 2)\n \n # These work\n node = MyNode('a', 'Add', stubnode, stubnodes, 1)\n node = MyNode('a', 'Add', None, stubnodes, 1)\n node = MyNode('a', 'Add', stubnode, [], 1)\n node = MyNode('a', 'Add', stubnode, stubnodes, 'bla')\n node = MyNode('a', 'Add', stubnode, stubnodes, [1, 2, 3])\n node = MyNode('a', 'Mult', stubnode, stubnodes, 1)\n node = MyNode('blas asdasd as', 'Mult', stubnode, stubnodes, 1)\n # Name must be a string\n raises(AssertionError, MyNode, 1, 'Add', stubnode, stubnodes, 1)\n # op must be an existing operator\n raises(AssertionError, MyNode, 'a', 'crap', stubnode, stubnodes, 1)\n # names ending with _node must be a node, and _nodes must be a list of nodes\n raises(AssertionError, MyNode, 'a', 'Add', 1, stubnodes, 1)\n raises(AssertionError, MyNode, 'a', 'Add', 'x', stubnodes, 1)\n raises(AssertionError, MyNode, 'a', 'Add', stubnode, 'not a node', 1)\n raises(AssertionError, MyNode, 'a', 'Add', stubnode, [1, 2], 1)\n # bar can be anything, but not a Node or list of Nodes\n raises(AssertionError, MyNode, 'a', 'Add', stubnode, stubnodes, stubnode)\n raises(AssertionError, MyNode, 'a', 'Add', stubnode, stubnodes, stubnodes)", "metadata": "root.test_Node_creation", "header": "['module', '___EOS___']", "index": 76 } ]
[ { "span": "node ", "start_line": 102, "start_column": 4, "end_line": 102, "end_column": 8 }, { "span": "node ", "start_line": 103, "start_column": 4, "end_line": 103, "end_column": 8 }, { "span": "node ", "start_line": 104, "start_column": 4, "end_line": 104, "end_column": 8 }, { "span": "node ", "start_line": 105, "start_column": 4, "end_line": 105, "end_column": 8 }, { "span": "node ", "start_line": 106, "start_column": 4, "end_line": 106, "end_column": 8 }, { "span": "node ", "start_line": 107, "start_column": 4, "end_line": 107, "end_column": 8 } ]
[ { "span": "node ", "start_line": 108, "start_column": 4, "end_line": 108, "end_column": 8 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Node", "\\u", "creation_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Node_", "=_", "common", "ast_", "._", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "My", "Node", "With", "out", "Slot", "s_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "My", "Stu", "b", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "My", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "'", "name", "'_", ",_", "'", "op", "'_", ",_", "'", "foo", "\\u", "node", "'_", ",_", "'", "foo", "\\u", "nodes", "'_", ",_", "'", "bar", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stub", "node_", "=_", "My", "Stu", "b", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stub", "nodes_", "=_", "[_", "My", "Stu", "b", "Node_", "(_", ")_", ",_", "My", "Stu", "b", "Node_", "(_", ")_", ",_", "My", "Stu", "b", "Node_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Node", " ", "is", " ", "an", " ", "abstract", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Node", "s", " ", "must", " ", "have", " ", "slot", "s", " ", "(", "and", " ", "no", " ", "\\u\\u", "dict", "\\u\\u", " ", "to", " ", "preserve", " ", "memory", ")_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node", "With", "out", "Slot", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "number", " ", "of", " ", "names", " ", "must", " ", "match_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Stu", "b", "Node_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "work_", "\\u\\u\\uNL\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "None_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "[_", "]_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "'", "bla", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "a", "'_", ",_", "'", "Mult", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "My", "Node_", "(_", "'", "bla", "s", " ", "asd", "asd", " ", "as", "'_", ",_", "'", "Mult", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Name", " ", "must", " ", "be", " ", "a", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "1_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "op", " ", "must", " ", "be", " ", "an", " ", "exist", "ing", " ", "operator_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "cra", "p", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "names", " ", "ending", " ", "with", " ", "\\u", "node", " ", "must", " ", "be", " ", "a", " ", "node", ",", " ", "and", " ", "\\u", "nodes", " ", "must", " ", "be", " ", "a", " ", "list", " ", "of", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "1_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "'", "x", "'_", ",_", "stub", "nodes_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "'", "not", " ", "a", " ", "node", "'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "[_", "1_", ",_", "2_", "]_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bar", " ", "can", " ", "be", " ", "anyt", "hing", ",", " ", "but", " ", "not", " ", "a", " ", "Node", " ", "or", " ", "list", " ", "of", " ", "Nodes_", "\\u\\u\\uNL\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "stub", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raises_", "(_", "Assert", "ion", "Error_", ",_", "My", "Node_", ",_", "'", "a", "'_", ",_", "'", "Add", "'_", ",_", "stub", "node_", ",_", "stub", "nodes_", ",_", "stub", "nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
acabin/docphp/docphp.py
[ { "content": " def handle_data(self, data):\n self.output += data\n pass", "metadata": "root.PopupHTMLParser.handle_data", "header": "['class', 'PopupHTMLParser', '(', 'HTMLParser', ')', ':', '___EOS___']", "index": 543 } ]
[ { "span": "pass", "start_line": 545, "start_column": 8, "end_line": 545, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "class_", "Pop", "up", "HTM", "LP", "arser", "_", "(_", "HTM", "LP", "arser", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "data_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "output_", "+=_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2 ]
Unused import
geopython/pywps/pywps/app/basic.py
[ { "content": "import logging\nimport lxml\nfrom werkzeug.wrappers import Response\nfrom pywps import __version__, OWS, NAMESPACES, OGCUNIT\n\nLOGGER = logging.getLogger(__name__)\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def xpath_ns(el, path):\n return el.xpath(path, namespaces=NAMESPACES)", "metadata": "root.xpath_ns", "header": "['module', '___EOS___']", "index": 7 }, { "content": "def xml_response(doc):\n \"\"\"XML response serializer\"\"\"\n\n LOGGER.debug('Serializing XML response')\n pywps_version_comment = '<!-- PyWPS %s -->\\n' % __version__\n xml = lxml.etree.tostring(doc, pretty_print=True)\n response = Response(pywps_version_comment.encode('utf8') + xml,\n content_type='text/xml')\n response.status_percentage = 100;\n return response", "metadata": "root.xml_response", "header": "['module', '___EOS___']", "index": 11 } ]
[ { "span": "from pywps import __version__, OWS, NAMESPACES, OGCUNIT", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 55 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "lxml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "werkzeug_", "._", "wrappers_", "import_", "Response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyw", "ps_", "import_", "\\u\\u", "version\\u\\u_", ",_", "OW", "S_", ",_", "NAMESPACE", "S_", ",_", "OG", "CU", "NIT", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LOGGER_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "xpa", "th", "\\u", "ns_", "(_", "el_", ",_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "el_", "._", "xpath_", "(_", "path_", ",_", "namespaces_", "=_", "NAMESPACE", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "xml", "\\u", "response_", "(_", "doc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "XML", " ", "response", " ", "serialize", "r", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LOGGER_", "._", "debug_", "(_", "'", "Seriali", "zin", "g", " ", "XML", " ", "response", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyw", "ps", "\\u", "version", "\\u", "comment_", "=_", "'<!", "--", " ", "Py", "WP", "S", " ", "%", "s", " ", "-->", "\\\\", "n", "'_", "%_", "\\u\\u", "version\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xml_", "=_", "lxml_", "._", "etree_", "._", "tostring_", "(_", "doc_", ",_", "pretty", "\\u", "print_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "Response_", "(_", "pyw", "ps", "\\u", "version", "\\u", "comment_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "+_", "xml_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "'", "text", "/", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "status", "\\u", "percentage_", "=_", "100_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "response_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/extras/completion/py/pymel/util/mathutils.py
[ { "content": "import math\n\nfrom __builtin__ import round as _round\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def gamma(c, g):\n \"\"\"\n Gamma color correction of c with a single scalar gamma value g\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.gamma", "header": "['module', '___EOS___']", "index": 4 }, { "content": "def conjugate(x):\n \"\"\"\n the conjugate part of x\n \"\"\"\n\n pass", "metadata": "root.conjugate", "header": "['module', '___EOS___']", "index": 14 }, { "content": "def smoothmap(min, max, x):\n \"\"\"\n Returns the value of a smooth remapping function.\n \n performs a smooth Hermite interpolation between 0 and 1 in the interval min to max,\n but does not clamp the range\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.smoothmap", "header": "['module', '___EOS___']", "index": 22 }, { "content": "def setRange(x=0.0, oldmin=0.0, oldmax=1.0, newmin=0.0, newmax=1.0):\n \"\"\"\n Resets x range from x linear interpolation of oldmin to oldmax to x linear interpolation from newmin to newmax\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.setRange", "header": "['module', '___EOS___']", "index": 35 }, { "content": "def round(value, ndigits=0):\n \"\"\"\n round(number[, ndigits]) -> float\n Round a number to a given precision in decimal digits (default 0 digits).\n This always returns a floating point number. Precision may be negative.\n This builtin function was overloaded in mathutils to work on complex numbers,\n in that case rel and imaginary values are rounded separately\n \"\"\"\n\n pass", "metadata": "root.round", "header": "['module', '___EOS___']", "index": 45 }, { "content": "def linmap(min, max, x):\n \"\"\"\n Returns the value of a linear remapping function.\n \n performs a linear interpolation between 0 and 1 in the interval min to max,\n but does not clamp the range\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.linmap", "header": "['module', '___EOS___']", "index": 57 }, { "content": "def hermite(x=0.0, v0=0.0, v1=0.0, s0=0.0, s1=0.0):\n \"\"\"\n As the MEL command : This command returns x point along on x hermite curve from the five given control arguments.\n The first two arguments are the start and end points of the curve, respectively.\n The next two arguments are the tangents of the curve at the start point and end point of the curve, respectively.\n The fifth argument, parameter, specifies the point on the hermite curve that is returned by this function.\n This parameter is the unitized distance along the curve from the start point to the end point.\n A parameter value of 0.0 corresponds to the start point and x parameter value of 1.0 corresponds to the end point of the curve.\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.hermite", "header": "['module', '___EOS___']", "index": 70 }, { "content": "def clamp(x=0.0, min=0.0, max=1.0):\n \"\"\"\n Clamps the value x between min and max\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.clamp", "header": "['module', '___EOS___']", "index": 85 }, { "content": "def blend(a, b, weight=0.5):\n \"\"\"\n blend(a, b[, weight=0.5]) :\n Blends values a and b according to normalized weight w,\n returns a for weight == 0.0 and b for weight = 1.0, a*(1.0-weight)+b*weight in between\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.blend", "header": "['module', '___EOS___']", "index": 95 }, { "content": "def imag(x):\n \"\"\"\n the imaginary part of x\n \"\"\"\n\n pass", "metadata": "root.imag", "header": "['module', '___EOS___']", "index": 107 }, { "content": "def smoothstep(min, max, x):\n \"\"\"\n Returns the value of a smooth step function.\n \n Returns 0 if x < min, 1 if x > max, and performs a smooth Hermite\n interpolation between 0 and 1 in the interval min to max.\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.smoothstep", "header": "['module', '___EOS___']", "index": 115 }, { "content": "def hermiteInterp(x=0.0, y0=0.0, y1=1.0, s0=0.0, s1=0.0):\n \"\"\"\n Hermite interpolation of x between points y0 and y1 of tangent slope s0 and s1\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.hermiteInterp", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def linstep(min, max, x):\n \"\"\"\n Returns the value of a linear step function.\n \n Returns 0 if x < min, 1 if x > max, and performs a linear\n interpolation between 0 and 1 in the interval min to max.\n \n :rtype: float\n \"\"\"\n\n pass", "metadata": "root.linstep", "header": "['module', '___EOS___']", "index": 138 }, { "content": "def real(x):\n \"\"\"\n the real part of x\n \"\"\"\n\n pass", "metadata": "root.real", "header": "['module', '___EOS___']", "index": 151 } ]
[ { "span": "import math", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 11 }, { "span": "from __builtin__ import round as _round", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 39 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "builtin\\u\\u_", "import_", "round_", "as_", "\\u", "round_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "gamma_", "(_", "c_", ",_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Gamma", " ", "color", " ", "correcti", "on", " ", "of", " ", "c", " ", "with", " ", "a", " ", "single", " ", "scala", "r", " ", "gamma", " ", "value", " ", "g", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "conjugate", "_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "conjugate", " ", "part", " ", "of", " ", "x", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "smooth", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "smooth", " ", "remap", "ping", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "perform", "s", " ", "a", " ", "smooth", " ", "Her", "mite", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "doe", "s", " ", "not", " ", "clamp", " ", "the", " ", "range", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Range_", "(_", "x_", "=_", "0.0_", ",_", "old", "min_", "=_", "0.0_", ",_", "old", "max_", "=_", "1.0_", ",_", "newm", "in_", "=_", "0.0_", ",_", "newm", "ax_", "=_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Reset", "s", " ", "x", " ", "range", " ", "from", " ", "x", " ", "linear", " ", "interpolati", "on", " ", "of", " ", "old", "min", " ", "to", " ", "old", "max", " ", "to", " ", "x", " ", "linear", " ", "interpolati", "on", " ", "from", " ", "newm", "in", " ", "to", " ", "newm", "ax", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "round_", "(_", "value_", ",_", "ndi", "git", "s_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "round", "(", "number", "[", ",", " ", "ndi", "git", "s", "])", " ", "->", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "Round", " ", "a", " ", "number", " ", "to", " ", "a", " ", "give", "n", " ", "preci", "sion", " ", "in", " ", "decima", "l", " ", "digit", "s", " ", "(", "default", " ", "0", " ", "digit", "s", ").", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "alw", "ay", "s", " ", "return", "s", " ", "a", " ", "float", "ing", " ", "point", " ", "number", ".", " ", " ", "Precis", "ion", " ", "may", " ", "be", " ", "negati", "ve", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "bui", "lti", "n", " ", "function", " ", "was", " ", "overload", "ed", " ", "in", " ", "math", "util", "s", " ", "to", " ", "work", " ", "on", " ", "complex", " ", "numbers", ",", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "tha", "t", " ", "case", " ", "rel", " ", "and", " ", "imagin", "ary", " ", "values", " ", "are", " ", "rounded", " ", "separately", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "lin", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "linear", " ", "remap", "ping", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "perform", "s", " ", "a", " ", "linear", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "doe", "s", " ", "not", " ", "clamp", " ", "the", " ", "range", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "herm", "ite_", "(_", "x_", "=_", "0.0_", ",_", "v0_", "=_", "0.0_", ",_", "v1_", "=_", "0.0_", ",_", "s0_", "=_", "0.0_", ",_", "s1_", "=_", "0.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "As", " ", "the", " ", "ME", "L", " ", "command", " ", ":", " ", "Thi", "s", " ", "command", " ", "return", "s", " ", "x", " ", "point", " ", "along", " ", "on", " ", "x", " ", "herm", "ite", " ", "curve", " ", "from", " ", "the", " ", "five", " ", "give", "n", " ", "control", " ", "argu", "ment", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "first", " ", "two", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "start", " ", "and", " ", "end", " ", "points", " ", "of", " ", "the", " ", "curve", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "next", " ", "two", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "tangent", "s", " ", "of", " ", "the", " ", "curve", " ", "at", " ", "the", " ", "start", " ", "point", " ", "and", " ", "end", " ", "point", " ", "of", " ", "the", " ", "curve", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "fift", "h", " ", "argu", "ment", ",", " ", "parameter", ",", " ", "speci", "fie", "s", " ", "the", " ", "point", " ", "on", " ", "the", " ", "herm", "ite", " ", "curve", " ", "tha", "t", " ", "is", " ", "return", "ed", " ", "by", " ", "this", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "parameter", " ", "is", " ", "the", " ", "unit", "ize", "d", " ", "distance", " ", "along", " ", "the", " ", "curve", " ", "from", " ", "the", " ", "start", " ", "point", " ", "to", " ", "the", " ", "end", " ", "point", ".", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "parameter", " ", "value", " ", "of", " ", "0.", "0", " ", "correspond", "s", " ", "to", " ", "the", " ", "start", " ", "point", " ", "and", " ", "x", " ", "parameter", " ", "value", " ", "of", " ", "1.0", " ", "correspond", "s", " ", "to", " ", "the", " ", "end", " ", "point", " ", "of", " ", "the", " ", "curve", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clamp", "_", "(_", "x_", "=_", "0.0_", ",_", "min_", "=_", "0.0_", ",_", "max_", "=_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Cla", "mps", " ", "the", " ", "value", " ", "x", " ", "bet", "ween", " ", "min", " ", "and", " ", "max", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "blend", "_", "(_", "a_", ",_", "b_", ",_", "weight_", "=_", "0.5_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "blend", "(", "a", ",", " ", "b", "[", ",", " ", "weight", "=", "0.", "5", "])", " ", ":", "\\", "10", ";", " ", " ", " ", " ", "Ble", "nd", "s", " ", "values", " ", "a", " ", "and", " ", "b", " ", "according", " ", "to", " ", "normali", "zed", " ", "weight", " ", "w", ",", "\\", "10", ";", " ", " ", " ", " ", "return", "s", " ", "a", " ", "for", " ", "weight", " ", "==", " ", "0.", "0", " ", "and", " ", "b", " ", "for", " ", "weight", " ", "=", " ", "1.0", ",", " ", "a", "*(", "1.0", "-", "weight", ")+", "b", "*", "weight", " ", "in", " ", "bet", "ween", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "imag_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "imagin", "ary", " ", "part", " ", "of", " ", "x", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "smooth", "step_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "smooth", " ", "step", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "0", " ", "if", " ", "x", " ", "<", " ", "min", ",", " ", "1", " ", "if", " ", "x", " ", ">", " ", "max", ",", " ", "and", " ", "perform", "s", " ", "a", " ", "smooth", " ", "Her", "mite", "\\", "10", ";", " ", " ", " ", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "herm", "ite", "Interp", "_", "(_", "x_", "=_", "0.0_", ",_", "y0_", "=_", "0.0_", ",_", "y1_", "=_", "1.0_", ",_", "s0_", "=_", "0.0_", ",_", "s1_", "=_", "0.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Her", "mite", " ", "interpolati", "on", " ", "of", " ", "x", " ", "bet", "ween", " ", "points", " ", "y", "0", " ", "and", " ", "y1", " ", "of", " ", "tangent", " ", "slope", " ", "s0", " ", "and", " ", "s1", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "lins", "tep_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "linear", " ", "step", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "0", " ", "if", " ", "x", " ", "<", " ", "min", ",", " ", "1", " ", "if", " ", "x", " ", ">", " ", "max", ",", " ", "and", " ", "perform", "s", " ", "a", " ", "linear", "\\", "10", ";", " ", " ", " ", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\u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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Conflicting attributes in base classes
sassoftware/conary/conary/streams.py
[ { "content": "class InfoStream(object):\n\n __slots__ = ()\n\n\n\n\n\n\n", "metadata": "root.InfoStream", "header": "['module', '___EOS___']", "index": 48 }, { "content": " def __deepcopy__(self, mem):\n return self.__class__(self.freeze())", "metadata": "root.InfoStream.__deepcopy__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 52 }, { "content": " def copy(self):\n return self.__class__(self.freeze())", "metadata": "root.InfoStream.copy", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 55 }, { "content": " def freeze(self, skipSet = None):\n raise NotImplementedError", "metadata": "root.InfoStream.freeze", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 58 }, { "content": " def diff(self, them):\n \"\"\"\n Return the diff twm needs to convert them into self. Return None\n if the two items are identical.\n \"\"\"\n raise NotImplementedError", "metadata": "root.InfoStream.diff", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 61 }, { "content": " def twm(self, diff, base):\n \"\"\"\n Performs a three way merge. Base is the original information,\n diff is one of the changes, and self is the (already changed)\n object. Returns a boolean saying whether or not the merge failed\n \"\"\"\n raise NotImplementedError", "metadata": "root.InfoStream.twm", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 68 }, { "content": " def __eq__(self, them, skipSet = None):\n raise NotImplementedError", "metadata": "root.InfoStream.__eq__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 76 }, { "content": " def __ne__(self, them):\n return not self.__eq__(them)", "metadata": "root.InfoStream.__ne__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 79 }, { "content": "class StringsStream(list, InfoStream):\n \"\"\"\n Stores list of arbitrary strings\n \"\"\"\n\n\n\n\n\n\n\n", "metadata": "root.StringsStream", "header": "['module', '___EOS___']", "index": 344 }, { "content": "class ReferencedTroveList(list, InfoStream):\n\n\n", "metadata": "root.ReferencedTroveList", "header": "['module', '___EOS___']", "index": 411 } ]
[ { "span": "class StringsStream(list, InfoStream):", "start_line": 344, "start_column": 0, "end_line": 344, "end_column": 38 }, { "span": "class ReferencedTroveList(list, InfoStream):", "start_line": 411, "start_column": 0, "end_line": 411, "end_column": 44 } ]
[ { "span": "def copy(self):", "start_line": 55, "start_column": 4, "end_line": 55, "end_column": 19 } ]
1
false
[ "[CLS]_", "Confl", "ict", "ing_", "attributes_", "in_", "base_", "classes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "deepc", "opy", "\\u\\u_", "(_", "self_", ",_", "mem_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "freeze_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "freeze_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "freeze_", "(_", "self_", ",_", "skip", "Set_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "diff_", "(_", "self_", ",_", "them", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "the", " ", "diff", " ", "tw", "m", " ", "need", "s", " ", "to", " ", "convert", " ", "them", " ", "int", "o", " ", "self", ".", " ", "Return", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "the", " ", "two", " ", "items", " ", "are", " ", "identi", "cal", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tw", "m_", "(_", "self_", ",_", "diff_", ",_", "base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Perform", "s", " ", "a", " ", "three", " ", "way", " ", "merge", ".", " ", "Base", " ", "is", " ", "the", " ", "original", " ", "informati", "on", ",", "\\", "10", ";", " ", " ", " ", " ", "diff", " ", "is", " ", "one", " ", "of", " ", "the", " ", "change", "s", ",", " ", "and", " ", "self", " ", "is", " ", "the", " ", "(", "alr", "ead", "y", " ", "change", "d", ")", "\\", "10", ";", " ", " ", " ", " ", "object", ".", " ", "Return", "s", " ", "a", " ", "boolean", " ", "say", "ing", " ", "whe", "ther", " ", "or", " ", "not", " ", "the", " ", "merge", " ", "fail", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "them", "_", ",_", "skip", "Set_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "ne\\u\\u_", "(_", "self_", ",_", "them", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "not_", "self_", "._", "\\u\\u", "eq\\u\\u_", "(_", "them", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "String", "s", "Stream_", "(_", "list_", ",_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Stor", "es", " ", "list", " ", "of", " ", "arbitra", "ry", " ", "string", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Reference", "d", "Trove", "List_", "(_", "list_", ",_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2 ]
Use of the return value of a procedure
cloudmatrix/esky/esky/bdist_esky/f_py2app.py
[ { "content": "def freeze(dist):\n \"\"\"Freeze the given distribution data using py2app.\"\"\"\n includes = dist.includes\n excludes = dist.excludes\n options = dist.freezer_options\n # Merge in any includes/excludes given in freezer_options\n includes.append(\"esky\")\n for inc in options.pop(\"includes\",()):\n includes.append(inc)\n for exc in options.pop(\"excludes\",()):\n excludes.append(exc)\n if \"pypy\" not in includes and \"pypy\" not in excludes:\n excludes.append(\"pypy\")\n options[\"includes\"] = includes\n options[\"excludes\"] = excludes\n # The control info (name, icon, etc) for the app will be taken from\n # the first script in the list. Subsequent scripts will be passed\n # as the extra_scripts argument.\n exes = list(dist.get_executables())\n if not exes:\n raise RuntimeError(\"no scripts specified\")\n cmd = _make_py2app_cmd(dist.freeze_dir,dist.distribution,options,exes)\n cmd.run()\n # Remove any .pyc files with a corresponding .py file.\n # This helps avoid timestamp changes that might interfere with\n # the generation of useful patches between versions.\n appnm = dist.distribution.get_name()+\".app\"\n app_dir = os.path.join(dist.freeze_dir,appnm)\n resdir = os.path.join(app_dir,\"Contents/Resources\")\n for (dirnm,_,filenms) in os.walk(resdir):\n for nm in filenms:\n if nm.endswith(\".pyc\"):\n pyfile = os.path.join(dirnm,nm[:-1])\n if os.path.exists(pyfile):\n os.unlink(pyfile+\"c\")\n if nm.endswith(\".pyo\"):\n pyfile = os.path.join(dirnm,nm[:-1])\n if os.path.exists(pyfile):\n os.unlink(pyfile+\"o\")\n # Copy data files into the freeze dir\n for (src,dst) in dist.get_data_files():\n dst = os.path.join(app_dir,\"Contents\",\"Resources\",dst)\n dstdir = os.path.dirname(dst)\n if not os.path.isdir(dstdir):\n dist.mkpath(dstdir)\n dist.copy_file(src,dst)\n # Copy package data into site-packages.zip\n zfpath = os.path.join(cmd.lib_dir,get_zipfile(dist.distribution))\n lib = zipfile.ZipFile(zfpath,\"a\")\n for (src,arcnm) in dist.get_package_data():\n lib.write(src,arcnm)\n lib.close()\n # Create the bootstraping code, using custom code if specified.\n esky_name = dist.distribution.get_name()\n code_source = [\"__esky_name__ = %r\" % (esky_name,)]\n code_source.append(inspect.getsource(esky.bootstrap))\n if not dist.compile_bootstrap_exes:\n code_source.append(_FAKE_ESKY_BOOTSTRAP_MODULE)\n code_source.append(_EXTRA_BOOTSTRAP_CODE)\n code_source.append(dist.get_bootstrap_code())\n code_source.append(\"if not __rpython__:\")\n code_source.append(\" bootstrap()\")\n code_source = \"\\n\".join(code_source)\n def copy_to_bootstrap_env(src,dst=None):\n if dst is None:\n dst = src\n src = os.path.join(appnm,src)\n dist.copy_to_bootstrap_env(src,dst)\n if dist.compile_bootstrap_exes:\n for exe in dist.get_executables(normalise=False):\n if not exe.include_in_bootstrap_env:\n continue\n relpath = os.path.join(\"Contents\",\"MacOS\",exe.name)\n dist.compile_to_bootstrap_exe(exe,code_source,relpath)\n else:\n # Copy the core dependencies into the bootstrap env.\n pydir = \"python%d.%d\" % sys.version_info[:2]\n for nm in (\"Python.framework\",\"lib\"+pydir+\".dylib\",):\n try:\n copy_to_bootstrap_env(\"Contents/Frameworks/\" + nm)\n except Exception, e:\n # Distutils does its own crazy exception-raising which I\n # have no interest in examining right now. Eventually this\n # guard will be more conservative.\n pass\n copy_to_bootstrap_env(\"Contents/Resources/include\")\n if sys.version_info[:2] < (3, 3):\n copy_to_bootstrap_env(\"Contents/Resources/lib/\"+pydir+\"/config\")\n else:\n copy_to_bootstrap_env(\"Contents/Resources/lib/\"+pydir+\"/config-%d.%dm\"\n % sys.version_info[:2])\n\n if \"fcntl\" not in sys.builtin_module_names:\n dynload = \"Contents/Resources/lib/\"+pydir+\"/lib-dynload\"\n for nm in os.listdir(os.path.join(app_dir,dynload)):\n if nm.startswith(\"fcntl\"):\n copy_to_bootstrap_env(os.path.join(dynload,nm))\n copy_to_bootstrap_env(\"Contents/Resources/__error__.sh\")\n # Copy site.py/site.pyc into the boostrap env, then zero them out.\n bsdir = dist.bootstrap_dir\n if os.path.exists(os.path.join(app_dir, \"Contents/Resources/site.py\")):\n copy_to_bootstrap_env(\"Contents/Resources/site.py\")\n with open(bsdir + \"/Contents/Resources/site.py\", \"wt\") as f:\n pass\n if os.path.exists(os.path.join(app_dir, \"Contents/Resources/site.pyc\")):\n copy_to_bootstrap_env(\"Contents/Resources/site.pyc\")\n with open(bsdir + \"/Contents/Resources/site.pyc\", \"wb\") as f:\n f.write(imp.get_magic() + struct.pack(\"<i\", 0))\n f.write(marshal.dumps(compile(\"\", \"site.py\", \"exec\")))\n if os.path.exists(os.path.join(app_dir, \"Contents/Resources/site.pyo\")):\n copy_to_bootstrap_env(\"Contents/Resources/site.pyo\")\n with open(bsdir + \"/Contents/Resources/site.pyo\", \"wb\") as f:\n f.write(imp.get_magic() + struct.pack(\"<i\", 0))\n # Copy the bootstrapping code into the __boot__.py file.\n copy_to_bootstrap_env(\"Contents/Resources/__boot__.py\")\n with open(bsdir+\"/Contents/Resources/__boot__.py\",\"wt\") as f:\n f.write(code_source)\n # Copy the loader program for each script into the bootstrap env.\n copy_to_bootstrap_env(\"Contents/MacOS/python\")\n for exe in dist.get_executables(normalise=False):\n if not exe.include_in_bootstrap_env:\n continue\n exepath = copy_to_bootstrap_env(\"Contents/MacOS/\"+exe.name)\n # Copy non-python resources (e.g. icons etc) into the bootstrap dir\n copy_to_bootstrap_env(\"Contents/Info.plist\")\n # Include Icon\n if exe.icon is not None:\n copy_to_bootstrap_env(\"Contents/Resources/\"+exe.icon)\n copy_to_bootstrap_env(\"Contents/PkgInfo\")\n with open(os.path.join(app_dir,\"Contents\",\"Info.plist\"),\"rt\") as f:\n infotxt = f.read()\n for nm in os.listdir(os.path.join(app_dir,\"Contents\",\"Resources\")):\n if \"<string>%s</string>\" % (nm,) in infotxt:\n copy_to_bootstrap_env(\"Contents/Resources/\"+nm)", "metadata": "root.freeze", "header": "['module', '___EOS___']", "index": 27 }, { "content": "def _make_py2app_cmd(dist_dir,distribution,options,exes):\n exe = exes[0]\n extra_exes = exes[1:]\n cmd = py2app(distribution)\n for (nm,val) in options.iteritems():\n setattr(cmd,nm,val)\n cmd.dist_dir = dist_dir\n cmd.app = [Target(script=exe.script,dest_base=exe.name)]\n cmd.extra_scripts = [e.script for e in extra_exes]\n cmd.finalize_options()\n cmd.plist[\"CFBundleExecutable\"] = exe.name\n old_run = cmd.run\n def new_run():\n # py2app munges the environment in ways that break things.\n old_deployment_target = os.environ.get(\"MACOSX_DEPLOYMENT_TARGET\",None)\n old_run()\n if old_deployment_target is None:\n os.environ.pop(\"MACOSX_DEPLOYMENT_TARGET\",None)\n else:\n os.environ[\"MACOSX_DEPLOYMENT_TARGET\"] = old_deployment_target\n # We need to script file to have the same name as the exe, which\n # it won't if they have changed it explicitly.\n resdir = os.path.join(dist_dir,distribution.get_name()+\".app\",\"Contents/Resources\")\n scriptf = os.path.join(resdir,exe.name+\".py\")\n if not os.path.exists(scriptf):\n old_scriptf = os.path.basename(exe.script)\n old_scriptf = os.path.join(resdir,old_scriptf)\n shutil.move(old_scriptf,scriptf)\n cmd.run = new_run\n return cmd", "metadata": "root._make_py2app_cmd", "header": "['module', '___EOS___']", "index": 176 } ]
[ { "span": "copy_to_bootstrap_env(\"Contents/MacOS/\"+exe.name)", "start_line": 149, "start_column": 22, "end_line": 149, "end_column": 71 } ]
[ { "span": "def copy_to_bootstrap_env(src,dst=None):", "start_line": 90, "start_column": 4, "end_line": 90, "end_column": 44 } ]
1
false
[ "[CLS]_", "Use_", "of_", "the_", "return_", "value_", "of_", "a_", "procedure_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "freeze_", "(_", "dist_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Freez", "e", " ", "the", " ", "give", "n", " ", "distribu", "tion", " ", "data", " ", "usi", "ng", " ", "py2", "app", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "includes_", "=_", "dist_", "._", "includes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "excludes_", "=_", "dist_", "._", "excludes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "dist_", "._", "freez", "er", "\\u", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Merge", " ", "in", " ", "any", " ", "include", "s", "/", "excludes", " ", "give", "n", " ", "in", " ", "freez", "er", "\\u", "options_", "\\u\\u\\uNL\\u\\u\\u_", "includes_", "._", "append_", "(_", "\"", "es", "ky", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "inc_", "in_", "options_", "._", "pop_", "(_", "\"", "include", "s", "\"_", ",_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "includes_", "._", "append_", "(_", "inc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "exc_", "in_", "options_", "._", "pop_", "(_", "\"", "excludes", "\"_", ",_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "excludes_", "._", "append_", "(_", "exc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"", "pypy", "\"_", "not_", "in_", "includes_", "and_", "\"", "pypy", "\"_", "not_", "in_", "excludes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "excludes_", "._", "append_", "(_", "\"", "pypy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "options_", "[_", "\"", "include", "s", "\"_", "]_", "=_", "includes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "[_", "\"", "excludes", "\"_", "]_", "=_", "excludes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "control", " ", "info", " ", "(", "name", ",", " ", "icon", ",", " ", "etc", ")", " ", "for", " ", "the", " ", "app", " ", "will", " ", "be", " ", "take", "n", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "first", " ", "script", " ", "in", " ", "the", " ", "list", ".", " ", " ", "Subs", "eque", "nt", " ", "scripts", " ", "will", " ", "be", " ", "passed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "the", " ", "extra", "\\u", "scripts", " ", "argu", "ment", "._", "\\u\\u\\uNL\\u\\u\\u_", "exe", "s_", "=_", "list_", "(_", "dist_", "._", "get", "\\u", "executable", "s_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "exe", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "\"", "no", " ", "scripts", " ", "specified", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "\\u", "make", "\\u", "py2", "app", "\\u", "cmd_", "(_", "dist_", "._", "freez", "e\\u", "dir_", ",_", "dist_", "._", "distribution_", ",_", "options_", ",_", "exe", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Remove", " ", "any", " ", ".", "pyc", " ", "files", " ", "with", " ", "a", " ", "correspond", "ing", " ", ".", "py", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Thi", "s", " ", "helps", " ", "avoid", " ", "timestamp", " ", "change", "s", " ", "tha", "t", " ", "mig", "ht", " ", "interf", "ere", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "the", " ", "generat", "ion", " ", "of", " ", "usef", "ul", " ", "patche", "s", " ", "bet", "ween", " ", "version", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "app", "nm_", "=_", "dist_", "._", "distribution_", "._", "get", "\\u", "name_", "(_", ")_", "+_", "\".", "app", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dist_", "._", "freez", "e\\u", "dir_", ",_", "app", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "dir", "nm_", ",_", "\\u_", ",_", "filen", "ms_", ")_", "in_", "os_", "._", "walk_", "(_", "res", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "nm_", "in_", "filen", "ms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "nm_", "._", "endswith_", "(_", "\".", "pyc", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pyfi", "le_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dir", "nm_", ",_", "nm_", "[_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "pyfi", "le_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "unlink_", "(_", "pyfi", "le_", "+_", "\"", "c", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "nm_", "._", "endswith_", "(_", "\".", "pyo", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pyfi", "le_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dir", "nm_", ",_", "nm_", "[_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "pyfi", "le_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "unlink_", "(_", "pyfi", "le_", "+_", "\"", "o", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "data", " ", "files", " ", "int", "o", " ", "the", " ", "freez", "e", " ", "dir_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "(_", "src_", ",_", "dst_", ")_", "in_", "dist_", "._", "get", "\\u", "data\\u", "files_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dst_", "=_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "\"_", ",_", "\"", "Reso", "urc", "es", "\"_", ",_", "dst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dst", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "dst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "dst", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dist_", "._", "mk", "path_", "(_", "dst", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dist_", "._", "copy", "\\u", "file_", "(_", "src_", ",_", "dst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "package", " ", "data", " ", "int", "o", " ", "site", "-", "package", "s", ".", "zip_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "zf", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "cmd_", "._", "lib", "\\u", "dir_", ",_", "get", "\\u", "zipfile_", "(_", "dist_", "._", "distribution_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lib_", "=_", "zipfile_", "._", "Zip", "File_", "(_", "zf", "path_", ",_", "\"", "a", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "src_", ",_", "arc", "nm_", ")_", "in_", "dist_", "._", "get", "\\u", "package", "\\u", "data_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lib_", "._", "write_", "(_", "src_", ",_", "arc", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lib_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Creat", "e", " ", "the", " ", "boots", "trap", "ing", " ", "code", ",", " ", "usi", "ng", " ", "custom", " ", "code", " ", "if", " ", "specified", "._", "\\u\\u\\uNL\\u\\u\\u_", "es", "ky", "\\u", "name_", "=_", "dist_", "._", "distribution_", "._", "get", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "=_", "[_", "\"\\u\\u", "es", "ky", "\\u", "name", "\\u\\u", " ", "=", " ", "%", "r", "\"_", "%_", "(_", "es", "ky", "\\u", "name_", ",_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "._", "append_", "(_", "inspect_", "._", "gets", "ource_", "(_", "es", "ky_", "._", "bootstrap_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "dist_", "._", "compile", "\\u", "boots", "trap", "\\u", "exe", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code", "\\u", "source_", "._", "append_", "(_", "\\u", "FAKE", "\\u", "ES", "KY", "\\u", "BOOT", "STRA", "P", "\\u", "MODULE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "._", "append_", "(_", "\\u", "EXTRA", "\\u", "BOOT", "STRA", "P", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "code", "\\u", "source_", "._", "append_", "(_", "dist_", "._", "get", "\\u", "boots", "trap", "\\u", "code_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "._", "append_", "(_", "\"", "if", " ", "not", " ", "\\u\\u", "rpy", "tho", "n", "\\u\\u:", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "._", "append_", "(_", "\"", " ", " ", " ", " ", "boots", "trap", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code", "\\u", "source_", "=_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "code", "\\u", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "src_", ",_", "dst_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "dst_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dst_", "=_", "src_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "src_", "=_", "os_", "._", "path_", "._", "join_", "(_", "app", "nm_", ",_", "src_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dist_", "._", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "src_", ",_", "dst_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dist_", "._", "compile", "\\u", "boots", "trap", "\\u", "exe", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "exe_", "in_", "dist_", "._", "get", "\\u", "executable", "s_", "(_", "normalise", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "exe_", "._", "include", "\\u", "in", "\\u", "boots", "trap", "\\u", "env_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "relpath_", "=_", "os_", "._", "path_", "._", "join_", "(_", "\"", "Conten", "ts", "\"_", ",_", "\"", "Mac", "OS", "\"_", ",_", "exe_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dist_", "._", "compile", "\\u", "to", "\\u", "boots", "trap", "\\u", "exe_", "(_", "exe_", ",_", "code", "\\u", "source_", ",_", "relpath_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "the", " ", "core", " ", "dependen", "cies", " ", "int", "o", " ", "the", " ", "boots", "trap", " ", "env", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pyd", "ir_", "=_", "\"", "python", "%", "d", ".", "%", "d", "\"_", "%_", "sys_", "._", "version", "\\u", "info_", "[_", ":_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "nm_", "in_", "(_", "\"", "Pyth", "on", ".", "frame", "work", "\"_", ",_", "\"", "lib", "\"_", "+_", "pyd", "ir_", "+_", "\".", "dylib", "\"_", ",_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Frame", "works", "/\"_", "+_", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Dist", "util", "s", " ", "doe", "s", " ", "its", " ", "own", " ", "cra", "zy", " ", "exception", "-", "rais", "ing", " ", "whi", "ch", " ", "I_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "have", " ", "no", " ", "interest", " ", "in", " ", "exam", "inin", "g", " ", "right", " ", "now", ".", " ", " ", "Event", "ual", "ly", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "guard", " ", "will", " ", "be", " ", "more", " ", "conserv", "ative", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "include", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", ":_", "2_", "]_", "<_", "(_", "3_", ",_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "lib", "/\"_", "+_", "pyd", "ir_", "+_", "\"/", "config", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "lib", "/\"_", "+_", "pyd", "ir_", "+_", "\"/", "config", "-%", "d", ".", "%", "dm", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "sys_", "._", "version", "\\u", "info_", "[_", ":_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"", "fcn", "tl", "\"_", "not_", "in_", "sys_", "._", "bui", "lti", "n", "\\u", "module", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dyn", "load_", "=_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "lib", "/\"_", "+_", "pyd", "ir_", "+_", "\"/", "lib", "-", "dyn", "load", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "nm_", "in_", "os_", "._", "listdir_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "dyn", "load_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "nm_", "._", "startswith_", "(_", "\"", "fcn", "tl", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dyn", "load_", ",_", "nm_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/\\u", "\\u", "error", "\\u\\u", ".", "sh", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Copy", " ", "site", ".", "py", "/", "site", ".", "pyc", " ", "int", "o", " ", "the", " ", "boost", "rap", " ", "env", ",", " ", "then", " ", "zero", " ", "them", " ", "out", "._", "\\u\\u\\uNL\\u\\u\\u_", "bsd", "ir_", "=_", "dist_", "._", "boots", "trap", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "py", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "py", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "bsd", "ir_", "+_", "\"/", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "py", "\"_", ",_", "\"", "wt", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyc", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "bsd", "ir_", "+_", "\"/", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyc", "\"_", ",_", "\"", "wb", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "imp_", "._", "get", "\\u", "magic_", "(_", ")_", "+_", "struct_", "._", "pack_", "(_", "\"<", "i", "\"_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "marshal_", "._", "dumps_", "(_", "compile_", "(_", "\"\"_", ",_", "\"", "site", ".", "py", "\"_", ",_", "\"", "exec", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyo", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyo", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "bsd", "ir_", "+_", "\"/", "Conten", "ts", "/", "Reso", "urc", "es", "/", "site", ".", "pyo", "\"_", ",_", "\"", "wb", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "imp_", "._", "get", "\\u", "magic_", "(_", ")_", "+_", "struct_", "._", "pack_", "(_", "\"<", "i", "\"_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "the", " ", "bootstrapp", "ing", " ", "code", " ", "int", "o", " ", "the", " ", "\\u\\u", "boot", "\\u\\u", ".", "py", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/\\u", "\\u", "boot", "\\u\\u", ".", "py", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "bsd", "ir_", "+_", "\"/", "Conten", "ts", "/", "Reso", "urc", "es", "/\\u", "\\u", "boot", "\\u\\u", ".", "py", "\"_", ",_", "\"", "wt", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "._", "write_", "(_", "code", "\\u", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "the", " ", "load", "er", " ", "program", " ", "for", " ", "each", " ", "script", " ", "int", "o", " ", "the", " ", "boots", "trap", " ", "env", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Mac", "OS", "/", "python", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "exe_", "in_", "dist_", "._", "get", "\\u", "executable", "s_", "(_", "normalise", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "exe_", "._", "include", "\\u", "in", "\\u", "boots", "trap", "\\u", "env_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exe", "path_", "=_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Mac", "OS", "/\"_", "+_", "exe_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Copy", " ", "non", "-", "python", " ", "resource", "s", " ", "(", "e", ".", "g", ".", " ", "icons", " ", "etc", ")", " ", "int", "o", " ", "the", " ", "boots", "trap", " ", "dir_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Info", ".", "plist", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Include", " ", "Icon_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "exe_", "._", "icon_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/\"_", "+_", "exe_", "._", "icon_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Pk", "g", "Info", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "\"_", ",_", "\"", "Info", ".", "plist", "\"_", ")_", ",_", "\"", "rt", "\"_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "info", "txt_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "nm_", "in_", "os_", "._", "listdir_", "(_", "os_", "._", "path_", "._", "join_", "(_", "app", "\\u", "dir_", ",_", "\"", "Conten", "ts", "\"_", ",_", "\"", "Reso", "urc", "es", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\"<", "string", ">", "%", "s", "</", "string", ">\"_", "%_", "(_", "nm_", ",_", ")_", "in_", "info", "txt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "copy", "\\u", "to", "\\u", "boots", "trap", "\\u", "env_", "(_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "/\"_", "+_", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "make", "\\u", "py2", "app", "\\u", "cmd_", "(_", "dist", "\\u", "dir_", ",_", "distribution_", ",_", "options_", ",_", "exe", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exe_", "=_", "exe", "s_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "exe", "s_", "=_", "exe", "s_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "py2", "app_", "(_", "distribution_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "nm_", ",_", "val_", ")_", "in_", "options_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "cmd_", ",_", "nm_", ",_", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "._", "dist", "\\u", "dir_", "=_", "dist", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "app_", "=_", "[_", "Target_", "(_", "script_", "=_", "exe_", "._", "script_", ",_", "dest", "\\u", "base_", "=_", "exe_", "._", "name_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "extra", "\\u", "scripts_", "=_", "[_", "e_", "._", "script_", "for_", "e_", "in_", "extra", "\\u", "exe", "s_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "finalize", "\\u", "options_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "plist_", "[_", "\"", "CF", "Bun", "dle", "Executable", "\"_", "]_", "=_", "exe_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "run_", "=_", "cmd_", "._", "run_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "new", "\\u", "run_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "py2", "app", " ", "mun", "ges", " ", "the", " ", "environ", "ment", " ", "in", " ", "way", "s", " ", "tha", "t", " ", "break", " ", "thing", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "old", "\\u", "deploy", "ment", "\\u", "target_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "\"", "MAC", "OSX", "\\u", "DEPLOY", "MENT", "\\u", "TARGET", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "deploy", "ment", "\\u", "target_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "environ_", "._", "pop_", "(_", "\"", "MAC", "OSX", "\\u", "DEPLOY", "MENT", "\\u", "TARGET", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "environ_", "[_", "\"", "MAC", "OSX", "\\u", "DEPLOY", "MENT", "\\u", "TARGET", "\"_", "]_", "=_", "old", "\\u", "deploy", "ment", "\\u", "target_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "We", " ", "need", " ", "to", " ", "script", " ", "file", " ", "to", " ", "have", " ", "the", " ", "same", " ", "name", " ", "as", " ", "the", " ", "exe", ",", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "it", " ", "won", "'", "t", " ", "if", " ", "the", "y", " ", "have", " ", "change", "d", " ", "it", " ", "explicit", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "res", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dist", "\\u", "dir_", ",_", "distribution_", "._", "get", "\\u", "name_", "(_", ")_", "+_", "\".", "app", "\"_", ",_", "\"", "Conten", "ts", "/", "Reso", "urc", "es", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "script", "f_", "=_", "os_", "._", "path_", "._", "join_", "(_", "res", "dir_", ",_", "exe_", "._", "name_", "+_", "\".", "py", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "script", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "old", "\\u", "script", "f_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "exe_", "._", "script_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "script", "f_", "=_", "os_", "._", "path_", "._", "join_", "(_", "res", "dir_", ",_", "old", "\\u", "script", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shutil_", "._", "move_", "(_", "old", "\\u", "script", "f_", ",_", "script", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "._", "run_", "=_", "new", "\\u", "run_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cmd_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
beville/ComicStreamer/comicstreamerlib/bonjour.py
[ { "content": "# coding=utf-8\n\n\"\"\"\nComicStreamer bonjour thread class\n\"\"\"\n\n\"\"\"\nCopyright 2012-2014 Anthony Beville\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n\thttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\"\"\"\nimport threading\nimport select\nimport sys\nimport logging\nimport socket\n\ntry:\n import pybonjour\n have_bonjour = True\nexcept:\n have_bonjour = False\n\n\n\n#-------------------------------------------------\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "codi", "ng", "=", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Com", "ic", "Stream", "er", " ", "bon", "jou", "r", " ", "thread", " ", "class", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Copy", "right", " ", "2012", "-", "2014", " ", " ", "Ant", "hon", "y", " ", "Be", "vil", "le", "\\", "10", ";", "\\", "10", ";", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", "\\", "10", ";", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", "\\", "10", ";", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at", "\\", "10", ";", "\\", "10", ";", "\t", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0", "\\", "10", ";", "\\", "10", ";", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "\\", "10", ";", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",", "\\", "10", ";", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", "\\", "10", ";", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", "\\", "10", ";", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "pyb", "on", "jou", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "have", "\\u", "bon", "jou", "r_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "have", "\\u", "bon", "jou", "r_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Conflicting attributes in base classes
AppScale/appscale/AppServer/lib/django-1.5/tests/modeltests/model_forms/tests.py
[ { "content": "class BaseCategoryForm(forms.ModelForm):\n class Meta:\n model = Category", "metadata": "root.BaseCategoryForm", "header": "['module', '___EOS___']", "index": 82 }, { "content": "class ArticleForm(forms.ModelForm):\n class Meta:\n model = Article", "metadata": "root.ArticleForm", "header": "['module', '___EOS___']", "index": 92 }, { "content": " def test_bad_form(self):\n #First class with a Meta class wins...\n class BadForm(ArticleForm, BaseCategoryForm):\n pass\n\n self.assertEqual(\n list(BadForm.base_fields),\n ['headline', 'slug', 'pub_date', 'writer', 'article', 'categories', 'status']\n )", "metadata": "root.ModelFormBaseTest.test_bad_form", "header": "['class', 'ModelFormBaseTest', '(', 'TestCase', ')', ':', '___EOS___']", "index": 269 } ]
[ { "span": "class BadForm(ArticleForm, BaseCategoryForm):", "start_line": 271, "start_column": 8, "end_line": 271, "end_column": 53 } ]
[ { "span": "class Meta:", "start_line": 83, "start_column": 4, "end_line": 83, "end_column": 15 }, { "span": "class Meta:", "start_line": 93, "start_column": 4, "end_line": 93, "end_column": 15 } ]
1
false
[ "[CLS]_", "Confl", "ict", "ing_", "attributes_", "in_", "base_", "classes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Base", "Cate", "gory", "Form_", "(_", "forms_", "._", "Model", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Category_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Artic", "le", "Form_", "(_", "forms_", "._", "Model", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Article_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Form", "Base", "Test_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "bad", "\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Fi", "rst", " ", "class", " ", "with", " ", "a", " ", "Meta", " ", "class", " ", "wins", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Ba", "d", "Form_", "(_", "Artic", "le", "Form_", ",_", "Base", "Cate", "gory", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "Ba", "d", "Form_", "._", "base", "\\u", "fields_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "headline", "'_", ",_", "'", "slug", "'_", ",_", "'", "pub", "\\u", "date", "'_", ",_", "'", "writer", "'_", ",_", "'", "article", "'_", ",_", "'", "categor", "ies", "'_", ",_", "'", "status", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
kenfar/DataGristle/scripts/tests/test_gristle_viewer_cmd.py
[ { "content": "#!/usr/bin/env python\n\"\"\" To do:\n 1. Add testing for stdout - but can be hard because it has interactive prompting.\n 2. Add testing for a recnum > last record in the file\n\n See the file \"LICENSE\" for the full license governing this code. \n Copyright 2011 Ken Farmer\n\"\"\"\n\nimport sys\nimport os\nimport tempfile\nimport random\nimport time\nimport fileinput\nimport subprocess\nimport imp\nimport envoy\nimport pytest\n\nscript_path = os.path.dirname(os.path.dirname(os.path.realpath((__file__))))\nfq_pgm = os.path.join(script_path, 'gristle_viewer')\n\nimport test_tools\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def generate_test_file(delim, record_cnt):\n (fd, fqfn) = tempfile.mkstemp(prefix='ViewerTestIn_')\n fp = os.fdopen(fd,\"w\") \n \n for i in range(record_cnt):\n fields = []\n fields.append(str(i))\n fields.append('A')\n fields.append('B')\n fields.append('C')\n fp.write(delim.join(fields)+'\\n')\n\n fp.close()\n return fqfn", "metadata": "root.generate_test_file", "header": "['module', '___EOS___']", "index": 27 }, { "content": "class TestCommandLine(object):\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TestCommandLine", "header": "['module', '___EOS___']", "index": 44 }, { "content": " def setup_method(self, method):\n self.in_fqfn = generate_test_file(delim='|', record_cnt=100)\n self.empty_fqfn = generate_test_file(delim='|', record_cnt=0)\n (dummy, self.out_fqfn) = tempfile.mkstemp(prefix='ViewerTestOut_') ", "metadata": "root.TestCommandLine.setup_method", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 46 }, { "content": " def teardown_method(self, method):\n os.remove(self.in_fqfn)\n os.remove(self.out_fqfn)\n test_tools.temp_file_remover(os.path.join(tempfile.gettempdir(), 'ViewerTest'))", "metadata": "root.TestCommandLine.teardown_method", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 51 }, { "content": " def test_easy_file(self):\n\n cmd = '%s %s -r 10 -o %s' % (fq_pgm, self.in_fqfn, self.out_fqfn)\n r = envoy.run(cmd)\n p_recs = []\n for rec in fileinput.input(self.out_fqfn):\n p_recs.append(rec)\n fileinput.close()\n\n assert len(p_recs) == 4\n\n assert p_recs[0].strip().startswith('field_0')\n assert p_recs[0].strip().endswith('10')\n\n assert p_recs[1].strip().startswith('field_1')\n assert p_recs[1].strip().endswith('A')\n\n assert p_recs[2].strip().startswith('field_2')\n assert p_recs[2].strip().endswith('B')\n\n assert p_recs[3].strip().startswith('field_3')\n assert p_recs[3].strip().endswith('C')", "metadata": "root.TestCommandLine.test_easy_file", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 57 }, { "content": " def test_bad_recnum(self):\n \"\"\" Shows that the program when given a recnum that doesn't exist will\n write no rows to the output file and print only a comment to stdout\n\n To do:\n - check for a negative number\n - check for return code\n \"\"\"\n\n p_outrecs = []\n cmd = '%s %s -r 999 -o %s' % (fq_pgm, self.in_fqfn, self.out_fqfn)\n r = envoy.run(cmd)\n for rec in fileinput.input(self.out_fqfn):\n p_outrecs.append(rec)\n fileinput.close()\n\n assert 'No record found' in r.std_out\n assert len(p_outrecs) == 0", "metadata": "root.TestCommandLine.test_bad_recnum", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 81 }, { "content": " def test_empty_file(self):\n cmd = \"%s %s -o %s -r 999 \" % (fq_pgm, self.empty_fqfn, self.out_fqfn )\n r = envoy.run(cmd)\n out_recs = []\n for rec in fileinput.input(self.out_fqfn):\n out_recs.append(rec)\n fileinput.close()\n assert len(out_recs) == 0", "metadata": "root.TestCommandLine.test_empty_file", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 101 }, { "content": " def test_full_multiple_files(self):\n cmd = \"%s %s %s -o %s -r 10 -d'|'\" % (fq_pgm, self.in_fqfn, self.in_fqfn, self.out_fqfn)\n r = envoy.run(cmd)\n out_recs = []\n for rec in fileinput.input(self.out_fqfn):\n out_recs.append(rec)\n fileinput.close()\n\n assert len(out_recs) == 4\n assert out_recs[0].strip().startswith('field_0')\n assert out_recs[0].strip().endswith('10')", "metadata": "root.TestCommandLine.test_full_multiple_files", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 111 }, { "content": " def test_full_multiple_empty_files(self):\n cmd = \"%s %s %s -o %s -r 10 -d'|'\" % (fq_pgm, self.empty_fqfn, self.empty_fqfn, self.out_fqfn)\n r = envoy.run(cmd)\n out_recs = []\n for rec in fileinput.input(self.out_fqfn):\n out_recs.append(rec)\n fileinput.close()\n\n assert len(out_recs) == 0", "metadata": "root.TestCommandLine.test_full_multiple_empty_files", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 124 }, { "content": " def dtest_full_multiple_empty_and_full_files(self):\n cmd = \"%s %s %s -o %s -r 10 -d'|'\" % (fq_pgm, self.empty_fqfn, self.in_fqfn, self.out_fqfn)\n r = envoy.run(cmd)\n out_recs = []\n for rec in fileinput.input(self.out_fqfn):\n out_recs.append(rec)\n fileinput.close()\n\n assert len(out_recs) == 4\n assert out_recs[0].strip().startswith('field_0')\n assert out_recs[0].strip().endswith('10')", "metadata": "root.TestCommandLine.dtest_full_multiple_empty_and_full_files", "header": "['class', 'TestCommandLine', '(', 'object', ')', ':', '___EOS___']", "index": 135 } ]
[ { "span": "import sys", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 10 }, { "span": "import random", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 13 }, { "span": "import time", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 11 }, { "span": "import subprocess", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 17 }, { "span": "import imp", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 10 }, { "span": "import pytest", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", "To", " ", "do", ":", "\\", "10", ";", " ", " ", "1", ".", " ", " ", "Add", " ", "testi", "ng", " ", "for", " ", "stdout", " ", "-", " ", "but", " ", "can", " ", "be", " ", "hard", " ", "bec", "aus", "e", " ", "it", " ", "has", " ", "interactive", " ", "prompt", "ing", ".", "\\", "10", ";", " ", " ", "2", ".", " ", " ", "Add", " ", "testi", "ng", " ", "for", " ", "a", " ", "rec", "num", " ", ">", " ", "last", " ", "record", " ", "in", " ", "the", " ", "file", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "See", " ", "the", " ", "file", " ", "\"", "LICENSE", "\"", " ", "for", " ", "the", " ", "full", " ", "license", " ", "govern", "ing", " ", "this", " ", "code", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "Copy", "right", " ", "2011", " ", "Ken", " ", "Far", "mer", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fileinput_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "imp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "envo", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "script", "\\u", "path_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fq", "\\u", "pgm", "_", "=_", "os_", "._", "path_", "._", "join_", "(_", "script", "\\u", "path_", ",_", "'", "gri", "stl", "e\\u", "viewer", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "test\\u", "tools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "generat", "e\\u", "test\\u", "file_", "(_", "delim_", ",_", "record", "\\u", "cnt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fd_", ",_", "fq", "fn_", ")_", "=_", "tempfile_", "._", "mkstemp_", "(_", "prefix_", "=_", "'", "View", "er", "Test", "In", "\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "=_", "os_", "._", "fdo", "pen_", "(_", "fd_", ",_", "\"", "w", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "record", "\\u", "cnt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fields_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "._", "append_", "(_", "str_", "(_", "i_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "._", "append_", "(_", "'", "A", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "._", "append_", "(_", "'", "B", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "._", "append_", "(_", "'", "C", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "write_", "(_", "delim_", "._", "join_", "(_", "fields_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "fq", "fn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "setup", "\\u", "method_", "(_", "self_", ",_", "method_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "in", "\\u", "fq", "fn_", "=_", "generat", "e\\u", "test\\u", "file_", "(_", "delim_", "=_", "'|'_", ",_", "record", "\\u", "cnt_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "empty", "\\u", "fq", "fn_", "=_", "generat", "e\\u", "test\\u", "file_", "(_", "delim_", "=_", "'|'_", ",_", "record", "\\u", "cnt_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "dummy_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "=_", "tempfile_", "._", "mkstemp_", "(_", "prefix_", "=_", "'", "View", "er", "Test", "Out", "\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tear", "down", "\\u", "method_", "(_", "self_", ",_", "method_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "self_", "._", "in", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "tools_", "._", "temp", "\\u", "file", "\\u", "remove", "r_", "(_", "os_", "._", "path_", "._", "join_", "(_", "tempfile_", "._", "gettempdir_", "(_", ")_", ",_", "'", "View", "er", "Test", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "easy", "\\u", "file_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "'%", "s", " ", "%", "s", " ", "-", "r", " ", "10", " ", "-", "o", " ", "%", "s", "'_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "in", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "\\u", "recs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p", "\\u", "recs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "p", "\\u", "recs_", ")_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "10", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "1_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "1_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "A", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "2_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "2_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "B", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "3_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p", "\\u", "recs_", "[_", "3_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "C", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "bad", "\\u", "rec", "num_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Show", "s", " ", "tha", "t", " ", "the", " ", "program", " ", "whe", "n", " ", "give", "n", " ", "a", " ", "rec", "num", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "exist", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "write", " ", "no", " ", "rows", " ", "to", " ", "the", " ", "output", " ", "file", " ", "and", " ", "print", " ", "only", " ", "a", " ", "comment", " ", "to", " ", "stdout", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "do", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "check", " ", "for", " ", "a", " ", "negati", "ve", " ", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "check", " ", "for", " ", "return", " ", "code", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p", "\\u", "outr", "ecs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "'%", "s", " ", "%", "s", " ", "-", "r", " ", "999", " ", "-", "o", " ", "%", "s", "'_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "in", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p", "\\u", "outr", "ecs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "'", "No", " ", "record", " ", "found", "'_", "in_", "r_", "._", "std", "\\u", "out_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "p", "\\u", "outr", "ecs_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "empty", "\\u", "file_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "\"%", "s", " ", "%", "s", " ", "-", "o", " ", "%", "s", " ", "-", "r", " ", "999", " ", "\"_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "empty", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out", "\\u", "recs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out", "\\u", "recs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "out", "\\u", "recs_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "full", "\\u", "multiple", "\\u", "files_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "\"%", "s", " ", "%", "s", " ", "%", "s", " ", "-", "o", " ", "%", "s", " ", "-", "r", " ", "10", " ", "-", "d", "'|", "'\"_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "in", "\\u", "fq", "fn_", ",_", "self_", "._", "in", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out", "\\u", "recs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out", "\\u", "recs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "out", "\\u", "recs_", ")_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "out", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "out", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "10", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "full", "\\u", "multiple", "\\u", "empty", "\\u", "files_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "\"%", "s", " ", "%", "s", " ", "%", "s", " ", "-", "o", " ", "%", "s", " ", "-", "r", " ", "10", " ", "-", "d", "'|", "'\"_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "empty", "\\u", "fq", "fn_", ",_", "self_", "._", "empty", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out", "\\u", "recs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out", "\\u", "recs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "out", "\\u", "recs_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command", "Line_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dte", "st", "\\u", "full", "\\u", "multiple", "\\u", "empty", "\\u", "and", "\\u", "full", "\\u", "files_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd_", "=_", "\"%", "s", " ", "%", "s", " ", "%", "s", " ", "-", "o", " ", "%", "s", " ", "-", "r", " ", "10", " ", "-", "d", "'|", "'\"_", "%_", "(_", "fq", "\\u", "pgm", "_", ",_", "self_", "._", "empty", "\\u", "fq", "fn_", ",_", "self_", "._", "in", "\\u", "fq", "fn_", ",_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "envo", "y_", "._", "run_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out", "\\u", "recs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rec_", "in_", "fileinput_", "._", "input_", "(_", "self_", "._", "out", "\\u", "fq", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out", "\\u", "recs_", "._", "append_", "(_", "rec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fileinput_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "out", "\\u", "recs_", ")_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "out", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "startswith_", "(_", "'", "field", "\\u", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "out", "\\u", "recs_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "._", "endswith_", "(_", "'", "10", "'_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
ucb-sts/sts/sts/controller_manager.py
[ { "content": "# Copyright 2011-2013 Colin Scott\n# Copyright 2011-2013 Andreas Wundsam\n# Copyright 2012-2013 Sam Whitlock\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at:\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n''' Convenience object for encapsulating and interacting with Controller processes '''\n\nfrom pox.lib.util import connect_socket_with_backoff\nfrom pox.lib.packet.ethernet import ethernet\nfrom pox.lib.ioworker.io_worker import JSONIOWorker\nfrom pox.openflow.software_switch import *\nfrom pox.openflow.libopenflow_01 import *\nfrom sts.entities import ControllerState\nfrom sts.util.console import msg\nfrom sts.util.network_namespace import bind_raw_socket\nfrom sts.util.convenience import base64_encode\nfrom sts.entities import ConnectionlessOFConnection\n\nimport subprocess\nimport os\nimport abc\nimport logging\nlog = logging.getLogger(\"ctrl_mgm\")\n\n\n\n\n\n\n\n# --- The following mock methods are for use by interactive_replay.py and openflow_replayer.py,\n# who do not necessarily want to replay with true controller instances ---\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ControllerManager(object):\n ''' Encapsulate a list of controllers objects '''\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.ControllerManager", "header": "['module', '___EOS___']", "index": 35 }, { "content": " def __init__(self, controllers, simulation=None):\n self.cid2controller = {\n controller.cid : controller\n for controller in controllers\n }\n self.simulation = simulation", "metadata": "root.ControllerManager.__init__", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 37 }, { "content": " def set_simulation(self, simulation):\n self.simulation = simulation", "metadata": "root.ControllerManager.set_simulation", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 44 }, { "content": " @property\n def controller_configs(self):\n return [ c.config for c in self.controllers ]", "metadata": "root.ControllerManager.controller_configs", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 47 }, { "content": " @property\n def controllers(self):\n cs = self.cid2controller.values()\n cs.sort(key=lambda c: c.cid)\n return cs", "metadata": "root.ControllerManager.controllers", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 51 }, { "content": " @property\n def remote_controllers(self):\n # N.B. includes local controllers in network namespaces or VMs.\n return [ c for c in self.controllers if c.remote ]", "metadata": "root.ControllerManager.remote_controllers", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 57 }, { "content": " @property\n def cids(self):\n ids = self.cid2controller.keys()\n ids.sort()\n return ids", "metadata": "root.ControllerManager.cids", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 62 }, { "content": " @property\n def live_controllers(self):\n ''' Note! you must invoke check_controller_status if you want an\n up-to-date list of the live controllers'''\n alive = [controller for controller in self.controllers if controller.state == ControllerState.ALIVE]\n return set(alive)", "metadata": "root.ControllerManager.live_controllers", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 68 }, { "content": " @property\n def down_controllers(self):\n ''' Note! you must invoke check_controller_status if you want an\n up-to-date list of the down controllers'''\n down = [controller for controller in self.controllers if controller.state == ControllerState.DEAD]\n return set(down)", "metadata": "root.ControllerManager.down_controllers", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 75 }, { "content": " def all_controllers_down(self):\n return len(self.live_controllers) == 0", "metadata": "root.ControllerManager.all_controllers_down", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 82 }, { "content": " def get_controller_by_label(self, label):\n for c in self.cid2controller.values():\n if c.label == label:\n return c\n return None", "metadata": "root.ControllerManager.get_controller_by_label", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 85 }, { "content": " def get_controller(self, cid):\n if cid not in self.cid2controller:\n raise ValueError(\"unknown cid %s\" % str(cid))\n return self.cid2controller[cid]", "metadata": "root.ControllerManager.get_controller", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 91 }, { "content": " def kill_all(self):\n for c in self.live_controllers:\n c.kill()\n self.cid2controller = {}", "metadata": "root.ControllerManager.kill_all", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 96 }, { "content": " @staticmethod\n def kill_controller(controller):\n controller.kill()", "metadata": "root.ControllerManager.kill_controller", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 101 }, { "content": " @staticmethod\n def reboot_controller(controller):\n controller.restart()", "metadata": "root.ControllerManager.reboot_controller", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 105 }, { "content": " def check_controller_status(self):\n ''' N.B. this method mutates the state of the controller objects '''\n controllers_with_problems = []\n for c in self.controllers:\n (ok, msg) = c.check_status(self.simulation)\n if ok and c.state == ControllerState.STARTING:\n c.state = ControllerState.ALIVE\n if not ok and c.state != ControllerState.STARTING:\n c.state = ControllerState.DEAD\n controllers_with_problems.append((c, msg))\n return controllers_with_problems", "metadata": "root.ControllerManager.check_controller_status", "header": "['class', 'ControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 109 }, { "content": "class ControllerPatchPanel(object):\n '''\n When multiple controllers are managing the network, we need to interpose on the\n messages sent between controllers, for at least two reasons:\n - interposition will allow us to simulate important failure modes, e.g.\n by delaying or dropping heartbeat messages.\n - interposition mitigates non-determinism during replay, as we have\n better control over message arrival.\n\n Note that wiring the distributed controllers to route through the\n patch panel is a separate task (specific to each controller), and is\n not implemented here. We assume here that the controllers route through\n (virtual) interfaces on this machine, one for each controller.\n '''\n __metaclass__ = abc.ABCMeta\n\n # TODO(cs): implement fingerprints for all control messages (e.g. Cassandra,\n # VRRP).\n\n\n\n\n\n\n", "metadata": "root.ControllerPatchPanel", "header": "['module', '___EOS___']", "index": 122 }, { "content": " def __init__(self, create_io_worker):\n self.create_io_worker = create_io_worker\n # { cid of connected controller -> ethernet address }\n self._cid2ethaddr = {}", "metadata": "root.ControllerPatchPanel.__init__", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 140 }, { "content": " def _initialize_switch(self):\n # Tell it to flood all ethernet broadcasts.\n # TODO(cs): as a (potentially substantial) optimization, act as an\n # ARP/DHCP server, since we know all addresses.\n for dl_dst in [EthAddr(\"FF:FF:FF:FF:FF:FF\"), EthAddr(\"00:00:00:00:00:00\")]:\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=dl_dst),\n action=ofp_action_output(port=OFPP_FLOOD)))\n # Tell it to drop all unmatched packets.\n self._send_command(ofp_flow_mod(match=ofp_match(), priority=1))", "metadata": "root.ControllerPatchPanel._initialize_switch", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 145 }, { "content": " @abc.abstractmethod\n def _send_command(self, command):\n pass", "metadata": "root.ControllerPatchPanel._send_command", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 155 }, { "content": " def register_controller(self, cid, guest_eth_addr, host_device):\n ''' Register a controller with this patch panel.'''\n self._cid2ethaddr[cid] = guest_eth_addr\n # Create a port for this controller.\n port = self._create_port_for_controller(guest_eth_addr, host_device)\n # Tell the switch to forward any packets destined for this controller out that port.\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=guest_eth_addr),\n action=ofp_action_output(port=port)))", "metadata": "root.ControllerPatchPanel.register_controller", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 159 }, { "content": " @abc.abstractmethod\n def _create_port_for_controller(self):\n pass", "metadata": "root.ControllerPatchPanel._create_port_for_controller", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 168 }, { "content": " def clean_up(self):\n pass", "metadata": "root.ControllerPatchPanel.clean_up", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 172 }, { "content": " def block_controller_pair(self, cid1, cid2):\n ''' Drop all messages sent between controller 1 and controller 2 until\n unblock_controller_pair is called. '''\n ethaddr1 = self._cid2ethaddr[cid1]\n ethaddr2 = self._cid2ethaddr[cid2]\n # Make sure to block both directions.\n # TODO(cs): support unidirectional blocks.\n # N.B. no actions implies drop.\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=ethaddr1,dl_src=ethaddr2),\n priority=OFP_DEFAULT_PRIORITY+1))\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=ethaddr2,dl_src=ethaddr1),\n priority=OFP_DEFAULT_PRIORITY+1))", "metadata": "root.ControllerPatchPanel.block_controller_pair", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 175 }, { "content": " def unblock_controller_pair(self, cid1, cid2):\n ''' Stop dropping messages sent between controller 1 and controller 2 '''\n ethaddr1 = self._cid2ethaddr[cid1]\n ethaddr2 = self._cid2ethaddr[cid2]\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=ethaddr1,dl_src=ethaddr2),\n priority=OFP_DEFAULT_PRIORITY+1,\n command=OFPFC_DELETE))\n self._send_command(ofp_flow_mod(match=ofp_match(dl_dst=ethaddr2,dl_src=ethaddr1),\n priority=OFP_DEFAULT_PRIORITY+1,\n command=OFPFC_DELETE))", "metadata": "root.ControllerPatchPanel.unblock_controller_pair", "header": "['class', 'ControllerPatchPanel', '(', 'object', ')', ':', '___EOS___']", "index": 188 }, { "content": "class UserSpaceControllerPatchPanel(ControllerPatchPanel):\n ''' Uses a python SoftwareSwitch to route between controllers.'''\n\n\n", "metadata": "root.UserSpaceControllerPatchPanel", "header": "['module', '___EOS___']", "index": 200 }, { "content": " def __init__(self, create_io_worker):\n super(UserSpaceControllerPatchPanel, self).__init__(create_io_worker)\n # We play a clever trick to route between controllers: use a\n # SoftwareSwitch to do the switching.\n # TODO(cs): three optimization possibilities if this switch can't keep up with\n # control plane traffic or latency (measured 75ms minimum RTT on\n # localhost, with high variance):\n # - Use OVS rather than our SoftwareSwitch. Tell OVS to automatically\n # forward broadcast traffic (which we don't care about), and\n # have it forward only select traffic to us. Further possibility: write a\n # separate click or custom C program to control OVS, that talks back to\n # this python process via RPC.\n # - Don't parse the entire ethernet packets -- just do a quick lookup on\n # the dl_dst.\n # - Write a subclass of SoftwareSwitch that does a single hash lookup\n # from dst EthAddr -> raw socket, without indirection through recococo\n # events.\n self.switch = SoftwareSwitch(-1, ports=[])\n # { outgoing port of our switch -> io_worker bound to host veth connected to controller }\n self._port2io_worker = {}\n # Add a DpOutEvent handler.\n # TODO(cs): potential optimization: don't redirect through revent;\n # have the switch directly output the pcap.\n self.switch.addListener(DpPacketOut,\n lambda event: self._port2io_worker[event.port].send(event.packet.pack()))\n self._initialize_switch()", "metadata": "root.UserSpaceControllerPatchPanel.__init__", "header": "['class', 'UserSpaceControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 202 }, { "content": " def clean_up(self):\n for io_worker in self._port2io_worker.itervalues():\n io_worker.close()", "metadata": "root.UserSpaceControllerPatchPanel.clean_up", "header": "['class', 'UserSpaceControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 229 }, { "content": " def _send_command(self, command):\n self.switch.on_message_received(None, command)", "metadata": "root.UserSpaceControllerPatchPanel._send_command", "header": "['class', 'UserSpaceControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 233 }, { "content": " def _create_port_for_controller(self, guest_eth_addr, host_device):\n # Wire up a new port for the switch leading to this controller's io_worker, and\n # The ethernet address we assign to the switch's port shouldn't matter afaict.\n port = ofp_phy_port(port_no=len(self.switch.ports)+1)\n self.switch.bring_port_up(port)\n\n # Hook up a raw_socket and io_worker for this host_device.\n # TODO(cs): suport pcap filtering as an alternative to raw sockets. Would\n # require us to modify pxpcap to allow us to wrap a non-blocking pcap in\n # an io_worker.\n raw_socket = bind_raw_socket(host_device)\n # Set up an io worker for our end of the socket, and tell it to\n # immediately send packets to the switch.\n # TODO(cs): create_io_worker is a broken reference!\n io_worker = self.create_io_worker(raw_socket)\n # TODO(cs): not sure if this line is strictly needed for the closure.\n switch = self.switch\n def _process_raw_socket_read(io_worker):\n # N.B. raw sockets return exactly one ethernet frame for every read().\n data = io_worker.peek_receive_buf()\n packet = ethernet(bytes(data))\n io_worker.consume_receive_buf(len(data))\n if log.isEnabledFor(logging.DEBUG):\n log.debug(\"Dequeing packet %s, port %s\" % (packet, port))\n switch.process_packet(packet, port.port_no)\n io_worker.set_receive_handler(_process_raw_socket_read)\n self._port2io_worker[port] = io_worker\n return port", "metadata": "root.UserSpaceControllerPatchPanel._create_port_for_controller", "header": "['class', 'UserSpaceControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 236 }, { "content": "class OVSControllerPatchPanel(ControllerPatchPanel):\n ''' Uses OVS to route between controllers. '''\n of_port = 8765\n messenger_port = 9876\n\n\n\n", "metadata": "root.OVSControllerPatchPanel", "header": "['module', '___EOS___']", "index": 265 }, { "content": " def __init__(self, create_io_worker):\n super(OVSControllerPatchPanel, self).__init__(create_io_worker)\n # Boot up POX.\n args = str(\"\"\"./pox.py openflow.of_01 --address=127.0.0.1 --port=%d\"\"\"\n \"\"\" messenger.messenger --tcp_address=127.0.0.1 --tcp_port=%d \"\"\"\n \"\"\" sts_of_forwarder.sts_of_forwarder \"\"\" %\n (self.of_port, self.messenger_port)).split()\n self.pox = subprocess.Popen(args, cwd=\"./pox/\", preexec_fn=lambda: os.setsid())\n # Establish connection with POX messenger component.\n true_socket = connect_socket_with_backoff(address=\"127.0.0.1\",\n port=self.messenger_port)\n self.json_worker = JSONIOWorker(create_io_worker(true_socket))\n # Send the handshake.\n self.json_worker.send({\"sts_connection\": \"\"})\n self._initialize_switch()", "metadata": "root.OVSControllerPatchPanel.__init__", "header": "['class', 'OVSControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 270 }, { "content": " def _send_command(self, command):\n b64_pkt = base64_encode(command)\n self.json_worker.send(b64_pkt)", "metadata": "root.OVSControllerPatchPanel._send_command", "header": "['class', 'OVSControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 286 }, { "content": " def _create_port_for_controller(self, guest_eth_addr, host_device):\n raise NotImplementedError(\"\")", "metadata": "root.OVSControllerPatchPanel._create_port_for_controller", "header": "['class', 'OVSControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 290 }, { "content": " def clean_up(self):\n self.json_worker.close()\n self.pox.kill()", "metadata": "root.OVSControllerPatchPanel.clean_up", "header": "['class', 'OVSControllerPatchPanel', '(', 'ControllerPatchPanel', ')', ':', '___EOS___']", "index": 293 }, { "content": "class MockControllerManager(object):\n # TODO(cs): these properties are only a temporary fix. In the long run, we\n # should refactor interactive_replayer to use its own help options, distinct\n # from interactive's help options.", "metadata": "root.MockControllerManager", "header": "['module', '___EOS___']", "index": 300 }, { "content": " def __init__(self, controller_configs):\n self.controller_configs = controller_configs", "metadata": "root.MockControllerManager.__init__", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 301 }, { "content": " def set_simulation(self, simulation): pass", "metadata": "root.MockControllerManager.set_simulation", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 303 }, { "content": " def kill_all(self): pass", "metadata": "root.MockControllerManager.kill_all", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 304 }, { "content": " @property\n def live_controllers(self): return []", "metadata": "root.MockControllerManager.live_controllers", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 308 }, { "content": " @property\n def down_controllers(self): return []", "metadata": "root.MockControllerManager.down_controllers", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 310 }, { "content": " def check_controller_status(self): return []", "metadata": "root.MockControllerManager.check_controller_status", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 312 }, { "content": " def all_controllers_down(self): return False", "metadata": "root.MockControllerManager.all_controllers_down", "header": "['class', 'MockControllerManager', '(', 'object', ')', ':', '___EOS___']", "index": 313 }, { "content": "def boot_mock_controllers(controller_configs, snapshot_service,\n sync_connection_manager, multiplex_sockets=False):\n return MockControllerManager(controller_configs)", "metadata": "root.boot_mock_controllers", "header": "['module', '___EOS___']", "index": 315 }, { "content": "def create_mock_connection(controller_config, software_switch, max_backoff_seconds=1024):\n return ConnectionlessOFConnection(controller_config.cid, software_switch.dpid)", "metadata": "root.create_mock_connection", "header": "['module', '___EOS___']", "index": 319 }, { "content": "def connect_to_mock_controllers(simulation):\n simulation.topology.connect_to_controllers(simulation.controller_manager.controller_configs,\n create_connection=create_mock_connection)", "metadata": "root.connect_to_mock_controllers", "header": "['module', '___EOS___']", "index": 322 } ]
[ { "span": "from sts.util.console import msg", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 32 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2011", "-", "2013", " ", "Col", "in", " ", "Scot", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2011", "-", "2013", " ", "Andre", "as", " ", "Wu", "nd", "sam", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2012", "-", "2013", " ", "Sam", " ", "Whi", "tlo", "ck_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Conve", "nie", "nce", " ", "object", " ", "for", " ", "encapsulat", "ing", " ", "and", " ", "interacti", "ng", " ", "with", " ", "Controlle", "r", " ", "process", "es", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "po", "x_", "._", "lib_", "._", "util_", "import_", "connect", "\\u", "socket", "\\u", "with", "\\u", "backoff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "po", "x_", "._", "lib_", "._", "packet_", "._", "ethernet", "_", "import_", "ethernet", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "po", "x_", "._", "lib_", "._", "io", "worker_", "._", "io", "\\u", "worker_", "import_", "JSO", "NI", "OW", "ork", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "po", "x_", "._", "openf", "low_", "._", "software", "\\u", "switch_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "po", "x_", "._", "openf", "low_", "._", "lib", "openf", "low", "\\u", "01_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sts_", "._", "entities_", "import_", "Controlle", "r", "State_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sts_", "._", "util_", "._", "console_", "import_", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sts_", "._", "util_", "._", "network", "\\u", "namespace_", "import_", "bind", "\\u", "raw", "\\u", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sts_", "._", "util_", "._", "convenien", "ce_", "import_", "base64", "\\u", "encode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sts_", "._", "entities_", "import_", "Connect", "ion", "less", "OF", "Connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "abc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "\"", "ctrl", "\\u", "mg", "m", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "---", " ", "The", " ", "follow", "ing", " ", "mock", " ", "method", "s", " ", "are", " ", "for", " ", "use", " ", "by", " ", "interactive", "\\u", "repla", "y", ".", "py", " ", "and", " ", "openf", "low", "\\u", "repla", "yer", ".", "py", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "who", " ", "do", " ", "not", " ", "necessar", "il", "y", " ", "want", " ", "to", " ", "repla", "y", " ", "with", " ", "true", " ", "controlle", "r", " ", "instance", "s", " ", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Enca", "psu", "late", " ", "a", " ", "list", " ", "of", " ", "controlle", "rs", " ", "object", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "controllers_", ",_", "simulation_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "controller_", "._", "cid_", ":_", "controller_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "controller_", "in_", "controllers_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "simulation_", "=_", "simulation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "simulation_", "(_", "self_", ",_", "simulation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "simulation_", "=_", "simulation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "controlle", "r", "\\u", "configs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "c_", "._", "config_", "for_", "c_", "in_", "self_", "._", "controllers_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "controllers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cs_", "=_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "._", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cs_", "._", "sort_", "(_", "key_", "=_", "lambda_", "c_", ":_", "c_", "._", "cid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "remote", "\\u", "controllers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "N", ".", "B", ".", " ", "include", "s", " ", "local", " ", "controlle", "rs", " ", "in", " ", "network", " ", "namespace", "s", " ", "or", " ", "VM", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "c_", "for_", "c_", "in_", "self_", "._", "controllers_", "if_", "c_", "._", "remote_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "cid", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ids_", "=_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ids_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "ids_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "live", "\\u", "controllers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Not", "e", "!", " ", "you", " ", "must", " ", "invoke", " ", "check", "\\u", "controlle", "r", "\\u", "status", " ", "if", " ", "you", " ", "want", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "up", "-", "to", "-", "date", " ", "list", " ", "of", " ", "the", " ", "live", " ", "controlle", "rs", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alive_", "=_", "[_", "controller_", "for_", "controller_", "in_", "self_", "._", "controllers_", "if_", "controller_", "._", "state_", "==_", "Controlle", "r", "State_", "._", "ALI", "VE_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "set_", "(_", "alive_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "down", "\\u", "controllers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Not", "e", "!", " ", "you", " ", "must", " ", "invoke", " ", "check", "\\u", "controlle", "r", "\\u", "status", " ", "if", " ", "you", " ", "want", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "up", "-", "to", "-", "date", " ", "list", " ", "of", " ", "the", " ", "down", " ", "controlle", "rs", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "down_", "=_", "[_", "controller_", "for_", "controller_", "in_", "self_", "._", "controllers_", "if_", "controller_", "._", "state_", "==_", "Controlle", "r", "State_", "._", "DEAD", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "set_", "(_", "down_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "all", "\\u", "controlle", "rs", "\\u", "down_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "live", "\\u", "controllers_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "controlle", "r", "\\u", "by", "\\u", "label_", "(_", "self_", ",_", "label_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "c_", "in_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "c_", "._", "label_", "==_", "label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "controller_", "(_", "self_", ",_", "cid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cid_", "not_", "in_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "unknown", " ", "cid", " ", "%", "s", "\"_", "%_", "str_", "(_", "cid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "[_", "cid_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "kill", "\\u", "all_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "c_", "in_", "self_", "._", "live", "\\u", "controllers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "._", "kill_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "cid", "2co", "ntr", "olle", "r_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "kill", "\\u", "controller_", "(_", "controller_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "controller_", "._", "kill_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "rebo", "ot", "\\u", "controller_", "(_", "controller_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "controller_", "._", "restart_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "controlle", "r", "\\u", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "N", ".", "B", ".", " ", "this", " ", "method", " ", "mutate", "s", " ", "the", " ", "state", " ", "of", " ", "the", " ", "controlle", "r", " ", "object", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controlle", "rs", "\\u", "with", "\\u", "problems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "self_", "._", "controllers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "ok_", ",_", "msg_", ")_", "=_", "c_", "._", "check", "\\u", "status_", "(_", "self_", "._", "simulation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ok_", "and_", "c_", "._", "state_", "==_", "Controlle", "r", "State_", "._", "START", "ING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "._", "state_", "=_", "Controlle", "r", "State_", "._", "ALI", "VE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "ok_", "and_", "c_", "._", "state_", "!=_", "Controlle", "r", "State_", "._", "START", "ING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "._", "state_", "=_", "Controlle", "r", "State_", "._", "DEAD", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controlle", "rs", "\\u", "with", "\\u", "problems_", "._", "append_", "(_", "(_", "c_", ",_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "controlle", "rs", "\\u", "with", "\\u", "problems_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", "Whe", "n", " ", "multiple", " ", "controlle", "rs", " ", "are", " ", "mana", "ging", " ", "the", " ", "network", ",", " ", "we", " ", "need", " ", "to", " ", "interp", "ose", " ", "on", " ", "the", "\\", "10", ";", " ", " ", "message", "s", " ", "sent", " ", "bet", "ween", " ", "controlle", "rs", ",", " ", "for", " ", "at", " ", "leas", "t", " ", "two", " ", "reasons", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "interp", "osition", " ", "will", " ", "allow", " ", "us", " ", "to", " ", "simulat", "e", " ", "importa", "nt", " ", "fail", "ure", " ", "mode", "s", ",", " ", "e", ".", "g", ".", "\\", "10", ";", " ", " ", "by", " ", "dela", "ying", " ", "or", " ", "drop", "ping", " ", "heart", "beat", " ", "message", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "interp", "osition", " ", "mit", "igat", "es", " ", "non", "-", "determini", "sm", " ", "dur", "ing", " ", "repla", "y", ",", " ", "as", " ", "we", " ", "have", "\\", "10", ";", " ", " ", "bett", "er", " ", "control", " ", "over", " ", "message", " ", "arrival", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", "Not", "e", " ", "tha", "t", " ", "wir", "ing", " ", "the", " ", "distributed", " ", "controlle", "rs", " ", "to", " ", "route", " ", "through", " ", "the", "\\", "10", ";", " ", " ", "patch", " ", "panel", " ", "is", " ", "a", " ", "separate", " ", "task", " ", "(", "specific", " ", "to", " ", "each", " ", "controlle", "r", "),", " ", "and", " ", "is", "\\", "10", ";", " ", " ", "not", " ", "implemented", " ", "here", ".", " ", "We", " ", "assume", " ", "here", " ", "tha", "t", " ", "the", " ", "controlle", "rs", " ", "route", " ", "through", "\\", "10", ";", " ", " ", "(", "virtual", ")", " ", "interface", "s", " ", "on", " ", "this", " ", "machine", ",", " ", "one", " ", "for", " ", "each", " ", "controlle", "r", ".", "\\", "10", ";", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "metaclass\\u\\u_", "=_", "abc_", "._", "ABC", "Meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "implement", " ", "fingerprint", "s", " ", "for", " ", "all", " ", "control", " ", "message", "s", " ", "(", "e", ".", "g", ".", " ", "Cass", "andra", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "VR", "RP", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "create", "\\u", "io", "\\u", "worker_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "create", "\\u", "io", "\\u", "worker_", "=_", "create", "\\u", "io", "\\u", "worker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "{", " ", "cid", " ", "of", " ", "connect", "ed", " ", "controlle", "r", " ", "->", " ", "ethernet", " ", "address", " ", "}_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "initialize", "\\u", "switch_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tell", " ", "it", " ", "to", " ", "flood", " ", "all", " ", "ethernet", " ", "broadcast", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "as", " ", "a", " ", "(", "potenti", "ally", " ", "substa", "nti", "al", ")", " ", "optimization", ",", " ", "act", " ", "as", " ", "an_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ARP", "/", "DHC", "P", " ", "server", ",", " ", "sinc", "e", " ", "we", " ", "know", " ", "all", " ", "addresse", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "dl", "\\u", "dst_", "in_", "[_", "Eth", "Addr_", "(_", "\"", "FF", ":", "FF", ":", "FF", ":", "FF", ":", "FF", ":", "FF", "\"_", ")_", ",_", "Eth", "Addr_", "(_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", "\"_", ")_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "dl", "\\u", "dst_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "ofp", "\\u", "action", "\\u", "output_", "(_", "port_", "=_", "OFP", "P", "\\u", "FLO", "OD_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tell", " ", "it", " ", "to", " ", "drop", " ", "all", " ", "unmatched", " ", "packet", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", ")_", ",_", "priority_", "=_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "abc_", "._", "abstractmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "send", "\\u", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "register", "\\u", "controller_", "(_", "self_", ",_", "cid_", ",_", "guest", "\\u", "eth", "\\u", "addr_", ",_", "host", "\\u", "device_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Register", " ", "a", " ", "controlle", "r", " ", "with", " ", "this", " ", "patch", " ", "panel", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "[_", "cid_", "]_", "=_", "guest", "\\u", "eth", "\\u", "addr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "port", " ", "for", " ", "this", " ", "controlle", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "port_", "=_", "self_", "._", "\\u", "create", "\\u", "port", "\\u", "for", "\\u", "controller_", "(_", "guest", "\\u", "eth", "\\u", "addr_", ",_", "host", "\\u", "device_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tell", " ", "the", " ", "switch", " ", "to", " ", "forward", " ", "any", " ", "packet", "s", " ", "destin", "ed", " ", "for", " ", "this", " ", "controlle", "r", " ", "out", " ", "tha", "t", " ", "port", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "guest", "\\u", "eth", "\\u", "addr_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "ofp", "\\u", "action", "\\u", "output_", "(_", "port_", "=_", "port_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "abc_", "._", "abstractmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "create", "\\u", "port", "\\u", "for", "\\u", "controller_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean", "\\u", "up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "block", "\\u", "controlle", "r", "\\u", "pair_", "(_", "self_", ",_", "cid", "1_", ",_", "cid", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Drop", " ", "all", " ", "message", "s", " ", "sent", " ", "bet", "ween", " ", "controlle", "r", " ", "1", " ", "and", " ", "controlle", "r", " ", "2", " ", "unti", "l", "\\", "10", ";", " ", " ", " ", " ", "unbl", "ock", "\\u", "controlle", "r", "\\u", "pair", " ", "is", " ", "call", "ed", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "etha", "ddr", "1_", "=_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "[_", "cid", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "etha", "ddr", "2_", "=_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "[_", "cid", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "to", " ", "block", " ", "bot", "h", " ", "direction", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "support", " ", "unid", "irect", "ional", " ", "blocks", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "N", ".", "B", ".", " ", "no", " ", "action", "s", " ", "implies", " ", "drop", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "etha", "ddr", "1_", ",_", "dl", "\\u", "src_", "=_", "etha", "ddr", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "priority_", "=_", "OFP", "\\u", "DEF", "AUL", "T", "\\u", "PRIORITY", "_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "etha", "ddr", "2_", ",_", "dl", "\\u", "src_", "=_", "etha", "ddr", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "priority_", "=_", "OFP", "\\u", "DEF", "AUL", "T", "\\u", "PRIORITY", "_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unbl", "ock", "\\u", "controlle", "r", "\\u", "pair_", "(_", "self_", ",_", "cid", "1_", ",_", "cid", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Sto", "p", " ", "drop", "ping", " ", "message", "s", " ", "sent", " ", "bet", "ween", " ", "controlle", "r", " ", "1", " ", "and", " ", "controlle", "r", " ", "2", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "etha", "ddr", "1_", "=_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "[_", "cid", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "etha", "ddr", "2_", "=_", "self_", "._", "\\u", "cid", "2e", "tha", "ddr_", "[_", "cid", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "etha", "ddr", "1_", ",_", "dl", "\\u", "src_", "=_", "etha", "ddr", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "priority_", "=_", "OFP", "\\u", "DEF", "AUL", "T", "\\u", "PRIORITY", "_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "command_", "=_", "OFP", "FC", "\\u", "DELETE_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "send", "\\u", "command_", "(_", "ofp", "\\u", "flow", "\\u", "mod_", "(_", "match_", "=_", "ofp", "\\u", "match_", "(_", "dl", "\\u", "dst_", "=_", "etha", "ddr", "2_", ",_", "dl", "\\u", "src_", "=_", "etha", "ddr", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "priority_", "=_", "OFP", "\\u", "DEF", "AUL", "T", "\\u", "PRIORITY", "_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "command_", "=_", "OFP", "FC", "\\u", "DELETE_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Us", "es", " ", "a", " ", "python", " ", "Sof", "twa", "re", "Switch", " ", "to", " ", "route", " ", "bet", "ween", " ", "controlle", "rs", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "create", "\\u", "io", "\\u", "worker_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "create", "\\u", "io", "\\u", "worker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "play", " ", "a", " ", "clev", "er", " ", "trick", " ", "to", " ", "route", " ", "bet", "ween", " ", "controlle", "rs", ":", " ", "use", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sof", "twa", "re", "Switch", " ", "to", " ", "do", " ", "the", " ", "switching", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "three", " ", "optimization", " ", "possibilit", "ies", " ", "if", " ", "this", " ", "switch", " ", "can", "'", "t", " ", "keep", " ", "up", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "control", " ", "plane", " ", "traffic", " ", "or", " ", "latenc", "y", " ", "(", "measure", "d", " ", "7", "5", "ms", " ", "minim", "um", " ", "RT", "T", " ", "on_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "local", "host", ",", " ", "with", " ", "high", " ", "varian", "ce", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "-", " ", "Us", "e", " ", "OVS", " ", "rat", "her", " ", "than", " ", "our", " ", "Sof", "twa", "re", "Switch", ".", " ", "Tell", " ", "OVS", " ", "to", " ", "automati", "call", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "forward", " ", "broadcast", " ", "traffic", " ", "(", "whi", "ch", " ", "we", " ", "don", "'", "t", " ", "care", " ", "abo", "ut", "),", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "have", " ", "it", " ", "forward", " ", "only", " ", "select", " ", "traffic", " ", "to", " ", "us", ".", " ", "Fur", "ther", " ", "possibilit", "y", ":", " ", "write", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "separate", " ", "click", " ", "or", " ", "custom", " ", "C", " ", "program", " ", "to", " ", "control", " ", "OVS", ",", " ", "tha", "t", " ", "talk", "s", " ", "back", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "this", " ", "python", " ", "process", " ", "via", " ", "RP", "C", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "-", " ", "Don", "'", "t", " ", "parse", " ", "the", " ", "entire", " ", "ethernet", " ", "packet", "s", " ", "--", " ", "just", " ", "do", " ", "a", " ", "quick", " ", "look", "up", " ", "on_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "the", " ", "dl", "\\u", "dst", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "-", " ", "Write", " ", "a", " ", "subclass", " ", "of", " ", "Sof", "twa", "re", "Switch", " ", "tha", "t", " ", "doe", "s", " ", "a", " ", "single", " ", "hash", " ", "lookup_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "from", " ", "dst", " ", "Eth", "Add", "r", " ", "->", " ", "raw", " ", "socket", ",", " ", "with", "out", " ", "indirect", "ion", " ", "through", " ", "reco", "coco", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "events", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "switch_", "=_", "Sof", "twa", "re", "Switch_", "(_", "-_", "1_", ",_", "ports_", "=_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "{", " ", "outgoing", " ", "port", " ", "of", " ", "our", " ", "switch", " ", "->", " ", "io", "\\u", "worker", " ", "bound", " ", "to", " ", "host", " ", "vet", "h", " ", "connect", "ed", " ", "to", " ", "controlle", "r", " ", "}_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "port", "2i", "o", "\\u", "worker_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "Dp", "Out", "Event", " ", "handler", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "potenti", "al", " ", "optimization", ":", " ", "don", "'", "t", " ", "redirec", "t", " ", "through", " ", "rev", "ent", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "have", " ", "the", " ", "switch", " ", "direct", "ly", " ", "output", " ", "the", " ", "pcap", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "switch_", "._", "add", "Listener_", "(_", "Dp", "Packe", "t", "Out_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "event_", ":_", "self_", "._", "\\u", "port", "2i", "o", "\\u", "worker_", "[_", "event_", "._", "port_", "]_", "._", "send_", "(_", "event_", "._", "packet_", "._", "pack_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "initialize", "\\u", "switch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean", "\\u", "up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "io", "\\u", "worker_", "in_", "self_", "._", "\\u", "port", "2i", "o", "\\u", "worker_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "io", "\\u", "worker_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "send", "\\u", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "switch_", "._", "on", "\\u", "message", "\\u", "received_", "(_", "None_", ",_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Spac", "e", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "create", "\\u", "port", "\\u", "for", "\\u", "controller_", "(_", "self_", ",_", "guest", "\\u", "eth", "\\u", "addr_", ",_", "host", "\\u", "device_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Wire", " ", "up", " ", "a", " ", "new", " ", "port", " ", "for", " ", "the", " ", "switch", " ", "lead", "ing", " ", "to", " ", "this", " ", "controlle", "r", "'", "s", " ", "io", "\\u", "worker", ",", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "ethernet", " ", "address", " ", "we", " ", "assign", " ", "to", " ", "the", " ", "switch", "'", "s", " ", "port", " ", "shou", "ld", "n", "'", "t", " ", "matte", "r", " ", "afa", "ict", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port_", "=_", "ofp", "\\u", "phy", "\\u", "port_", "(_", "port", "\\u", "no_", "=_", "len_", "(_", "self_", "._", "switch_", "._", "ports_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "switch_", "._", "bring", "\\u", "port", "\\u", "up_", "(_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Hook", " ", "up", " ", "a", " ", "raw", "\\u", "socket", " ", "and", " ", "io", "\\u", "worker", " ", "for", " ", "this", " ", "host", "\\u", "device", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "sup", "ort", " ", "pcap", " ", "filtering", " ", "as", " ", "an", " ", "alternative", " ", "to", " ", "raw", " ", "socket", "s", ".", " ", "Wo", "ul", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "require", " ", "us", " ", "to", " ", "modif", "y", " ", "px", "pcap", " ", "to", " ", "allow", " ", "us", " ", "to", " ", "wrap", " ", "a", " ", "non", "-", "blockin", "g", " ", "pcap", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "an", " ", "io", "\\u", "worker", "._", "\\u\\u\\uNL\\u\\u\\u_", "raw", "\\u", "socket_", "=_", "bind", "\\u", "raw", "\\u", "socket_", "(_", "host", "\\u", "device_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Set", " ", "up", " ", "an", " ", "io", " ", "worker", " ", "for", " ", "our", " ", "end", " ", "of", " ", "the", " ", "socket", ",", " ", "and", " ", "tell", " ", "it", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "immediate", "ly", " ", "send", " ", "packet", "s", " ", "to", " ", "the", " ", "switch", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "create", "\\u", "io", "\\u", "worker", " ", "is", " ", "a", " ", "broken", " ", "reference", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "io", "\\u", "worker_", "=_", "self_", "._", "create", "\\u", "io", "\\u", "worker_", "(_", "raw", "\\u", "socket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "not", " ", "sure", " ", "if", " ", "this", " ", "line", " ", "is", " ", "strict", "ly", " ", "need", "ed", " ", "for", " ", "the", " ", "clos", "ure", "._", "\\u\\u\\uNL\\u\\u\\u_", "switch_", "=_", "self_", "._", "switch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "process", "\\u", "raw", "\\u", "socket", "\\u", "read_", "(_", "io", "\\u", "worker_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "N", ".", "B", ".", " ", "raw", " ", "socket", "s", " ", "return", " ", "exact", "ly", " ", "one", " ", "ethernet", " ", "frame", " ", "for", " ", "every", " ", "read", "()", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "io", "\\u", "worker_", "._", "peek", "\\u", "receive", "\\u", "buf_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packet_", "=_", "ethernet", "_", "(_", "bytes_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "io", "\\u", "worker_", "._", "consume", "\\u", "receive", "\\u", "buf_", "(_", "len_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "log_", "._", "is", "Enable", "d", "For_", "(_", "logging_", "._", "DEBUG_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "debug_", "(_", "\"", "Deq", "ue", "ing", " ", "packet", " ", "%", "s", ",", " ", "port", " ", "%", "s", "\"_", "%_", "(_", "packet_", ",_", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "switch_", "._", "process", "\\u", "packet_", "(_", "packet_", ",_", "port_", "._", "port", "\\u", "no_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "io", "\\u", "worker_", "._", "set\\u", "receive", "\\u", "handler_", "(_", "\\u", "process", "\\u", "raw", "\\u", "socket", "\\u", "read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "port", "2i", "o", "\\u", "worker_", "[_", "port_", "]_", "=_", "io", "\\u", "worker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Us", "es", " ", "OVS", " ", "to", " ", "route", " ", "bet", "ween", " ", "controlle", "rs", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "of", "\\u", "port_", "=_", "876", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messenger", "\\u", "port_", "=_", "9876", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "create", "\\u", "io", "\\u", "worker_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "create", "\\u", "io", "\\u", "worker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Boot", " ", "up", " ", "PO", "X", "._", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "str_", "(_", "\"\"\"", "./", "po", "x", ".", "py", " ", "openf", "low", ".", "of", "\\u", "01", " ", "--", "address", "=", "127", ".0", ".0", ".1", " ", "--", "port", "=", "%", "d", "\"\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", " ", " ", " ", " ", "messenger", ".", "messenger", " ", "--", "tcp", "\\u", "address", "=", "127", ".0", ".0", ".1", " ", "--", "tcp", "\\u", "port", "=", "%", "d", " ", "\"\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", " ", " ", " ", " ", "sts", "\\u", "of", "\\u", "forward", "er", ".", "sts", "\\u", "of", "\\u", "forward", "er", " ", "\"\"\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "of", "\\u", "port_", ",_", "self_", "._", "messenger", "\\u", "port_", ")_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "po", "x_", "=_", "subprocess_", "._", "Popen_", "(_", "args_", ",_", "cwd_", "=_", "\"./", "po", "x", "/\"_", ",_", "pree", "xec", "\\u", "fn_", "=_", "lambda_", ":_", "os_", "._", "sets", "id_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Esta", "blis", "h", " ", "connecti", "on", " ", "with", " ", "PO", "X", " ", "messenger", " ", "component", "._", "\\u\\u\\uNL\\u\\u\\u_", "true", "\\u", "socket_", "=_", "connect", "\\u", "socket", "\\u", "with", "\\u", "backoff_", "(_", "address_", "=_", "\"", "127", ".0", ".0", ".1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "port_", "=_", "self_", "._", "messenger", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "json", "\\u", "worker_", "=_", "JSO", "NI", "OW", "ork", "er_", "(_", "create", "\\u", "io", "\\u", "worker_", "(_", "true", "\\u", "socket_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sen", "d", " ", "the", " ", "handshake", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "json", "\\u", "worker_", "._", "send_", "(_", "{_", "\"", "sts", "\\u", "connecti", "on", "\"_", ":_", "\"\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "initialize", "\\u", "switch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "send", "\\u", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "b64", "\\u", "pkt_", "=_", "base64", "\\u", "encode_", "(_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "json", "\\u", "worker_", "._", "send_", "(_", "b64", "\\u", "pkt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "create", "\\u", "port", "\\u", "for", "\\u", "controller_", "(_", "self_", ",_", "guest", "\\u", "eth", "\\u", "addr_", ",_", "host", "\\u", "device_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "OVS", "Controlle", "r", "Pat", "ch", "Panel_", "(_", "Controlle", "r", "Pat", "ch", "Panel_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean", "\\u", "up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "json", "\\u", "worker_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "po", "x_", "._", "kill_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", "(", "cs", "):", " ", "these", " ", "proper", "ties", " ", "are", " ", "only", " ", "a", " ", "temporar", "y", " ", "fix", ".", " ", "In", " ", "the", " ", "long", " ", "run", ",", " ", "we", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shou", "ld", " ", "refactor", " ", "interactive", "\\u", "repla", "yer", " ", "to", " ", "use", " ", "its", " ", "own", " ", "help", " ", "options", ",", " ", "distinct_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "interactive", "'", "s", " ", "help", " ", "options", "._", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "controlle", "r", "\\u", "configs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "controlle", "r", "\\u", "configs_", "=_", "controlle", "r", "\\u", "configs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "simulation_", "(_", "self_", ",_", "simulation_", ")_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "kill", "\\u", "all_", "(_", "self_", ")_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "live", "\\u", "controllers_", "(_", "self_", ")_", ":_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "down", "\\u", "controllers_", "(_", "self_", ")_", ":_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "check", "\\u", "controlle", "r", "\\u", "status_", "(_", "self_", ")_", ":_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "all", "\\u", "controlle", "rs", "\\u", "down_", "(_", "self_", ")_", ":_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "boot", "\\u", "mock", "\\u", "controllers_", "(_", "controlle", "r", "\\u", "configs_", ",_", "snapshot", "\\u", "service_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sync", "\\u", "connecti", "on", "\\u", "manager_", ",_", "multiple", "x", "\\u", "sockets_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Moc", "k", "Controlle", "r", "Manager_", "(_", "controlle", "r", "\\u", "configs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "mock", "\\u", "connection_", "(_", "controlle", "r", "\\u", "config_", ",_", "software", "\\u", "switch_", ",_", "max", "\\u", "backoff", "\\u", "seconds_", "=_", "1024_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Connect", "ion", "less", "OF", "Connection_", "(_", "controlle", "r", "\\u", "config_", "._", "cid_", ",_", "software", "\\u", "switch_", "._", "dpid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect", "\\u", "to", "\\u", "mock", "\\u", "controllers_", "(_", "simulation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "simulation_", "._", "topology_", "._", "connect", "\\u", "to", "\\u", "controllers_", "(_", "simulation_", "._", "controlle", "r", "\\u", "manager_", "._", "controlle", "r", "\\u", "configs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "\\u", "connection_", "=_", "create", "\\u", "mock", "\\u", "connection_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
cournape/Bento/bento/backends/waf_tools/f2py.py
[ { "content": "def _interface_gen_callback(task_gen, node, interface_task_name):\n if not hasattr(task_gen, \"name\"):\n module_name = f2py_modulename(node)\n else:\n module_name = task_gen.name\n\n intermediate_output = node.parent.find_or_declare(\"%s.pyf\" % module_name)\n module_node = node.parent.find_or_declare(\"%smodule.c\" % module_name)\n # Guard against overwriting existing source code by accident. Did I say I\n # hate find_or_declare ?\n assert intermediate_output.is_bld()\n assert module_node.is_bld()\n\n interface_task = task_gen.create_task(interface_task_name, node, intermediate_output)\n\n f2py_task = task_gen.create_task('f2py', intermediate_output, module_node)\n add_f2py_tasks(task_gen, f2py_task, module_name, module_node)", "metadata": "root._interface_gen_callback", "header": "['module', '___EOS___']", "index": 109 }, { "content": "@extension('.pyf')\ndef add_f2py_files(task_gen, node):\n ext = '.c'\n\n if not is_pyf(node):\n raise ValueError(\"Gne ?\")\n\n if not hasattr(task_gen, \"name\"):\n module_name = f2py_modulename(node)\n else:\n module_name = task_gen.name\n module_node = node.parent.find_or_declare(\"%smodule.c\" % module_name)\n\n f2py_task = task_gen.create_task('f2py', node, module_node)\n add_f2py_tasks(task_gen, f2py_task, module_name, module_node)", "metadata": "root.add_f2py_files", "header": "['module', '___EOS___']", "index": 142 }, { "content": "@extension('.ipyf')\ndef add_f2py_files(task_gen, node):\n ext = '.pyf'\n\n if not hasattr(task_gen, \"name\"):\n module_name = f2py_modulename(node)\n else:\n module_name = task_gen.name\n intermediate_output = node.parent.find_or_declare(\"%s.pyf\" % module_name)\n assert intermediate_output.is_bld()\n\n if \"f2py_interface\" in task_gen.features:\n interface_task = task_gen.create_task(\"f2py_interface\", node, intermediate_output)\n elif \"f2py_fake_interface\" in task_gen.features:\n interface_task = task_gen.create_task(\"f2py_fake_interface\", node, intermediate_output)\n else:\n raise ValueError(\"You need to use f2py_interface or f2py_fake_interface for .ipyf !\")\n task_gen.source += interface_task.outputs\n #module_node = node.parent.find_or_declare(\"%smodule.c\" % module_name)\n\n #f2py_task = task_gen.create_task('f2py', node, module_node)\n #add_f2py_tasks(task_gen, f2py_task, module_name, module_node)", "metadata": "root.add_f2py_files", "header": "['module', '___EOS___']", "index": 158 } ]
[ { "span": "interface_task ", "start_line": 122, "start_column": 4, "end_line": 122, "end_column": 18 }, { "span": "ext ", "start_line": 144, "start_column": 4, "end_line": 144, "end_column": 7 }, { "span": "ext ", "start_line": 160, "start_column": 4, "end_line": 160, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "interface", "\\u", "gen", "\\u", "callback_", "(_", "task", "\\u", "gen_", ",_", "node_", ",_", "interface", "\\u", "task", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "hasattr_", "(_", "task", "\\u", "gen_", ",_", "\"", "name", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "f2", "py", "\\u", "modulename", "_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "task", "\\u", "gen_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "intermediate", "\\u", "output_", "=_", "node_", "._", "parent_", "._", "find", "\\u", "or", "\\u", "declare_", "(_", "\"%", "s", ".", "pyf", "\"_", "%_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "module", "\\u", "node_", "=_", "node_", "._", "parent_", "._", "find", "\\u", "or", "\\u", "declare_", "(_", "\"%", "smo", "dul", "e", ".", "c", "\"_", "%_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Guard", " ", "against", " ", "overwrit", "ing", " ", "exist", "ing", " ", "source", " ", "code", " ", "by", " ", "accident", ".", " ", "Di", "d", " ", "I", " ", "say", " ", "I_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hat", "e", " ", "find", "\\u", "or", "\\u", "declar", "e", " ", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "intermediate", "\\u", "output_", "._", "is", "\\u", "bld", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "module", "\\u", "node_", "._", "is", "\\u", "bld", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "interface", "\\u", "task_", "=_", "task", "\\u", "gen_", "._", "create", "\\u", "task_", "(_", "interface", "\\u", "task", "\\u", "name_", ",_", "node_", ",_", "intermediate", "\\u", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f2", "py", "\\u", "task_", "=_", "task", "\\u", "gen_", "._", "create", "\\u", "task_", "(_", "'", "f2", "py", "'_", ",_", "intermediate", "\\u", "output_", ",_", "module", "\\u", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "\\u", "f2", "py", "\\u", "tasks_", "(_", "task", "\\u", "gen_", ",_", "f2", "py", "\\u", "task_", ",_", "module", "\\u", "name_", ",_", "module", "\\u", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "extension_", "(_", "'.", "pyf", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "f2", "py", "\\u", "files_", "(_", "task", "\\u", "gen_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ext_", "=_", "'.", "c", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "is", "\\u", "pyf", "_", "(_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "Gn", "e", " ", "?\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "task", "\\u", "gen_", ",_", "\"", "name", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "f2", "py", "\\u", "modulename", "_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "task", "\\u", "gen_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "module", "\\u", "node_", "=_", "node_", "._", "parent_", "._", "find", "\\u", "or", "\\u", "declare_", "(_", "\"%", "smo", "dul", "e", ".", "c", "\"_", "%_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f2", "py", "\\u", "task_", "=_", "task", "\\u", "gen_", "._", "create", "\\u", "task_", "(_", "'", "f2", "py", "'_", ",_", "node_", ",_", "module", "\\u", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "\\u", "f2", "py", "\\u", "tasks_", "(_", "task", "\\u", "gen_", ",_", "f2", "py", "\\u", "task_", ",_", "module", "\\u", "name_", ",_", "module", "\\u", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "extension_", "(_", "'.", "ipy", "f", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "f2", "py", "\\u", "files_", "(_", "task", "\\u", "gen_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ext_", "=_", "'.", "pyf", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "task", "\\u", "gen_", ",_", "\"", "name", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "f2", "py", "\\u", "modulename", "_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", "=_", "task", "\\u", "gen_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "intermediate", "\\u", "output_", "=_", "node_", "._", "parent_", "._", "find", "\\u", "or", "\\u", "declare_", "(_", "\"%", "s", ".", "pyf", "\"_", "%_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "intermediate", "\\u", "output_", "._", "is", "\\u", "bld", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\"", "f2", "py", "\\u", "interface", "\"_", "in_", "task", "\\u", "gen_", "._", "features_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "interface", "\\u", "task_", "=_", "task", "\\u", "gen_", "._", "create", "\\u", "task_", "(_", "\"", "f2", "py", "\\u", "interface", "\"_", ",_", "node_", ",_", "intermediate", "\\u", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "\"", "f2", "py", "\\u", "fake", "\\u", "interface", "\"_", "in_", "task", "\\u", "gen_", "._", "features_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "interface", "\\u", "task_", "=_", "task", "\\u", "gen_", "._", "create", "\\u", "task_", "(_", "\"", "f2", "py", "\\u", "fake", "\\u", "interface", "\"_", ",_", "node_", ",_", "intermediate", "\\u", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "You", " ", "need", " ", "to", " ", "use", " ", "f2", "py", "\\u", "interface", " ", "or", " ", "f2", "py", "\\u", "fake", "\\u", "interface", " ", "for", " ", ".", "ipy", "f", " ", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "task", "\\u", "gen_", "._", "source_", "+=_", "interface", "\\u", "task_", "._", "outputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "module", "\\u", "node", " ", "=", " ", "node", ".", "parent", ".", "find", "\\u", "or", "\\u", "declar", "e", "(\"", "%", "smo", "dul", "e", ".", "c", "\"", " ", "%", " ", "module", "\\u", "name", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "f2", "py", "\\u", "task", " ", "=", " ", "task", "\\u", "gen", ".", "create", "\\u", "task", "('", "f2", "py", "',", " ", "node", ",", " ", "module", "\\u", "node", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "add", "\\u", "f2", "py", "\\u", "task", "s", "(", "task", "\\u", "gen", ",", " ", "f2", "py", "\\u", "task", ",", " ", "module", "\\u", "name", ",", " ", "module", "\\u", "node", ")_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
twisted/nevow/nevow/flat/flatsax.py
[ { "content": " def endElementNS(self, name, qname):\n me = self.stack.pop()\n if self.stack:\n self.current = self.stack[-1].children\n else:\n self.current = self.document", "metadata": "root.ToStan.endElementNS", "header": "['class', 'ToStan', '(', 'handler', '.', 'ContentHandler', ',', 'handler', '.', 'EntityResolver', ')', ':', '___EOS___']", "index": 193 } ]
[ { "span": "me ", "start_line": 194, "start_column": 8, "end_line": 194, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "To", "Stan", "_", "(_", "handler_", "._", "Conten", "t", "Handler_", ",_", "handler_", "._", "Entit", "y", "Resolver_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "end", "Element", "NS_", "(_", "self_", ",_", "name_", ",_", "qname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "me_", "=_", "self_", "._", "stack_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "stack_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "current_", "=_", "self_", "._", "stack_", "[_", "-_", "1_", "]_", "._", "children_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "current_", "=_", "self_", "._", "document_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
sdiehl/numpush/tests/test_splice.py
[ { "content": "import _multiprocessing\n#from unittest2 import skip\n\nimport sys\nimport os\nimport socket\nsys.path.append(os.getcwd())\nfrom numpush.posix_io.splice import \\\n posix_splice, \\\n posix_splice_thread, \\\n posix_splice_sockets, \\\n SPLICE_MORE, SPLICE_MOVE\n\nDATA= 'a'*1024\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_single():\n os.mkfifo('w')\n os.mkfifo('r')\n\n try:\n w = open('w', 'w+')\n r = open('r', 'a+')\n\n w.write(DATA)\n w.flush()\n\n flags = SPLICE_MORE | SPLICE_MOVE\n posix_splice(w, r, 1024, flags)\n\n assert r.read(1024) == DATA\n\n finally:\n os.unlink('w')\n os.unlink('r')", "metadata": "root.test_single", "header": "['module', '___EOS___']", "index": 15 }, { "content": "def test_multithreaded():\n os.mkfifo('w')\n os.mkfifo('r')\n\n try:\n w = open('w', 'w+')\n r = open('r', 'a+')\n\n w.write(DATA)\n w.flush()\n\n flags = SPLICE_MORE | SPLICE_MOVE\n thread = posix_splice_thread(w, r, 1024, flags)\n thread.join()\n assert r.read(1024) == DATA\n\n finally:\n os.unlink('w')\n os.unlink('r')", "metadata": "root.test_multithreaded", "header": "['module', '___EOS___']", "index": 35 } ]
[ { "span": "import _multiprocessing", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 23 }, { "span": "import socket", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 13 }, { "span": "from numpush.posix_io.splice import \\\n posix_splice, \\\n posix_splice_thread, \\\n posix_splice_sockets, \\\n SPLICE_MORE, SPLICE_MOVE", "start_line": 7, "start_column": 0, "end_line": 11, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "\\u", "multiprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "from", " ", "unittest", "2", " ", "import", " ", "skip_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "os_", "._", "getcwd_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nump", "ush_", "._", "posix", "\\u", "io_", "._", "splice", "_", "import_", "posix", "\\u", "splice", "_", ",_", "posix", "\\u", "splice", "\\u", "thread_", ",_", "posix", "\\u", "splice", "\\u", "sockets_", ",_", "SPL", "ICE", "\\u", "MOR", "E_", ",_", "SPL", "ICE", "\\u", "MOVE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DATA_", "=_", "'", "a", "'_", "*_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "single_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkf", "ifo", "_", "(_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "mkf", "ifo", "_", "(_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "w_", "=_", "open_", "(_", "'", "w", "'_", ",_", "'", "w", "+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "open_", "(_", "'", "r", "'_", ",_", "'", "a", "+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "w_", "._", "write_", "(_", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "flags_", "=_", "SPL", "ICE", "\\u", "MOR", "E_", "|_", "SPL", "ICE", "\\u", "MOVE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "posix", "\\u", "splice", "_", "(_", "w_", ",_", "r_", ",_", "1024_", ",_", "flags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "r_", "._", "read_", "(_", "1024_", ")_", "==_", "DATA_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "unlink_", "(_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "unlink_", "(_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "multit", "hread", "ed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkf", "ifo", "_", "(_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "mkf", "ifo", "_", "(_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "w_", "=_", "open_", "(_", "'", "w", "'_", ",_", "'", "w", "+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "open_", "(_", "'", "r", "'_", ",_", "'", "a", "+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "w_", "._", "write_", "(_", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "flags_", "=_", "SPL", "ICE", "\\u", "MOR", "E_", "|_", "SPL", "ICE", "\\u", "MOVE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thread_", "=_", "posix", "\\u", "splice", "\\u", "thread_", "(_", "w_", ",_", "r_", ",_", "1024_", ",_", "flags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thread_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "r_", "._", "read_", "(_", "1024_", ")_", "==_", "DATA_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "unlink_", "(_", "'", "w", "'_", ")_", "\\u\\u\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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
rizar/attention-lvcsr/libs/Theano/theano/sandbox/cuda/tests/test_mlp.py
[ { "content": "def test_run_nnet_med():\n utt.seed_rng()\n rval_cpu = run_nnet(False, 10, 128, 50, 4, n_train=10000)", "metadata": "root.test_run_nnet_med", "header": "['module', '___EOS___']", "index": 154 }, { "content": "def test_run_nnet_small():\n utt.seed_rng()\n rval_cpu = run_nnet(False, 10, 10, 4, 4, n_train=100000)", "metadata": "root.test_run_nnet_small", "header": "['module', '___EOS___']", "index": 159 }, { "content": "def run_conv_nnet2_classif(use_gpu, seed, isize, ksize, bsize,\n n_train=10,\n check_isfinite=True,\n pickle=False,\n verbose=0,\n version=-1):\n \"\"\"Run the train function returned by build_conv_nnet2_classif on one device.\n \"\"\"\n\n utt.seed_rng(seed) # Seeds numpy.random with seed\n train, params, x_shape, y_shape, mode = build_conv_nnet2_classif(\n use_gpu=use_gpu,\n isize=isize,\n ksize=ksize,\n n_batch=bsize,\n verbose=verbose,\n version=version,\n check_isfinite=check_isfinite)\n\n if use_gpu:\n device = 'GPU'\n else:\n device = 'CPU'\n\n xval = my_rand(*x_shape)\n yval = my_rand(*y_shape)\n lr = theano._asarray(0.01, dtype='float32')\n\n rvals = my_zeros(n_train)\n t0 = time.time()\n for i in xrange(n_train):\n rvals[i] = train(xval, yval, lr)[0]\n t1 = time.time()\n print_mode(mode)\n\n if pickle and isinstance(mode, theano.compile.ProfileMode):\n import pickle\n print(\"BEGIN %s profile mode dump\" % device)\n print(pickle.dumps(mode))\n print(\"END %s profile mode dump\" % device)\n\n # print \"%s time: %.3f\" % (device, t1-t0)\n # print \"estimated time for one pass through MNIST with %s: %f\" % (\n # device, (t1-t0) * (60000.0 / (n_train*bsize)))", "metadata": "root.run_conv_nnet2_classif", "header": "['module', '___EOS___']", "index": 413 } ]
[ { "span": "rval_cpu ", "start_line": 156, "start_column": 4, "end_line": 156, "end_column": 12 }, { "span": "rval_cpu ", "start_line": 161, "start_column": 4, "end_line": 161, "end_column": 12 }, { "span": "t0 ", "start_line": 442, "start_column": 4, "end_line": 442, "end_column": 6 }, { "span": "t1 ", "start_line": 445, "start_column": 4, "end_line": 445, "end_column": 6 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "run", "\\u", "nnet", "\\u", "med_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "utt", "_", "._", "seed", "\\u", "rng_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval", "\\u", "cpu_", "=_", "run", "\\u", "nnet", "_", "(_", "False_", ",_", "10_", ",_", "128_", ",_", "50_", ",_", "4_", ",_", "n", "\\u", "train_", "=_", "10000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "run", "\\u", "nnet", "\\u", "small_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "utt", "_", "._", "seed", "\\u", "rng_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval", "\\u", "cpu_", "=_", "run", "\\u", "nnet", "_", "(_", "False_", ",_", "10_", ",_", "10_", ",_", "4_", ",_", "4_", ",_", "n", "\\u", "train_", "=_", "100000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "conv", "\\u", "nnet", "2", "\\u", "classif", "_", "(_", "use", "\\u", "gpu_", ",_", "seed_", ",_", "isi", "ze_", ",_", "ksize_", ",_", "bsi", "ze_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "train_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "check", "\\u", "isfinite_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pickle_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verbose_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Run", " ", "the", " ", "train", " ", "function", " ", "return", "ed", " ", "by", " ", "build", "\\u", "conv", "\\u", "nnet", "2", "\\u", "classif", " ", "on", " ", "one", " ", "device", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "utt", "_", "._", "seed", "\\u", "rng_", "(_", "seed_", ")_", "#", " ", "See", "ds", " ", "nump", "y", ".", "random", " ", "with", " ", "seed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train_", ",_", "params_", ",_", "x", "\\u", "shape_", ",_", "y", "\\u", "shape_", ",_", "mode_", "=_", "build", "\\u", "conv", "\\u", "nnet", "2", "\\u", "classif", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "gpu_", "=_", "use", "\\u", "gpu_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "isi", "ze_", "=_", "isi", "ze_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ksize_", "=_", "ksize_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "batch_", "=_", "bsi", "ze_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "verbose_", "=_", "verbose_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "version_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "check", "\\u", "isfinite_", "=_", "check", "\\u", "isfinite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "use", "\\u", "gpu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "device_", "=_", "'", "GPU", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "device_", "=_", "'", "CPU", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "xval", "_", "=_", "my", "\\u", "rand_", "(_", "*_", "x", "\\u", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yval", "_", "=_", "my", "\\u", "rand_", "(_", "*_", "y", "\\u", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lr_", "=_", "theano_", "._", "\\u", "asarray_", "(_", "0.01_", ",_", "dtype_", "=_", "'", "float", "32", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval", "s_", "=_", "my", "\\u", "zeros_", "(_", "n", "\\u", "train_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t0_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "n", "\\u", "train_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rval", "s_", "[_", "i_", "]_", "=_", "train_", "(_", "xval", "_", ",_", "yval", "_", ",_", "lr_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print", "\\u", "mode_", "(_", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "pickle_", "and_", "isinstance_", "(_", "mode_", ",_", "theano_", "._", "compile_", "._", "Profil", "e", "Mode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "BEGIN", " ", "%", "s", " ", "profile", " ", "mode", " ", "dump", "\"_", "%_", "device_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "pickle_", "._", "dumps_", "(_", "mode_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "END", " ", "%", "s", " ", "profile", " ", "mode", " ", "dump", "\"_", "%_", "device_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "\"%", "s", " ", "time", ":", " ", "%", ".3", "f", "\"", " ", "%", " ", "(", "device", ",", " ", "t1", "-", "t0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "\"", "estimate", "d", " ", "time", " ", "for", " ", "one", " ", "pass", " ", "through", " ", "MNIST", " ", "with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variable
bolme/pyvision/src/pyvision/util/fast_util.py
[ { "content": " def __call__(self, mat, threshold = None, sort_results = True):\n '''\n All any local maximum that are greater than threshhold up to a total of \n max_length.\n \n To save time arrays that hold the maxes and vals that are created \n once and reused for each call. This means that local maximum detection\n is not thread safe. If using this class with threads create an instance\n for each thread.\n \n @param mat: 2d Real Matrix input.\n @param threshold: Mininum value of local maxima.\n @param sort_results: set to False to save time and return an unorderd list.\n \n @returns: maxes,vals\n '''\n maxes = self.maxes\n vals = self.vals\n r,c = mat.shape\n max_length = self.max_length\n \n if threshold != None:\n count = weave.inline(\n ''' \n int count = 0;\n \n for( int i = 1; i < r-1 ; i++){\n for(int j = 1; j < c-1 ; j++){\n // Check if the current location meets the threshold\n \n if (mat(i,j) > threshold &&\n mat(i,j) > mat(i,j-1) &&\n mat(i,j) > mat(i,j+1) &&\n mat(i,j) > mat(i-1,j-1) &&\n mat(i,j) > mat(i-1,j) &&\n mat(i,j) > mat(i-1,j+1) &&\n mat(i,j) > mat(i+1,j-1) &&\n mat(i,j) > mat(i+1,j) &&\n mat(i,j) > mat(i+1,j+1)){\n \n // This is a local max\n maxes(count,0) = i;\n maxes(count,1) = j;\n vals(count) = mat(i,j);\n count += 1;\n \n if(count == max_length){\n i = r;\n j = c;\n }\n } \n }\n }\n \n return_val = count;\n ''',\n arg_names=['mat','maxes','vals','max_length','threshold','r','c'],\n type_converters=weave.converters.blitz,\n )\n else:\n count = weave.inline(\n ''' \n int count = 0;\n \n for( int i = 1; i < r-1 ; i++){\n for(int j = 1; j < c-1 ; j++){\n // Check if the current location meets the threshold\n \n if (mat(i,j) > mat(i,j-1) &&\n mat(i,j) > mat(i,j+1) &&\n mat(i,j) > mat(i-1,j-1) &&\n mat(i,j) > mat(i-1,j) &&\n mat(i,j) > mat(i-1,j+1) &&\n mat(i,j) > mat(i+1,j-1) &&\n mat(i,j) > mat(i+1,j) &&\n mat(i,j) > mat(i+1,j+1)){\n \n // This is a local max\n maxes(count,0) = i;\n maxes(count,1) = j;\n vals(count) = mat(i,j);\n count += 1;\n \n if(count == max_length){\n i = r;\n j = c;\n }\n } \n }\n }\n \n return_val = count;\n ''',\n arg_names=['mat','maxes','vals','max_length','r','c'],\n type_converters=weave.converters.blitz,\n )\n \n if sort_results == False:\n return maxes[:count,:].copy(),vals[:count].copy()\n \n order = np.argsort(vals[:count])[::-1]\n maxes = maxes[order]\n vals = vals[order]\n \n #print vals\n #print maxes\n \n return maxes,vals", "metadata": "root.LocalMaximumDetector.__call__", "header": "['class', 'LocalMaximumDetector', ':', '___EOS___']", "index": 10 } ]
[ { "span": "r,", "start_line": 28, "start_column": 8, "end_line": 28, "end_column": 9 }, { "span": "c ", "start_line": 28, "start_column": 10, "end_line": 28, "end_column": 11 }, { "span": "max_length ", "start_line": 29, "start_column": 8, "end_line": 29, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Local", "Maxim", "um", "Detector_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "call\\u\\u_", "(_", "self_", ",_", "mat_", ",_", "threshold_", "=_", "None_", ",_", "sort", "\\u", "results_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "All", " ", "any", " ", "local", " ", "maxim", "um", " ", "tha", "t", " ", "are", " ", "great", "er", " ", "than", " ", "thresh", "hold", " ", "up", " ", "to", " ", "a", " ", "total", " ", "of", " ", "\\", "10", ";", " ", " ", " ", " ", "max", "\\u", "length", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "save", " ", "time", " ", "arrays", " ", "tha", "t", " ", "hold", " ", "the", " ", "maxe", "s", " ", "and", " ", "vals", " ", "tha", "t", " ", "are", " ", "created", " ", "\\", "10", ";", " ", " ", " ", " ", "onc", "e", " ", "and", " ", "reus", "ed", " ", "for", " ", "each", " ", "call", ".", " ", " ", "Thi", "s", " ", "means", " ", "tha", "t", " ", "local", " ", "maxim", "um", " ", "detect", "ion", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "not", " ", "thread", " ", "safe", ".", " ", "If", " ", "usi", "ng", " ", "this", " ", "class", " ", "with", " ", "thread", "s", " ", "create", " ", "an", " ", "instance", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "each", " ", "thread", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "mat", ":", " ", "2d", " ", "Real", " ", "Matrix", " ", "input", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "threshol", "d", ":", " ", "Mini", "num", " ", "value", " ", "of", " ", "local", " ", "maxim", "a", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "sort", "\\u", "results", ":", " ", "set", " ", "to", " ", "Fal", "se", " ", "to", " ", "save", " ", "time", " ", "and", " ", "return", " ", "an", " ", "uno", "rder", "d", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "@", "return", "s", ":", " ", "maxe", "s", ",", "vals", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "maxe", "s_", "=_", "self_", "._", "maxe", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "self_", "._", "vals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", ",_", "c_", "=_", "mat_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "length_", "=_", "self_", "._", "max", "\\u", "length_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "threshold_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "=_", "weave", "_", "._", "inline_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "count", " ", "=", " ", "0", ";", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "for", "(", " ", "int", " ", "i", " ", "=", " ", "1", ";", " ", "i", " ", "<", " ", "r", "-1", " ", ";", " ", "i", "++", "){", "\\", "10", ";", " ", " ", "for", "(", "int", " ", "j", " ", "=", " ", "1", ";", " ", "j", " ", "<", " ", "c", "-1", " ", ";", " ", "j", "++", "){", "\\", "10", ";", " ", " ", "//", " ", "Check", " ", "if", " ", "the", " ", "current", " ", "location", " ", "meet", "s", " ", "the", " ", "threshol", "d", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", "if", " ", "(", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "threshol", "d", " ", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", ",", "j", "-1", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", ",", "j", "+", "1", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", "-1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", "+", "1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", "-1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", "+", "1", "))", "{", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "//", " ", "Thi", "s", " ", "is", " ", "a", " ", "local", " ", "max", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "maxe", "s", "(", "count", ",", "0", ")", " ", "=", " ", "i", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "maxe", "s", "(", "count", ",", "1", ")", " ", "=", " ", "j", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "vals", "(", "count", ")", " ", "=", " ", "mat", "(", "i", ",", "j", ");", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "count", " ", "+=", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "if", "(", "count", " ", "==", " ", "max", "\\u", "length", "){", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "i", " ", "=", " ", "r", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "j", " ", "=", " ", "c", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", "}", " ", " ", " ", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "return", "\\u", "val", " ", "=", " ", "count", ";", "\\", "10", ";", " ", " ", " ", " ", "'''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "arg", "\\u", "names_", "=_", "[_", "'", "mat", "'_", ",_", "'", "maxe", "s", "'_", ",_", "'", "vals", "'_", ",_", "'", "max", "\\u", "length", "'_", ",_", "'", "threshol", "d", "'_", ",_", "'", "r", "'_", ",_", "'", "c", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type", "\\u", "converters_", "=_", "weave", "_", "._", "converters_", "._", "blit", "z_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "=_", "weave", "_", "._", "inline_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "count", " ", "=", " ", "0", ";", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "for", "(", " ", "int", " ", "i", " ", "=", " ", "1", ";", " ", "i", " ", "<", " ", "r", "-1", " ", ";", " ", "i", "++", "){", "\\", "10", ";", " ", " ", "for", "(", "int", " ", "j", " ", "=", " ", "1", ";", " ", "j", " ", "<", " ", "c", "-1", " ", ";", " ", "j", "++", "){", "\\", "10", ";", " ", " ", "//", " ", "Check", " ", "if", " ", "the", " ", "current", " ", "location", " ", "meet", "s", " ", "the", " ", "threshol", "d", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", "if", " ", "(", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", ",", "j", "-1", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", ",", "j", "+", "1", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", "-1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "-1", ",", "j", "+", "1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", "-1", ")", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", ")", " ", " ", " ", "&&", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "mat", "(", "i", ",", "j", ")", " ", ">", " ", "mat", "(", "i", "+", "1", ",", "j", "+", "1", "))", "{", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "//", " ", "Thi", "s", " ", "is", " ", "a", " ", "local", " ", "max", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "maxe", "s", "(", "count", ",", "0", ")", " ", "=", " ", "i", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "maxe", "s", "(", "count", ",", "1", ")", " ", "=", " ", "j", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "vals", "(", "count", ")", " ", "=", " ", "mat", "(", "i", ",", "j", ");", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "count", " ", "+=", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "if", "(", "count", " ", "==", " ", "max", "\\u", "length", "){", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "i", " ", "=", " ", "r", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "j", " ", "=", " ", "c", ";", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", "}", " ", " ", " ", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "return", "\\u", "val", " ", "=", " ", "count", ";", "\\", "10", ";", " ", " ", " ", " ", "'''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "arg", "\\u", "names_", "=_", "[_", "'", "mat", "'_", ",_", "'", "maxe", "s", "'_", ",_", "'", "vals", "'_", ",_", "'", "max", "\\u", "length", "'_", ",_", "'", "r", "'_", ",_", "'", "c", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type", "\\u", "converters_", "=_", "weave", "_", "._", "converters_", "._", "blit", "z_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sort", "\\u", "results_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "maxe", "s_", "[_", ":_", "count_", ",_", ":_", "]_", "._", "copy_", "(_", ")_", ",_", "vals_", "[_", ":_", "count_", "]_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "order_", "=_", "np_", "._", "argsort_", "(_", "vals_", "[_", ":_", "count_", "]_", ")_", "[_", ":_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "maxe", "s_", "=_", "maxe", "s_", "[_", "order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vals_", "=_", "vals_", "[_", "order_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "vals_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "maxe", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "maxe", "s_", ",_", "vals_" ]
[ 4, 4, 4, 4, 4, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
signalfx/maestro-ng/tests/unittests.py
[ { "content": " def test_ship_endpoint(self):\n ship = entities.Ship('foo', '10.0.0.1', '192.168.10.1')\n self.assertEqual(ship.name, 'foo')\n self.assertEqual(ship.ip, '10.0.0.1')\n self.assertEqual(ship.endpoint, '192.168.10.1')\n self.assertTrue(ship.endpoint in ship.backend.base_url)", "metadata": "root.ShipTest.test_ship_endpoint", "header": "['class', 'ShipTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 29 }, { "content": " def test_log_config_default(self):\n self.assertTrue(\"LogConfig\" not in self._cntr().host_config)", "metadata": "root.ContainerTest.test_log_config_default", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 129 }, { "content": " def test_log_config_syslog(self):\n container = self._cntr(config={'log_driver': 'syslog'})\n self.assertTrue(\"LogConfig\" in container.host_config)\n self.assertEqual(container.host_config['LogConfig'],\n {'Type': 'syslog', 'Config': {}})", "metadata": "root.ContainerTest.test_log_config_syslog", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 132 }, { "content": " def test_log_config_syslog_with_opts(self):\n container = self._cntr(config={'log_driver': 'syslog', 'log_opt': {\n 'syslog-address': 'tcp://127.0.0.1:514'\n }})\n self.assertTrue(\"LogConfig\" in container.host_config)\n self.assertEqual(container.host_config['LogConfig'], {\n 'Type': 'syslog', 'Config': {\n 'syslog-address': 'tcp://127.0.0.1:514'\n }})", "metadata": "root.ContainerTest.test_log_config_syslog_with_opts", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 138 }, { "content": " def test_log_config_converts_options_to_string(self):\n container = self._cntr(config={'log_driver': 'json-file', 'log_opt': {\n 'max-size': '2M', 'max-file': 2\n }})\n self.assertTrue(\"LogConfig\" in container.host_config)\n self.assertEqual(len(container.host_config['LogConfig']['Config']), 2)\n for value in container.host_config['LogConfig']['Config'].values():\n self.assertTrue(isinstance(value, six.string_types))", "metadata": "root.ContainerTest.test_log_config_converts_options_to_string", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 159 }, { "content": " def test_volumes_simple_bind(self):\n container = self._cntr(config={'volumes': {'/outside': '/inside'}})\n self.assertTrue('/outside' in container.volumes)\n self.assertEqual(container.volumes,\n {'/outside': {'bind': '/inside'}})", "metadata": "root.ContainerTest.test_volumes_simple_bind", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 208 }, { "content": " def test_volumes_dict_bind_no_mode(self):\n container = self._cntr(config={'volumes': {\n '/outside': {'target': '/inside'}}})\n self.assertTrue('/outside' in container.volumes)\n self.assertEqual(container.volumes,\n {'/outside': {'bind': '/inside', 'mode': 'rw'}})", "metadata": "root.ContainerTest.test_volumes_dict_bind_no_mode", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 214 }, { "content": " def test_volumes_ro_bind(self):\n container = self._cntr(config={'volumes': {\n '/outside': {\n 'target': '/inside', 'mode': 'ro'\n }}})\n self.assertTrue('/outside' in container.volumes)\n self.assertEqual(container.volumes,\n {'/outside': {'bind': '/inside', 'mode': 'ro'}})", "metadata": "root.ContainerTest.test_volumes_ro_bind", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 221 }, { "content": " def test_volumes_bind_with_mode(self):\n container = self._cntr(config={'volumes': {\n '/outside': {\n 'target': '/inside', 'mode': 'ro,Z'\n }}})\n self.assertTrue('/outside' in container.volumes)\n self.assertEqual(container.volumes,\n {'/outside': {'bind': '/inside', 'mode': 'ro,Z'}})", "metadata": "root.ContainerTest.test_volumes_bind_with_mode", "header": "['class', 'ContainerTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 230 }, { "content": " def test_ship_parsing(self):\n config = self._get_config('test_ships')\n c = maestro.Conductor(config)\n self.assertEqual(c.ships['ship1'].ip, '10.0.0.1')\n self.assertEqual(c.ships['ship1'].endpoint, '192.168.10.1')\n self.assertTrue('192.168.10.1' in c.ships['ship1'].backend.base_url)\n\n self.assertEqual(c.ships['ship2'].ip, '10.0.0.2')\n self.assertEqual(c.ships['ship2'].endpoint, '10.0.0.2')\n self.assertTrue('1234' in c.ships['ship2'].backend.base_url)", "metadata": "root.ConfigTest.test_ship_parsing", "header": "['class', 'ConfigTest', '(', 'BaseConfigFileUsingTest', ')', ':', '___EOS___']", "index": 343 } ]
[ { "span": "self.assertTrue(ship.endpoint in ship.backend.base_url)", "start_line": 34, "start_column": 8, "end_line": 34, "end_column": 63 }, { "span": "self.assertTrue(\"LogConfig\" not in self._cntr().host_config)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 68 }, { "span": "self.assertTrue(\"LogConfig\" in container.host_config)", "start_line": 134, "start_column": 8, "end_line": 134, "end_column": 61 }, { "span": "self.assertTrue(\"LogConfig\" in container.host_config)", "start_line": 142, "start_column": 8, "end_line": 142, "end_column": 61 }, { "span": "self.assertTrue(\"LogConfig\" in container.host_config)", "start_line": 163, "start_column": 8, "end_line": 163, "end_column": 61 }, { "span": "self.assertTrue('/outside' in container.volumes)", "start_line": 210, "start_column": 8, "end_line": 210, "end_column": 56 }, { "span": "self.assertTrue('/outside' in container.volumes)", "start_line": 217, "start_column": 8, "end_line": 217, "end_column": 56 }, { "span": "self.assertTrue('/outside' in container.volumes)", "start_line": 226, "start_column": 8, "end_line": 226, "end_column": 56 }, { "span": "self.assertTrue('/outside' in container.volumes)", "start_line": 235, "start_column": 8, "end_line": 235, "end_column": 56 }, { "span": "self.assertTrue('192.168.10.1' in c.ships['ship1'].backend.base_url)", "start_line": 348, "start_column": 8, "end_line": 348, "end_column": 76 }, { "span": "self.assertTrue('1234' in c.ships['ship2'].backend.base_url)", "start_line": 352, "start_column": 8, "end_line": 352, "end_column": 68 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Ship", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ship", "\\u", "endpoint_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ship_", "=_", "entities_", "._", "Ship", "_", "(_", "'", "foo", "'_", ",_", "'", "10.", "0.", "0.", "1", "'_", ",_", "'", "192", ".1", "68.", "10.1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ship_", "._", "name_", ",_", "'", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ship_", "._", "ip_", ",_", "'", "10.", "0.", "0.", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ship_", "._", "endpoint_", ",_", "'", "192", ".1", "68.", "10.1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ship_", "._", "endpoint_", "in_", "ship_", "._", "backend_", "._", "base", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "log", "\\u", "config", "\\u", "default_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "\"", "Log", "Config", "\"_", "not_", "in_", "self_", "._", "\\u", "cntr", "_", "(_", ")_", "._", "host", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "log", "\\u", "config", "\\u", "syslog_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "log", "\\u", "driver", "'_", ":_", "'", "syslo", "g", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Log", "Config", "\"_", "in_", "container_", "._", "host", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "host", "\\u", "config_", "[_", "'", "Log", "Config", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "Type", "'_", ":_", "'", "syslo", "g", "'_", ",_", "'", "Config", "'_", ":_", "{_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "log", "\\u", "config", "\\u", "syslo", "g", "\\u", "with", "\\u", "opts_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "log", "\\u", "driver", "'_", ":_", "'", "syslo", "g", "'_", ",_", "'", "log", "\\u", "opt", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "syslo", "g", "-", "address", "'_", ":_", "'", "tcp", "://", "127", ".0", ".0", ".1", ":", "514", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Log", "Config", "\"_", "in_", "container_", "._", "host", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "host", "\\u", "config_", "[_", "'", "Log", "Config", "'_", "]_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Type", "'_", ":_", "'", "syslo", "g", "'_", ",_", "'", "Config", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "syslo", "g", "-", "address", "'_", ":_", "'", "tcp", "://", "127", ".0", ".0", ".1", ":", "514", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "log", "\\u", "config", "\\u", "convert", "s", "\\u", "options", "\\u", "to", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "log", "\\u", "driver", "'_", ":_", "'", "json", "-", "file", "'_", ",_", "'", "log", "\\u", "opt", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "-", "size", "'_", ":_", "'", "2", "M", "'_", ",_", "'", "max", "-", "file", "'_", ":_", "2_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Log", "Config", "\"_", "in_", "container_", "._", "host", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "container_", "._", "host", "\\u", "config_", "[_", "'", "Log", "Config", "'_", "]_", "[_", "'", "Config", "'_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "container_", "._", "host", "\\u", "config_", "[_", "'", "Log", "Config", "'_", "]_", "[_", "'", "Config", "'_", "]_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "value_", ",_", "six_", "._", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "volume", "s", "\\u", "simple", "\\u", "bind_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "volume", "s", "'_", ":_", "{_", "'/", "outsi", "de", "'_", ":_", "'/", "insi", "de", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'/", "outsi", "de", "'_", "in_", "container_", "._", "volumes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "volumes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'/", "outsi", "de", "'_", ":_", "{_", "'", "bind", "'_", ":_", "'/", "insi", "de", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "volume", "s", "\\u", "dict", "\\u", "bind", "\\u", "no", "\\u", "mode_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "volume", "s", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'/", "outsi", "de", "'_", ":_", "{_", "'", "target", "'_", ":_", "'/", "insi", "de", "'_", "}_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'/", "outsi", "de", "'_", "in_", "container_", "._", "volumes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "volumes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'/", "outsi", "de", "'_", ":_", "{_", "'", "bind", "'_", ":_", "'/", "insi", "de", "'_", ",_", "'", "mode", "'_", ":_", "'", "rw", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "volume", "s", "\\u", "ro", "\\u", "bind_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "volume", "s", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'/", "outsi", "de", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "target", "'_", ":_", "'/", "insi", "de", "'_", ",_", "'", "mode", "'_", ":_", "'", "ro", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'/", "outsi", "de", "'_", "in_", "container_", "._", "volumes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "volumes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'/", "outsi", "de", "'_", ":_", "{_", "'", "bind", "'_", ":_", "'/", "insi", "de", "'_", ",_", "'", "mode", "'_", ":_", "'", "ro", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Containe", "r", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "volume", "s", "\\u", "bind", "\\u", "with", "\\u", "mode_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "container_", "=_", "self_", "._", "\\u", "cntr", "_", "(_", "config_", "=_", "{_", "'", "volume", "s", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'/", "outsi", "de", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "target", "'_", ":_", "'/", "insi", "de", "'_", ",_", "'", "mode", "'_", ":_", "'", "ro", ",", "Z", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'/", "outsi", "de", "'_", "in_", "container_", "._", "volumes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "container_", "._", "volumes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'/", "outsi", "de", "'_", ":_", "{_", "'", "bind", "'_", ":_", "'/", "insi", "de", "'_", ",_", "'", "mode", "'_", ":_", "'", "ro", ",", "Z", "'_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config", "Test_", "(_", "Base", "Config", "File", "Us", "ing", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ship", "\\u", "parsing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config_", "=_", "self_", "._", "\\u", "get", "\\u", "config_", "(_", "'", "test\\u", "ships", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "mae", "stro", "_", "._", "Conduct", "or_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "ships_", "[_", "'", "ship", "1", "'_", "]_", "._", "ip_", ",_", "'", "10.", "0.", "0.", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "ships_", "[_", "'", "ship", "1", "'_", "]_", "._", "endpoint_", ",_", "'", "192", ".1", "68.", "10.1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "192", ".1", "68.", "10.1", "'_", "in_", "c_", "._", "ships_", "[_", "'", "ship", "1", "'_", "]_", "._", "backend_", "._", "base", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "ships_", "[_", "'", "ship", "2", "'_", "]_", "._", "ip_", ",_", "'", "10.", "0.", "0.", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "ships_", "[_", "'", "ship", "2", "'_", "]_", "._", "endpoint_", ",_", "'", "10.", "0.", "0.", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "1234", "'_", "in_", "c_", "._", "ships_", "[_", "'", "ship", "2", "'_", "]_", "._", "backend_", "._", "base", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused local variable
dossier/dossier.models/dossier/models/openquery/fetcher.py
[ { "content": " def get_async(self, urls, callback):\n def get(url, headers):\n resp = requests.get(url, headers=headers)\n if resp:\n si = self.process_response(resp)\n callback(si, resp.url)\n\n @asyncio.coroutine\n def run(urls, concurrency, loop):\n urls = list(urls)\n pending = [loop.run_in_executor(None, get, url, self.headers) for url in urls[:concurrency]]\n rest = urls[concurrency:]\n while pending:\n done, pending = yield asyncio.From(asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED))\n while rest and len(pending) < concurrency:\n pending.add(loop.run_in_executor(None, get, rest.pop(), self.headers))\n for future in done:\n try:\n si = future.result()\n # callback(si, si.original_url)\n except Exception:\n logger.info('failed on url', exc_info=True)\n\n loop = asyncio.get_event_loop()\n # TODO: make magic concurrency number a parameter\n loop.run_until_complete(run(urls, concurrency=32, loop=loop)) ", "metadata": "root.Fetcher.get_async", "header": "['class', 'Fetcher', '(', 'object', ')', ':', '___EOS___']", "index": 29 } ]
[ { "span": "si ", "start_line": 47, "start_column": 24, "end_line": 47, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Fetcher_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "async_", "(_", "self_", ",_", "urls_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "get_", "(_", "url_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resp_", "=_", "requests_", "._", "get_", "(_", "url_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "resp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "si_", "=_", "self_", "._", "process", "\\u", "response_", "(_", "resp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callback_", "(_", "si_", ",_", "resp_", "._", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "asyncio_", "._", "coroutine_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "run_", "(_", "urls_", ",_", "concurrency", "_", ",_", "loop_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urls_", "=_", "list_", "(_", "urls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pending_", "=_", "[_", "loop_", "._", "run", "\\u", "in", "\\u", "executor_", "(_", "None_", ",_", "get_", ",_", "url_", ",_", "self_", "._", "headers_", ")_", "for_", "url_", "in_", "urls_", "[_", ":_", "concurrency", "_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rest_", "=_", "urls_", "[_", "concurrency", "_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "pending_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "done_", ",_", "pending_", "=_", "yield_", "asyncio_", "._", "From_", "(_", "asyncio_", "._", "wait_", "(_", "pending_", ",_", "return", "\\u", "when_", "=_", "asyncio_", "._", "FIR", "ST", "\\u", "COMPLETED", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "rest_", "and_", "len_", "(_", "pending_", ")_", "<_", "concurrency", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pending_", "._", "add_", "(_", "loop_", "._", "run", "\\u", "in", "\\u", "executor_", "(_", "None_", ",_", "get_", ",_", "rest_", "._", "pop_", "(_", ")_", ",_", "self_", "._", "headers_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "future_", "in_", "done_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "si_", "=_", "future_", "._", "result_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "callback", "(", "si", ",", " ", "si", ".", "original", "\\u", "url", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "logger_", "._", "info_", "(_", "'", "fail", "ed", " ", "on", " ", "url", "'_", ",_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "loop_", "=_", "asyncio_", "._", "get", "\\u", "event", "\\u", "loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "make", " ", "magic", " ", "concurrency", " ", "number", " ", "a", " ", "parameter_", "\\u\\u\\uNL\\u\\u\\u_", "loop_", "._", "run", "\\u", "unti", "l\\u", "complete_", "(_", "run_", "(_", "urls_", ",_", "concurrency", "_", "=_", "32_", ",_", "loop_", "=_", "loop_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
ImageEngine/gaffer/python/GafferRenderManTest/RenderManShaderTest.py
[ { "content": "\tdef testSerialisation( self ) :\n\n\t\ts = Gaffer.ScriptNode()\n\t\ts[\"n\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"n\"].loadShader( \"plastic\" )\n\n\t\tss = s.serialise()\n\n\t\ts = Gaffer.ScriptNode()\n\t\ts.execute( ss )\n\n\t\tst = s[\"n\"].state()\n\t\tself.assertEqual( len( st ), 1 )\n\n\t\tself.assertEqual( st[0].type, \"ri:surface\" )\n\t\tself.assertEqual( st[0].name, \"plastic\" )\n\n\t\tself.failUnless( isinstance( s[\"n\"][\"parameters\"][\"Ks\"], Gaffer.FloatPlug ) )\n\t\tself.failUnless( isinstance( s[\"n\"][\"parameters\"][\"Kd\"], Gaffer.FloatPlug ) )\n\t\tself.failUnless( isinstance( s[\"n\"][\"parameters\"][\"Ka\"], Gaffer.FloatPlug ) )\n\t\tself.failUnless( isinstance( s[\"n\"][\"parameters\"][\"roughness\"], Gaffer.FloatPlug ) )\n\t\tself.failUnless( isinstance( s[\"n\"][\"parameters\"][\"specularcolor\"], Gaffer.Color3fPlug ) )\n\n\t\tself.assertTrue( \"parameters1\" not in s[\"n\"] )", "metadata": "root.RenderManShaderTest.testSerialisation", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 73 }, { "content": "\tdef testCoshaderHash( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderParameter.sl\" )\n\n\t\tshaderNode = GafferRenderMan.RenderManShader()\n\t\tshaderNode.loadShader( shader )\n\n\t\tself.assertTrue( \"coshaderParameter\" in shaderNode[\"parameters\"] )\n\t\tself.assertEqual( shaderNode[\"parameters\"][\"coshaderParameter\"].typeId(), Gaffer.Plug.staticTypeId() )\n\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\tcoshaderNode = GafferRenderMan.RenderManShader()\n\t\tcoshaderNode.loadShader( coshader )\n\n\t\tshaderNode[\"parameters\"][\"coshaderParameter\"].setInput( coshaderNode[\"out\"] )\n\n\t\th1 = shaderNode.stateHash()\n\n\t\tcoshaderNode[\"parameters\"][\"floatParameter\"].setValue( 0.25 )\n\n\t\tself.assertNotEqual( shaderNode.stateHash(), h1 )", "metadata": "root.RenderManShaderTest.testCoshaderHash", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 124 }, { "content": "\tdef testCoshader( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderParameter.sl\" )\n\n\t\tshaderNode = GafferRenderMan.RenderManShader()\n\t\tshaderNode.loadShader( shader )\n\n\t\tself.assertTrue( \"coshaderParameter\" in shaderNode[\"parameters\"] )\n\t\tself.assertEqual( shaderNode[\"parameters\"][\"coshaderParameter\"].typeId(), Gaffer.Plug.staticTypeId() )\n\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\tcoshaderNode = GafferRenderMan.RenderManShader()\n\t\tcoshaderNode.loadShader( coshader )\n\n\t\tshaderNode[\"parameters\"][\"coshaderParameter\"].setInput( coshaderNode[\"out\"] )\n\n\t\ts = shaderNode.state()\n\t\tself.assertEqual( len( s ), 2 )\n\n\t\tself.assertEqual( s[0].name, coshader )\n\t\tself.assertEqual( s[1].name, shader )\n\t\tself.assertEqual( s[0].parameters[\"__handle\"], s[1].parameters[\"coshaderParameter\"] )", "metadata": "root.RenderManShaderTest.testCoshader", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 164 }, { "content": "\tdef testDisablingCoshaders( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderParameter.sl\" )\n\n\t\tshaderNode = GafferRenderMan.RenderManShader()\n\t\tshaderNode.loadShader( shader )\n\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\tcoshaderNode = GafferRenderMan.RenderManShader()\n\t\tcoshaderNode.loadShader( coshader )\n\n\t\tshaderNode[\"parameters\"][\"coshaderParameter\"].setInput( coshaderNode[\"out\"] )\n\n\t\ts = shaderNode.state()\n\t\tself.assertEqual( len( s ), 2 )\n\n\t\tself.assertEqual( s[0].name, coshader )\n\t\tself.assertEqual( s[1].name, shader )\n\n\t\th = shaderNode.stateHash()\n\n\t\tcoshaderNode[\"enabled\"].setValue( False )\n\n\t\ts2 = shaderNode.state()\n\t\tself.assertEqual( len( s2 ), 1 )\n\n\t\tself.assertEqual( s2[0].name, shader )\n\t\tself.assertTrue( \"coshaderParameter\" not in s2[0].parameters )\n\n\t\tself.assertNotEqual( shaderNode.stateHash(), h )", "metadata": "root.RenderManShaderTest.testDisablingCoshaders", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 583 }, { "content": "\tdef testDynamicCoshaderArrayParameters( self ) :\n\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\t\tcoshaderNode = GafferRenderMan.RenderManShader()\n\t\tcoshaderNode.loadShader( coshader )\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParameters.sl\" )\n\t\tshaderNode = GafferRenderMan.RenderManShader()\n\t\tshaderNode.loadShader( shader )\n\n\t\tself.assertEqual( len( shaderNode[\"parameters\"][\"dynamicShaderArray\"] ), 1 )\n\t\tself.assertTrue( isinstance( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0], Gaffer.Plug ) )\n\t\tself.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0].getInput() is None )\n\n\t\tshaderNode[\"parameters\"][\"dynamicShaderArray\"][0].setInput( coshaderNode[\"out\"] )\n\n\t\tself.assertEqual( len( shaderNode[\"parameters\"][\"dynamicShaderArray\"] ), 2 )\n\t\tself.assertTrue( isinstance( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0], Gaffer.Plug ) )\n\t\tself.assertTrue( isinstance( shaderNode[\"parameters\"][\"dynamicShaderArray\"][1], Gaffer.Plug ) )\n\t\tself.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0].getInput().isSame( coshaderNode[\"out\"] ) )\n\t\tself.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )\n\n\t\tshaderNode[\"parameters\"][\"dynamicShaderArray\"][0].setInput( None )\n\n\t\tself.assertEqual( len( shaderNode[\"parameters\"][\"dynamicShaderArray\"] ), 1 )\n\t\tself.assertTrue( isinstance( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0], Gaffer.Plug ) )\n\t\tself.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0].getInput() is None )", "metadata": "root.RenderManShaderTest.testDynamicCoshaderArrayParameters", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1105 }, { "content": "\tdef testSerialiseDynamicCoshaderArrayParameters( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParameters.sl\" )\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\ts = Gaffer.ScriptNode()\n\n\t\ts[\"n\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"n\"].loadShader( shader )\n\n\t\ts[\"c\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"c\"].loadShader( coshader )\n\n\t\ts[\"n\"][\"parameters\"][\"dynamicShaderArray\"][0].setInput( s[\"c\"][\"out\"] )\n\t\ts[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].setInput( s[\"c\"][\"out\"] )\n\t\ts[\"n\"][\"parameters\"][\"dynamicShaderArray\"][2].setInput( s[\"c\"][\"out\"] )\n\t\ts[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].setInput( None )\n\n\t\tself.assertEqual( len( s[\"n\"][\"parameters\"][\"dynamicShaderArray\"] ), 4 )\n\n\t\ts2 = Gaffer.ScriptNode()\n\t\ts2.execute( s.serialise() )\n\n\t\tself.assertEqual( len( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"] ), 4 )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][0].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][2].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][3].getInput() is None )\n\n\t\ts2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][3].setInput( s2[\"c\"][\"out\"] )\n\n\t\tself.assertEqual( len( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"] ), 5 )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][0].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][2].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][3].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][4].getInput() is None )", "metadata": "root.RenderManShaderTest.testSerialiseDynamicCoshaderArrayParameters", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1133 }, { "content": "\tdef testConvertFixedCoshaderArrayToDynamic( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParameters.sl\" )\n\t\tshaderV2 = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParametersV2.sl\" )\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\ts = Gaffer.ScriptNode()\n\n\t\ts[\"n\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"n\"].loadShader( shader )\n\n\t\ts[\"c\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"c\"].loadShader( coshader )\n\n\t\ts[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].setInput( s[\"c\"][\"out\"] )\n\t\tself.assertTrue( len( s[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 4 )\n\n\t\ts[\"n\"].loadShader( shaderV2, keepExistingValues = True )\n\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput().isSame( s[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].getInput() is None )\n\n\t\ts[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].setInput( None )\n\n\t\tself.assertEqual( len( s[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 1 )\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "metadata": "root.RenderManShaderTest.testConvertFixedCoshaderArrayToDynamic", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1171 }, { "content": "\tdef testConvertFixedCoshaderArrayToDynamicWithFirstPlugUnconnected( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParameters.sl\" )\n\t\tshaderV2 = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParametersV2.sl\" )\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\ts = Gaffer.ScriptNode()\n\n\t\ts[\"n\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"n\"].loadShader( shader )\n\n\t\ts[\"c\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"c\"].loadShader( coshader )\n\n\t\ts[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].setInput( s[\"c\"][\"out\"] )\n\t\tself.assertTrue( len( s[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 4 )\n\n\t\ts[\"n\"].loadShader( shaderV2, keepExistingValues = True )\n\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].getInput().isSame( s[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )\n\n\t\ts[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].setInput( None )\n\n\t\tself.assertEqual( len( s[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 1 )\n\t\tself.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "metadata": "root.RenderManShaderTest.testConvertFixedCoshaderArrayToDynamicWithFirstPlugUnconnected", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1198 }, { "content": "\tdef testConvertFixedCoshaderArrayToDynamicDuringLoading( self ) :\n\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParameters.sl\" )\n\t\tcoshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\n\t\ts = Gaffer.ScriptNode()\n\n\t\ts[\"n\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"n\"].loadShader( shader )\n\n\t\ts[\"c\"] = GafferRenderMan.RenderManShader()\n\t\ts[\"c\"].loadShader( coshader )\n\n\t\ts[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].setInput( s[\"c\"][\"out\"] )\n\t\tself.assertTrue( len( s[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 4 )\n\n\t\tGafferRenderMan.RenderManShader.shaderLoader().clear()\n\t\tshader = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderArrayParametersV2.sl\", shaderName = \"coshaderArrayParameters\" )\n\n\t\ts2 = Gaffer.ScriptNode()\n\t\ts2.execute( s.serialise() )\n\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].getInput().isSame( s2[\"c\"][\"out\"] ) )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )\n\n\t\ts2[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].setInput( None )\n\n\t\tself.assertEqual( len( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"] ), 1 )\n\t\tself.assertTrue( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "metadata": "root.RenderManShaderTest.testConvertFixedCoshaderArrayToDynamicDuringLoading", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1225 }, { "content": "\tdef testHandlesAreHumanReadable( self ) :\n\n\t\ts1 = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshader.sl\" )\n\t\ts2 = self.compileShader( os.path.dirname( __file__ ) + \"/shaders/coshaderParameter.sl\" )\n\n\t\tsn1 = GafferRenderMan.RenderManShader( \"Shader1\" )\n\t\tsn2 = GafferRenderMan.RenderManShader( \"Shader2\" )\n\t\tsn1.loadShader( s1 )\n\t\tsn2.loadShader( s2 )\n\n\t\tsn2[\"parameters\"][\"coshaderParameter\"].setInput( sn1[\"out\"] )\n\n\t\tstate = sn2.state()\n\t\tself.assertTrue( \"Shader1\" in state[0].parameters[\"__handle\"].value )", "metadata": "root.RenderManShaderTest.testHandlesAreHumanReadable", "header": "['class', 'RenderManShaderTest', '(', 'GafferRenderManTest', '.', 'RenderManTestCase', ')', ':', '___EOS___']", "index": 1484 } ]
[ { "span": "self.assertTrue( \"parameters1\" not in s[\"n\"] )", "start_line": 96, "start_column": 2, "end_line": 96, "end_column": 48 }, { "span": "self.assertTrue( \"coshaderParameter\" in shaderNode[\"parameters\"] )", "start_line": 131, "start_column": 2, "end_line": 131, "end_column": 68 }, { "span": "self.assertTrue( \"coshaderParameter\" in shaderNode[\"parameters\"] )", "start_line": 171, "start_column": 2, "end_line": 171, "end_column": 68 }, { "span": "self.assertTrue( \"coshaderParameter\" not in s2[0].parameters )", "start_line": 611, "start_column": 2, "end_line": 611, "end_column": 64 }, { "span": "self.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0].getInput() is None )", "start_line": 1117, "start_column": 2, "end_line": 1117, "end_column": 89 }, { "span": "self.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )", "start_line": 1125, "start_column": 2, "end_line": 1125, "end_column": 89 }, { "span": "self.assertTrue( shaderNode[\"parameters\"][\"dynamicShaderArray\"][0].getInput() is None )", "start_line": 1131, "start_column": 2, "end_line": 1131, "end_column": 89 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )", "start_line": 1158, "start_column": 2, "end_line": 1158, "end_column": 86 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][3].getInput() is None )", "start_line": 1160, "start_column": 2, "end_line": 1160, "end_column": 86 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][1].getInput() is None )", "start_line": 1166, "start_column": 2, "end_line": 1166, "end_column": 86 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"dynamicShaderArray\"][4].getInput() is None )", "start_line": 1169, "start_column": 2, "end_line": 1169, "end_column": 86 }, { "span": "self.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][1].getInput() is None )", "start_line": 1191, "start_column": 2, "end_line": 1191, "end_column": 83 }, { "span": "self.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "start_line": 1196, "start_column": 2, "end_line": 1196, "end_column": 83 }, { "span": "self.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "start_line": 1218, "start_column": 2, "end_line": 1218, "end_column": 83 }, { "span": "self.assertTrue( s[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "start_line": 1223, "start_column": 2, "end_line": 1223, "end_column": 83 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "start_line": 1248, "start_column": 2, "end_line": 1248, "end_column": 84 }, { "span": "self.assertTrue( s2[\"n\"][\"parameters\"][\"fixedShaderArray\"][0].getInput() is None )", "start_line": 1253, "start_column": 2, "end_line": 1253, "end_column": 84 }, { "span": "self.assertTrue( \"Shader1\" in state[0].parameters[\"__handle\"].value )", "start_line": 1497, "start_column": 2, "end_line": 1497, "end_column": 71 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Seriali", "sation", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "\"", "plas", "tic", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ss_", "=_", "s_", "._", "serial", "ise_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "execute_", "(_", "ss_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "st_", "=_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "state_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "st_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "st_", "[_", "0_", "]_", "._", "type_", ",_", "\"", "ri", ":", "surf", "ace", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "st_", "[_", "0_", "]_", "._", "name_", ",_", "\"", "plas", "tic", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "fail", "Unless_", "(_", "isinstance_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "Ks", "\"_", "]_", ",_", "Ga", "ffer", "_", "._", "Float", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail", "Unless_", "(_", "isinstance_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "Kd", "\"_", "]_", ",_", "Ga", "ffer", "_", "._", "Float", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail", "Unless_", "(_", "isinstance_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "Ka", "\"_", "]_", ",_", "Ga", "ffer", "_", "._", "Float", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail", "Unless_", "(_", "isinstance_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "rough", "ness", "\"_", "]_", ",_", "Ga", "ffer", "_", "._", "Float", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail", "Unless_", "(_", "isinstance_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "specular", "color", "\"_", "]_", ",_", "Ga", "ffer", "_", "._", "Color", "3f", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "parameter", "s1", "\"_", "not_", "in_", "s_", "[_", "\"", "n", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Cos", "had", "er", "Hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Parameter", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "Node_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "cos", "had", "er", "Parameter", "\"_", "in_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "type", "Id_", "(_", ")_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", "._", "static", "Type", "Id_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er", "Node_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "set", "Input_", "(_", "cos", "had", "er", "Node_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h1_", "=_", "shade", "r", "Node_", "._", "state", "Hash_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "float", "Parameter", "\"_", "]_", "._", "set", "Value_", "(_", "0.25_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Not", "Equal_", "(_", "shade", "r", "Node_", "._", "state", "Hash_", "(_", ")_", ",_", "h1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Cos", "had", "er_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Parameter", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "Node_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "cos", "had", "er", "Parameter", "\"_", "in_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "type", "Id_", "(_", ")_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", "._", "static", "Type", "Id_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er", "Node_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "set", "Input_", "(_", "cos", "had", "er", "Node_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "shade", "r", "Node_", "._", "state_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "0_", "]_", "._", "name_", ",_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "1_", "]_", "._", "name_", ",_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "0_", "]_", "._", "parameters_", "[_", "\"\\u\\u", "handle", "\"_", "]_", ",_", "s_", "[_", "1_", "]_", "._", "parameters_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Disa", "blin", "g", "Cos", "had", "ers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Parameter", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "Node_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er", "Node_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "set", "Input_", "(_", "cos", "had", "er", "Node_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "shade", "r", "Node_", "._", "state_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "0_", "]_", "._", "name_", ",_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "[_", "1_", "]_", "._", "name_", ",_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "h_", "=_", "shade", "r", "Node_", "._", "state", "Hash_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "had", "er", "Node_", "[_", "\"", "enable", "d", "\"_", "]_", "._", "set", "Value_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s2_", "=_", "shade", "r", "Node_", "._", "state_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s2_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s2_", "[_", "0_", "]_", "._", "name_", ",_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "cos", "had", "er", "Parameter", "\"_", "not_", "in_", "s2_", "[_", "0_", "]_", "._", "parameters_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Not", "Equal_", "(_", "shade", "r", "Node_", "._", "state", "Hash_", "(_", ")_", ",_", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Dynamic", "Cos", "had", "er", "Array", "Parameters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er", "Node_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "Node_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "Node_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "set", "Input_", "(_", "cos", "had", "er", "Node_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "cos", "had", "er", "Node_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "set", "Input_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", ",_", "Ga", "ffer", "_", "._", "Plug", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "shade", "r", "Node_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Seriali", "se", "Dynamic", "Cos", "had", "er", "Array", "Parameters_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "2_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s2_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s2_", "._", "execute_", "(_", "s_", "._", "serial", "ise_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "2_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "3_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "3_", "]_", "._", "set", "Input_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", ")_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "2_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "3_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "dynami", "c", "Shader", "Array", "\"_", "]_", "[_", "4_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Convert", "Fix", "ed", "Cos", "had", "er", "Array", "To", "Dynamic", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "V2_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", "V2", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shade", "r", "V2_", ",_", "keep", "Exist", "ing", "Values_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "set", "Input_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Convert", "Fix", "ed", "Cos", "had", "er", "Array", "To", "Dynamic", "With", "Fi", "rst", "Plug", "Unco", "nnect", "ed_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shade", "r", "V2_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", "V2", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shade", "r", "V2_", ",_", "keep", "Exist", "ing", "Values_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Convert", "Fix", "ed", "Cos", "had", "er", "Array", "To", "Dynamic", "Dur", "ing", "Load", "ing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "had", "er_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "._", "load", "Shader", "_", "(_", "shader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "[_", "\"", "c", "\"_", "]_", "._", "load", "Shader", "_", "(_", "cos", "had", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "s_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "s_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "._", "shade", "r", "Loader_", "(_", ")_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shader_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Array", "Parameter", "s", "V2", ".", "sl", "\"_", ",_", "shade", "r", "Name_", "=_", "\"", "cos", "had", "er", "Array", "Parameter", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s2_", "=_", "Ga", "ffer", "_", "._", "Script", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s2_", "._", "execute_", "(_", "s_", "._", "serial", "ise_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "get", "Input_", "(_", ")_", "._", "is", "Sam", "e_", "(_", "s2_", "[_", "\"", "c", "\"_", "]_", "[_", "\"", "out", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "1_", "]_", "._", "set", "Input_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s2_", "[_", "\"", "n", "\"_", "]_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "fixed", "Shader", "Array", "\"_", "]_", "[_", "0_", "]_", "._", "get", "Input_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Render", "Man", "Shader", "Test_", "(_", "Ga", "ffer", "Render", "Man", "Test_", "._", "Render", "Man", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Handle", "s", "Are", "Huma", "n", "Read", "able_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s1_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s2_", "=_", "self_", "._", "compile", "Shader", "_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "+_", "\"/", "shade", "rs", "/", "cos", "had", "er", "Parameter", ".", "sl", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sn", "1_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", "\"", "Shader", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sn", "2_", "=_", "Ga", "ffer", "Render", "Man", "_", "._", "Render", "Man", "Shader", "_", "(_", "\"", "Shader", "2", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sn", "1_", "._", "load", "Shader", "_", "(_", "s1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sn", "2_", "._", "load", "Shader", "_", "(_", "s2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sn", "2_", "[_", "\"", "parameter", "s", "\"_", "]_", "[_", "\"", "cos", "had", "er", "Parameter", "\"_", "]_", "._", "set", "Input_", "(_", "sn", "1_", "[_", "\"", "out", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "state_", "=_", "sn", "2_", "._", "state_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Shader", "1", "\"_", "in_", "state_", "[_", "0_", "]_", "._", "parameters_", "[_", "\"\\u\\u", "handle", "\"_", "]_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
XiaoMi/minos/owl/alert/management/commands/alert.py
[ { "content": "import ConfigParser\nimport argparse\nimport datetime\nimport json\nimport logging\nimport os\nimport smtplib\nimport sys\nimport time\nimport utils.mail\n\nimport deploy_utils\n\nfrom optparse import make_option\nfrom os import path\n\nfrom django.conf import settings\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django.utils import timezone\n\nfrom monitor.models import Status, Service, Cluster, Job, Task\n\nBOOL_METRIC_MAP = {\n \"tag.IsOutOfSync\": \"true\",\n \"tag.HAState\": \"active\",\n}\n\nSTATUS_FILE_PATH = 'cluster.status'\n# alert when cluster is not OK for ERROR_TIMES_FOR_ALERT\nERROR_TIMES_FOR_ALERT = 3\n\nlogger = logging.getLogger(__name__)\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class CollectorConfig:\n class Service:\n def __init__(self, options, config, name):\n # Parse service config.\n self.name = name\n self.jobs = config.get(name, \"jobs\").split()\n self.clusters = {}\n for cluster_name in config.get(name, \"clusters\").split():\n args = argparse.Namespace()\n args.service = self.name\n args.cluster = cluster_name\n # Parse cluster config.\n self.clusters[cluster_name] = deploy_utils.get_service_config(args)\n self.metric_url = config.get(name, \"metric_url\")\n\n", "metadata": "root.CollectorConfig", "header": "['module', '___EOS___']", "index": 33 }, { "content": " def __init__(self, args, options):\n # Parse collector config.\n config_path = os.path.join(deploy_utils.get_config_dir(), 'owl/collector.cfg')\n self.args = args\n self.options = options\n self.config = self.parse_config_file(config_path)\n self.services = {}\n for service_name in self.config.get(\"collector\", \"services\").split():\n self.services[service_name] = CollectorConfig.Service(\n options, self.config, service_name)\n self.period = self.config.getint(\"collector\", \"period\")", "metadata": "root.CollectorConfig.__init__", "header": "['class', 'CollectorConfig', ':', '___EOS___']", "index": 48 }, { "content": " def parse_config_file(self, config_path):\n config_parser = ConfigParser.SafeConfigParser()\n config_parser.optionxform = str\n logger.info(\"Parsing config file: %s\", config_path)\n if not config_parser.read(config_path):\n logger.critical(\"Can't parse config file: %s\", config_path)\n sys.exit(1)\n logger.info(\"Successfully parsed config file\")\n return config_parser", "metadata": "root.CollectorConfig.parse_config_file", "header": "['class', 'CollectorConfig', ':', '___EOS___']", "index": 60 }, { "content": "class StatusChecker:\n \"\"\"Check status of all active clusters and jobs, which are inferred from\n tasks' status.\"\"\"\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.StatusChecker", "header": "['module', '___EOS___']", "index": 70 }, { "content": " def __init__(self, collector_config, last_status, options, mailer):\n self.collector_config = collector_config\n self.last_status = last_status\n self.options = options\n self.alert_msg = ''\n self.mailer = mailer", "metadata": "root.StatusChecker.__init__", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 74 }, { "content": " def get_latest_metric(self, task, group_name, metric_name):\n try:\n metric = json.loads(task.last_metrics)\n return metric[group_name][metric_name]\n except Exception as e:\n logger.warning(\"%r failed to get metric: %r\", task, e)\n return 0", "metadata": "root.StatusChecker.get_latest_metric", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 81 }, { "content": " def is_namenode_active(self, task):\n try:\n metric = self.get_latest_metric(\n task, \"Hadoop:service=NameNode,name=FSNamesystem\", \"tag.HAState\")\n return bool(metric)\n except Exception as e:\n logger.warning(\"%r failed to get metric: %r\", task, e)\n return False", "metadata": "root.StatusChecker.is_namenode_active", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 89 }, { "content": " def is_master_active(self, task):\n try:\n metric = self.get_latest_metric(\n task, \"hadoop:service=Master,name=Master\", \"IsActiveMaster\")\n return bool(metric)\n except Exception as e:\n logger.warning(\"%r failed to get metric: %r\", task, e)\n return False", "metadata": "root.StatusChecker.is_master_active", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 98 }, { "content": " def check_hdfs_cluster_status(self, cluster):\n job = cluster.jobs[\"journalnode\"]\n if (job.running_tasks_count < 2 or\n job.running_tasks_count < (job.total_tasks_count / 2 + 1)):\n job.last_status = Status.ERROR\n job.last_message = \"Too few running journalnodes!\"\n\n job = cluster.jobs[\"namenode\"]\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No running namenodes!\"\n else:\n active = 0\n for task in job.running_tasks.itervalues():\n if self.is_namenode_active(task):\n # update cluster entry\n cluster.entry = '%s:%d' % (task.host, task.port)\n cluster.version = self.get_latest_metric(task,\n 'Hadoop:service=NameNode,name=NameNodeInfo',\n 'Version')\n active += 1\n if active > 1:\n job.last_status = Status.ERROR\n job.last_message = \"Too many active namenodes!\"\n elif active < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No active namenodes!\"\n elif job.running_tasks_count < 2:\n job.last_status = Status.WARN\n job.last_message = \"Less than 2 running namenodes, no HA guarantee\"\n\n job = cluster.jobs[\"datanode\"]\n if job.running_tasks_count < 3:\n job.last_status = Status.ERROR\n job.last_message = \"Too few running datanodes!\"\n cluster.last_status = max([job.last_status for job in cluster.jobs.itervalues()])", "metadata": "root.StatusChecker.check_hdfs_cluster_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 107 }, { "content": " def check_hbase_cluster_status(self, cluster):\n job = cluster.jobs[\"master\"]\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No running masters!\"\n else:\n active = 0\n for task in job.running_tasks.itervalues():\n if self.is_master_active(task):\n # update cluster entry\n cluster.entry = '%s:%d' % (task.host, task.port)\n version = self.get_latest_metric(task,\n 'hadoop:service=HBase,name=Info',\n 'version')\n revision = self.get_latest_metric(task,\n 'hadoop:service=HBase,name=Info',\n 'revision')\n cluster.version = '%s, r%s' % (version, revision)\n active += 1\n if active > 1:\n job.last_status = Status.ERROR\n job.last_message = \"Too many active masters!\"\n elif active < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No active masters!\"\n elif job.running_tasks_count < 2:\n # TODO: Now it always reports warning as backup master doesn't run a http\n # server before it acquires zk lock. Comment this out and would change\n # master's startup workflow.\n #job.last_status = Status.WARN\n #job.last_message = \"Less than 2 running masters, no HA guarantee\"\n pass\n\n job = cluster.jobs[\"regionserver\"]\n if job.running_tasks_count < 3:\n job.last_status = Status.ERROR\n job.last_message = \"Too few running regionservers!\"\n cluster.last_status = max([job.last_status for job in cluster.jobs.itervalues()])", "metadata": "root.StatusChecker.check_hbase_cluster_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 144 }, { "content": " def check_yarn_cluster_status(self, cluster):\n job = cluster.jobs[\"resourcemanager\"]\n for task in job.running_tasks.itervalues():\n # update cluster entry\n cluster.entry = '%s:%d' % (task.host, task.port)\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No running resourcemanager!\"\n\n job = cluster.jobs[\"proxyserver\"]\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No running proxyserver!\"\n\n job = cluster.jobs[\"nodemanager\"]\n if job.running_tasks_count < 3:\n job.last_status = Status.ERROR\n job.last_message = \"Too few running nodemanager!\"\n cluster.last_status = max([job.last_status for job in cluster.jobs.itervalues()])\n\n job = cluster.jobs[\"historyserver\"]\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"Too few running historyserver!\"\n cluster.last_status = max([job.last_status for job in cluster.jobs.itervalues()])", "metadata": "root.StatusChecker.check_yarn_cluster_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 183 }, { "content": " def check_impala_cluster_status(self, cluster):\n job = cluster.jobs[\"statestored\"]\n for task in job.running_tasks.itervalues():\n # update cluster entry\n cluster.entry = '%s:%d' % (task.host, task.port)\n if job.running_tasks_count < 1:\n job.last_status = Status.ERROR\n job.last_message = \"No running statestored!\"\n\n job = cluster.jobs[\"impalad\"]\n if job.running_tasks_count < 3:\n job.last_status = Status.ERROR\n job.last_message = \"Too few running impalad!\"\n cluster.last_status = max([job.last_status for job in cluster.jobs.itervalues()])", "metadata": "root.StatusChecker.check_impala_cluster_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 209 }, { "content": " def check_cluster_status(self, cluster):\n cluster.jobs = {}\n cluster.last_status = Status.OK\n cluster.last_message = \"\"\n\n for job in cluster.job_set.all():\n job.running_tasks = {}\n job.tasks = {}\n job.last_status = Status.OK\n job.last_message = \"\"\n job.running_tasks_count = 0\n job.total_tasks_count = 0\n for task in job.task_set.filter(active=True):\n if task.health:\n job.running_tasks[task.id] = task\n job.running_tasks_count += 1\n job.total_tasks_count += 1\n cluster.jobs[job.name] = job\n\n service_handler = {\n \"hdfs\": self.check_hdfs_cluster_status,\n \"hbase\": self.check_hbase_cluster_status,\n \"yarn\": self.check_yarn_cluster_status,\n \"impala\": self.check_impala_cluster_status,\n }\n service_handler[cluster.service.name](cluster)\n self.handle_status_result(cluster)", "metadata": "root.StatusChecker.check_cluster_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 224 }, { "content": " def handle_status_result(self, cluster):\n # last_status store cluster_name->(status, status_times)\n (cluster_status, status_times) = self.last_status.setdefault(str(cluster), (Status.OK, 0))\n need_send_alert = False\n\n if cluster.last_status != cluster_status:\n self.last_status[str(cluster)] = (cluster.last_status, 1)\n if cluster.last_status == Status.OK and status_times >= ERROR_TIMES_FOR_ALERT:\n # send alert when cluster changed to from PROBLEM(alerted) to OK\n need_send_alert = True\n else:\n self.last_status[str(cluster)] = (cluster.last_status, status_times+1)\n # send alert when cluster in PROBLEM stutus reached ERROR_TIMES_FOR_ALERT times\n if cluster.last_status != Status.OK and status_times + 1 == ERROR_TIMES_FOR_ALERT:\n need_send_alert = True\n\n if need_send_alert:\n self.alert_msg += '[%s]Cluster[%s]\\n' \\\n % ('OK' if cluster.last_status == Status.OK else 'PROBLEM',\n cluster)\n for job in cluster.jobs.itervalues():\n if job.last_status != Status.OK:\n self.alert_msg += 'Job[%s] not healthy: %s\\n' % (job.name, job.last_message)\n self.alert_msg += '******\\n'", "metadata": "root.StatusChecker.handle_status_result", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 252 }, { "content": " def check_status(self):\n self.alert_msg = ''\n logger.info(\"checking clusters status\")\n\n self.start_time = time.time()\n for cluster in Cluster.objects.filter(active=True).all():\n self.check_cluster_status(cluster)\n logger.info(\"spent %f seconds for updating clusters status\",\n time.time() - self.start_time)\n if self.alert_msg:\n logger.warn('alert msg: %r' % self.alert_msg)\n self.mailer.send_email(subject = 'OWL cluster alert',\n content = self.alert_msg,\n to_email = self.options['to_email'])\n json.dump(self.last_status, open(STATUS_FILE_PATH, 'w'))", "metadata": "root.StatusChecker.check_status", "header": "['class', 'StatusChecker', ':', '___EOS___']", "index": 278 }, { "content": "class Command(BaseCommand):\n args = ''\n help = \"Run the background collector to fetch metrics from /jmx on each server.\"\n\n option_list = BaseCommand.option_list + (\n make_option(\n \"--to_email\",\n help=\"Email address to\"),\n make_option(\n \"--period\",\n default=60,\n help=\"Check period\"),\n )\n", "metadata": "root.Command", "header": "['module', '___EOS___']", "index": 294 }, { "content": " def handle(self, *args, **options):\n self.args = args\n self.options = options\n self.mailer = utils.mail.Mailer(options)\n\n self.stdout.write(\"args: %r\\n\" % (args, ))\n self.stdout.write(\"options: %r\\n\" % options)\n\n self.collector_config = CollectorConfig(self.args, self.options)\n\n self.last_status = {}\n try:\n self.last_status = json.load(open(STATUS_FILE_PATH, 'r'))\n except Exception as e:\n logger.warning('Failed to load status file: %r', e)\n\n status_checker = StatusChecker(self.collector_config,\n self.last_status,\n self.options,\n self.mailer)\n\n while True:\n try:\n status_checker.check_status()\n except Exception as e:\n logger.warning('OWL cluster checker error: %r', e)\n # send alert email when program got error\n admin_email = ''\n try:\n admin_email = settings.ADMINS[0][1]\n except:\n pass\n self.mailer.send_email(subject = 'OWL cluster check error',\n content = repr(e),\n to_email = admin_email,\n )\n time.sleep(int(self.options['period']))", "metadata": "root.Command.handle", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 308 } ]
[ { "span": "import datetime", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 15 }, { "span": "import smtplib", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 14 }, { "span": "from os import path", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 19 }, { "span": "from django.core.management.base import BaseCommand, CommandError", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 65 }, { "span": "from django.utils import timezone", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 33 }, { "span": "from monitor.models import Status, Service, Cluster, Job, Task", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 62 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "Config", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "smtplib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "utils_", "._", "mail_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "deploy", "\\u", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "optparse_", "import_", "make", "\\u", "option_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "import_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "management_", "._", "base_", "import_", "Base", "Command_", ",_", "Command", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "timezone_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "monitor_", "._", "models_", "import_", "Status_", ",_", "Service_", ",_", "Cluster_", ",_", "Job_", ",_", "Task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "BOO", "L", "\\u", "METRIC", "\\u", "MAP_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "tag", ".", "Is", "Out", "Of", "Sync", "\"_", ":_", "\"", "true", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "tag", ".", "HAS", "tate", "\"_", ":_", "\"", "active", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "STATUS", "\\u", "FILE", "\\u", "PATH_", "=_", "'", "cluster", ".", "status", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "alert", " ", "whe", "n", " ", "cluster", " ", "is", " ", "not", " ", "OK", " ", "for", " ", "ERROR", "\\u", "TIMES", "\\u", "FOR", "\\u", "ALERT", "_", "\\u\\u\\uNL\\u\\u\\u_", "ERROR", "\\u", "TIMES", "\\u", "FOR", "\\u", "ALERT", "_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Collect", "or", "Config_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Service_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "options_", ",_", "config_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pars", "e", " ", "service", " ", "config", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "jobs_", "=_", "config_", "._", "get_", "(_", "name_", ",_", "\"", "jobs", "\"_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "clusters_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cluster", "\\u", "name_", "in_", "config_", "._", "get_", "(_", "name_", ",_", "\"", "cluster", "s", "\"_", ")_", "._", "split_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "argparse_", "._", "Namespace_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "service_", "=_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "cluster_", "=_", "cluster", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pars", "e", " ", "cluster", " ", "config", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "clusters_", "[_", "cluster", "\\u", "name_", "]_", "=_", "deploy", "\\u", "utils_", "._", "get", "\\u", "service", "\\u", "config_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "metric", "\\u", "url_", "=_", "config_", "._", "get_", "(_", "name_", ",_", "\"", "metric", "\\u", "url", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Collect", "or", "Config_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ",_", "options_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pars", "e", " ", "collect", "or", " ", "config", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config", "\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "deploy", "\\u", "utils_", "._", "get", "\\u", "config", "\\u", "dir_", "(_", ")_", ",_", "'", "ow", "l", "/", "collect", "or", ".", "cfg", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "args_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "options_", "=_", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "config_", "=_", "self_", "._", "parse", "\\u", "config", "\\u", "file_", "(_", "config", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "services_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "service", "\\u", "name_", "in_", "self_", "._", "config_", "._", "get_", "(_", "\"", "collect", "or", "\"_", ",_", "\"", "service", "s", "\"_", ")_", "._", "split_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "services_", "[_", "service", "\\u", "name_", "]_", "=_", "Collect", "or", "Config_", "._", "Service_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "options_", ",_", "self_", "._", "config_", ",_", "service", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "period_", "=_", "self_", "._", "config_", "._", "getint_", "(_", "\"", "collect", "or", "\"_", ",_", "\"", "period", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Collect", "or", "Config_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "\\u", "config", "\\u", "file_", "(_", "self_", ",_", "config", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "config", "\\u", "parser_", "=_", "Config", "Parser_", "._", "Safe", "Config", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "parser_", "._", "option", "xform_", "=_", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "Pars", "ing", " ", "config", " ", "file", ":", " ", "%", "s", "\"_", ",_", "config", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "config", "\\u", "parser_", "._", "read_", "(_", "config", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "critical_", "(_", "\"", "Can", "'", "t", " ", "parse", " ", "config", " ", "file", ":", " ", "%", "s", "\"_", ",_", "config", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "Success", "full", "y", " ", "parsed", " ", "config", " ", "file", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "config", "\\u", "parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "status", " ", "of", " ", "all", " ", "active", " ", "cluster", "s", " ", "and", " ", "jobs", ",", " ", "whi", "ch", " ", "are", " ", "inferred", " ", "from", "\\", "10", ";", " ", " ", "task", "s", "'", " ", "status", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "collector\\u", "config_", ",_", "last", "\\u", "status_", ",_", "options_", ",_", "mailer", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "collector\\u", "config_", "=_", "collector\\u", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "status_", "=_", "last", "\\u", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "options_", "=_", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "alert", "\\u", "msg_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mailer", "_", "=_", "mailer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "self_", ",_", "task_", ",_", "group", "\\u", "name_", ",_", "metric", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metric_", "=_", "json_", "._", "loads_", "(_", "task_", "._", "last", "\\u", "metrics_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "metric_", "[_", "group", "\\u", "name_", "]_", "[_", "metric", "\\u", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"%", "r", " ", "fail", "ed", " ", "to", " ", "get", " ", "metric", ":", " ", "%", "r", "\"_", ",_", "task_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "name", "node", "\\u", "active_", "(_", "self_", ",_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metric_", "=_", "self_", "._", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "task_", ",_", "\"", "Had", "oop", ":", "service", "=", "Name", "Node", ",", "name", "=", "FS", "Names", "yste", "m", "\"_", ",_", "\"", "tag", ".", "HAS", "tate", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "bool_", "(_", "metric_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"%", "r", " ", "fail", "ed", " ", "to", " ", "get", " ", "metric", ":", " ", "%", "r", "\"_", ",_", "task_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "master", "\\u", "active_", "(_", "self_", ",_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metric_", "=_", "self_", "._", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "task_", ",_", "\"", "hadoop", ":", "service", "=", "Master", ",", "name", "=", "Master", "\"_", ",_", "\"", "Is", "Activ", "e", "Master", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "bool_", "(_", "metric_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"%", "r", " ", "fail", "ed", " ", "to", " ", "get", " ", "metric", ":", " ", "%", "r", "\"_", ",_", "task_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "hdfs", "\\u", "cluster", "\\u", "status_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "journal", "node", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "2_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "(_", "job_", "._", "total", "\\u", "task", "s", "\\u", "count_", "/_", "2_", "+_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "journal", "nodes", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "name", "node", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "runn", "ing", " ", "name", "nodes", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "active_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "task_", "in_", "job_", "._", "runn", "ing", "\\u", "tasks_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "is", "\\u", "name", "node", "\\u", "active_", "(_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "cluster", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cluster_", "._", "entry_", "=_", "'%", "s", ":", "%", "d", "'_", "%_", "(_", "task_", "._", "host_", ",_", "task_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cluster_", "._", "version_", "=_", "self_", "._", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "task_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Had", "oop", ":", "service", "=", "Name", "Node", ",", "name", "=", "Name", "Node", "Info", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Version", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "active_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "many", " ", "active", " ", "name", "nodes", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "active_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "active", " ", "name", "nodes", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "WARN_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Less", " ", "than", " ", "2", " ", "runn", "ing", " ", "name", "nodes", ",", " ", "no", " ", "HA", " ", "guaran", "tee", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "datan", "ode", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "datan", "odes", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "max_", "(_", "[_", "job_", "._", "last", "\\u", "status_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "hbase", "\\u", "cluster", "\\u", "status_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "master", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "runn", "ing", " ", "master", "s", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "active_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "task_", "in_", "job_", "._", "runn", "ing", "\\u", "tasks_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "is", "\\u", "master", "\\u", "active_", "(_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "cluster", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cluster_", "._", "entry_", "=_", "'%", "s", ":", "%", "d", "'_", "%_", "(_", "task_", "._", "host_", ",_", "task_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "self_", "._", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "task_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hadoop", ":", "service", "=", "HB", "ase", ",", "name", "=", "Info", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "version", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "revision_", "=_", "self_", "._", "get", "\\u", "late", "st", "\\u", "metric_", "(_", "task_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hadoop", ":", "service", "=", "HB", "ase", ",", "name", "=", "Info", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "revis", "ion", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cluster_", "._", "version_", "=_", "'%", "s", ",", " ", "r", "%", "s", "'_", "%_", "(_", "version_", ",_", "revision_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "active_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "many", " ", "active", " ", "master", "s", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "active_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "active", " ", "master", "s", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "No", "w", " ", "it", " ", "alw", "ay", "s", " ", "report", "s", " ", "warn", "ing", " ", "as", " ", "backup", " ", "master", " ", "doe", "sn", "'", "t", " ", "run", " ", "a", " ", "http_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "server", " ", "bef", "ore", " ", "it", " ", "acquir", "es", " ", "zk", " ", "lock", ".", " ", "Comme", "nt", " ", "this", " ", "out", " ", "and", " ", "wou", "ld", " ", "change_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "master", "'", "s", " ", "start", "up", " ", "workf", "low", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "job", ".", "last", "\\u", "status", " ", "=", " ", "Status", ".", "WARN_", "\\u\\u\\uNL\\u\\u\\u_", "#", "job", ".", "last", "\\u", "message", " ", "=", " ", "\"", "Less", " ", "than", " ", "2", " ", "runn", "ing", " ", "master", "s", ",", " ", "no", " ", "HA", " ", "guaran", "tee", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "regions", "erver", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "regions", "erver", "s", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "max_", "(_", "[_", "job_", "._", "last", "\\u", "status_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "yarn", "\\u", "cluster", "\\u", "status_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "resource", "manage", "r", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "task_", "in_", "job_", "._", "runn", "ing", "\\u", "tasks_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "cluster", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cluster_", "._", "entry_", "=_", "'%", "s", ":", "%", "d", "'_", "%_", "(_", "task_", "._", "host_", ",_", "task_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "runn", "ing", " ", "resource", "manage", "r", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "proxy", "server", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "runn", "ing", " ", "proxy", "server", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "node", "manage", "r", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "node", "manage", "r", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "max_", "(_", "[_", "job_", "._", "last", "\\u", "status_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "histo", "ry", "server", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "histo", "ry", "server", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "max_", "(_", "[_", "job_", "._", "last", "\\u", "status_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "impala", "\\u", "cluster", "\\u", "status_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "state", "store", "d", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "task_", "in_", "job_", "._", "runn", "ing", "\\u", "tasks_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "cluster", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cluster_", "._", "entry_", "=_", "'%", "s", ":", "%", "d", "'_", "%_", "(_", "task_", "._", "host_", ",_", "task_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "No", " ", "runn", "ing", " ", "state", "store", "d", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "cluster_", "._", "jobs_", "[_", "\"", "impala", "d", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"", "Too", " ", "few", " ", "runn", "ing", " ", "impala", "d", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "max_", "(_", "[_", "job_", "._", "last", "\\u", "status_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "cluster", "\\u", "status_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cluster_", "._", "jobs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cluster_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cluster_", "._", "last", "\\u", "message_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "job_", "in_", "cluster_", "._", "job", "\\u", "set_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "runn", "ing", "\\u", "tasks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "tasks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "status_", "=_", "Status_", "._", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "last", "\\u", "message_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "total", "\\u", "task", "s", "\\u", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "task_", "in_", "job_", "._", "task", "\\u", "set_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "task_", "._", "health_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "job_", "._", "runn", "ing", "\\u", "tasks_", "[_", "task_", "._", "id_", "]_", "=_", "task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "job_", "._", "runn", "ing", "\\u", "task", "s", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "._", "total", "\\u", "task", "s", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cluster_", "._", "jobs_", "[_", "job_", "._", "name_", "]_", "=_", "job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "service", "\\u", "handler_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "hdfs", "\"_", ":_", "self_", "._", "check", "\\u", "hdfs", "\\u", "cluster", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "hbase", "\"_", ":_", "self_", "._", "check", "\\u", "hbase", "\\u", "cluster", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "yarn", "\"_", ":_", "self_", "._", "check", "\\u", "yarn", "\\u", "cluster", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "impala", "\"_", ":_", "self_", "._", "check", "\\u", "impala", "\\u", "cluster", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "service", "\\u", "handler_", "[_", "cluster_", "._", "service_", "._", "name_", "]_", "(_", "cluster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "handle", "\\u", "status", "\\u", "result_", "(_", "cluster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "status", "\\u", "result_", "(_", "self_", ",_", "cluster_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "last", "\\u", "status", " ", "store", " ", "cluster", "\\u", "name", "->", "(", "status", ",", " ", "status", "\\u", "times", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "cluster", "\\u", "status_", ",_", "status", "\\u", "times_", ")_", "=_", "self_", "._", "last", "\\u", "status_", "._", "setdefault_", "(_", "str_", "(_", "cluster_", ")_", ",_", "(_", "Status_", "._", "OK_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "need", "\\u", "send", "\\u", "alert_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cluster_", "._", "last", "\\u", "status_", "!=_", "cluster", "\\u", "status_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "\\u", "status_", "[_", "str_", "(_", "cluster_", ")_", "]_", "=_", "(_", "cluster_", "._", "last", "\\u", "status_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cluster_", "._", "last", "\\u", "status_", "==_", "Status_", "._", "OK_", "and_", "status", "\\u", "times_", ">=_", "ERROR", "\\u", "TIMES", "\\u", "FOR", "\\u", "ALERT", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "alert", " ", "whe", "n", " ", "cluster", " ", "change", "d", " ", "to", " ", "from", " ", "PROB", "LEM", "(", "alert", "ed", ")", " ", "to", " ", "OK_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "need", "\\u", "send", "\\u", "alert_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "\\u", "status_", "[_", "str_", "(_", "cluster_", ")_", "]_", "=_", "(_", "cluster_", "._", "last", "\\u", "status_", ",_", "status", "\\u", "times_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "alert", " ", "whe", "n", " ", "cluster", " ", "in", " ", "PROB", "LEM", " ", "stu", "tus", " ", "reache", "d", " ", "ERROR", "\\u", "TIMES", "\\u", "FOR", "\\u", "ALERT", " ", "times_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cluster_", "._", "last", "\\u", "status_", "!=_", "Status_", "._", "OK_", "and_", "status", "\\u", "times_", "+_", "1_", "==_", "ERROR", "\\u", "TIMES", "\\u", "FOR", "\\u", "ALERT", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "need", "\\u", "send", "\\u", "alert_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "need", "\\u", "send", "\\u", "alert_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "alert", "\\u", "msg_", "+=_", "'[", "%", "s", "]", "Cluster", "[", "%", "s", "]\\\\", "n", "'_", "%_", "(_", "'", "OK", "'_", "if_", "cluster_", "._", "last", "\\u", "status_", "==_", "Status_", "._", "OK_", "else_", "'", "PROB", "LEM", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cluster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "job_", "in_", "cluster_", "._", "jobs_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "job_", "._", "last", "\\u", "status_", "!=_", "Status_", "._", "OK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "alert", "\\u", "msg_", "+=_", "'", "Jo", "b", "[", "%", "s", "]", " ", "not", " ", "healthy", ":", " ", "%", "s", "\\\\", "n", "'_", "%_", "(_", "job_", "._", "name_", ",_", "job_", "._", "last", "\\u", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "alert", "\\u", "msg_", "+=_", "'**", "****", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Status", "Checker_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "alert", "\\u", "msg_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "checking", " ", "cluster", "s", " ", "status", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cluster_", "in_", "Cluster_", "._", "objects_", "._", "filter_", "(_", "active_", "=_", "True_", ")_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "check", "\\u", "cluster", "\\u", "status_", "(_", "cluster_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "spe", "nt", " ", "%", "f", " ", "second", "s", " ", "for", " ", "updat", "ing", " ", "cluster", "s", " ", "status", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "time_", "(_", ")_", "-_", "self_", "._", "start", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "alert", "\\u", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warn_", "(_", "'", "alert", " ", "msg", ":", " ", "%", "r", "'_", "%_", "self_", "._", "alert", "\\u", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mailer", "_", "._", "send", "\\u", "email_", "(_", "subject_", "=_", "'", "OWL", " ", "cluster", " ", "alert", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "self_", "._", "alert", "\\u", "msg_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "to", "\\u", "email_", "=_", "self_", "._", "options_", "[_", "'", "to", "\\u", "email", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "json_", "._", "dump_", "(_", "self_", "._", "last", "\\u", "status_", ",_", "open_", "(_", "STATUS", "\\u", "FILE", "\\u", "PATH_", ",_", "'", "w", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "help_", "=_", "\"", "Run", " ", "the", " ", "background", " ", "collect", "or", " ", "to", " ", "fetch", " ", "metric", "s", " ", "from", " ", "/", "jm", "x", " ", "on", " ", "each", " ", "server", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "option", "\\u", "list_", "=_", "Base", "Command_", "._", "option", "\\u", "list_", "+_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "to", "\\u", "email", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "Ema", "il", " ", "address", " ", "to", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", "period", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "60_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "Check", " ", "period", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "handle_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "options_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "args_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "options_", "=_", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mailer", "_", "=_", "utils_", "._", "mail_", "._", "Mail", "er_", "(_", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stdout_", "._", "write_", "(_", "\"", "args", ":", " ", "%", "r", "\\\\", "n", "\"_", "%_", "(_", "args_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stdout_", "._", "write_", "(_", "\"", "options", ":", " ", "%", "r", "\\\\", "n", "\"_", "%_", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "collector\\u", "config_", "=_", "Collect", "or", "Config_", "(_", "self_", "._", "args_", ",_", "self_", "._", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "last", "\\u", "status_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "last", "\\u", "status_", "=_", "json_", "._", "load_", "(_", "open_", "(_", "STATUS", "\\u", "FILE", "\\u", "PATH_", ",_", "'", "r", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Fail", "ed", " ", "to", " ", "load", " ", "status", " ", "file", ":", " ", "%", "r", "'_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status", "\\u", "checker_", "=_", "Status", "Checker_", "(_", "self_", "._", "collector\\u", "config_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "last", "\\u", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "options_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "mailer", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status", "\\u", "checker_", "._", "check", "\\u", "status_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "OWL", " ", "cluster", " ", "checke", "r", " ", "error", ":", " ", "%", "r", "'_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "alert", " ", "email", " ", "whe", "n", " ", "program", " ", "got", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "admin", "\\u", "email_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "admin", "\\u", "email_", "=_", "settings_", "._", "ADMINS_", "[_", "0_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "mailer", "_", "._", "send", "\\u", "email_", "(_", "subject_", "=_", "'", "OWL", " ", "cluster", " ", "check", " ", "error", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "repr_", "(_", "e_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "to", "\\u", "email_", "=_", "admin", "\\u", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_",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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
tehmaze/nagios-cli/nagios_cli/cli.py
[ { "content": " def setup_prompt(self):\n prompt = self.config.get('ui.prompt_separator', ':').join(\n map(str, self.context.stack)\n )\n self.prompt = self.ui.color('prompt',\n self.config.get('ui.prompt') % (\n self.ui.color('prompt.object',\n self.config.get('ui.prompt_separator', ':').join(\n map(str, self.context.stack)\n )\n )\n )\n ) + ' '", "metadata": "root.CLI.setup_prompt", "header": "['class', 'CLI', '(', 'object', ')', ':', '___EOS___']", "index": 41 }, { "content": " def command_run(self, name, args):\n if name not in self.commands:\n matches = []\n for state in xrange(0, len(self.commands)):\n match = self.complete(name, state)\n if match is None:\n break\n else:\n matches.append(match)\n\n # One possible match, complete it\n if len(matches) == 1:\n return self.command_run(matches[0], args)\n\n return False\n\n if not self.commands[name].valid_in_context(self.context):\n print 'Not valid in context'\n return False\n\n try:\n self.commands[name].run(*args)\n except TypeError, e:\n msg = e.message\n info = RE_RUN_GIVEN.search(e.message)\n if info:\n # Function arguments count (minus self)\n args = self.commands[name].run.func_code.co_argcount - 1\n try:\n least = args - len(self.commands[name].run.func_defaults)\n except TypeError:\n least = 0\n # Given arguments count (minus self)\n given = int(info.groupdict()['given']) - 1\n if args == least:\n error = 'exactly'\n count = args\n elif given < least:\n error = 'at least'\n count = least\n elif given > args:\n error = 'at most'\n count = args\n else:\n print 'huh?', args, least, given\n return\n\n plural = ''\n if count != 1:\n plural = 's'\n self.error('Syntax error: %s takes %s %d argument%s (%d given)' % \\\n (name, error, count, plural, given))\n return True\n else:\n print dir(e)\n print e.message\n print e.args\n raise\n\n return True", "metadata": "root.CLI.command_run", "header": "['class', 'CLI', '(', 'object', ')', ':', '___EOS___']", "index": 151 } ]
[ { "span": "prompt ", "start_line": 42, "start_column": 8, "end_line": 42, "end_column": 14 }, { "span": "msg ", "start_line": 174, "start_column": 12, "end_line": 174, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "CLI_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "setup", "\\u", "prompt_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prompt_", "=_", "self_", "._", "config_", "._", "get_", "(_", "'", "ui", ".", "prompt", "\\u", "separator", "'_", ",_", "':'_", ")_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "str_", ",_", "self_", "._", "context_", "._", "stack_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prompt_", "=_", "self_", "._", "ui_", "._", "color_", "(_", "'", "prompt", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "config_", "._", "get_", "(_", "'", "ui", ".", "prompt", "'_", ")_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ui_", "._", "color_", "(_", "'", "prompt", ".", "object", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "config_", "._", "get_", "(_", "'", "ui", ".", "prompt", "\\u", "separator", "'_", ",_", "':'_", ")_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "str_", ",_", "self_", "._", "context_", "._", "stack_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "+_", "'", " ", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CLI_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "command", "\\u", "run_", "(_", "self_", ",_", "name_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "name_", "not_", "in_", "self_", "._", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "matches_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "state_", "in_", "xrange_", "(_", "0_", ",_", "len_", "(_", "self_", "._", "commands_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "match_", "=_", "self_", "._", "complete_", "(_", "name_", ",_", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "matches_", "._", "append_", "(_", "match_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "One", " ", "possib", "le", " ", "match", ",", " ", "complete", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "matches_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "command", "\\u", "run_", "(_", "matches_", "[_", "0_", "]_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "commands_", "[_", "name_", "]_", "._", "valid", "\\u", "in", "\\u", "context_", "(_", "self_", "._", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Not", " ", "valid", " ", "in", " ", "context", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "commands_", "[_", "name_", "]_", "._", "run_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "e_", "._", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "=_", "RE", "\\u", "RUN", "\\u", "GI", "VEN", "_", "._", "search_", "(_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Function", " ", "argu", "ment", "s", " ", "count", " ", "(", "minu", "s", " ", "self", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "self_", "._", "commands_", "[_", "name_", "]_", "._", "run_", "._", "func", "\\u", "code_", "._", "co", "\\u", "argc", "ount_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "leas", "t_", "=_", "args_", "-_", "len_", "(_", "self_", "._", "commands_", "[_", "name_", "]_", "._", "run_", "._", "func", "\\u", "defaults_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "leas", "t_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Give", "n", " ", "argu", "ment", "s", " ", "count", " ", "(", "minu", "s", " ", "self", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "given_", "=_", "int_", "(_", "info_", "._", "groupdict_", "(_", ")_", "[_", "'", "give", "n", "'_", "]_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "==_", "leas", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "error_", "=_", "'", "exact", "ly", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "given_", "<_", "leas", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "error_", "=_", "'", "at", " ", "leas", "t", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "leas", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "given_", ">_", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "error_", "=_", "'", "at", " ", "most", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "'", "hu", "h", "?'_", ",_", "args_", ",_", "leas", "t_", ",_", "given_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plural_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "count_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "plural_", "=_", "'", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "error_", "(_", "'", "Syntax", " ", "error", ":", " ", "%", "s", " ", "take", "s", " ", "%", "s", " ", "%", "d", " ", "argu", "ment", "%", "s", " ", "(%", "d", " ", "give", "n", ")'_", "%_", "(_", "name_", ",_", "error_", ",_", "count_", ",_", "plural_", ",_", "given_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "dir_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "e_", "._", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "e_", "._", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
gijzelaerr/python-snap7/test/test_util.py
[ { "content": " def test_get_string(self):\n \"\"\"\n Text extraction from string from bytearray\n \"\"\"\n test_array = bytearray(_bytearray)\n\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n self.assertTrue(row['NAME'] == 'test')", "metadata": "root.TestS7util.test_get_string", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 35 }, { "content": " def test_write_string(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n row['NAME'] = 'abc'\n self.assertTrue(row['NAME'] == 'abc')\n row['NAME'] = ''\n self.assertTrue(row['NAME'] == '')\n try:\n row['NAME'] = 'waaaaytoobig'\n except ValueError:\n pass\n # value should still be empty\n self.assertTrue(row['NAME'] == '')", "metadata": "root.TestS7util.test_write_string", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 44 }, { "content": " def test_get_int(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n x = row['ID']\n self.assertTrue(x == 0)", "metadata": "root.TestS7util.test_get_int", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 58 }, { "content": " def test_set_int(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n row['ID'] = 259\n self.assertTrue(row['ID'] == 259)", "metadata": "root.TestS7util.test_set_int", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 64 }, { "content": " def test_get_bool(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n self.assertTrue(row['testbool1'] == 1)\n self.assertTrue(row['testbool8'] == 0)", "metadata": "root.TestS7util.test_get_bool", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 70 }, { "content": " def test_set_bool(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n row['testbool8'] = 1\n row['testbool1'] = 0\n\n self.assertTrue(row['testbool8'] == 1)\n self.assertTrue(row['testbool1'] == 0)", "metadata": "root.TestS7util.test_set_bool", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 76 }, { "content": " def test_db_creation(self):\n test_array = bytearray(_bytearray * 10)\n\n test_db = util.DB(1, test_array, test_spec,\n row_size=len(_bytearray),\n size=10,\n layout_offset=4,\n db_offset=0)\n\n self.assertTrue(len(test_db.index) == 10)\n\n for i, row in test_db:\n # print row\n self.assertTrue(row['testbool1'] == 1)\n self.assertTrue(row['testbool2'] == 1)\n self.assertTrue(row['testbool3'] == 1)\n self.assertTrue(row['testbool4'] == 1)\n\n self.assertTrue(row['testbool5'] == 0)\n self.assertTrue(row['testbool6'] == 0)\n self.assertTrue(row['testbool7'] == 0)\n self.assertTrue(row['testbool8'] == 0)\n self.assertTrue(row['NAME'] == 'test')", "metadata": "root.TestS7util.test_db_creation", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 85 }, { "content": " def test_set_dword(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n # The range of numbers is 0 to 4294967295.\n row['testDword'] = 9999999\n self.assertTrue(row['testDword'] == 9999999)", "metadata": "root.TestS7util.test_set_dword", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 120 }, { "content": " def test_get_dword(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n self.assertTrue(row['testDword'] == 4294967295)", "metadata": "root.TestS7util.test_get_dword", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 127 }, { "content": " def test_export(self):\n test_array = bytearray(_bytearray)\n row = util.DB_Row(test_array, test_spec, layout_offset=4)\n data = row.export()\n self.assertTrue('testDword' in data)\n self.assertTrue('testbool1' in data)\n self.assertTrue(data['testbool5'] == 0)", "metadata": "root.TestS7util.test_export", "header": "['class', 'TestS7util', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 132 } ]
[ { "span": "self.assertTrue(row['NAME'] == 'test')", "start_line": 42, "start_column": 8, "end_line": 42, "end_column": 46 }, { "span": "self.assertTrue(row['NAME'] == 'abc')", "start_line": 48, "start_column": 8, "end_line": 48, "end_column": 45 }, { "span": "self.assertTrue(row['NAME'] == '')", "start_line": 50, "start_column": 8, "end_line": 50, "end_column": 42 }, { "span": "self.assertTrue(row['NAME'] == '')", "start_line": 56, "start_column": 8, "end_line": 56, "end_column": 42 }, { "span": "self.assertTrue(x == 0)", "start_line": 62, "start_column": 8, "end_line": 62, "end_column": 31 }, { "span": "self.assertTrue(row['ID'] == 259)", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 41 }, { "span": "self.assertTrue(row['testbool1'] == 1)", "start_line": 73, "start_column": 8, "end_line": 73, "end_column": 46 }, { "span": "self.assertTrue(row['testbool8'] == 0)", "start_line": 74, "start_column": 8, "end_line": 74, "end_column": 46 }, { "span": "self.assertTrue(row['testbool8'] == 1)", "start_line": 82, "start_column": 8, "end_line": 82, "end_column": 46 }, { "span": "self.assertTrue(row['testbool1'] == 0)", "start_line": 83, "start_column": 8, "end_line": 83, "end_column": 46 }, { "span": "self.assertTrue(len(test_db.index) == 10)", "start_line": 94, "start_column": 8, "end_line": 94, "end_column": 49 }, { "span": "self.assertTrue(row['testbool1'] == 1)", "start_line": 98, "start_column": 12, "end_line": 98, "end_column": 50 }, { "span": "self.assertTrue(row['testbool2'] == 1)", "start_line": 99, "start_column": 12, "end_line": 99, "end_column": 50 }, { "span": "self.assertTrue(row['testbool3'] == 1)", "start_line": 100, "start_column": 12, "end_line": 100, "end_column": 50 }, { "span": "self.assertTrue(row['testbool4'] == 1)", "start_line": 101, "start_column": 12, "end_line": 101, "end_column": 50 }, { "span": "self.assertTrue(row['testbool5'] == 0)", "start_line": 103, "start_column": 12, "end_line": 103, "end_column": 50 }, { "span": "self.assertTrue(row['testbool6'] == 0)", "start_line": 104, "start_column": 12, "end_line": 104, "end_column": 50 }, { "span": "self.assertTrue(row['testbool7'] == 0)", "start_line": 105, "start_column": 12, "end_line": 105, "end_column": 50 }, { "span": "self.assertTrue(row['testbool8'] == 0)", "start_line": 106, "start_column": 12, "end_line": 106, "end_column": 50 }, { "span": "self.assertTrue(row['NAME'] == 'test')", "start_line": 107, "start_column": 12, "end_line": 107, "end_column": 50 }, { "span": "self.assertTrue(row['testDword'] == 9999999)", "start_line": 125, "start_column": 8, "end_line": 125, "end_column": 52 }, { "span": "self.assertTrue(row['testDword'] == 4294967295)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 55 }, { "span": "self.assertTrue('testDword' in data)", "start_line": 136, "start_column": 8, "end_line": 136, "end_column": 44 }, { "span": "self.assertTrue('testbool1' in data)", "start_line": 137, "start_column": 8, "end_line": 137, "end_column": 44 }, { "span": "self.assertTrue(data['testbool5'] == 0)", "start_line": 138, "start_column": 8, "end_line": 138, "end_column": 47 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "get", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Text", " ", "extracti", "on", " ", "from", " ", "string", " ", "from", " ", "bytea", "rray", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "NAME", "'_", "]_", "==_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "write", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "'", "NAME", "'_", "]_", "=_", "'", "abc", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "NAME", "'_", "]_", "==_", "'", "abc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "'", "NAME", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "NAME", "'_", "]_", "==_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "[_", "'", "NAME", "'_", "]_", "=_", "'", "wa", "aaa", "yto", "obi", "g", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "value", " ", "shou", "ld", " ", "still", " ", "be", " ", "empty_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "NAME", "'_", "]_", "==_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "int_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "row_", "[_", "'", "ID", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "x_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "set\\u", "int_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "'", "ID", "'_", "]_", "=_", "259_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "ID", "'_", "]_", "==_", "259_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "bool_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "1", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "8", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "set\\u", "bool_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "'", "testb", "ool", "8", "'_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "[_", "'", "testb", "ool", "1", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "8", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "1", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "db", "\\u", "creation_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", "*_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "db_", "=_", "util_", "._", "DB_", "(_", "1_", ",_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "row", "\\u", "size_", "=_", "len_", "(_", "\\u", "bytearray_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "layout", "\\u", "offset_", "=_", "4_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "db", "\\u", "offset_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "test\\u", "db_", "._", "index_", ")_", "==_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", ",_", "row_", "in_", "test\\u", "db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "row_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "1", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "2", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "3", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "4", "'_", "]_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "5", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "6", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "7", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "testb", "ool", "8", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "NAME", "'_", "]_", "==_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "set\\u", "dwor", "d_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "range", " ", "of", " ", "numbers", " ", "is", " ", "0", " ", "to", " ", "429496729", "5._", "\\u\\u\\uNL\\u\\u\\u_", "row_", "[_", "'", "test", "Dw", "ord", "'_", "]_", "=_", "9999999", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "test", "Dw", "ord", "'_", "]_", "==_", "9999999", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "dwor", "d_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", "[_", "'", "test", "Dw", "ord", "'_", "]_", "==_", "429496729", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "S", "7", "util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "export_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "array_", "=_", "bytearray_", "(_", "\\u", "bytearray_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "util_", "._", "DB", "\\u", "Row_", "(_", "test\\u", "array_", ",_", "test\\u", "spec_", ",_", "layout", "\\u", "offset_", "=_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "row_", "._", "export_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "test", "Dw", "ord", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "testb", "ool", "1", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "data_", "[_", "'", "testb", "ool", "5", "'_", "]_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
gferreira/hTools2/Lib/hTools2/modules/git.py
[ { "content": "# [h] : git tools\n\n# imports\n\nimport os\nimport subprocess\n\n# objects\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class GitHandler(object):\n\n \"\"\"A simple object to call commands on a git repository.\"\"\"\n\n # attributes\n\n #: The folder in which the git repository lives.\n folder = None\n\n #: A list with names of remote repositories.\n remotes = []\n\n # functions\n\n\n\n\n\n\n\n\n", "metadata": "root.GitHandler", "header": "['module', '___EOS___']", "index": 9 }, { "content": " def __init__(self, repo_dir):\n self.folder = repo_dir", "metadata": "root.GitHandler.__init__", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 23 }, { "content": " def command(self, command):\n \"\"\"A generic function to call git commands on a repo.\"\"\"\n # build command\n if type(command) is str:\n command = command.split(' ')\n _command = [ 'git' ] + command\n # run command\n process = subprocess.Popen(_command,\n cwd=self.folder,\n stdout=subprocess.PIPE,\n stderr=subprocess.PIPE,\n shell=False)\n (output, error) = process.communicate()\n # return\n if len(output) > 0:\n return output\n else:\n return error", "metadata": "root.GitHandler.command", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 26 }, { "content": " def status(self):\n # output = self.command(['status', '--%s' % mode])\n output = self.command(['status'])\n return output", "metadata": "root.GitHandler.status", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 45 }, { "content": " def add(self, file_name=None, all_files=True, track=True):\n if file_name:\n output = self.command('add %s' % file_name)\n else:\n if all_files:\n output = self.command('add .')\n if track:\n output = self.command('add -A')\n return output", "metadata": "root.GitHandler.add", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 50 }, { "content": " def commit(self, message):\n output = self.command(['commit', '-m %s' % message])\n return output", "metadata": "root.GitHandler.commit", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 60 }, { "content": " def log(self, n=10):\n #output = self.command(['log', '--pretty=oneline', '-%s' % n])\n output = self.command(['log', '--pretty=format:%H %ad %an %s', '-%s' % n])\n return output", "metadata": "root.GitHandler.log", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 64 }, { "content": " def diff(self, mode='raw'):\n ### modes: raw, numstat, shortstat, summary, patch-with-stat, name-status, name-only\n ### see http://git-scm.com/docs/git-diff\n output = self.command(['diff', '--%s' % mode])\n return output", "metadata": "root.GitHandler.diff", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 69 }, { "content": " def remote(self):\n output = self.command('remote')\n remotes = output.split()\n return remotes", "metadata": "root.GitHandler.remote", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 75 }, { "content": " def push(self, remote=None, branch=None):\n if (branch and remote) is None:\n output = self.command('push')\n else:\n if remote:\n if branch:\n output = self.command(['push', remote, branch])\n else:\n output = self.command(['push', remote])\n return output", "metadata": "root.GitHandler.push", "header": "['class', 'GitHandler', '(', 'object', ')', ':', '___EOS___']", "index": 80 } ]
[ { "span": "import os", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "[", "h", "]", " ", ":", " ", "git", " ", "tools_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "imports_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "simple", " ", "object", " ", "to", " ", "call", " ", "command", "s", " ", "on", " ", "a", " ", "git", " ", "repos", "itor", "y", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "folder", " ", "in", " ", "whi", "ch", " ", "the", " ", "git", " ", "repos", "itor", "y", " ", "lives", "._", "\\u\\u\\uNL\\u\\u\\u_", "folder_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", " ", "with", " ", "names", " ", "of", " ", "remote", " ", "repos", "itori", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "remotes", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "functions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "repo", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "folder_", "=_", "repo", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "gener", "ic", " ", "function", " ", "to", " ", "call", " ", "git", " ", "command", "s", " ", "on", " ", "a", " ", "repo", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "build", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "type_", "(_", "command_", ")_", "is_", "str_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "=_", "command_", "._", "split_", "(_", "'", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "command_", "=_", "[_", "'", "git", "'_", "]_", "+_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "run", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "process_", "=_", "subprocess_", "._", "Popen_", "(_", "\\u", "command_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cwd_", "=_", "self_", "._", "folder_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stderr_", "=_", "subprocess_", "._", "PIPE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "shell_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "output_", ",_", "error_", ")_", "=_", "process_", "._", "communicate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "return_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "output_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "status_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "output", " ", "=", " ", "self", ".", "command", "([", "'", "status", "',", " ", "'--", "%", "s", "'", " ", "%", " ", "mode", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "status", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add_", "(_", "self_", ",_", "file", "\\u", "name_", "=_", "None_", ",_", "all", "\\u", "files_", "=_", "True_", ",_", "track_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "file", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "'", "add", " ", "%", "s", "'_", "%_", "file", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "all", "\\u", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "'", "add", " ", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "track_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "'", "add", " ", "-", "A", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "commit_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "commit", "'_", ",_", "'-", "m", " ", "%", "s", "'_", "%_", "message_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "log_", "(_", "self_", ",_", "n_", "=_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "output", " ", "=", " ", "self", ".", "command", "([", "'", "log", "',", " ", "'--", "pretty", "=", "one", "line", "',", " ", "'-", "%", "s", "'", " ", "%", " ", "n", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "log", "'_", ",_", "'--", "pretty", "=", "format", ":", "%", "H", " ", "%", "ad", " ", "%", "an", " ", "%", "s", "'_", ",_", "'-", "%", "s", "'_", "%_", "n_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "diff_", "(_", "self_", ",_", "mode_", "=_", "'", "raw", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", " ", "mode", "s", ":", " ", "raw", ",", " ", "nums", "tat", ",", " ", "short", "stat", ",", " ", "summar", "y", ",", " ", "patch", "-", "with", "-", "stat", ",", " ", "name", "-", "status", ",", " ", "name", "-", "only_", "\\u\\u\\uNL\\u\\u\\u_", "###", " ", "see", " ", "http", "://", "git", "-", "scm", ".", "com", "/", "docs", "/", "git", "-", "diff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "diff", "'_", ",_", "'--", "%", "s", "'_", "%_", "mode_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remote_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "'", "remote", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remotes", "_", "=_", "output_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "remotes", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Git", "Handler_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "push_", "(_", "self_", ",_", "remote_", "=_", "None_", ",_", "branch_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "branch_", "and_", "remote_", ")_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "self_", "._", "command_", "(_", "'", "push", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "remote_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "branch_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "push", "'_", ",_", "remote_", ",_", "branch_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "output_", "=_", "self_", "._", "command_", "(_", "[_", "'", "push", "'_", ",_", "remote_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
ipython/ipython-py3k/IPython/parallel/engine/streamkernel.py
[ { "content": " def shutdown_request(self, stream, ident, parent):\n \"\"\"kill ourself. This should really be handled in an external process\"\"\"\n try:\n self.abort_queues()\n except:\n content = self._wrap_exception('shutdown')\n else:\n content = dict(parent['content'])\n content['status'] = 'ok'\n msg = self.session.send(stream, 'shutdown_reply',\n content=content, parent=parent, ident=ident)\n self.log.debug(str(msg))\n dc = ioloop.DelayedCallback(lambda : sys.exit(0), 1000, self.loop)\n dc.start()", "metadata": "root.Kernel.shutdown_request", "header": "['class', 'Kernel', '(', 'SessionFactory', ')', ':', '___NEWLINE___', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '# Kernel interface', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '___NL___', '# kwargs:', '___NL___', '___EOS___']", "index": 179 }, { "content": " def dispatch_control(self, msg):\n idents,msg = self.session.feed_identities(msg, copy=False)\n try:\n msg = self.session.unpack_message(msg, content=True, copy=False)\n except:\n self.log.error(\"Invalid Message\", exc_info=True)\n return\n else:\n self.log.debug(\"Control received, %s\", msg)\n \n header = msg['header']\n msg_id = header['msg_id']\n \n handler = self.control_handlers.get(msg['msg_type'], None)\n if handler is None:\n self.log.error(\"UNKNOWN CONTROL MESSAGE TYPE: %r\"%msg['msg_type'])\n else:\n handler(self.control_stream, idents, msg)", "metadata": "root.Kernel.dispatch_control", "header": "['class', 'Kernel', '(', 'SessionFactory', ')', ':', '___NEWLINE___', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '# Kernel interface', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '___NL___', '# kwargs:', '___NL___', '___EOS___']", "index": 194 }, { "content": " def execute_request(self, stream, ident, parent):\n self.log.debug('execute request %s'%parent)\n try:\n code = parent['content']['code']\n except:\n self.log.error(\"Got bad msg: %s\"%parent, exc_info=True)\n return\n self.session.send(self.iopub_stream, 'pyin', {'code':code},parent=parent,\n ident=asbytes('%s.pyin'%self.prefix))\n started = datetime.now()\n try:\n comp_code = self.compiler(code, '<zmq-kernel>')\n # allow for not overriding displayhook\n if hasattr(sys.displayhook, 'set_parent'):\n sys.displayhook.set_parent(parent)\n sys.stdout.set_parent(parent)\n sys.stderr.set_parent(parent)\n exec(comp_code, self.user_ns, self.user_ns)\n except:\n exc_content = self._wrap_exception('execute')\n # exc_msg = self.session.msg(u'pyerr', exc_content, parent)\n self.session.send(self.iopub_stream, 'pyerr', exc_content, parent=parent,\n ident=asbytes('%s.pyerr'%self.prefix))\n reply_content = exc_content\n else:\n reply_content = {'status' : 'ok'}\n \n reply_msg = self.session.send(stream, 'execute_reply', reply_content, parent=parent, \n ident=ident, subheader = dict(started=started))\n self.log.debug(str(reply_msg))\n if reply_msg['content']['status'] == 'error':\n self.abort_queues()", "metadata": "root.Kernel.execute_request", "header": "['class', 'Kernel', '(', 'SessionFactory', ')', ':', '___NEWLINE___', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '# Kernel interface', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '___NL___', '# kwargs:', '___NL___', '___EOS___']", "index": 249 }, { "content": " def apply_request(self, stream, ident, parent):\n # flush previous reply, so this request won't block it\n stream.flush(zmq.POLLOUT)\n try:\n content = parent['content']\n bufs = parent['buffers']\n msg_id = parent['header']['msg_id']\n # bound = parent['header'].get('bound', False)\n except:\n self.log.error(\"Got bad msg: %s\"%parent, exc_info=True)\n return\n # pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)\n # self.iopub_stream.send(pyin_msg)\n # self.session.send(self.iopub_stream, u'pyin', {u'code':code},parent=parent)\n sub = {'dependencies_met' : True, 'engine' : self.ident,\n 'started': datetime.now()}\n try:\n # allow for not overriding displayhook\n if hasattr(sys.displayhook, 'set_parent'):\n sys.displayhook.set_parent(parent)\n sys.stdout.set_parent(parent)\n sys.stderr.set_parent(parent)\n # exec \"f(*args,**kwargs)\" in self.user_ns, self.user_ns\n working = self.user_ns\n # suffix = \n prefix = \"_\"+str(msg_id).replace(\"-\",\"\")+\"_\"\n \n f,args,kwargs = unpack_apply_message(bufs, working, copy=False)\n # if bound:\n # bound_ns = Namespace(working)\n # args = [bound_ns]+list(args)\n\n fname = getattr(f, '__name__', 'f')\n \n fname = prefix+\"f\"\n argname = prefix+\"args\"\n kwargname = prefix+\"kwargs\"\n resultname = prefix+\"result\"\n \n ns = { fname : f, argname : args, kwargname : kwargs , resultname : None }\n # print ns\n working.update(ns)\n code = \"%s=%s(*%s,**%s)\"%(resultname, fname, argname, kwargname)\n try:\n exec(code, working,working)\n result = working.get(resultname)\n finally:\n for key in ns.keys():\n working.pop(key)\n # if bound:\n # working.update(bound_ns)\n \n packed_result,buf = serialize_object(result)\n result_buf = [packed_result]+buf\n except:\n exc_content = self._wrap_exception('apply')\n # exc_msg = self.session.msg(u'pyerr', exc_content, parent)\n self.session.send(self.iopub_stream, 'pyerr', exc_content, parent=parent,\n ident=asbytes('%s.pyerr'%self.prefix))\n reply_content = exc_content\n result_buf = []\n \n if exc_content['ename'] == 'UnmetDependency':\n sub['dependencies_met'] = False\n else:\n reply_content = {'status' : 'ok'}\n \n # put 'ok'/'error' status in header, for scheduler introspection:\n sub['status'] = reply_content['status']\n \n reply_msg = self.session.send(stream, 'apply_reply', reply_content, \n parent=parent, ident=ident,buffers=result_buf, subheader=sub)\n \n # flush i/o\n # should this be before reply_msg is sent, like in the single-kernel code, \n # or should nothing get in the way of real results?\n sys.stdout.flush()\n sys.stderr.flush()", "metadata": "root.Kernel.apply_request", "header": "['class', 'Kernel', '(', 'SessionFactory', ')', ':', '___NEWLINE___', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '# Kernel interface', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '___NL___', '# kwargs:', '___NL___', '___EOS___']", "index": 292 }, { "content": " def dispatch_queue(self, stream, msg):\n self.control_stream.flush()\n idents,msg = self.session.feed_identities(msg, copy=False)\n try:\n msg = self.session.unpack_message(msg, content=True, copy=False)\n except:\n self.log.error(\"Invalid Message\", exc_info=True)\n return\n else:\n self.log.debug(\"Message received, %s\", msg)\n \n \n header = msg['header']\n msg_id = header['msg_id']\n if self.check_aborted(msg_id):\n self.aborted.remove(msg_id)\n # is it safe to assume a msg_id will not be resubmitted?\n reply_type = msg['msg_type'].split('_')[0] + '_reply'\n status = {'status' : 'aborted'}\n reply_msg = self.session.send(stream, reply_type, subheader=status,\n content=status, parent=msg, ident=idents)\n return\n handler = self.shell_handlers.get(msg['msg_type'], None)\n if handler is None:\n self.log.error(\"UNKNOWN MESSAGE TYPE: %r\"%msg['msg_type'])\n else:\n handler(stream, idents, msg)", "metadata": "root.Kernel.dispatch_queue", "header": "['class', 'Kernel', '(', 'SessionFactory', ')', ':', '___NEWLINE___', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '# Kernel interface', '___NL___', '#---------------------------------------------------------------------------', '___NL___', '___NL___', '# kwargs:', '___NL___', '___EOS___']", "index": 371 } ]
[ { "span": "except:", "start_line": 183, "start_column": 8, "end_line": 183, "end_column": 15 }, { "span": "except:", "start_line": 198, "start_column": 8, "end_line": 198, "end_column": 15 }, { "span": "except:", "start_line": 253, "start_column": 8, "end_line": 253, "end_column": 15 }, { "span": "except:", "start_line": 267, "start_column": 8, "end_line": 267, "end_column": 15 }, { "span": "except:", "start_line": 300, "start_column": 8, "end_line": 300, "end_column": 15 }, { "span": "except:", "start_line": 346, "start_column": 8, "end_line": 346, "end_column": 15 }, { "span": "except:", "start_line": 376, "start_column": 8, "end_line": 376, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Kernel_", "(_", "Sess", "ion", "Factory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Kern", "el", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "kwarg", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "shut", "down", "\\u", "request_", "(_", "self_", ",_", "stream_", ",_", "ident_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "kill", " ", "ours", "elf", ".", " ", " ", "Thi", "s", " ", "shou", "ld", " ", "reall", "y", " ", "be", " ", "handle", "d", " ", "in", " ", "an", " ", "external", " ", "process", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "abort", "\\u", "queues_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "self_", "._", "\\u", "wrap", "\\u", "exception_", "(_", "'", "shut", "down", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "dict_", "(_", "parent_", "[_", "'", "content", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "[_", "'", "status", "'_", "]_", "=_", "'", "ok", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "msg_", "=_", "self_", "._", "session_", "._", "send_", "(_", "stream_", ",_", "'", "shut", "down", "\\u", "repl", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "content_", ",_", "parent_", "=_", "parent_", ",_", "ident_", "=_", "ident_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "._", "debug_", "(_", "str_", "(_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dc_", "=_", "ioloop_", "._", "Delay", "ed", "Callback_", "(_", "lambda_", ":_", "sys_", "._", "exit_", "(_", "0_", ")_", ",_", "1000_", ",_", "self_", "._", "loop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dc_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Kernel_", "(_", "Sess", "ion", "Factory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Kern", "el", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "kwarg", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dispatch", "\\u", "control_", "(_", "self_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ident", "s_", ",_", "msg_", "=_", "self_", "._", "session_", "._", "feed", "\\u", "identities", "_", "(_", "msg_", ",_", "copy_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "self_", "._", "session_", "._", "unpack", "\\u", "message_", "(_", "msg_", ",_", "content_", "=_", "True_", ",_", "copy_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "Inva", "lid", " ", "Messag", "e", "\"_", ",_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "debug_", "(_", "\"", "Control", " ", "receive", "d", ",", " ", "%", "s", "\"_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "header_", "=_", "msg_", "[_", "'", "header", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "\\u", "id_", "=_", "header_", "[_", "'", "msg", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "handler_", "=_", "self_", "._", "control", "\\u", "handlers_", "._", "get_", "(_", "msg_", "[_", "'", "msg", "\\u", "type", "'_", "]_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handler_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "UNK", "NOW", "N", " ", "CONTR", "OL", " ", "MESSAGE", " ", "TYPE", ":", " ", "%", "r", "\"_", "%_", "msg_", "[_", "'", "msg", "\\u", "type", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "(_", "self_", "._", "control", "\\u", "stream_", ",_", "ident", "s_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Kernel_", "(_", "Sess", "ion", "Factory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Kern", "el", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "kwarg", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute", "\\u", "request_", "(_", "self_", ",_", "stream_", ",_", "ident_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "debug_", "(_", "'", "execute", " ", "request", " ", "%", "s", "'_", "%_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code_", "=_", "parent_", "[_", "'", "content", "'_", "]_", "[_", "'", "code", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "Got", " ", "bad", " ", "msg", ":", " ", "%", "s", "\"_", "%_", "parent_", ",_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "session_", "._", "send_", "(_", "self_", "._", "iop", "ub", "\\u", "stream_", ",_", "'", "pyi", "n", "'_", ",_", "{_", "'", "code", "'_", ":_", "code_", "}_", ",_", "parent_", "=_", "parent_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ident_", "=_", "as", "bytes_", "(_", "'%", "s", ".", "pyi", "n", "'_", "%_", "self_", "._", "prefix_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "started_", "=_", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "comp", "\\u", "code_", "=_", "self_", "._", "compiler_", "(_", "code_", ",_", "'<", "zmq", "-", "kernel", ">'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "allow", " ", "for", " ", "not", " ", "overrid", "ing", " ", "display", "hook_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hasattr_", "(_", "sys_", "._", "display", "hook_", ",_", "'", "set\\u", "parent", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "display", "hook_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "exec_", "(_", "comp", "\\u", "code_", ",_", "self_", "._", "user", "\\u", "ns_", ",_", "self_", "._", "user", "\\u", "ns_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "content_", "=_", "self_", "._", "\\u", "wrap", "\\u", "exception_", "(_", "'", "execute", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "exc", "\\u", "msg", " ", "=", " ", "self", ".", "session", ".", "msg", "(", "u", "'", "pye", "rr", "',", " ", "exc", "\\u", "content", ",", " ", "parent", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "send_", "(_", "self_", "._", "iop", "ub", "\\u", "stream_", ",_", "'", "pye", "rr", "'_", ",_", "exc", "\\u", "content_", ",_", "parent_", "=_", "parent_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ident_", "=_", "as", "bytes_", "(_", "'%", "s", ".", "pye", "rr", "'_", "%_", "self_", "._", "prefix_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "y", "\\u", "content_", "=_", "exc", "\\u", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "repl", "y", "\\u", "content_", "=_", "{_", "'", "status", "'_", ":_", "'", "ok", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "repl", "y", "\\u", "msg_", "=_", "self_", "._", "session_", "._", "send_", "(_", "stream_", ",_", "'", "execute", "\\u", "repl", "y", "'_", ",_", "repl", "y", "\\u", "content_", ",_", "parent_", "=_", "parent_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ident_", "=_", "ident_", ",_", "sub", "header_", "=_", "dict_", "(_", "started_", "=_", "started_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "._", "debug_", "(_", "str_", "(_", "repl", "y", "\\u", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "repl", "y", "\\u", "msg_", "[_", "'", "content", "'_", "]_", "[_", "'", "status", "'_", "]_", "==_", "'", "error", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "abort", "\\u", "queues_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Kernel_", "(_", "Sess", "ion", "Factory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Kern", "el", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "kwarg", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "appl", "y", "\\u", "request_", "(_", "self_", ",_", "stream_", ",_", "ident_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "flush", " ", "previ", "ous", " ", "repl", "y", ",", " ", "so", " ", "this", " ", "request", " ", "won", "'", "t", " ", "block", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stream_", "._", "flush_", "(_", "zmq_", "._", "POLL", "OUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "parent_", "[_", "'", "content", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf", "s_", "=_", "parent_", "[_", "'", "buffer", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "\\u", "id_", "=_", "parent_", "[_", "'", "header", "'_", "]_", "[_", "'", "msg", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bound", " ", "=", " ", "parent", "['", "header", "']", ".", "get", "('", "bound", "',", " ", "Fal", "se", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "Got", " ", "bad", " ", "msg", ":", " ", "%", "s", "\"_", "%_", "parent_", ",_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pyi", "n", "\\u", "msg", " ", "=", " ", "self", ".", "session", ".", "msg", "(", "u", "'", "pyi", "n", "',", "{", "u", "'", "code", "':", "code", "},", " ", "parent", "=", "parent", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "iop", "ub", "\\u", "stream", ".", "send", "(", "pyi", "n", "\\u", "msg", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "session", ".", "send", "(", "self", ".", "iop", "ub", "\\u", "stream", ",", " ", "u", "'", "pyi", "n", "',", " ", "{", "u", "'", "code", "':", "code", "},", "parent", "=", "parent", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sub_", "=_", "{_", "'", "dependen", "cies", "\\u", "met", "'_", ":_", "True_", ",_", "'", "eng", "ine", "'_", ":_", "self_", "._", "ident_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "start", "ed", "'_", ":_", "datetime_", "._", "now_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "allow", " ", "for", " ", "not", " ", "overrid", "ing", " ", "display", "hook_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "sys_", "._", "display", "hook_", ",_", "'", "set\\u", "parent", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "display", "hook_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "._", "set\\u", "parent_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "exec", " ", "\"", "f", "(*", "args", ",*", "*", "kwarg", "s", ")\"", " ", "in", " ", "self", ".", "user", "\\u", "ns", ",", " ", "self", ".", "user", "\\u", "ns_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "working", "_", "=_", "self_", "._", "user", "\\u", "ns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "suff", "ix", " ", "=", " _", "\\u\\u\\uNL\\u\\u\\u_", "prefix_", "=_", "\"\\u\"_", "+_", "str_", "(_", "msg", "\\u", "id_", ")_", "._", "replace_", "(_", "\"-\"_", ",_", "\"\"_", ")_", "+_", "\"\\u\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", ",_", "args_", ",_", "kwargs_", "=_", "unpack", "\\u", "appl", "y", "\\u", "message_", "(_", "buf", "s_", ",_", "working", "_", ",_", "copy_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "bound", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bound", "\\u", "ns", " ", "=", " ", "Names", "pace", "(", "working", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "args", " ", "=", " ", "[", "bound", "\\u", "ns", "]+", "list", "(", "args", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fname_", "=_", "getattr_", "(_", "f_", ",_", "'\\u", "\\u", "name", "\\u\\u'_", ",_", "'", "f", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fname_", "=_", "prefix_", "+_", "\"", "f", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argname", "_", "=_", "prefix_", "+_", "\"", "args", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kwarg", "name_", "=_", "prefix_", "+_", "\"", "kwarg", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result", "name_", "=_", "prefix_", "+_", "\"", "result", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ns_", "=_", "{_", "fname_", ":_", "f_", ",_", "argname", "_", ":_", "args_", ",_", "kwarg", "name_", ":_", "kwargs_", ",_", "result", "name_", ":_", "None_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "ns_", "\\u\\u\\uNL\\u\\u\\u_", "working", "_", "._", "update_", "(_", "ns_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "\"%", "s", "=", "%", "s", "(*", "%", "s", ",*", "*", "%", "s", ")\"_", "%_", "(_", "result", "name_", ",_", "fname_", ",_", "argname", "_", ",_", "kwarg", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec_", "(_", "code_", ",_", "working", "_", ",_", "working", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "working", "_", "._", "get_", "(_", "result", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", "in_", "ns_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "working", "_", "._", "pop_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "bound", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "working", ".", "update", "(", "bound", "\\u", "ns", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pack", "ed", "\\u", "result_", ",_", "buf_", "=_", "serialize", "\\u", "object_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result", "\\u", "buf_", "=_", "[_", "pack", "ed", "\\u", "result_", "]_", "+_", "buf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "content_", "=_", "self_", "._", "\\u", "wrap", "\\u", "exception_", "(_", "'", "appl", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "exc", "\\u", "msg", " ", "=", " ", "self", ".", "session", ".", "msg", "(", "u", "'", "pye", "rr", "',", " ", "exc", "\\u", "content", ",", " ", "parent", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "send_", "(_", "self_", "._", "iop", "ub", "\\u", "stream_", ",_", "'", "pye", "rr", "'_", ",_", "exc", "\\u", "content_", ",_", "parent_", "=_", "parent_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ident_", "=_", "as", "bytes_", "(_", "'%", "s", ".", "pye", "rr", "'_", "%_", "self_", "._", "prefix_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "y", "\\u", "content_", "=_", "exc", "\\u", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result", "\\u", "buf_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "exc", "\\u", "content_", "[_", "'", "ena", "me", "'_", "]_", "==_", "'", "Un", "met", "Dependenc", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sub_", "[_", "'", "dependen", "cies", "\\u", "met", "'_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "repl", "y", "\\u", "content_", "=_", "{_", "'", "status", "'_", ":_", "'", "ok", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "put", " ", "'", "ok", "'/'", "error", "'", " ", "status", " ", "in", " ", "header", ",", " ", "for", " ", "schedule", "r", " ", "introspect", "ion", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sub_", "[_", "'", "status", "'_", "]_", "=_", "repl", "y", "\\u", "content_", "[_", "'", "status", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "repl", "y", "\\u", "msg_", "=_", "self_", "._", "session_", "._", "send_", "(_", "stream_", ",_", "'", "appl", "y", "\\u", "repl", "y", "'_", ",_", "repl", "y", "\\u", "content_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "=_", "parent_", ",_", "ident_", "=_", "ident_", ",_", "buffers_", "=_", "result", "\\u", "buf_", ",_", "sub", "header_", "=_", "sub_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "flush", " ", "i", "/", "o_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shou", "ld", " ", "this", " ", "be", " ", "bef", "ore", " ", "repl", "y", "\\u", "msg", " ", "is", " ", "sent", ",", " ", "like", " ", "in", " ", "the", " ", "single", "-", "kernel", " ", "code", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "shou", "ld", " ", "not", "hing", " ", "get", " ", "in", " ", "the", " ", "way", " ", "of", " ", "real", " ", "results", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Kernel_", "(_", "Sess", "ion", "Factory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Kern", "el", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "kwarg", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dispatch", "\\u", "queue_", "(_", "self_", ",_", "stream_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "control", "\\u", "stream_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ident", "s_", ",_", "msg_", "=_", "self_", "._", "session_", "._", "feed", "\\u", "identities", "_", "(_", "msg_", ",_", "copy_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "self_", "._", "session_", "._", "unpack", "\\u", "message_", "(_", "msg_", ",_", "content_", "=_", "True_", ",_", "copy_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "Inva", "lid", " ", "Messag", "e", "\"_", ",_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "debug_", "(_", "\"", "Messag", "e", " ", "receive", "d", ",", " ", "%", "s", "\"_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "header_", "=_", "msg_", "[_", "'", "header", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "\\u", "id_", "=_", "header_", "[_", "'", "msg", "\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "abort", "ed_", "(_", "msg", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "abort", "ed_", "._", "remove_", "(_", "msg", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "is", " ", "it", " ", "safe", " ", "to", " ", "assume", " ", "a", " ", "msg", "\\u", "id", " ", "will", " ", "not", " ", "be", " ", "resu", "bmi", "tted", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "repl", "y", "\\u", "type_", "=_", "msg_", "[_", "'", "msg", "\\u", "type", "'_", "]_", "._", "split_", "(_", "'\\u'_", ")_", "[_", "0_", "]_", "+_", "'\\u", "repl", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "{_", "'", "status", "'_", ":_", "'", "abort", "ed", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "y", "\\u", "msg_", "=_", "self_", "._", "session_", "._", "send_", "(_", "stream_", ",_", "repl", "y", "\\u", "type_", ",_", "sub", "header_", "=_", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "status_", ",_", "parent_", "=_", "msg_", ",_", "ident_", "=_", "ident", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "handler_", "=_", "self_", "._", "shell", "\\u", "handlers_", "._", "get_", "(_", "msg_", "[_", "'", "msg", "\\u", "type", "'_", "]_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handler_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"", "UNK", "NOW", "N", " ", "MESSAGE", " ", "TYPE", ":", " ", "%", "r", "\"_", "%_", "msg_", "[_", "'", "msg", "\\u", "type", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "(_", "stream_", ",_", "ident", "s_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
AcademicsToday/py-academicstoday/academicstoday_project/student/tests/test_exam.py
[ { "content": "from django.core.urlresolvers import resolve\nfrom django.http import HttpRequest\nfrom django.http import QueryDict\nfrom django.test import TestCase\nfrom django.test import Client\nfrom django.contrib.auth.models import User\nfrom django.contrib.auth import authenticate, login, logout\nfrom django.contrib.auth.decorators import login_required\nfrom django.conf.urls.static import static, settings\nimport json\nfrom registrar.models import Course\nfrom registrar.models import Teacher\nfrom registrar.models import Student\nfrom registrar.models import Exam\nfrom registrar.models import ExamSubmission\nfrom registrar.models import MultipleChoiceQuestion\nfrom registrar.models import MultipleChoiceSubmission\nfrom student.views import exam\n\n\nTEST_USER_EMAIL = \"[email protected]\"\nTEST_USER_USERNAME = \"Ledo\"\nTEST_USER_PASSWORD = \"ContinentalUnion\"\nTEST_USER_EMAIL2 = \"[email protected]\"\nTEST_USER_USERNAME2 = \"whalesquid\"\nTEST_USER_PASSWORD2 = \"Evolvers\"\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ExamTestCase(TestCase):\n \n \n\n\n\n\n \n \n \n \n\n\n\n\n ", "metadata": "root.ExamTestCase", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def tearDown(self):\n courses = Course.objects.all()\n for course in courses:\n course.delete()\n User.objects.all().delete()", "metadata": "root.ExamTestCase.tearDown", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 29 }, { "content": " def setUp(self):\n # Create our Trudy student\n User.objects.create_user(\n email=TEST_USER_EMAIL2,\n username=TEST_USER_USERNAME2,\n password=TEST_USER_PASSWORD2\n )\n user = User.objects.get(email=TEST_USER_EMAIL2)\n teacher = Teacher.objects.create(user=user)\n Student.objects.create(user=user).save()\n \n # Create our Student.\n User.objects.create_user(\n email=TEST_USER_EMAIL,\n username=TEST_USER_USERNAME,\n password=TEST_USER_PASSWORD\n )\n user = User.objects.get(email=TEST_USER_EMAIL)\n teacher = Teacher.objects.create(user=user)\n student = Student.objects.create(user=user)\n \n # Create a test course.\n Course.objects.create(\n id=1,\n title=\"Comics Book Course\",\n sub_title=\"The definitive course on comics!\",\n category=\"\",\n teacher=teacher,\n )\n course = Course.objects.get(id=1)\n\n # Create our assignment(s)\n Exam.objects.create(\n exam_id=1,\n exam_num=1,\n title=\"Hideauze\",\n description=\"Anime related assignment.\",\n worth=50,\n course=course,\n )\n exam = Exam.objects.get(exam_id=1)\n\n # Create questions\n MultipleChoiceQuestion.objects.create(\n question_id=2,\n exam=exam,\n title=\"Hideauze\",\n description=\"Who where the Hideauze?\",\n a=\"Former Humans\",\n a_is_correct=True,\n b=\"Aliens\",\n b_is_correct=False,\n c=\"Magical or Supernatural Creatures\",\n c_is_correct=False,\n d=\"Transhumanists\",\n d_is_correct=True,\n e=\"Heavenly Creatures\",\n e_is_correct=True,\n )", "metadata": "root.ExamTestCase.setUp", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 35 }, { "content": " def get_logged_in_client(self):\n client = Client()\n client.login(\n username=TEST_USER_USERNAME,\n password=TEST_USER_PASSWORD\n )\n return client", "metadata": "root.ExamTestCase.get_logged_in_client", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 95 }, { "content": " def test_url_resolves_to_exams_page_view(self):\n found = resolve('/course/1/exams')\n self.assertEqual(found.func, exam.exams_page)", "metadata": "root.ExamTestCase.test_url_resolves_to_exams_page_view", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 103 }, { "content": " def test_exams_page_with_no_submissions(self):\n client = self.get_logged_in_client()\n response = client.post('/course/1/exams')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'Comics Book Course',response.content)\n self.assertIn(b'view_exam(1);',response.content)", "metadata": "root.ExamTestCase.test_exams_page_with_no_submissions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 107 }, { "content": " def test_url_resolves_to_exams_table_view(self):\n found = resolve('/course/1/exams_table')\n self.assertEqual(found.func, exam.exams_table)", "metadata": "root.ExamTestCase.test_url_resolves_to_exams_table_view", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 114 }, { "content": " def test_exams_table_returns_with_no_submissions(self):\n client = self.get_logged_in_client()\n response = client.post('/course/1/exams_table')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'view_exam(1);',response.content)", "metadata": "root.ExamTestCase.test_exams_table_returns_with_no_submissions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 118 }, { "content": " def test_url_resolves_to_delete_exam(self):\n found = resolve('/course/1/delete_exam')\n self.assertEqual(found.func, exam.delete_exam)", "metadata": "root.ExamTestCase.test_url_resolves_to_delete_exam", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 124 }, { "content": " def test_delete_exam_with_no_submissions(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n response = client.post('/course/1/delete_exam',{\n 'exam_id': 1,\n }, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['status'], 'failed')\n self.assertEqual(array['message'], 'record does not exist')", "metadata": "root.ExamTestCase.test_delete_exam_with_no_submissions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 128 }, { "content": " def test_delete_exam_with_submissions_and_correct_user(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n response = client.post('/course/1/exam/1/submit_exam',{}, **kwargs)\n self.assertEqual(response.status_code, 200)\n response = client.post('/course/1/delete_exam',{\n 'exam_id': 1,\n }, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['status'], 'success')\n self.assertEqual(array['message'], 'exam was deleted')", "metadata": "root.ExamTestCase.test_delete_exam_with_submissions_and_correct_user", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 140 }, { "content": " def test_delete_exam_with_submissions_and_incorrect_user(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n response = client.post('/course/1/exam/1/submit_exam',{}, **kwargs)\n self.assertEqual(response.status_code, 200)\n client.logout()\n client.login(\n username=TEST_USER_USERNAME2,\n password=TEST_USER_PASSWORD2\n )\n response = client.post('/course/1/delete_exam',{\n 'exam_id': 1,\n }, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['status'], 'failed')\n self.assertEqual(array['message'], 'record does not exist')", "metadata": "root.ExamTestCase.test_delete_exam_with_submissions_and_incorrect_user", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 154 }, { "content": " def test_url_resolves_to_exam_page_view(self):\n found = resolve('/course/1/exam/1')\n self.assertEqual(found.func, exam.exam_page)", "metadata": "root.ExamTestCase.test_url_resolves_to_exam_page_view", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 173 }, { "content": " def test_assignment_page(self):\n client = self.get_logged_in_client()\n response = client.post('/course/1/exam/1')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'Exam #1',response.content)", "metadata": "root.ExamTestCase.test_assignment_page", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 177 }, { "content": " def test_submit_mc_exam_answer_with_submissions(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n response = client.post('/course/1/exam/1/submit_mc_exam_answer',{\n 'question_id': 2,\n 'answer': 'A',\n }, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['status'], 'success')\n self.assertEqual(array['message'], 'submitted')", "metadata": "root.ExamTestCase.test_submit_mc_exam_answer_with_submissions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 183 }, { "content": " def test_submit_exam_without_answering_questions(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n response = client.post('/course/1/exam/1/submit_exam',{}, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['message'], 'submitted')\n self.assertEqual(array['status'], 'success')", "metadata": "root.ExamTestCase.test_submit_exam_without_answering_questions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 196 }, { "content": " def test_submit_quiz_with_answering_questions(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n client.post('/course/1/exam/1/submit_tf_exam_answer',{\n 'question_id': 1,\n 'answer': 'A',\n }, **kwargs)\n response = client.post('/course/1/exam/1/submit_exam',{}, **kwargs)\n self.assertEqual(response.status_code, 200)\n json_string = response.content.decode(encoding='UTF-8')\n array = json.loads(json_string)\n self.assertEqual(array['message'], 'submitted')\n self.assertEqual(array['status'], 'success')", "metadata": "root.ExamTestCase.test_submit_quiz_with_answering_questions", "header": "['class', 'ExamTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 206 } ]
[ { "span": "from django.http import HttpRequest", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 35 }, { "span": "from django.http import QueryDict", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 33 }, { "span": "from django.contrib.auth import authenticate, login, logout", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 59 }, { "span": "from django.contrib.auth.decorators import login_required", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 57 }, { "span": "from django.conf.urls.static import static, settings", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 52 }, { "span": "from registrar.models import ExamSubmission", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 43 }, { "span": "from registrar.models import MultipleChoiceSubmission", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 53 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "resolve_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Query", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "import_", "authenticate_", ",_", "login_", ",_", "logout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "decorators_", "import_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "._", "urls_", "._", "static_", "import_", "static_", ",_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Course_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Teacher", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Student_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Exam", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Exam", "Submission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Multipl", "e", "Choi", "ce", "Question_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "registrar", "_", "._", "models_", "import_", "Multipl", "e", "Choi", "ce", "Submission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "student_", "._", "views_", "import_", "exam", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "EMAIL_", "=_", "\"", "led", "o", "@", "ga", "h", ".", "com", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "USERNAME_", "=_", "\"", "Led", "o", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "PASSWORD_", "=_", "\"", "Conti", "nent", "al", "Uni", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "EMA", "IL", "2_", "=_", "\"", "wh", "ales", "qui", "d", "@", "hide", "au", "ze", ".", "com", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "USER", "NAME", "2_", "=_", "\"", "wh", "ales", "qui", "d", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEST", "\\u", "USER", "\\u", "PASS", "WORD", "2_", "=_", "\"", "Evol", "vers", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "tear", "Down_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "courses_", "=_", "Course_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "course_", "in_", "courses_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "course_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "User_", "._", "objects_", "._", "all_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "our", " ", "Tru", "dy", " ", "student_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "User_", "._", "objects_", "._", "create", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "email_", "=_", "TEST", "\\u", "USER", "\\u", "EMA", "IL", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "TEST", "\\u", "USER", "\\u", "USER", "NAME", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "TEST", "\\u", "USER", "\\u", "PASS", "WORD", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "email_", "=_", "TEST", "\\u", "USER", "\\u", "EMA", "IL", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "teacher_", "=_", "Teacher", "_", "._", "objects_", "._", "create_", "(_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Student_", "._", "objects_", "._", "create_", "(_", "user_", "=_", "user_", ")_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "our", " ", "Stud", "ent", "._", "\\u\\u\\uNL\\u\\u\\u_", "User_", "._", "objects_", "._", "create", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "email_", "=_", "TEST", "\\u", "USER", "\\u", "EMAIL_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "TEST", "\\u", "USER", "\\u", "USERNAME_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "TEST", "\\u", "USER", "\\u", "PASSWORD_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "email_", "=_", "TEST", "\\u", "USER", "\\u", "EMAIL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "teacher_", "=_", "Teacher", "_", "._", "objects_", "._", "create_", "(_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "student_", "=_", "Student_", "._", "objects_", "._", "create_", "(_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "test", " ", "course", "._", "\\u\\u\\uNL\\u\\u\\u_", "Course_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "\"", "Com", "ics", " ", "Boo", "k", " ", "Cour", "se", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sub\\u", "title_", "=_", "\"", "The", " ", "definit", "ive", " ", "course", " ", "on", " ", "comics", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "category_", "=_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "teacher_", "=_", "teacher_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "course_", "=_", "Course_", "._", "objects_", "._", "get_", "(_", "id_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "our", " ", "assign", "ment", "(", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "Exam", "_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "exam", "\\u", "id_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exam", "\\u", "num_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "\"", "Hi", "dea", "uz", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "\"", "Anim", "e", " ", "relate", "d", " ", "assign", "ment", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "worth", "_", "=_", "50_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "course_", "=_", "course_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exam", "_", "=_", "Exam", "_", "._", "objects_", "._", "get_", "(_", "exam", "\\u", "id_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "questions_", "\\u\\u\\uNL\\u\\u\\u_", "Multipl", "e", "Choi", "ce", "Question_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "question", "\\u", "id_", "=_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exam", "_", "=_", "exam", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "\"", "Hi", "dea", "uz", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "\"", "Who", " ", "where", " ", "the", " ", "Hi", "dea", "uz", "e", "?\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "a_", "=_", "\"", "Form", "er", " ", "Huma", "ns", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "a", "\\u", "is", "\\u", "correct_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "b_", "=_", "\"", "Ali", "ens", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "b", "\\u", "is", "\\u", "correct_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "\"", "Mag", "ical", " ", "or", " ", "Super", "natur", "al", " ", "Creat", "ure", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "c\\u", "is", "\\u", "correct_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "d_", "=_", "\"", "Trans", "human", "ists", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "d\\u", "is", "\\u", "correct_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "e_", "=_", "\"", "Heav", "enl", "y", " ", "Creat", "ure", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "e\\u", "is", "\\u", "correct_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "login_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "TEST", "\\u", "USER", "\\u", "USERNAME_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "TEST", "\\u", "USER", "\\u", "PASSWORD_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "url", "\\u", "resolve", "s", "\\u", "to", "\\u", "exam", "s", "\\u", "page", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found_", "=_", "resolve_", "(_", "'/", "course", "/", "1", "/", "exam", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "func_", ",_", "exam", "_", "._", "exam", "s", "\\u", "page_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exam", "s", "\\u", "page", "\\u", "with", "\\u", "no", "\\u", "submissions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "Com", "ics", " ", "Boo", "k", " ", "Cour", "se", "'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "view", "\\u", "exam", "(", "1", ");'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "url", "\\u", "resolve", "s", "\\u", "to", "\\u", "exam", "s", "\\u", "table", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found_", "=_", "resolve_", "(_", "'/", "course", "/", "1", "/", "exam", "s", "\\u", "table", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "func_", ",_", "exam", "_", "._", "exam", "s", "\\u", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exam", "s", "\\u", "table", "\\u", "return", "s", "\\u", "with", "\\u", "no", "\\u", "submissions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "s", "\\u", "table", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "view", "\\u", "exam", "(", "1", ");'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "url", "\\u", "resolve", "s", "\\u", "to", "\\u", "delete", "\\u", "exam", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found_", "=_", "resolve_", "(_", "'/", "course", "/", "1", "/", "delete", "\\u", "exam", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "func_", ",_", "exam", "_", "._", "delete", "\\u", "exam", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "exam", "\\u", "with", "\\u", "no", "\\u", "submissions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "delete", "\\u", "exam", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "exam", "\\u", "id", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "fail", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "record", " ", "doe", "s", " ", "not", " ", "exist", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "exam", "\\u", "with", "\\u", "subm", "ission", "s", "\\u", "and", "\\u", "correct", "\\u", "user_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "exam", "'_", ",_", "{_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "delete", "\\u", "exam", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "exam", "\\u", "id", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "exam", " ", "was", " ", "delete", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "exam", "\\u", "with", "\\u", "subm", "ission", "s", "\\u", "and", "\\u", "incorrect", "\\u", "user_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "exam", "'_", ",_", "{_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "logout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "login_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "TEST", "\\u", "USER", "\\u", "USER", "NAME", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "TEST", "\\u", "USER", "\\u", "PASS", "WORD", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "delete", "\\u", "exam", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "exam", "\\u", "id", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "fail", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "record", " ", "doe", "s", " ", "not", " ", "exist", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "url", "\\u", "resolve", "s", "\\u", "to", "\\u", "exam", "\\u", "page", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found_", "=_", "resolve_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "func_", ",_", "exam", "_", "._", "exam", "\\u", "page_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "assign", "ment", "\\u", "page_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "Exam", " ", "#", "1", "'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "submit", "\\u", "mc", "\\u", "exam", "\\u", "answer", "\\u", "with", "\\u", "submissions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "mc", "\\u", "exam", "\\u", "answer", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "\\u", "id", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "answer", "'_", ":_", "'", "A", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "submitted", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "submit", "\\u", "exam", "\\u", "with", "out", "\\u", "answer", "ing", "\\u", "questions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "exam", "'_", ",_", "{_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "submitted", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Exam", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "submit", "\\u", "quiz", "\\u", "with", "\\u", "answer", "ing", "\\u", "questions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "'_", ":_", "'", "XML", "Http", "Request", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "tf", "\\u", "exam", "\\u", "answer", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "\\u", "id", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "answer", "'_", ":_", "'", "A", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "course", "/", "1", "/", "exam", "/", "1", "/", "submit", "\\u", "exam", "'_", ",_", "{_", "}_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "json", "\\u", "string_", "=_", "response_", "._", "content_", "._", "decode_", "(_", "encoding_", "=_", "'", "UT", "F", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "array_", "=_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "message", "'_", "]_", ",_", "'", "submitted", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
the-xkcd-community/the-red-spider-project/src/level_up.py
[ { "content": "#!/usr/bin/env python\n\n# Copyright 2012 Alex Hammel\n# Licensed under the Red Spider Project License.\n# See the License.txt that shipped with your copy of this software for details.\n\nfrom __future__ import print_function\nimport sys\nimport os\ntry:\n from tkinter import *\nexcept:\n from Tkinter import *\nimport argparse\n\n#\n# Some definitions:\n#\n# The _line count_ for a language is the number of source lines of code\n# written in that language, not counting comments or blank lines.\n#\n# The _score_ for a language is the line count divided by the C-equivalent\n# KLOC scaling factor (see below).\n#\n# The _level_ is a rough, unreliable, and entirely humorous reflection of a\n# hacker's ability in a given language, given the combined _score_ of all of\n# the code she or he has written in that language. The analogy is to the\n# concept of a level in role-playing games, where the player character might\n# gain a level in strength after caving in a certain number of goblin\n# skulls. Levels get proportionally harder to attain: it's easier to go from\n# level 2 to level 3 than to go from level 3 to level 4.\n#\n# If you're curious about the score required to attain a particular level\n# (cheater), open up a python shell in the level_up directory and do this:\n#\n# > import level_up\n# > levels = make_level_generator()\n# > next(levels)\n#\n# Repeat the last command until your curiosity is satisfied.\n#\n# Complaints to the effect that level_up fails to reflect your 133t ski11z\n# should be redirected to /dev/null\n#\n\n\n# This is the C-equivalent KLOC conversion table. Based on task-controlled\n# benchmarks (http://shootout.alioth.debian.org/), it takes about 2300 lines of\n# Ada to complete a task that could be accomplished with 1000 lines of C,\n# for example. The ridiculous number of significant digits is left in to\n# add a little randomness.\n\nC_EQUIV_KLOC = {\"Ada\": 2.321176,\n \"C\": 1,\n \"C#\": 1.250588,\n \"C++\": 1.694118,\n \"Clean\": 0.9811765,\n \"Clojure\": 1.268824,\n \"Erlang\": 0.9876471,\n \"F#\": 0.9411765,\n \"Fortran\": 1.137647,\n \"Go\": 0.8235294,\n \"Haskell\": 1.356471,\n \"Java\": 1.458824,\n \"JavaScript\": 0.5494118,\n \"Lisp\": 1.857647,\n \"Lua\": 0.6529412,\n \"Mozart/Oz\": 0.6576471,\n \"OCaml\": 1.022353,\n \"Pascal\": 1.197647,\n \"Perl\": 0.5270588,\n \"PHP\": 0.5682353,\n \"Python\": 0.7364706,\n \"Scheme\": 0.9376471,\n \"Ruby\": 0.4941176,\n \"Smalltalk\": 0.8682353\n }\n\n# In the comment syntax table, the first element of the triple is the single\n# line comment syntax, and the nex two are the multi-line comment opening\n# and closing\n\nCOMMENT_SYNTAX = {\"Ada\": (\"--\", None, None),\n \"C\": (\"//\", \"/*\", \"*/\"),\n \"C#\": (\"//\", \"/*\", \"*/\"),\n \"C++\": (\"//\", \"/*\", \"*/\"),\n \"Clojure\": (\";\", None, None), #Other comment syntaxes are\n #supported, but semicolon\n #comments seem to be most\n #common. Who uses clojure,\n #anyway?\n \"Erlang\": (\"%\", None, None),\n \"F#\": (\"//\", \"(*\", \"*)\"),\n \"Fortran\": (\"C\", None, None),\n \"Go\": (\"//\", \"/*\", \"*/\"),\n \"Haskell\": (\"--\", \"{-\", \"-}\"),\n \"Java\": (\"//\", \"/*\", \"*/\"),\n \"JavaScript\": (\"//\", \"/*\", \"*/\"),\n \"Lisp\": (\";\", \"#|\", \"|#\"),\n \"Lua\": (\"--\", \"--[[\", \"--]]\"),\n \"OCaml\": (None, \"(*\", \"*)\"),\n \"Pascal\": (None, \"(*\", \"*)\"),\n \"Perl\": (\"#\", (\"=begin\", \"=for\"), \"=cut\"),\n \"PHP\": (\"//\", \"/*\", \"*/\"),\n \"Python\": (\"#\", None, None),\n \"Scheme\": (\";\", \"#|\", \"|#\"),\n \"Ruby\": (\"#\", \"=begin\", \"=end\"),\n \"Smalltalk\": (None, '\"', '\"')\n }\n\nEXTENSIONS = {\".adb\": \"Ada\",\n \".c\": \"C\",\n \".cs\": \"C#\",\n \".cpp\": \"C++\",\n \".clj\": \"Clojure\",\n \".erl\": \"Erlang\",\n \".fs\": \"F#\",\n \".f\": \"Fortran\",\n \".go\": \"Go\",\n \".hs\": \"Haskell\",\n \".java\": \"Java\",\n \".js\": \"JavaScript\",\n \".lisp\": \"Lisp\",\n \".lua\": \"Lua\",\n \".ml\": \"OCaml\",\n \".pas\": \"Pascal\",\n \".pl\": \"Perl\",\n \".php\": \"PHP\",\n \".py\": \"Python\",\n \".scm\": \"Scheme\",\n \".rb\": \"Ruby\",\n \".st\": \"Smalltalk\"\n }\n\nSCORE_FILE = os.path.join(os.getenv(\"RED_SPIDER_ROOT\"),\n \"work\",\n \"level_up\",\n \"scores\"\n )\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2012", " ", "Alex", " ", "Ham", "mel", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "the", " ", "Red", " ", "Spi", "der", " ", "Project", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "License", ".", "txt", " ", "tha", "t", " ", "ship", "ped", " ", "with", " ", "your", " ", "copy", " ", "of", " ", "this", " ", "software", " ", "for", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "tkinter_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "Tkinter_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Some", " ", "definit", "ion", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "The", " ", "\\u", "line", " ", "count", "\\u", " ", "for", " ", "a", " ", "language", " ", "is", " ", "the", " ", "number", " ", "of", " ", "source", " ", "lines", " ", "of", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "writt", "en", " ", "in", " ", "tha", "t", " ", "language", ",", " ", "not", " ", "counti", "ng", " ", "comment", "s", " ", "or", " ", "blank", " ", "lines", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "The", " ", "\\u", "score", "\\u", " ", "for", " ", "a", " ", "language", " ", "is", " ", "the", " ", "line", " ", "count", " ", "divide", "d", " ", "by", " ", "the", " ", "C", "-", "equivalent", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "KL", "OC", " ", "scal", "ing", " ", "factor", " ", "(", "see", " ", "belo", "w", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "The", " ", "\\u", "level", "\\u", " ", "is", " ", "a", " ", "rough", ",", " ", "unre", "lia", "ble", ",", " ", "and", " ", "entire", "ly", " ", "hum", "oro", "us", " ", "reflection", " ", "of", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "hacke", "r", "'", "s", " ", "abilit", "y", " ", "in", " ", "a", " ", "give", "n", " ", "language", ",", " ", "give", "n", " ", "the", " ", "combin", "ed", " ", "\\u", "score", "\\u", " ", "of", " ", "all", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "code", " ", "she", " ", "or", " ", "he", " ", "has", " ", "writt", "en", " ", "in", " ", "tha", "t", " ", "language", ".", " ", "The", " ", "analog", "y", " ", "is", " ", "to", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "concept", " ", "of", " ", "a", " ", "level", " ", "in", " ", "role", "-", "play", "ing", " ", "games", ",", " ", "where", " ", "the", " ", "player", " ", "character", " ", "mig", "ht_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "gain", " ", "a", " ", "level", " ", "in", " ", "streng", "th", " ", "after", " ", "cav", "ing", " ", "in", " ", "a", " ", "cert", "ain", " ", "number", " ", "of", " ", "gob", "lin_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sku", "lls", ".", " ", "Levels", " ", "get", " ", "proportional", "ly", " ", "hard", "er", " ", "to", " ", "att", "ain", ":", " ", "it", "'", "s", " ", "easi", "er", " ", "to", " ", "go", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "level", " ", "2", " ", "to", " ", "level", " ", "3", " ", "than", " ", "to", " ", "go", " ", "from", " ", "level", " ", "3", " ", "to", " ", "level", " ", "4._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "If", " ", "you", "'", "re", " ", "curi", "ous", " ", "abo", "ut", " ", "the", " ", "score", " ", "require", "d", " ", "to", " ", "att", "ain", " ", "a", " ", "partic", "ular", " ", "level_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "(", "cheat", "er", "),", " ", "open", " ", "up", " ", "a", " ", "python", " ", "shell", " ", "in", " ", "the", " ", "level", "\\u", "up", " ", "director", "y", " ", "and", " ", "do", " ", "this", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", ">", " ", "import", " ", "level", "\\u", "up_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", ">", " ", "level", "s", " ", "=", " ", "make", "\\u", "level", "\\u", "generat", "or", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", ">", " ", "next", "(", "level", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Repeat", " ", "the", " ", "last", " ", "command", " ", "unti", "l", " ", "your", " ", "curi", "osity", " ", "is", " ", "satisfied", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Comp", "lain", "ts", " ", "to", " ", "the", " ", "effect", " ", "tha", "t", " ", "level", "\\u", "up", " ", "fail", "s", " ", "to", " ", "reflect", " ", "your", " ", "133", "t", " ", "ski", "11", "z_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "shou", "ld", " ", "be", " ", "redirected", " ", "to", " ", "/", "dev", "/", "null_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "the", " ", "C", "-", "equivalent", " ", "KL", "OC", " ", "conve", "rsi", "on", " ", "table", ".", " ", "Base", "d", " ", "on", " ", "task", "-", "controlle", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "benchmarks", " ", "(", "http", "://", "shoot", "out", ".", "ali", "oth", ".", "debi", "an", ".", "org", "/)", ",", " ", "it", " ", "take", "s", " ", "abo", "ut", " ", "2300", " ", "lines", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ada", " ", "to", " ", "complete", " ", "a", " ", "task", " ", "tha", "t", " ", "coul", "d", " ", "be", " ", "accom", "pli", "shed", " ", "with", " ", "1000", " ", "lines", " ", "of", " ", "C", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "example", ".", " ", "The", " ", "rid", "icul", "ous", " ", "number", " ", "of", " ", "significant", " ", "digit", "s", " ", "is", " ", "left", " ", "in", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "a", " ", "litt", "le", " ", "random", "ness", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C", "\\u", "EQU", "IV", "\\u", "KL", "OC", "_", "=_", "{_", "\"", "Ada", "\"_", ":_", "2.3", "211", "76_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "\"_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "#\"_", ":_", "1.2", "505", "88_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "++", "\"_", ":_", "1.6", "941", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Clean", "\"_", ":_", "0.98", "1176", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Clo", "jur", "e", "\"_", ":_", "1.2", "688", "24_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Er", "lang", "\"_", ":_", "0.98", "764", "71_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "F", "#\"_", ":_", "0.94", "1176", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Fort", "ran", "\"_", ":_", "1.1", "376", "47_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Go", "\"_", ":_", "0.82", "352", "94_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Has", "kel", "l", "\"_", ":_", "1.3", "564", "71_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ja", "va", "\"_", ":_", "1.4", "588", "24_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ja", "va", "Script", "\"_", ":_", "0.54", "941", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Lis", "p", "\"_", ":_", "1.8", "576", "47_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Lu", "a", "\"_", ":_", "0.65", "294", "12_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Mo", "zar", "t", "/", "Oz", "\"_", ":_", "0.65", "764", "71_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "OC", "aml", "\"_", ":_", "1.02", "235", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pas", "cal", "\"_", ":_", "1.1", "976", "47_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Per", "l", "\"_", ":_", "0.52", "705", "88_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "PH", "P", "\"_", ":_", "0.56", "823", "53_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", "\"_", ":_", "0.73", "647", "06_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sche", "me", "\"_", ":_", "0.93", "764", "71_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Rub", "y", "\"_", ":_", "0.49", "411", "76_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Small", "talk", "\"_", ":_", "0.86", "823", "53_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "In", " ", "the", " ", "comment", " ", "synta", "x", " ", "table", ",", " ", "the", " ", "first", " ", "element", " ", "of", " ", "the", " ", "triple", " ", "is", " ", "the", " ", "single_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "line", " ", "comment", " ", "synta", "x", ",", " ", "and", " ", "the", " ", "nex", " ", "two", " ", "are", " ", "the", " ", "multi", "-", "line", " ", "comment", " ", "opening", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "closing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "COMMENT", "\\u", "SYNTAX", "_", "=_", "{_", "\"", "Ada", "\"_", ":_", "(_", "\"--\"_", ",_", "None_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "#\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "C", "++", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Clo", "jur", "e", "\"_", ":_", "(_", "\";\"_", ",_", "None_", ",_", "None_", ")_", ",_", "#", "Ot", "her", " ", "comment", " ", "synta", "xes", " ", "are", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "support", "ed", ",", " ", "but", " ", "semico", "lon_", "\\u\\u\\uNL\\u\\u\\u_", "#", "comment", "s", " ", "see", "m", " ", "to", " ", "be", " ", "most", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "common", ".", " ", "Who", " ", "use", "s", " ", "clo", "jur", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "anyway", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Er", "lang", "\"_", ":_", "(_", "\"%\"_", ",_", "None_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "F", "#\"_", ":_", "(_", "\"//", "\"_", ",_", "\"(", "*\"_", ",_", "\"*", ")\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Fort", "ran", "\"_", ":_", "(_", "\"", "C", "\"_", ",_", "None_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Go", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Has", "kel", "l", "\"_", ":_", "(_", "\"--\"_", ",_", "\"{", "-\"_", ",_", "\"-", "}\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ja", "va", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ja", "va", "Script", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Lis", "p", "\"_", ":_", "(_", "\";\"_", ",_", "\"#", "|\"_", ",_", "\"|", "#\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Lu", "a", "\"_", ":_", "(_", "\"--\"_", ",_", "\"--", "[[", "\"_", ",_", "\"--", "]]", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "OC", "aml", "\"_", ":_", "(_", "None_", ",_", "\"(", "*\"_", ",_", "\"*", ")\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pas", "cal", "\"_", ":_", "(_", "None_", ",_", "\"(", "*\"_", ",_", "\"*", ")\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Per", "l", "\"_", ":_", "(_", "\"#\"_", ",_", "(_", "\"=", "begin", "\"_", ",_", "\"=", "for", "\"_", ")_", ",_", "\"=", "cut", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "PH", "P", "\"_", ":_", "(_", "\"//", "\"_", ",_", "\"/*", "\"_", ",_", "\"*", "/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Pyth", "on", "\"_", ":_", "(_", "\"#\"_", ",_", "None_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sche", "me", "\"_", ":_", "(_", "\";\"_", ",_", "\"#", "|\"_", ",_", "\"|", "#\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Rub", "y", "\"_", ":_", "(_", "\"#\"_", ",_", "\"=", "begin", "\"_", ",_", "\"=", "end", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Small", "talk", "\"_", ":_", "(_", "None_", ",_", "'\"'_", ",_", "'\"'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "EXTENSIONS_", "=_", "{_", "\".", "adb", "\"_", ":_", "\"", "Ada", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "c", "\"_", ":_", "\"", "C", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "cs", "\"_", ":_", "\"", "C", "#\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "cpp", "\"_", ":_", "\"", "C", "++", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "cl", "j", "\"_", ":_", "\"", "Clo", "jur", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "erl", "\"_", ":_", "\"", "Er", "lang", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "fs", "\"_", ":_", "\"", "F", "#\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "f", "\"_", ":_", "\"", "Fort", "ran", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "go", "\"_", ":_", "\"", "Go", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "hs", "\"_", ":_", "\"", "Has", "kel", "l", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "java", "\"_", ":_", "\"", "Ja", "va", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "js", "\"_", ":_", "\"", "Ja", "va", "Script", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "lis", "p", "\"_", ":_", "\"", "Lis", "p", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "lua", "\"_", ":_", "\"", "Lu", "a", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "ml", "\"_", ":_", "\"", "OC", "aml", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "pas", "\"_", ":_", "\"", "Pas", "cal", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "pl", "\"_", ":_", "\"", "Per", "l", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "php", "\"_", ":_", "\"", "PH", "P", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "py", "\"_", ":_", "\"", "Pyth", "on", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "scm", "\"_", ":_", "\"", "Sche", "me", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "rb", "\"_", ":_", "\"", "Rub", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\".", "st", "\"_", ":_", "\"", "Small", "talk", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SCORE", "\\u", "FILE_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "getenv_", "(_", "\"", "RED", "\\u", "SPI", "DER", "\\u", "ROO", "T", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "work", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "level", "\\u", "up", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "score", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
pricingassistant/mrq/tests/test_sorted.py
[ { "content": "from mrq.job import Job\nimport datetime\nfrom mrq.queue import Queue\nimport time\nimport pytest\n\n\n\n\n# def test_sorted_graph_dashboardtest(worker):\n\n# p_queue = \"test_timed_set\"\n\n# worker.start_deps()\n\n# assert Queue(p_queue).size() == 0\n\n# now = time.time()\n\n# worker.send_raw_tasks(p_queue, {\n# \"000\": now - 3600 * 6,\n# \"aaa\": now,\n# \"aaa2\": now + 3600 * 12,\n# \"bbb\": now + 3600000,\n# \"ccc\": now\n# }, start=False)\n# time.sleep(10000)\n\n# worker.stop_deps()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_sorted_graph(worker):\n\n p_queue = \"test_sorted_set\"\n\n worker.start_deps()\n\n assert Queue(p_queue).size() == 0\n\n worker.send_raw_tasks(p_queue, {\n \"000\": -1,\n \"aaa\": 1,\n \"aaa2\": 1.5,\n \"bbb\": 2,\n \"ccc\": 4\n }, start=False, block=False)\n time.sleep(0.5)\n\n assert Queue(p_queue).size() == 5\n assert Queue(p_queue).get_sorted_graph(\n 1, 4, slices=3, include_inf=True) == [1, 2, 1, 0, 1]\n assert Queue(p_queue).get_sorted_graph(\n 1, 4, slices=3, include_inf=False) == [2, 1, 0]\n\n worker.stop_deps()", "metadata": "root.test_sorted_graph", "header": "['module', '___EOS___']", "index": 7 } ]
[ { "span": "from mrq.job import Job", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 23 }, { "span": "import datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "import pytest", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "mr", "q_", "._", "job_", "import_", "Job_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mr", "q_", "._", "queue_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "def", " ", "test\\u", "sorte", "d\\u", "graph", "\\u", "dash", "board", "test", "(", "worker", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "p", "\\u", "queue", " ", "=", " ", "\"", "test\\u", "timed", "\\u", "set", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "worker", ".", "start", "\\u", "dep", "s", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "assert", " ", "Queue", "(", "p", "\\u", "queue", ").", "size", "()", " ", "==", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "now", " ", "=", " ", "time", ".", "time", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "worker", ".", "send", "\\u", "raw", "\\u", "task", "s", "(", "p", "\\u", "queue", ",", " ", "{_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "000", "\":", " ", "now", " ", "-", " ", "3600", " ", "*", " ", "6", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "aaa", "\":", " ", "now", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "aaa", "2", "\":", " ", "now", " ", "+", " ", "3600", " ", "*", " ", "1", "2", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "bbb", "\":", " ", "now", " ", "+", " ", "3600", "000", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "ccc", "\":", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "},", " ", "start", "=", "Fal", "se", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "time", ".", "sleep", "(", "10000", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "worker", ".", "stop", "\\u", "dep", "s", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "sorte", "d\\u", "graph_", "(_", "worker_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p", "\\u", "queue_", "=_", "\"", "test\\u", "sorte", "d\\u", "set", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "worker_", "._", "start", "\\u", "deps_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "Queue_", "(_", "p", "\\u", "queue_", ")_", "._", "size_", "(_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "worker_", "._", "send", "\\u", "raw", "\\u", "tasks_", "(_", "p", "\\u", "queue_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "000", "\"_", ":_", "-_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "aaa", "\"_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "aaa", "2", "\"_", ":_", "1.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "bbb", "\"_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ccc", "\"_", ":_", "4_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "start_", "=_", "False_", ",_", "block_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "Queue_", "(_", "p", "\\u", "queue_", ")_", "._", "size_", "(_", ")_", "==_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "Queue_", "(_", "p", "\\u", "queue_", ")_", "._", "get", "\\u", "sorte", "d\\u", "graph_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ",_", "4_", ",_", "slices_", "=_", "3_", ",_", "include", "\\u", "inf_", "=_", "True_", ")_", "==_", "[_", "1_", ",_", "2_", ",_", "1_", ",_", "0_", ",_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "Queue_", "(_", "p", "\\u", "queue_", ")_", "._", "get", "\\u", "sorte", "d\\u", "graph_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ",_", "4_", ",_", "slices_", "=_", "3_", ",_", "include", "\\u", "inf_", "=_", "False_", ")_", "==_", "[_", "2_", ",_", "1_", ",_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_",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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
SheffieldML/GPy/GPy/util/config.py
[ { "content": "#\n# This loads the configuration\n#\nimport os\ntry:\n #Attempt Python 2 ConfigParser setup\n import ConfigParser\n config = ConfigParser.ConfigParser()\n from ConfigParser import NoOptionError\nexcept ImportError:\n #Attempt Python 3 ConfigParser setup\n import configparser\n config = configparser.ConfigParser()\n from configparser import NoOptionError\n \n\n# This is the default configuration file that always needs to be present.\ndefault_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'defaults.cfg'))\n\n# These files are optional\n# This specifies configurations that are typically specific to the machine (it is found alongside the GPy installation).\nlocal_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'installation.cfg'))\n\n# This specifies configurations specific to the user (it is found in the user home directory)\nhome = os.getenv('HOME') or os.getenv('USERPROFILE')\nuser_file = os.path.join(home,'.config','gpy', 'user.cfg')\n\n# Read in the given files.\nconfig.readfp(open(default_file))\nconfig.read([local_file, user_file])\n\nif not config:\n raise ValueError(\"No configuration file found at either \" + user_file + \" or \" + local_file + \" or \" + default_file + \".\")\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from ConfigParser import NoOptionError", "start_line": 8, "start_column": 4, "end_line": 8, "end_column": 42 }, { "span": "from configparser import NoOptionError", "start_line": 13, "start_column": 4, "end_line": 13, "end_column": 42 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "load", "s", " ", "the", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Atte", "mpt", " ", "Pyth", "on", " ", "2", " ", "Config", "Parser", " ", "setup_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "Config", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "Config", "Parser_", "._", "Config", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Config", "Parser_", "import_", "No", "Optio", "n", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Atte", "mpt", " ", "Pyth", "on", " ", "3", " ", "Config", "Parser", " ", "setup_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "configparser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "configparser_", "._", "Config", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "configparser_", "import_", "No", "Optio", "n", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "the", " ", "default", " ", "configura", "tion", " ", "file", " ", "tha", "t", " ", "alw", "ay", "s", " ", "need", "s", " ", "to", " ", "be", " ", "presen", "t", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "default", "\\u", "file_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "'..'_", ",_", "'", "default", "s", ".", "cfg", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "files", " ", "are", " ", "optional_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "speci", "fie", "s", " ", "configura", "tion", "s", " ", "tha", "t", " ", "are", " ", "typical", "ly", " ", "specific", " ", "to", " ", "the", " ", "machine", " ", "(", "it", " ", "is", " ", "found", " ", "along", "side", " ", "the", " ", "GP", "y", " ", "installation", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "local", "\\u", "file_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "'..'_", ",_", "'", "installation", ".", "cfg", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "speci", "fie", "s", " ", "configura", "tion", "s", " ", "specific", " ", "to", " ", "the", " ", "user", " ", "(", "it", " ", "is", " ", "found", " ", "in", " ", "the", " ", "user", " ", "home", " ", "director", "y", ")_", "\\u\\u\\uNL\\u\\u\\u_", "home_", "=_", "os_", "._", "getenv_", "(_", "'", "HOM", "E", "'_", ")_", "or_", "os_", "._", "getenv_", "(_", "'", "USER", "PROFILE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "file_", "=_", "os_", "._", "path_", "._", "join_", "(_", "home_", ",_", "'.", "config", "'_", ",_", "'", "gp", "y", "'_", ",_", "'", "user", ".", "cfg", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Read", " ", "in", " ", "the", " ", "give", "n", " ", "files", "._", "\\u\\u\\uNL\\u\\u\\u_", "config_", "._", "readf", "p_", "(_", "open_", "(_", "default", "\\u", "file_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "._", "read_", "(_", "[_", "local", "\\u", "file_", ",_", "user", "\\u", "file_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "config_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "No", " ", "configura", "tion", " ", "file", " ", "found", " ", "at", " ", "eit", "her", " ", "\"_", "+_", "user", "\\u", "file_", "+_", "\"", " ", "or", " ", "\"_", "+_", "local", "\\u", "file_", "+_", "\"", " ", "or", " ", "\"_", "+_", "default", "\\u", "file_", "+_", "\".\"_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
chromaway/ngcccbase/ngcccbase/p2ptrade/ewctrl.py
[ { "content": " def prepare_targets(self, etx_spec, their):\n self.targets = []\n for address, color_spec, value in etx_spec.targets:\n colordef = self.ewctrl.resolve_color_spec(color_spec)\n self.targets.append(ColorTarget(address,\n SimpleColorValue(colordef=colordef,\n value=value)))\n wam = self.model.get_address_manager()\n colormap = self.model.get_color_map()\n their_colordef = self.ewctrl.resolve_color_spec(their['color_spec'])\n their_color_set = ColorSet.from_color_ids(self.model.get_color_map(),\n [their_colordef.get_color_id()])\n ct = ColorTarget(wam.get_change_address(their_color_set).get_address(),\n SimpleColorValue(colordef=their_colordef,\n value=their['value']))\n self.targets.append(ct)", "metadata": "root.OperationalETxSpec.prepare_targets", "header": "['class', 'OperationalETxSpec', '(', 'SimpleOperationalTxSpec', ')', ':', '___EOS___']", "index": 64 } ]
[ { "span": "colormap ", "start_line": 72, "start_column": 8, "end_line": 72, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Opera", "tion", "al", "ET", "x", "Spec_", "(_", "Simple", "Opera", "tion", "al", "Tx", "Spec_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "prepar", "e\\u", "targets_", "(_", "self_", ",_", "et", "x", "\\u", "spec_", ",_", "thei", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "targets_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "address_", ",_", "color", "\\u", "spec_", ",_", "value_", "in_", "et", "x", "\\u", "spec_", "._", "targets_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "color", "def_", "=_", "self_", "._", "ew", "ctrl_", "._", "resolve", "\\u", "color", "\\u", "spec_", "(_", "color", "\\u", "spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "targets_", "._", "append_", "(_", "Color", "Target_", "(_", "address_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Simple", "Color", "Value_", "(_", "color", "def_", "=_", "color", "def_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "value_", "=_", "value_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wam", "_", "=_", "self_", "._", "model_", "._", "get", "\\u", "address", "\\u", "manager_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "colormap_", "=_", "self_", "._", "model_", "._", "get", "\\u", "color", "\\u", "map_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thei", "r", "\\u", "color", "def_", "=_", "self_", "._", "ew", "ctrl_", "._", "resolve", "\\u", "color", "\\u", "spec_", "(_", "thei", "r_", "[_", "'", "color", "\\u", "spec", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thei", "r", "\\u", "color", "\\u", "set_", "=_", "Color", "Set_", "._", "from", "\\u", "color", "\\u", "ids_", "(_", "self_", "._", "model_", "._", "get", "\\u", "color", "\\u", "map_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "thei", "r", "\\u", "color", "def_", "._", "get", "\\u", "color", "\\u", "id_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ct_", "=_", "Color", "Target_", "(_", "wam", "_", "._", "get", "\\u", "change", "\\u", "address_", "(_", "thei", "r", "\\u", "color", "\\u", "set_", ")_", "._", "get", "\\u", "address_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Simple", "Color", "Value_", "(_", "color", "def_", "=_", "thei", "r", "\\u", "color", "def_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "value_", "=_", "thei", "r_", "[_", "'", "value", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "targets_", "._", "append_", "(_", "ct_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
azoft-dev-team/imagrium/env/Lib/test/test_threading.py
[ { "content": " def run(self):\n delay = random.random() / 10000.0\n if verbose:\n print 'task %s will run for %.1f usec' % (\n self.name, delay * 1e6)\n\n with self.sema:\n with self.mutex:\n self.nrunning.inc()\n if verbose:\n print self.nrunning.get(), 'tasks are running'\n self.testcase.assertTrue(self.nrunning.get() <= 3)\n\n time.sleep(delay)\n if verbose:\n print 'task', self.name, 'done'\n\n with self.mutex:\n self.nrunning.dec()\n self.testcase.assertTrue(self.nrunning.get() >= 0)\n if verbose:\n print '%s is finished. %d tasks are running' % (\n self.name, self.nrunning.get())", "metadata": "root.TestThread.run", "header": "['class', 'TestThread', '(', 'threading', '.', 'Thread', ')', ':', '___EOS___']", "index": 36 }, { "content": " @unittest.skipIf(is_jython, \"FIXME: not working on Jython\")\n def test_various_ops(self):\n # This takes about n/3 seconds to run (about n/3 clumps of tasks,\n # times about 1 second per clump).\n NUMTASKS = 10\n\n # no more than 3 of the 10 can run at once\n sema = threading.BoundedSemaphore(value=3)\n mutex = threading.RLock()\n numrunning = Counter()\n\n threads = []\n\n for i in range(NUMTASKS):\n t = TestThread(\"<thread %d>\"%i, self, sema, mutex, numrunning)\n threads.append(t)\n self.assertEqual(t.ident, None)\n self.assertTrue(re.match('<TestThread\\(.*, initial\\)>', repr(t)))\n t.start()\n\n if verbose:\n print 'waiting for all tasks to complete'\n for t in threads:\n t.join(NUMTASKS)\n self.assertTrue(not t.is_alive())\n self.assertNotEqual(t.ident, 0)\n self.assertFalse(t.ident is None)\n self.assertTrue(re.match('<TestThread\\(.*, \\w+ -?\\d+\\)>', repr(t)))\n if verbose:\n print 'all tasks done'\n self.assertEqual(numrunning.get(), 0)", "metadata": "root.ThreadTests.test_various_ops", "header": "['class', 'ThreadTests', '(', 'BaseTestCase', ')', ':', '___NEWLINE___', '___NL___', '# Create a bunch of threads, let each do some work, wait until all are', '___NL___', '# done.', '___NL___', '___EOS___']", "index": 73 }, { "content": " @unittest.skipIf(is_jython, \"FIXME: not working on Jython\")\n def test_ident_of_no_threading_threads(self):\n # The ident still must work for the main thread and dummy threads.\n self.assertFalse(threading.currentThread().ident is None)\n def f():\n ident.append(threading.currentThread().ident)\n done.set()\n done = threading.Event()\n ident = []\n thread.start_new_thread(f, ())\n done.wait()\n self.assertFalse(ident[0] is None)\n # Kill the \"immortal\" _DummyThread\n del threading._active[ident[0]]", "metadata": "root.ThreadTests.test_ident_of_no_threading_threads", "header": "['class', 'ThreadTests', '(', 'BaseTestCase', ')', ':', '___NEWLINE___', '___NL___', '# Create a bunch of threads, let each do some work, wait until all are', '___NL___', '# done.', '___NL___', '___EOS___']", "index": 105 } ]
[ { "span": "self.testcase.assertTrue(self.nrunning.get() <= 3)", "start_line": 47, "start_column": 16, "end_line": 47, "end_column": 66 }, { "span": "self.testcase.assertTrue(self.nrunning.get() >= 0)", "start_line": 55, "start_column": 16, "end_line": 55, "end_column": 66 }, { "span": "self.assertFalse(t.ident is None)", "start_line": 99, "start_column": 12, "end_line": 99, "end_column": 45 }, { "span": "self.assertFalse(threading.currentThread().ident is None)", "start_line": 108, "start_column": 8, "end_line": 108, "end_column": 65 }, { "span": "self.assertFalse(ident[0] is None)", "start_line": 116, "start_column": 8, "end_line": 116, "end_column": 42 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Thread_", "(_", "threading_", "._", "Thread_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "delay_", "=_", "random_", "._", "random_", "(_", ")_", "/_", "10000", ".0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "task", " ", "%", "s", " ", "will", " ", "run", " ", "for", " ", "%", ".1", "f", " ", "usec", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", ",_", "delay_", "*_", "1e6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "sema", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "mutex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nr", "unn", "ing_", "._", "inc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "self_", "._", "nr", "unn", "ing_", "._", "get_", "(_", ")_", ",_", "'", "task", "s", " ", "are", " ", "runn", "ing", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "testcase_", "._", "assert", "True_", "(_", "self_", "._", "nr", "unn", "ing_", "._", "get_", "(_", ")_", "<=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "delay_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "task", "'_", ",_", "self_", "._", "name_", ",_", "'", "don", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "mutex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nr", "unn", "ing_", "._", "dec_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "testcase_", "._", "assert", "True_", "(_", "self_", "._", "nr", "unn", "ing_", "._", "get_", "(_", ")_", ">=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "'%", "s", " ", "is", " ", "finish", "ed", ".", " ", "%", "d", " ", "task", "s", " ", "are", " ", "runn", "ing", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", ",_", "self_", "._", "nr", "unn", "ing_", "._", "get_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Thread", "Tests_", "(_", "Base", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "bunch", " ", "of", " ", "thread", "s", ",", " ", "let", " ", "each", " ", "do", " ", "some", " ", "work", ",", " ", "wait", " ", "unti", "l", " ", "all", " ", "are", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "unittest_", "._", "skip", "If_", "(_", "is", "\\u", "jy", "tho", "n_", ",_", "\"", "FIX", "ME", ":", " ", "not", " ", "working", " ", "on", " ", "Jy", "tho", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "vari", "ous", "\\u", "ops_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "take", "s", " ", "abo", "ut", " ", "n", "/", "3", " ", "second", "s", " ", "to", " ", "run", " ", "(", "abo", "ut", " ", "n", "/", "3", " ", "clu", "mps", " ", "of", " ", "task", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "times", " ", "abo", "ut", " ", "1", " ", "second", " ", "per", " ", "clu", "mp", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NUM", "TASK", "S_", "=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "no", " ", "more", " ", "than", " ", "3", " ", "of", " ", "the", " ", "10", " ", "can", " ", "run", " ", "at", " ", "once_", "\\u\\u\\uNL\\u\\u\\u_", "sema", "_", "=_", "threading_", "._", "Bound", "ed", "Semaphore", "_", "(_", "value_", "=_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mutex_", "=_", "threading_", "._", "RL", "ock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "numr", "unn", "ing_", "=_", "Counter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "threads_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "NUM", "TASK", "S_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "Test", "Thread_", "(_", "\"<", "thread", " ", "%", "d", ">\"_", "%_", "i_", ",_", "self_", ",_", "sema", "_", ",_", "mutex_", ",_", "numr", "unn", "ing_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "threads_", "._", "append_", "(_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "t_", "._", "ident_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "match_", "(_", "'<", "Test", "Thread", "\\\\(", ".*", ",", " ", "initial", "\\\\)", ">'_", ",_", "repr_", "(_", "t_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "wait", "ing", " ", "for", " ", "all", " ", "task", "s", " ", "to", " ", "complete", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "t_", "in_", "threads_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "join_", "(_", "NUM", "TASK", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "not_", "t_", "._", "is", "\\u", "alive_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Not", "Equal_", "(_", "t_", "._", "ident_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "t_", "._", "ident_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "re_", "._", "match_", "(_", "'<", "Test", "Thread", "\\\\(", ".*", ",", " ", "\\\\", "w", "+", " ", "-?", "\\\\", "d", "+\\\\", ")>", "'_", ",_", "repr_", "(_", "t_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "all", " ", "task", "s", " ", "don", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numr", "unn", "ing_", "._", "get_", "(_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Thread", "Tests_", "(_", "Base", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "bunch", " ", "of", " ", "thread", "s", ",", " ", "let", " ", "each", " ", "do", " ", "some", " ", "work", ",", " ", "wait", " ", "unti", "l", " ", "all", " ", "are", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unittest_", "._", "skip", "If_", "(_", "is", "\\u", "jy", "tho", "n_", ",_", "\"", "FIX", "ME", ":", " ", "not", " ", "working", " ", "on", " ", "Jy", "tho", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "ident", "\\u", "of", "\\u", "no", "\\u", "thread", "ing", "\\u", "threads_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "ident", " ", "still", " ", "must", " ", "work", " ", "for", " ", "the", " ", "main", " ", "thread", " ", "and", " ", "dummy", " ", "thread", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "threading_", "._", "current", "Thread_", "(_", ")_", "._", "ident_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "f_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ident_", "._", "append_", "(_", "threading_", "._", "current", "Thread_", "(_", ")_", "._", "ident_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "done_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "done_", "=_", "threading_", "._", "Event_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ident_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thread_", "._", "start", "\\u", "new", "\\u", "thread_", "(_", "f_", ",_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "done_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "ident_", "[_", "0_", "]_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Kill", " ", "the", " ", "\"", "imm", "orta", "l", "\"", " ", "\\u", "Du", "mm", "y", "Thread_", "\\u\\u\\uNL\\u\\u\\u_", "del_", "threading_", "._", "\\u", "active_", "[_", "ident_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Missing call to `__init__` during object initialization
dcramer/django-compositepks/django/core/files/base.py
[ { "content": " def __init__(self, file):\n self.file = file\n self._name = file.name\n self._mode = file.mode\n self._closed = False", "metadata": "root.File.__init__", "header": "['class', 'File', '(', 'object', ')', ':', '___EOS___']", "index": 12 }, { "content": "class ContentFile(File):\n \"\"\"\n A File-like object that takes just raw content, rather than an actual file.\n \"\"\"\n\n\n", "metadata": "root.ContentFile", "header": "['module', '___EOS___']", "index": 149 }, { "content": " def __init__(self, content):\n self.file = StringIO(content or '')\n self.size = len(content or '')\n self.file.seek(0)\n self._closed = False", "metadata": "root.ContentFile.__init__", "header": "['class', 'ContentFile', '(', 'File', ')', ':', '___EOS___']", "index": 153 } ]
[ { "span": "class ContentFile(File):", "start_line": 149, "start_column": 0, "end_line": 149, "end_column": 24 } ]
[ { "span": "def __init__(self, file):", "start_line": 12, "start_column": 4, "end_line": 12, "end_column": 29 }, { "span": "def __init__(self, content):", "start_line": 153, "start_column": 4, "end_line": 153, "end_column": 32 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "File_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file_", "=_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "name_", "=_", "file_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "mode_", "=_", "file_", "._", "mode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "closed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Conten", "t", "File_", "(_", "File_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "File", "-", "like", " ", "object", " ", "tha", "t", " ", "take", "s", " ", "just", " ", "raw", " ", "content", ",", " ", "rat", "her", " ", "than", " ", "an", " ", "actual", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Conten", "t", "File_", "(_", "File_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file_", "=_", "String", "IO_", "(_", "content_", "or_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "size_", "=_", "len_", "(_", "content_", "or_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "closed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
anandology/pyjamas/library/pyjamas/ui/VerticalSlider.py
[ { "content": "from gwt.ui.VerticalSlider import (\n Control,\n DOM,\n Factory,\n Focus,\n VerticalSlider,\n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from gwt.ui.VerticalSlider import (\n Control,\n DOM,\n Factory,\n Focus,\n VerticalSlider,\n)", "start_line": 0, "start_column": 0, "end_line": 6, "end_column": 1 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "gw", "t_", "._", "ui_", "._", "Vertica", "l", "Slider_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Control_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DOM_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Factory_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Focus_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Vertica", "l", "Slider_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Missing call to `__init__` during object initialization
wireservice/agate/agate/csv_py2.py
[ { "content": "class UnicodeDictWriter(csv.DictWriter):\n \"\"\"\n Defer almost all implementation to :class:`csv.DictWriter`, but wraps our\n unicode writer instead of :func:`csv.writer`.\n \"\"\"", "metadata": "root.UnicodeDictWriter", "header": "['module', '___EOS___']", "index": 136 }, { "content": " def __init__(self, f, fieldnames, restval='', extrasaction='raise', *args, **kwds):\n self.fieldnames = fieldnames\n self.restval = restval\n\n if extrasaction.lower() not in ('raise', 'ignore'):\n raise ValueError('extrasaction (%s) must be \"raise\" or \"ignore\"' % extrasaction)\n\n self.extrasaction = extrasaction\n\n self.writer = UnicodeWriter(f, *args, **kwds)", "metadata": "root.UnicodeDictWriter.__init__", "header": "['class', 'UnicodeDictWriter', '(', 'csv', '.', 'DictWriter', ')', ':', '___EOS___']", "index": 141 } ]
[ { "span": "class UnicodeDictWriter(csv.DictWriter):", "start_line": 136, "start_column": 0, "end_line": 136, "end_column": 40 } ]
[ { "span": "def __init__(self, f, fieldnames, restval='', extrasaction='raise', *args, **kwds):", "start_line": 141, "start_column": 4, "end_line": 141, "end_column": 87 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Unic", "ode", "Dict", "Writer_", "(_", "csv_", "._", "Dict", "Writer_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Defe", "r", " ", "alm", "ost", " ", "all", " ", "implementation", " ", "to", " ", ":", "class", ":`", "csv", ".", "Dict", "Write", "r", "`", ",", " ", "but", " ", "wrap", "s", " ", "our", "\\", "10", ";", " ", " ", " ", " ", "unicode", " ", "writer", " ", "inst", "ead", " ", "of", " ", ":", "func", ":`", "csv", ".", "writer", "`.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Unic", "ode", "Dict", "Writer_", "(_", "csv_", "._", "Dict", "Writer_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "f_", ",_", "fieldnames_", ",_", "rest", "val_", "=_", "''_", ",_", "extra", "sac", "tion_", "=_", "'", "raise", "'_", ",_", "*_", "args_", ",_", "**_", "kwds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fieldnames_", "=_", "fieldnames_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "rest", "val_", "=_", "rest", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "extra", "sac", "tion_", "._", "lower_", "(_", ")_", "not_", "in_", "(_", "'", "raise", "'_", ",_", "'", "ignore", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "extra", "sac", "tion", " ", "(%", "s", ")", " ", "must", " ", "be", " ", "\"", "raise", "\"", " ", "or", " ", "\"", "ignore", "\"'_", "%_", "extra", "sac", "tion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "extra", "sac", "tion_", "=_", "extra", "sac", "tion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "writer_", "=_", "Unic", "ode", "Writer_", "(_", "f_", ",_", "*_", "args_", ",_", "**_", "kwds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
sahana/eden/modules/tropo.py
[ { "content": "\"\"\"\nThe TropoPython module. This module implements a set of classes and methods for manipulating the Voxeo Tropo WebAPI.\n\nUsage:\n\n----\nfrom tropo import Tropo\n\ntropo = Tropo()\ntropo.say(\"Hello, World\")\njson = tropo.RenderJson()\n----\n\nYou can write this JSON back to standard output to get Tropo to perform\nthe action. For example, on Google Appengine you might write something like:\n\nhandler.response.out.write(json)\n\nMuch of the time, a you will interact with Tropo by examining the Result\nobject and communicating back to Tropo via the Tropo class methods, such\nas \"say\". In some cases, you'll want to build a class object directly such as in :\n\n choices = tropo.Choices(\"[5 digits]\").obj\n\n tropo.ask(choices,\n say=\"Please enter your 5 digit zip code.\",\n attempts=3, bargein=True, name=\"zip\", timeout=5, voice=\"dave\")\n ...\n\nNOTE: This module requires python 2.5 or higher.\n\n\"\"\"\n\n#try:\n# import cjson as jsonlib\n# jsonlib.dumps = jsonlib.encode\n# jsonlib.loads = jsonlib.decode\n#except ImportError:\n# try:\n# from django.utils import simplejson as jsonlib\ntry:\n import json as jsonlib # try stdlib (Python 2.6)\nexcept ImportError:\n try:\n import simplejson as jsonlib # try external module\n except:\n import gluon.contrib.simplejson as jsonlib # fallback to pure-Python module\n\nimport logging\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n print \"\"\"\n\n This is the Python web API for http://www.tropo.com/\n\n To run the test suite, please run:\n\n cd test\n python test.py\n\n\n\"\"\"\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 45, "start_column": 4, "end_line": 45, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "The", " ", "Trop", "o", "Pyth", "on", " ", "module", ".", " ", "Thi", "s", " ", "module", " ", "implement", "s", " ", "a", " ", "set", " ", "of", " ", "classe", "s", " ", "and", " ", "method", "s", " ", "for", " ", "manipulati", "ng", " ", "the", " ", "Vo", "xe", "o", " ", "Trop", "o", " ", "Web", "API", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", "\\", "10", ";", "\\", "10", ";", "----", "\\", "10", ";", "from", " ", "trop", "o", " ", "import", " ", "Trop", "o", "\\", "10", ";", "\\", "10", ";", "trop", "o", " ", "=", " ", "Trop", "o", "()", "\\", "10", ";", "trop", "o", ".", "say", "(\"", "Hell", "o", ",", " ", "Wor", "ld", "\")", "\\", "10", ";", "json", " ", "=", " ", "trop", "o", ".", "Render", "Js", "on", "()", "\\", "10", ";", "----", "\\", "10", ";", "\\", "10", ";", "You", " ", "can", " ", "write", " ", "this", " ", "JSO", "N", " ", "back", " ", "to", " ", "standard", " ", "output", " ", "to", " ", "get", " ", "Trop", "o", " ", "to", " ", "perform", "\\", "10", ";", "the", " ", "action", ".", " ", "For", " ", "example", ",", " ", "on", " ", "Goo", "gle", " ", "App", "eng", "ine", " ", "you", " ", "mig", "ht", " ", "write", " ", "somet", "hing", " ", "like", ":", "\\", "10", ";", "\\", "10", ";", "handler", ".", "response", ".", "out", ".", "write", "(", "json", ")", "\\", "10", ";", "\\", "10", ";", "Mu", "ch", " ", "of", " ", "the", " ", "time", ",", " ", "a", " ", "you", " ", "will", " ", "interact", " ", "with", " ", "Trop", "o", " ", "by", " ", " ", "exam", "inin", "g", " ", "the", " ", "Result", "\\", "10", ";", "object", " ", "and", " ", "communicati", "ng", " ", "back", " ", "to", " ", "Trop", "o", " ", "via", " ", "the", " ", "Trop", "o", " ", "class", " ", "method", "s", ",", " ", "suc", "h", "\\", "10", ";", "as", " ", "\"", "say", "\".", " ", "In", " ", "some", " ", "case", "s", ",", " ", "you", "'", "ll", " ", "want", " ", "to", " ", "build", " ", "a", " ", "class", " ", "object", " ", "direct", "ly", " ", "suc", "h", " ", "as", " ", "in", " ", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "choice", "s", " ", "=", " ", "trop", "o", ".", "Choi", "ces", "(\"", "[", "5", " ", "digit", "s", "]\"", ").", "obj", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "trop", "o", ".", "ask", "(", "choice", "s", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "say", "=\"", "Ple", "ase", " ", "enter", " ", "your", " ", "5", " ", "digit", " ", "zip", " ", "code", ".\",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "atte", "mpt", "s", "=", "3", ",", " ", "bar", "ge", "in", "=", "Tru", "e", ",", " ", "name", "=\"", "zip", "\",", " ", "timeo", "ut", "=", "5", ",", " ", "voice", "=\"", "dav", "e", "\")", "\\", "10", ";", " ", " ", " ", " ", "...", "\\", "10", ";", "\\", "10", ";", "NOTE", ":", " ", "Thi", "s", " ", "module", " ", "require", "s", " ", "python", " ", "2.5", " ", "or", " ", "higher", ".", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "import", " ", "cj", "son", " ", "as", " ", "jsonl", "ib_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "jsonl", "ib", ".", "dump", "s", " ", "=", " ", "jsonl", "ib", ".", "encode_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "jsonl", "ib", ".", "load", "s", " ", "=", " ", "jsonl", "ib", ".", "decode_", "\\u\\u\\uNL\\u\\u\\u_", "#", "except", " ", "Import", "Error", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "from", " ", "django", ".", "util", "s", " ", "import", " ", "simple", "json", " ", "as", " ", "jsonl", "ib_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "json_", "as_", "jsonl", "ib_", "#", " ", "try", " ", "stdlib", " ", "(", "Pyth", "on", " ", "2.6", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "simplejson_", "as_", "jsonl", "ib_", "#", " ", "try", " ", "external", " ", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "gluon_", "._", "contrib_", "._", "simplejson_", "as_", "jsonl", "ib_", "#", " ", "fall", "back", " ", "to", " ", "pure", "-", "Pyth", "on", " ", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"\"\"", "\\", "10", ";", "\\", "10", ";", " ", "Thi", "s", " ", "is", " ", "the", " ", "Pyth", "on", " ", "web", " ", "API", " ", "for", " ", "http", "://", "www", ".", "trop", "o", ".", "com", "/", "\\", "10", ";", "\\", "10", ";", " ", "To", " ", "run", " ", "the", " ", "test", " ", "suit", "e", ",", " ", "plea", "se", " ", "run", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "cd", " ", "test", "\\", "10", ";", " ", " ", " ", " ", "python", " ", "test", ".", "py", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
rbgirshick/fast-rcnn/tools/train_net.py
[ { "content": "#!/usr/bin/env python\n\n# --------------------------------------------------------\n# Fast R-CNN\n# Copyright (c) 2015 Microsoft\n# Licensed under The MIT License [see LICENSE for details]\n# Written by Ross Girshick\n# --------------------------------------------------------\n\n\"\"\"Train a Fast R-CNN network on a region of interest database.\"\"\"\n\nimport _init_paths\nfrom fast_rcnn.train import get_training_roidb, train_net\nfrom fast_rcnn.config import cfg, cfg_from_file, cfg_from_list, get_output_dir\nfrom datasets.factory import get_imdb\nimport caffe\nimport argparse\nimport pprint\nimport numpy as np\nimport sys\n\n\nif __name__ == '__main__':\n args = parse_args()\n\n print('Called with args:')\n print(args)\n\n if args.cfg_file is not None:\n cfg_from_file(args.cfg_file)\n if args.set_cfgs is not None:\n cfg_from_list(args.set_cfgs)\n\n print('Using config:')\n pprint.pprint(cfg)\n\n if not args.randomize:\n # fix the random seeds (numpy and caffe) for reproducibility\n np.random.seed(cfg.RNG_SEED)\n caffe.set_random_seed(cfg.RNG_SEED)\n\n # set up caffe\n caffe.set_mode_gpu()\n if args.gpu_id is not None:\n caffe.set_device(args.gpu_id)\n\n imdb = get_imdb(args.imdb_name)\n print 'Loaded dataset `{:s}` for training'.format(imdb.name)\n roidb = get_training_roidb(imdb)\n\n output_dir = get_output_dir(imdb, None)\n print 'Output will be saved to `{:s}`'.format(output_dir)\n\n train_net(args.solver, roidb, output_dir,\n pretrained_model=args.pretrained_model,\n max_iters=args.max_iters)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def parse_args():\n \"\"\"\n Parse input arguments\n \"\"\"\n parser = argparse.ArgumentParser(description='Train a Fast R-CNN network')\n parser.add_argument('--gpu', dest='gpu_id',\n help='GPU device id to use [0]',\n default=0, type=int)\n parser.add_argument('--solver', dest='solver',\n help='solver prototxt',\n default=None, type=str)\n parser.add_argument('--iters', dest='max_iters',\n help='number of iterations to train',\n default=40000, type=int)\n parser.add_argument('--weights', dest='pretrained_model',\n help='initialize with pretrained model weights',\n default=None, type=str)\n parser.add_argument('--cfg', dest='cfg_file',\n help='optional config file',\n default=None, type=str)\n parser.add_argument('--imdb', dest='imdb_name',\n help='dataset to train on',\n default='voc_2007_trainval', type=str)\n parser.add_argument('--rand', dest='randomize',\n help='randomize (do not use a fixed seed)',\n action='store_true')\n parser.add_argument('--set', dest='set_cfgs',\n help='set config keys', default=None,\n nargs=argparse.REMAINDER)\n\n if len(sys.argv) == 1:\n parser.print_help()\n sys.exit(1)\n\n args = parser.parse_args()\n return args", "metadata": "root.parse_args", "header": "['module', '___EOS___']", "index": 21 } ]
[ { "span": "import _init_paths", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 18 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fast", " ", "R", "-", "CNN", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "201", "5", " ", "Micro", "soft", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "The", " ", "MIT", " ", "License", " ", "[", "see", " ", "LICENSE", " ", "for", " ", "deta", "il", "s", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Writ", "ten", " ", "by", " ", "Ros", "s", " ", "Gir", "shi", "ck_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Train", " ", "a", " ", "Fast", " ", "R", "-", "CNN", " ", "network", " ", "on", " ", "a", " ", "region", " ", "of", " ", "interest", " ", "databa", "se", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "\\u", "init", "\\u", "paths_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fast", "\\u", "rc", "nn_", "._", "train_", "import_", "get", "\\u", "train", "ing", "\\u", "roid", "b_", ",_", "train", "\\u", "net_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fast", "\\u", "rc", "nn_", "._", "config_", "import_", "cfg_", ",_", "cfg", "\\u", "from", "\\u", "file_", ",_", "cfg", "\\u", "from", "\\u", "list_", ",_", "get", "\\u", "output", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datasets_", "._", "factory_", "import_", "get", "\\u", "imdb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "caffe", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Call", "ed", " ", "with", " ", "args", ":'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "args_", "._", "cfg", "\\u", "file_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cfg", "\\u", "from", "\\u", "file_", "(_", "args_", "._", "cfg", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "set\\u", "cfg", "s_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cfg", "\\u", "from", "\\u", "list_", "(_", "args_", "._", "set\\u", "cfg", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "'", "Us", "ing", " ", "config", ":'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pprint_", "._", "pprint_", "(_", "cfg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "args_", "._", "randomize", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "fix", " ", "the", " ", "random", " ", "seeds", " ", "(", "nump", "y", " ", "and", " ", "caffe", ")", " ", "for", " ", "repro", "duci", "bility_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "np_", "._", "random_", "._", "seed_", "(_", "cfg_", "._", "RN", "G", "\\u", "SEED", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "caffe", "_", "._", "set\\u", "random", "\\u", "seed_", "(_", "cfg_", "._", "RN", "G", "\\u", "SEED", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "up", " ", "caffe", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "caffe", "_", "._", "set\\u", "mode", "\\u", "gpu_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "gpu", "\\u", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "caffe", "_", "._", "set\\u", "device_", "(_", "args_", "._", "gpu", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "imdb_", "=_", "get", "\\u", "imdb_", "(_", "args_", "._", "imd", "b", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Load", "ed", " ", "dataset", " ", "`", "{:", "s", "}`", " ", "for", " ", "train", "ing", "'_", "._", "format_", "(_", "imdb_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "roid", "b_", "=_", "get", "\\u", "train", "ing", "\\u", "roid", "b_", "(_", "imdb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "output", "\\u", "dir_", "=_", "get", "\\u", "output", "\\u", "dir_", "(_", "imdb_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Output", " ", "will", " ", "be", " ", "saved", " ", "to", " ", "`", "{:", "s", "}`", "'_", "._", "format_", "(_", "output", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "train", "\\u", "net_", "(_", "args_", "._", "solver_", ",_", "roid", "b_", ",_", "output", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pretrained", "\\u", "model_", "=_", "args_", "._", "pretrained", "\\u", "model_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "iters_", "=_", "args_", "._", "max", "\\u", "iters_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "parse", "\\u", "args_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Pars", "e", " ", "input", " ", "argu", "ment", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "description_", "=_", "'", "Train", " ", "a", " ", "Fast", " ", "R", "-", "CNN", " ", "network", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "gpu", "'_", ",_", "dest_", "=_", "'", "gpu", "\\u", "id", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "GPU", " ", "device", " ", "id", " ", "to", " ", "use", " ", "[", "0", "]'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "0_", ",_", "type_", "=_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "solve", "r", "'_", ",_", "dest_", "=_", "'", "solve", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "solve", "r", " ", "protot", "xt", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "type_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "iters", "'_", ",_", "dest_", "=_", "'", "max", "\\u", "iters", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "number", " ", "of", " ", "iterati", "ons", " ", "to", " ", "train", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "40000", "_", ",_", "type_", "=_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "weight", "s", "'_", ",_", "dest_", "=_", "'", "pretrained", "\\u", "model", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "initialize", " ", "with", " ", "pretrained", " ", "model", " ", "weight", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "type_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "cfg", "'_", ",_", "dest_", "=_", "'", "cfg", "\\u", "file", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "option", "al", " ", "config", " ", "file", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ",_", "type_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "imd", "b", "'_", ",_", "dest_", "=_", "'", "imd", "b", "\\u", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "dataset", " ", "to", " ", "train", " ", "on", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "voc", "\\u", "2007", "\\u", "train", "val", "'_", ",_", "type_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "rand", "'_", ",_", "dest_", "=_", "'", "randomize", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "randomize", " ", "(", "do", " ", "not", " ", "use", " ", "a", " ", "fixed", " ", "seed", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "set", "'_", ",_", "dest_", "=_", "'", "set\\u", "cfg", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "set", " ", "config", " ", "keys", "'_", ",_", "default_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nargs_", "=_", "argparse_", "._", "REM", "AIN", "DER", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "sys_", "._", "argv_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "._", "print", "\\u", "help_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
open-cloud/xos/xos/services/requestrouter/admin.py
[ { "content": "from django.contrib import admin\n\nfrom services.requestrouter.models import *\nfrom django import forms\nfrom django.utils.safestring import mark_safe\nfrom django.contrib.auth.admin import UserAdmin\nfrom django.contrib.admin.widgets import FilteredSelectMultiple\nfrom django.contrib.auth.forms import ReadOnlyPasswordHashField\nfrom django.contrib.auth.signals import user_logged_in\nfrom django.utils import timezone\nfrom django.contrib.contenttypes import generic\nfrom suit.widgets import LinkedSelect\nfrom core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, ServicePrivilegeInline\n\n\n\n\nadmin.site.register(RequestRouterService, RequestRouterServiceAdmin)\nadmin.site.register(ServiceMap, ServiceMapAdmin)\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class RequestRouterAdmin(ReadOnlyAwareAdmin):\n # Change the application breadcrumb to point to an RR Service if one is\n # defined\n\n change_form_template = \"admin/change_form_bc.html\"\n change_list_template = \"admin/change_list_bc.html\"\n custom_app_breadcrumb_name = \"Request Router\"", "metadata": "root.RequestRouterAdmin", "header": "['module', '___EOS___']", "index": 14 }, { "content": " @property\n def custom_app_breadcrumb_url(self):\n services = RequestRouterService.objects.all()\n if len(services)==1:\n return \"/admin/requestrouter/requestrouterservice/%s/\" % services[0].id\n else:\n return \"/admin/requestrouter/requestrouterservice/\"", "metadata": "root.RequestRouterAdmin.custom_app_breadcrumb_url", "header": "['class', 'RequestRouterAdmin', '(', 'ReadOnlyAwareAdmin', ')', ':', '___NEWLINE___', '# Change the application breadcrumb to point to an RR Service if one is', '___NL___', '# defined', '___NL___', '___EOS___']", "index": 21 }, { "content": "class RequestRouterServiceAdmin(ServiceAppAdmin):\n model = RequestRouterService\n verbose_name = \"Request Router Service\"\n verbose_name_plural = \"Request Router Service\"\n list_display = (\"name\",\"enabled\")\n fieldsets = [(None, {'fields': ['name','enabled','versionNumber', 'description','behindNat','defaultTTL','defaultAction','lastResortAction','maxAnswers'], 'classes':['suit-tab suit-tab-general']})]\n inlines = [SliceInline,ServiceAttrAsTabInline,ServicePrivilegeInline]\n\n user_readonly_fields = [\"name\", \"enabled\", \"versionNumber\", \"description\", \"behindNat\", \"defaultTTL\", \"defaultAction\", \"lastResortAction\", \"maxAnswers\"]\n\n suit_form_tabs =(('general', 'Request Router Service Details'),\n ('administration', 'Administration'),\n ('slices','Slices'),\n ('serviceattrs','Additional Attributes'),\n ('serviceprivileges','Privileges'),\n )\n\n suit_form_includes = (('rradmin.html', 'top', 'administration'),)", "metadata": "root.RequestRouterServiceAdmin", "header": "['module', '___EOS___']", "index": 29 }, { "content": "class ServiceMapAdmin(RequestRouterAdmin):\n model = ServiceMap\n verbose_name = \"Service Map\"\n verbose_name_plural = \"Service Map\"\n list_display = (\"name\", \"owner\", \"slice\", \"prefix\")\n fieldsets = [(None, {'fields': ['name','owner','slice', 'prefix','siteMap','accessMap'], 'classes':['suit-tab suit-tab-general']})]\n\n user_readonly_fields = [\"name\", \"owner\", \"slice\", \"prefix\", \"siteMap\", \"accessMap\"]\n\n suit_form_tabs =(('general', 'Service Map Details'),\n )", "metadata": "root.ServiceMapAdmin", "header": "['module', '___EOS___']", "index": 48 } ]
[ { "span": "from django import forms", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 24 }, { "span": "from django.utils.safestring import mark_safe", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 45 }, { "span": "from django.contrib.auth.admin import UserAdmin", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 47 }, { "span": "from django.contrib.admin.widgets import FilteredSelectMultiple", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 63 }, { "span": "from django.contrib.auth.forms import ReadOnlyPasswordHashField", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 63 }, { "span": "from django.contrib.auth.signals import user_logged_in", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 54 }, { "span": "from django.utils import timezone", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 33 }, { "span": "from django.contrib.contenttypes import generic", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 47 }, { "span": "from suit.widgets import LinkedSelect", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "contrib_", "import_", "admin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "services_", "._", "request", "router_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "import_", "forms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "safe", "string_", "import_", "mark", "\\u", "safe_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "admin_", "import_", "User", "Admin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "admin_", "._", "widgets_", "import_", "Filter", "ed", "Select", "Multiple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "forms_", "import_", "Read", "On", "ly", "Passw", "ord", "Hash", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "signals_", "import_", "user", "\\u", "logged", "\\u", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "timezone_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "import_", "generic_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "suit_", "._", "widgets_", "import_", "Linke", "d", "Select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "admin_", "import_", "Service", "App", "Admin_", ",_", "Slice", "Inline_", ",_", "Service", "Attr", "As", "Tab", "Inline_", ",_", "Read", "On", "ly", "Awa", "re", "Admin_", ",_", "Service", "Privilege", "Inline_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "admin_", "._", "site_", "._", "register_", "(_", "Request", "Route", "r", "Service_", ",_", "Request", "Route", "r", "Service", "Admin_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin_", "._", "site_", "._", "register_", "(_", "Service", "Map_", ",_", "Service", "Map", "Admin_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Request", "Route", "r", "Admin_", "(_", "Read", "On", "ly", "Awa", "re", "Admin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Change", " ", "the", " ", "applica", "tion", " ", "breadcrumb", " ", "to", " ", "point", " ", "to", " ", "an", " ", "RR", " ", "Service", " ", "if", " ", "one", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defined_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "change", "\\u", "form", "\\u", "template_", "=_", "\"", "admin", "/", "change", "\\u", "form", "\\u", "bc", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "change", "\\u", "list", "\\u", "template_", "=_", "\"", "admin", "/", "change", "\\u", "list", "\\u", "bc", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "app", "\\u", "breadcrumb", "\\u", "name_", "=_", "\"", "Request", " ", "Route", "r", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Request", "Route", "r", "Admin_", "(_", "Read", "On", "ly", "Awa", "re", "Admin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Change", " ", "the", " ", "applica", "tion", " ", "breadcrumb", " ", "to", " ", "point", " ", "to", " ", "an", " ", "RR", " ", "Service", " ", "if", " ", "one", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defined_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "custom", "\\u", "app", "\\u", "breadcrumb", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "services_", "=_", "Request", "Route", "r", "Service_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "services_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"/", "admin", "/", "request", "router", "/", "request", "router", "service", "/", "%", "s", "/\"_", "%_", "services_", "[_", "0_", "]_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"/", "admin", "/", "request", "router", "/", "request", "router", "service", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Request", "Route", "r", "Service", "Admin_", "(_", "Service", "App", "Admin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Request", "Route", "r", "Service_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbo", "se", "\\u", "name_", "=_", "\"", "Request", " ", "Route", "r", " ", "Service", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbo", "se", "\\u", "name", "\\u", "plural_", "=_", "\"", "Request", " ", "Route", "r", " ", "Service", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list", "\\u", "display_", "=_", "(_", "\"", "name", "\"_", ",_", "\"", "enable", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fieldsets_", "=_", "[_", "(_", "None_", ",_", "{_", "'", "fields", "'_", ":_", "[_", "'", "name", "'_", ",_", "'", "enable", "d", "'_", ",_", "'", "version", "Number", "'_", ",_", "'", "description", "'_", ",_", "'", "beh", "ind", "Nat", "'_", ",_", "'", "default", "TTL", "'_", ",_", "'", "default", "Action", "'_", ",_", "'", "last", "Reso", "rt", "Action", "'_", ",_", "'", "max", "Answer", "s", "'_", "]_", ",_", "'", "classe", "s", "'_", ":_", "[_", "'", "suit", "-", "tab", " ", "suit", "-", "tab", "-", "genera", "l", "'_", "]_", "}_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inlines_", "=_", "[_", "Slice", "Inline_", ",_", "Service", "Attr", "As", "Tab", "Inline_", ",_", "Service", "Privilege", "Inline_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "read", "only", "\\u", "fields_", "=_", "[_", "\"", "name", "\"_", ",_", "\"", "enable", "d", "\"_", ",_", "\"", "version", "Number", "\"_", ",_", "\"", "description", "\"_", ",_", "\"", "beh", "ind", "Nat", "\"_", ",_", "\"", "default", "TTL", "\"_", ",_", "\"", "default", "Action", "\"_", ",_", "\"", "last", "Reso", "rt", "Action", "\"_", ",_", "\"", "max", "Answer", "s", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suit", "\\u", "form", "\\u", "tabs_", "=_", "(_", "(_", "'", "genera", "l", "'_", ",_", "'", "Request", " ", "Route", "r", " ", "Service", " ", "Det", "ail", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "administrati", "on", "'_", ",_", "'", "Administrati", "on", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "slice", "s", "'_", ",_", "'", "Slice", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "service", "attr", "s", "'_", ",_", "'", "Addition", "al", " ", "Attribute", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "service", "privilege", "s", "'_", ",_", "'", "Privilege", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suit", "\\u", "form", "\\u", "includes_", "=_", "(_", "(_", "'", "rra", "dmin", ".", "html", "'_", ",_", "'", "top", "'_", ",_", "'", "administrati", "on", "'_", ")_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Service", "Map", "Admin_", "(_", "Request", "Route", "r", "Admin_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Service", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbo", "se", "\\u", "name_", "=_", "\"", "Service", " ", "Map", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verbo", "se", "\\u", "name", "\\u", "plural_", "=_", "\"", "Service", " ", "Map", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list", "\\u", "display_", "=_", "(_", "\"", "name", "\"_", ",_", "\"", "owner", "\"_", ",_", "\"", "slice", "\"_", ",_", "\"", "prefix", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fieldsets_", "=_", "[_", "(_", "None_", ",_", "{_", "'", "fields", "'_", ":_", "[_", "'", "name", "'_", ",_", "'", "owner", "'_", ",_", "'", "slice", "'_", ",_", "'", "prefix", "'_", ",_", "'", "site", "Map", "'_", ",_", "'", "access", "Map", "'_", "]_", ",_", "'", "classe", "s", "'_", ":_", "[_", "'", "suit", "-", "tab", " ", "suit", "-", "tab", "-", "genera", "l", "'_", "]_", "}_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "read", "only", "\\u", "fields_", "=_", "[_", "\"", "name", "\"_", ",_", "\"", "owner", "\"_", ",_", "\"", "slice", "\"_", ",_", "\"", "prefix", "\"_", ",_", "\"", "site", "Map", "\"_", ",_", "\"", "access", "Map", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suit", "\\u", "form", "\\u", "tabs_", "=_", "(_", "(_", "'", "genera", "l", "'_", ",_", "'", "Service", " ", "Map", " ", "Det", "ail", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
lorien/grab/grab/spider/base.py
[ { "content": " def get_task_from_queue(self):\n start = time.time()\n try:\n with self.timer.log_time('task_queue'):\n return self.task_queue.get()\n except queue.Empty:\n size = self.task_queue.size()\n if size:\n logger_verbose.debug(\n 'No ready-to-go tasks, Waiting for '\n 'scheduled tasks (%d)' % size)\n return True\n else:\n logger_verbose.debug('Task queue is empty.')\n return None", "metadata": "root.Spider.get_task_from_queue", "header": "['class', 'Spider', '(', 'DeprecatedThingsSpiderMixin', ')', ':', '___EOS___']", "index": 583 }, { "content": " def run_parser(self):\n \"\"\"\n Main work cycle of spider process working in parser-mode.\n \"\"\"\n self.is_parser_idle.clear()\n # Use Stat instance that does not print any logging messages\n if self.parser_mode:\n self.stat = Stat(logging_period=None)\n self.prepare_parser()\n process_request_count = 0\n try:\n recent_task_time = time.time()\n while True:\n try:\n result = self.network_result_queue.get(block=False)\n except queue.Empty:\n self.is_parser_idle.set()\n time.sleep(0.1)\n self.is_parser_idle.clear()\n logger_verbose.debug('Network result queue is empty')\n # Set `waiting_shutdown_event` only after 1 seconds\n # of waiting for tasks to avoid\n # race-condition issues\n #if time.time() - recent_task_time > 1:\n # self.waiting_shutdown_event.set()\n if self.shutdown_event.is_set():\n logger_verbose.debug('Got shutdown event')\n return\n else:\n process_request_count += 1\n recent_task_time = time.time()\n if self.parser_mode:\n self.stat.reset()\n #if self.waiting_shutdown_event.is_set():\n # self.waiting_shutdown_event.clear()\n try:\n handler = self.find_task_handler(result['task'])\n except NoTaskHandler as ex:\n ex.tb = format_exc()\n self.parser_result_queue.put((ex, result['task']))\n self.stat.inc('parser:handler-not-found')\n else:\n self.process_network_result_with_handler(\n result, handler)\n self.stat.inc('parser:handler-processed')\n finally:\n if self.parser_mode:\n data = {\n 'type': 'stat',\n 'counters': self.stat.counters,\n 'collections': self.stat.collections,\n }\n self.parser_result_queue.put((data,\n result['task']))\n if self.parser_mode:\n if self.parser_requests_per_process:\n if (process_request_count >=\n self.parser_requests_per_process):\n break\n except Exception as ex:\n logging.error('', exc_info=ex)\n raise\n #finally:\n # self.waiting_shutdown_event.set()", "metadata": "root.Spider.run_parser", "header": "['class', 'Spider', '(', 'DeprecatedThingsSpiderMixin', ')', ':', '___EOS___']", "index": 669 }, { "content": " def run(self):\n \"\"\"\n Main method. All work is done here.\n \"\"\"\n if self.mp_mode:\n from multiprocessing import Process, Event, Queue\n else:\n from multiprocessing.dummy import Process, Event, Queue\n\n self.timer.start('total')\n self.transport = MulticurlTransport(self.thread_number)\n\n if self.http_api_port:\n http_api_proc = self.start_api_thread()\n else:\n http_api_proc = None\n\n self.parser_result_queue = Queue()\n self.parser_pipeline = ParserPipeline(\n bot=self,\n mp_mode=self.mp_mode,\n pool_size=self.parser_pool_size,\n shutdown_event=self.shutdown_event,\n network_result_queue=self.network_result_queue,\n parser_result_queue=self.parser_result_queue,\n requests_per_process=self.parser_requests_per_process,\n )\n network_result_queue_limit = max(10, self.thread_number * 2)\n \n try:\n # Run custom things defined by this specific spider\n # By defaut it does nothing\n self.prepare()\n\n # Setup task queue if it has not been configured yet\n if self.task_queue is None:\n self.setup_queue()\n\n # Initiate task generator. Only in main process!\n with self.timer.log_time('task_generator'):\n self.start_task_generators()\n\n # Work in infinite cycle untill\n # `self.work_allowed` flag is True\n #shutdown_countdown = 0 # !!!\n pending_tasks = deque()\n while self.work_allowed:\n free_threads = self.transport.get_free_threads_number()\n # Load new task only if:\n # 1) network transport has free threads\n # 2) network result queue is not full\n # 3) cache is disabled OR cache has free resources\n if (self.transport.get_free_threads_number()\n and (self.network_result_queue.qsize()\n < network_result_queue_limit)\n and (self.cache_pipeline is None\n or self.cache_pipeline.has_free_resources())):\n if pending_tasks:\n task = pending_tasks.popleft()\n else:\n task = self.get_task_from_queue()\n if task is None:\n # If received task is None then\n # check if spider is ready to be shut down\n if not pending_tasks and self.is_ready_to_shutdown():\n #shutdown_countdown -= 1\n #time.sleep(0.02)\n #if shutdown_countdown <= 0:\n self.shutdown_event.set()\n #print('STOP!!!!!!!!!')\n self.stop()\n break # Break from `while self.work_allowed` cycle\n elif isinstance(task, bool) and (task is True):\n # If received task is True\n # and there is no active network threads then\n # take some sleep\n if not self.transport.get_active_threads_number():\n time.sleep(0.01)\n else:\n logger_verbose.debug('Got new task from task queue: %s'\n % task)\n task.network_try_count += 1\n is_valid, reason = self.check_task_limits(task)\n if is_valid:\n task_grab = self.setup_grab_for_task(task)\n if self.cache_pipeline:\n self.cache_pipeline.input_queue.put(\n ('load', (task, task_grab)),\n )\n else:\n self.submit_task_to_transport(task, task_grab)\n else:\n self.log_rejected_task(task, reason)\n handler = task.get_fallback_handler(self)\n if handler:\n handler(task)\n\n with self.timer.log_time('network_transport'):\n logger_verbose.debug('Asking transport layer to do '\n 'something')\n self.transport.process_handlers()\n\n logger_verbose.debug('Processing network results (if any).')\n\n # Collect completed network results\n # Each result could be valid or failed\n # Result is dict {ok, grab, grab_config_backup, task, emsg}\n results = [(x, False) for x in\n self.transport.iterate_results()]\n if self.cache_pipeline:\n while True:\n try:\n action, result = self.cache_pipeline\\\n .result_queue.get(False)\n except queue.Empty:\n break\n else:\n assert action in ('network_result', 'task')\n if action == 'network_result':\n results.append((result, True))\n elif action == 'task':\n task = result\n task_grab = self.setup_grab_for_task(task)\n if (self.transport.get_free_threads_number()\n and (self.network_result_queue.qsize()\n < network_result_queue_limit)):\n self.submit_task_to_transport(task, task_grab)\n else:\n pending_tasks.append(task)\n\n # Take sleep to avoid millions of iterations per second.\n # 1) If no results from network transport\n # 2) If task queue is empty (or if there are only delayed tasks)\n # 3) If no network activity\n # 4) If parser result queue is empty\n if (not results\n and (task is None or bool(task) == True)\n and not self.transport.get_active_threads_number()\n and not self.parser_result_queue.qsize()\n and (self.cache_pipeline is None\n or (self.cache_pipeline.input_queue.qsize() == 0\n and self.cache_pipeline.is_idle()\n and self.cache_pipeline.result_queue.qsize() == 0))\n ):\n time.sleep(0.001)\n\n for result, from_cache in results:\n if self.cache_pipeline and not from_cache:\n if result['ok']:\n self.cache_pipeline.input_queue.put(\n ('save', (result['task'], result['grab']))\n )\n self.log_network_result_stats(\n result, from_cache=from_cache)\n if self.is_valid_network_result(result):\n #print('!! PUT NETWORK RESULT INTO QUEUE (base.py)')\n self.network_result_queue.put(result)\n else:\n self.log_failed_network_result(result)\n # Try to do network request one more time\n if self.network_try_limit > 0:\n result['task'].refresh_cache = True\n result['task'].setup_grab_config(\n result['grab_config_backup'])\n self.add_task(result['task'])\n if from_cache:\n self.stat.inc('spider:task-%s-cache' % result['task'].name)\n self.stat.inc('spider:request')\n\n while True:\n try:\n p_res, p_task = self.parser_result_queue.get(block=False)\n except queue.Empty:\n break\n else:\n self.stat.inc('spider:parser-result')\n self.process_handler_result(p_res, p_task)\n\n if not self.shutdown_event.is_set():\n self.parser_pipeline.check_pool_health()\n\n logger_verbose.debug('Work done')\n except KeyboardInterrupt:\n logger.info('\\nGot ^C signal in process %d. Stopping.'\n % os.getpid())\n self.interrupted = True\n raise\n finally:\n # This code is executed when main cycles is breaked\n self.timer.stop('total')\n self.stat.print_progress_line()\n self.shutdown()\n\n # Stop HTTP API process\n if http_api_proc:\n http_api_proc.server.shutdown()\n http_api_proc.join()\n\n if self.task_queue:\n self.task_queue.clear()\n\n # Stop parser processes\n self.shutdown_event.set()\n self.parser_pipeline.shutdown()\n logger.debug('Main process [pid=%s]: work done' % os.getpid())", "metadata": "root.Spider.run", "header": "['class', 'Spider', '(', 'DeprecatedThingsSpiderMixin', ')', ':', '___EOS___']", "index": 901 } ]
[ { "span": "start ", "start_line": 584, "start_column": 8, "end_line": 584, "end_column": 13 }, { "span": "recent_task_time ", "start_line": 699, "start_column": 20, "end_line": 699, "end_column": 36 }, { "span": "free_threads ", "start_line": 948, "start_column": 16, "end_line": 948, "end_column": 28 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Spider_", "(_", "Dep", "reca", "ted", "Thin", "gs", "Spi", "der", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "task", "\\u", "from", "\\u", "queue_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "timer_", "._", "log", "\\u", "time_", "(_", "'", "task", "\\u", "queue", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "task", "\\u", "queue_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "queue_", "._", "Empty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "self_", "._", "task", "\\u", "queue_", "._", "size_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "No", " ", "read", "y", "-", "to", "-", "go", " ", "task", "s", ",", " ", "Wait", "ing", " ", "for", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "schedule", "d", " ", "task", "s", " ", "(%", "d", ")'_", "%_", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Task", " ", "queue", " ", "is", " ", "empty", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Spider_", "(_", "Dep", "reca", "ted", "Thin", "gs", "Spi", "der", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "parser_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Main", " ", "work", " ", "cycle", " ", "of", " ", "spider", " ", "process", " ", "working", " ", "in", " ", "parser", "-", "mode", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "is", "\\u", "parser", "\\u", "idle_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Us", "e", " ", "Stat", " ", "instance", " ", "tha", "t", " ", "doe", "s", " ", "not", " ", "print", " ", "any", " ", "logg", "ing", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "parser", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "stat_", "=_", "Stat_", "(_", "logg", "ing", "\\u", "period_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "prepar", "e\\u", "parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "\\u", "request", "\\u", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "recent", "\\u", "task", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "=_", "self_", "._", "network", "\\u", "result", "\\u", "queue_", "._", "get_", "(_", "block_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "queue_", "._", "Empty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "is", "\\u", "parser", "\\u", "idle_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "is", "\\u", "parser", "\\u", "idle_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Network", " ", "result", " ", "queue", " ", "is", " ", "empty", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Set", " ", "`", "wait", "ing", "\\u", "shut", "down", "\\u", "event", "`", " ", "only", " ", "after", " ", "1", " ", "seconds_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "wait", "ing", " ", "for", " ", "task", "s", " ", "to", " ", "avoid", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "race", "-", "condition", " ", "issues_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "time", ".", "time", "()", " ", "-", " ", "recent", "\\u", "task", "\\u", "time", " ", ">", " ", "1", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "wait", "ing", "\\u", "shut", "down", "\\u", "event", ".", "set", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "shut", "down", "\\u", "event_", "._", "is", "\\u", "set_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Got", " ", "shut", "down", " ", "event", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "process", "\\u", "request", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "recent", "\\u", "task", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "parser", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "stat_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "self", ".", "wait", "ing", "\\u", "shut", "down", "\\u", "event", ".", "is", "\\u", "set", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "wait", "ing", "\\u", "shut", "down", "\\u", "event", ".", "clear", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "handler_", "=_", "self_", "._", "find", "\\u", "task", "\\u", "handler_", "(_", "result_", "[_", "'", "task", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Task", "Handler_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "ex_", "._", "tb_", "=_", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", "._", "put_", "(_", "(_", "ex_", ",_", "result_", "[_", "'", "task", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stat_", "._", "inc_", "(_", "'", "parser", ":", "handler", "-", "not", "-", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "process", "\\u", "network", "\\u", "result", "\\u", "with", "\\u", "handler_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "result_", ",_", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stat_", "._", "inc_", "(_", "'", "parser", ":", "handler", "-", "process", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "parser", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "stat", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "counter", "s", "'_", ":_", "self_", "._", "stat_", "._", "counters_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "collection", "s", "'_", ":_", "self_", "._", "stat_", "._", "collections_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", "._", "put_", "(_", "(_", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "task", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "parser", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "parser", "\\u", "request", "s", "\\u", "per", "\\u", "process_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "(_", "process", "\\u", "request", "\\u", "count_", ">=_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "parser", "\\u", "request", "s", "\\u", "per", "\\u", "process_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "''_", ",_", "exc", "\\u", "info_", "=_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "final", "ly", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "wait", "ing", "\\u", "shut", "down", "\\u", "event", ".", "set", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Spider_", "(_", "Dep", "reca", "ted", "Thin", "gs", "Spi", "der", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Main", " ", "method", ".", " ", "All", " ", "work", " ", "is", " ", "don", "e", " ", "here", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "mp", "\\u", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "multiprocessing_", "import_", "Process_", ",_", "Event_", ",_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "multiprocessing_", "._", "dummy_", "import_", "Process_", ",_", "Event_", ",_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "timer_", "._", "start_", "(_", "'", "total", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "=_", "Multi", "curl", "Transport_", "(_", "self_", "._", "thread", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "http", "\\u", "api", "\\u", "port_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "http", "\\u", "api", "\\u", "proc_", "=_", "self_", "._", "start", "\\u", "api", "\\u", "thread_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "http", "\\u", "api", "\\u", "proc_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", "=_", "Queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parser", "\\u", "pipeline_", "=_", "Parser", "Pipeline_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "bot_", "=_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mp", "\\u", "mode_", "=_", "self_", "._", "mp", "\\u", "mode_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pool", "\\u", "size_", "=_", "self_", "._", "parser", "\\u", "pool", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "shut", "down", "\\u", "event_", "=_", "self_", "._", "shut", "down", "\\u", "event_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "network", "\\u", "result", "\\u", "queue_", "=_", "self_", "._", "network", "\\u", "result", "\\u", "queue_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parser", "\\u", "result", "\\u", "queue_", "=_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request", "s", "\\u", "per", "\\u", "process_", "=_", "self_", "._", "parser", "\\u", "request", "s", "\\u", "per", "\\u", "process_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network", "\\u", "result", "\\u", "queue", "\\u", "limit_", "=_", "max_", "(_", "10_", ",_", "self_", "._", "thread", "\\u", "number_", "*_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Run", " ", "custom", " ", "thing", "s", " ", "defin", "ed", " ", "by", " ", "this", " ", "specific", " ", "spider_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "By", " ", "def", "aut", " ", "it", " ", "doe", "s", " ", "nothing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "prepare_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", "up", " ", "task", " ", "queue", " ", "if", " ", "it", " ", "has", " ", "not", " ", "bee", "n", " ", "configur", "ed", " ", "ye", "t_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "task", "\\u", "queue_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "setup", "\\u", "queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initiat", "e", " ", "task", " ", "generat", "or", ".", " ", "On", "ly", " ", "in", " ", "main", " ", "process", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "timer_", "._", "log", "\\u", "time_", "(_", "'", "task", "\\u", "generat", "or", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "\\u", "task", "\\u", "generators_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Work", " ", "in", " ", "infini", "te", " ", "cycle", " ", "unti", "ll_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "`", "self", ".", "work", "\\u", "allow", "ed", "`", " ", "flag", " ", "is", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "#", "shut", "down", "\\u", "countdown", " ", "=", " ", "0", " ", "#", " ", "!!!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pend", "ing", "\\u", "tasks_", "=_", "deque_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "self_", "._", "work", "\\u", "allowed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "free", "\\u", "threads_", "=_", "self_", "._", "transport_", "._", "get", "\\u", "free", "\\u", "thread", "s", "\\u", "number_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Load", " ", "new", " ", "task", " ", "only", " ", "if", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ")", " ", "network", " ", "transport", " ", "has", " ", "free", " ", "threads_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ")", " ", "network", " ", "result", " ", "queue", " ", "is", " ", "not", " ", "full_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", ")", " ", "cache", " ", "is", " ", "disable", "d", " ", "OR", " ", "cache", " ", "has", " ", "free", " ", "resources_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "self_", "._", "transport_", "._", "get", "\\u", "free", "\\u", "thread", "s", "\\u", "number_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "(_", "self_", "._", "network", "\\u", "result", "\\u", "queue_", "._", "qsize_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "<_", "network", "\\u", "result", "\\u", "queue", "\\u", "limit_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "(_", "self_", "._", "cache", "\\u", "pipeline_", "is_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "self_", "._", "cache", "\\u", "pipeline_", "._", "has", "\\u", "free", "\\u", "resources_", "(_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "pend", "ing", "\\u", "tasks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "task_", "=_", "pend", "ing", "\\u", "tasks_", "._", "popleft_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "task_", "=_", "self_", "._", "get", "\\u", "task", "\\u", "from", "\\u", "queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "task_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "receive", "d", " ", "task", " ", "is", " ", "Non", "e", " ", "then_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "spider", " ", "is", " ", "read", "y", " ", "to", " ", "be", " ", "shut", " ", "down_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "pend", "ing", "\\u", "tasks_", "and_", "self_", "._", "is", "\\u", "read", "y", "\\u", "to", "\\u", "shutdown_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "shut", "down", "\\u", "countdown", " ", "-=", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "#", "time", ".", "sleep", "(", "0.02", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "shut", "down", "\\u", "countdown", " ", "<=", " ", "0", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "shut", "down", "\\u", "event_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "('", "STOP", "!!!!!!", "!!!", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "#", " ", "Break", " ", "from", " ", "`", "whi", "le", " ", "self", ".", "work", "\\u", "allow", "ed", "`", " ", "cycle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "task_", ",_", "bool_", ")_", "and_", "(_", "task_", "is_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "receive", "d", " ", "task", " ", "is", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "there", " ", "is", " ", "no", " ", "active", " ", "network", " ", "thread", "s", " ", "then_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "take", " ", "some", " ", "sleep_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "self_", "._", "transport_", "._", "get", "\\u", "active", "\\u", "thread", "s", "\\u", "number_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "time_", "._", "sleep_", "(_", "0.01_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Got", " ", "new", " ", "task", " ", "from", " ", "task", " ", "queue", ":", " ", "%", "s", "'_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "task_", "._", "network", "\\u", "try", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "valid_", ",_", "reason_", "=_", "self_", "._", "check", "\\u", "task", "\\u", "limits_", "(_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "is", "\\u", "valid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "task", "\\u", "grab_", "=_", "self_", "._", "setup", "\\u", "gra", "b", "\\u", "for", "\\u", "task_", "(_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "cache", "\\u", "pipeline_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "cache", "\\u", "pipeline_", "._", "input", "\\u", "queue_", "._", "put_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "load", "'_", ",_", "(_", "task_", ",_", "task", "\\u", "grab_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "submit", "\\u", "task", "\\u", "to", "\\u", "transport_", "(_", "task_", ",_", "task", "\\u", "grab_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "log", "\\u", "reject", "ed", "\\u", "task_", "(_", "task_", ",_", "reason_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "=_", "task_", "._", "get", "\\u", "fall", "back", "\\u", "handler_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handler_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "handler_", "(_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "timer_", "._", "log", "\\u", "time_", "(_", "'", "network", "\\u", "transport", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "As", "king", " ", "transport", " ", "layer", " ", "to", " ", "do", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "somet", "hing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "._", "process", "\\u", "handlers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Process", "ing", " ", "network", " ", "results", " ", "(", "if", " ", "any", ").'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Collect", " ", "complete", "d", " ", "network", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ea", "ch", " ", "result", " ", "coul", "d", " ", "be", " ", "valid", " ", "or", " ", "failed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Result", " ", "is", " ", "dict", " ", "{", "ok", ",", " ", "gra", "b", ",", " ", "gra", "b", "\\u", "config", "\\u", "backup", ",", " ", "task", ",", " ", "ems", "g", "}_", "\\u\\u\\uNL\\u\\u\\u_", "results_", "=_", "[_", "(_", "x_", ",_", "False_", ")_", "for_", "x_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "transport_", "._", "iterate", "\\u", "results_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "cache", "\\u", "pipeline_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "action_", ",_", "result_", "=_", "self_", "._", "cache", "\\u", "pipeline_", "._", "result", "\\u", "queue_", "._", "get_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "queue_", "._", "Empty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "assert_", "action_", "in_", "(_", "'", "network", "\\u", "result", "'_", ",_", "'", "task", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "action_", "==_", "'", "network", "\\u", "result", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "results_", "._", "append_", "(_", "(_", "result_", ",_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "action_", "==_", "'", "task", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "task_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "task", "\\u", "grab_", "=_", "self_", "._", "setup", "\\u", "gra", "b", "\\u", "for", "\\u", "task_", "(_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "transport_", "._", "get", "\\u", "free", "\\u", "thread", "s", "\\u", "number_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "(_", "self_", "._", "network", "\\u", "result", "\\u", "queue_", "._", "qsize_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "<_", "network", "\\u", "result", "\\u", "queue", "\\u", "limit_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "submit", "\\u", "task", "\\u", "to", "\\u", "transport_", "(_", "task_", ",_", "task", "\\u", "grab_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pend", "ing", "\\u", "tasks_", "._", "append_", "(_", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tak", "e", " ", "sleep", " ", "to", " ", "avoid", " ", "milli", "ons", " ", "of", " ", "iterati", "ons", " ", "per", " ", "second", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ")", " ", "If", " ", "no", " ", "results", " ", "from", " ", "network", " ", "transport_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", ")", " ", "If", " ", "task", " ", "queue", " ", "is", " ", "empty", " ", "(", "or", " ", "if", " ", "there", " ", "are", " ", "only", " ", "delayed", " ", "task", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", ")", " ", "If", " ", "no", " ", "network", " ", "activity_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "4", ")", " ", "If", " ", "parser", " ", "result", " ", "queue", " ", "is", " ", "empty_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "results_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "(_", "task_", "is_", "None_", "or_", "bool_", "(_", "task_", ")_", "==_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "not_", "self_", "._", "transport_", "._", "get", "\\u", "active", "\\u", "thread", "s", "\\u", "number_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "not_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", "._", "qsize_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "(_", "self_", "._", "cache", "\\u", "pipeline_", "is_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "(_", "self_", "._", "cache", "\\u", "pipeline_", "._", "input", "\\u", "queue_", "._", "qsize_", "(_", ")_", "==_", "0_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "self_", "._", "cache", "\\u", "pipeline_", "._", "is", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "self_", "._", "cache", "\\u", "pipeline_", "._", "result", "\\u", "queue_", "._", "qsize_", "(_", ")_", "==_", "0_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "time_", "._", "sleep_", "(_", "0.001_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "result_", ",_", "from", "\\u", "cache_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "cache", "\\u", "pipeline_", "and_", "not_", "from", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "result_", "[_", "'", "ok", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "cache", "\\u", "pipeline_", "._", "input", "\\u", "queue_", "._", "put_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "save", "'_", ",_", "(_", "result_", "[_", "'", "task", "'_", "]_", ",_", "result_", "[_", "'", "gra", "b", "'_", "]_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "log", "\\u", "network", "\\u", "result", "\\u", "stats_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "result_", ",_", "from", "\\u", "cache_", "=_", "from", "\\u", "cache_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "is", "\\u", "valid", "\\u", "network", "\\u", "result_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "('", "!!", " ", "PU", "T", " ", "NET", "WORK", " ", "RESU", "LT", " ", "INT", "O", " ", "QUEUE", " ", "(", "base", ".", "py", ")'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "network", "\\u", "result", "\\u", "queue_", "._", "put_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "log", "\\u", "fail", "ed", "\\u", "network", "\\u", "result_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "to", " ", "do", " ", "network", " ", "request", " ", "one", " ", "more", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "network", "\\u", "try", "\\u", "limit_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "result_", "[_", "'", "task", "'_", "]_", "._", "refre", "sh", "\\u", "cache_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "task", "'_", "]_", "._", "setup", "\\u", "gra", "b", "\\u", "config_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "gra", "b", "\\u", "config", "\\u", "backup", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "task_", "(_", "result_", "[_", "'", "task", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "from", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "stat_", "._", "inc_", "(_", "'", "spider", ":", "task", "-%", "s", "-", "cache", "'_", "%_", "result_", "[_", "'", "task", "'_", "]_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "stat_", "._", "inc_", "(_", "'", "spider", ":", "request", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "p", "\\u", "res_", ",_", "p", "\\u", "task_", "=_", "self_", "._", "parser", "\\u", "result", "\\u", "queue_", "._", "get_", "(_", "block_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "queue_", "._", "Empty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "stat_", "._", "inc_", "(_", "'", "spider", ":", "parser", "-", "result", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "process", "\\u", "handler", "\\u", "result_", "(_", "p", "\\u", "res_", ",_", "p", "\\u", "task_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "shut", "down", "\\u", "event_", "._", "is", "\\u", "set_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "parser", "\\u", "pipeline_", "._", "check", "\\u", "pool", "\\u", "health_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logg", "er", "\\u", "verbose_", "._", "debug_", "(_", "'", "Work", " ", "don", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'\\\\", "n", "Got", " ", "^", "C", " ", "signal", " ", "in", " ", "process", " ", "%", "d", ".", " ", "Stopp", "ing", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "os_", "._", "getpid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "interrupted", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "code", " ", "is", " ", "executed", " ", "whe", "n", " ", "main", " ", "cycle", "s", " ", "is", " ", "break", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "._", "stop_", "(_", "'", "total", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stat_", "._", "print", "\\u", "progress", "\\u", "line_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sto", "p", " ", "HTTP", " ", "API", " ", "process_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "http", "\\u", "api", "\\u", "proc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "http", "\\u", "api", "\\u", "proc_", "._", "server_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http", "\\u", "api", "\\u", "proc_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "task", "\\u", "queue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "task", "\\u", "queue_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sto", "p", " ", "parser", " ", "processes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "shut", "down", "\\u", "event_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parser", "\\u", "pipeline_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Main", " ", "process", " ", "[", "pid", "=", "%", "s", "]:", " ", "work", " ", "don", "e", "'_", "%_", "os_", "._", "getpid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
michaelcontento/revolver/revolver/text.py
[ { "content": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import, division, with_statement\n\nfrom cuisine import text_detect_eol as detect_eol\nfrom cuisine import text_ensure_line as ensure_line\nfrom cuisine import text_normalize as spaces_normalize\nfrom cuisine import text_nospace as spaces_remove\nfrom cuisine import text_replace_line as replace_line\nfrom cuisine import text_strip_margin as strip_margin\nfrom cuisine import text_template as template\nfrom cuisine import WINDOWS_EOL, UNIX_EOL, MAC_EOL\nfrom fabric.utils import indent\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from cuisine import text_detect_eol as detect_eol", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 49 }, { "span": "from cuisine import text_ensure_line as ensure_line", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 51 }, { "span": "from cuisine import text_normalize as spaces_normalize", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 54 }, { "span": "from cuisine import text_nospace as spaces_remove", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 49 }, { "span": "from cuisine import text_replace_line as replace_line", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 53 }, { "span": "from cuisine import text_strip_margin as strip_margin", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 53 }, { "span": "from cuisine import text_template as template", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 45 }, { "span": "from cuisine import WINDOWS_EOL, UNIX_EOL, MAC_EOL", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 50 }, { "span": "from fabric.utils import indent", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 31 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", ",_", "division_", ",_", "with", "\\u", "statement_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "detect", "\\u", "eol_", "as_", "detect", "\\u", "eol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "ensure", "\\u", "line_", "as_", "ensure", "\\u", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "normalize_", "as_", "space", "s", "\\u", "normalize_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "nos", "pace_", "as_", "space", "s", "\\u", "remove_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "replace", "\\u", "line_", "as_", "replace", "\\u", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "strip", "\\u", "margin_", "as_", "strip", "\\u", "margin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "text", "\\u", "template_", "as_", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cui", "sine", "_", "import_", "WINDOWS", "\\u", "EO", "L_", ",_", "UNIX", "\\u", "EO", "L_", ",_", "MAC", "\\u", "EO", "L_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fabric_", "._", "utils_", "import_", "indent_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1 ]
Variable defined multiple times
dokterbob/satchmo/satchmo/projects/simple/local_settings.py
[ { "content": "# this is an extremely simple Satchmo standalone store.\n\nimport logging\nimport os, os.path\n\nLOCAL_DEV = True\nDEBUG = True\nTEMPLATE_DEBUG = DEBUG\n\nif LOCAL_DEV:\n INTERNAL_IPS = ('127.0.0.1',)\n\nDIRNAME = os.path.dirname(os.path.abspath(__file__))\n\n# trick to get the two-levels up directory, which for the \"simple\" project should be the satchmo dir\n# for most \"normal\" projects, you should directly set the SATCHMO_DIRNAME, and skip the trick\n_parent = lambda x: os.path.normpath(os.path.join(x, '..'))\nSATCHMO_DIRNAME = _parent(_parent(DIRNAME))\n \n# since we don't have any custom media for this project, lets just use Satchmo's\nMEDIA_ROOT = os.path.join(SATCHMO_DIRNAME, 'static/')\n\ngettext_noop = lambda s:s\n\nLANGUAGE_CODE = 'en-us'\nLANGUAGES = (\n ('en', gettext_noop('English')),\n)\n\n# Only set these if Satchmo is part of another Django project\n#These are used when loading the test data\nSITE_NAME = \"simple\"\nMEDIA_ROOT = os.path.join(SATCHMO_DIRNAME, 'static/')\nDJANGO_PROJECT = 'simple'\nDJANGO_SETTINGS_MODULE = 'simple.settings'\n\n# \"simple\" doesn't have any custom templates, usually you'd have one here for your site.\nTEMPLATE_DIRS = (\n os.path.join(DIRNAME, \"templates\"),\n)\n\nDATABASE_ENGINE = 'sqlite3'\nDATABASE_NAME = os.path.join(DIRNAME, 'simple.db')\nSECRET_KEY = 'EXAMPLE SECRET KEY'\n\n##### For Email ########\n# If this isn't set in your settings file, you can set these here\n#EMAIL_HOST = 'host here'\n#EMAIL_PORT = 587\n#EMAIL_HOST_USER = 'your user here'\n#EMAIL_HOST_PASSWORD = 'your password'\n#EMAIL_USE_TLS = True\n\n#These are used when loading the test data\nSITE_DOMAIN = \"localhost\"\nSITE_NAME = \"Simple Satchmo\"\n\n# not suitable for deployment, for testing only, for deployment strongly consider memcached.\nCACHE_BACKEND = \"locmem:///\"\nCACHE_TIMEOUT = 60*5\nCACHE_PREFIX = \"Z\"\n\nACCOUNT_ACTIVATION_DAYS = 7\n\n#Configure logging\nLOGFILE = \"satchmo.log\"\nlogging.basicConfig(level=logging.DEBUG,\n format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',\n datefmt='%a, %d %b %Y %H:%M:%S')\n\n#fileLog = logging.FileHandler(os.path.join(DIRNAME, LOGFILE), 'w')\n#fileLog.setLevel(logging.DEBUG)\n# add the handler to the root logger\n#logging.getLogger('').addHandler(fileLog)\nlogging.getLogger('keyedcache').setLevel(logging.INFO)\nlogging.getLogger('l10n').setLevel(logging.INFO)\nlogging.info(\"Satchmo Started\")\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "MEDIA_ROOT ", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 10 }, { "span": "SITE_NAME ", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 9 } ]
[ { "span": "MEDIA_ROOT ", "start_line": 32, "start_column": 0, "end_line": 32, "end_column": 10 }, { "span": "SITE_NAME ", "start_line": 55, "start_column": 0, "end_line": 55, "end_column": 9 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "an", " ", "extreme", "ly", " ", "simple", " ", "Sat", "chm", "o", " ", "standalone", " ", "store", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LOCAL", "\\u", "DEV", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DEBUG_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TEMPL", "ATE", "\\u", "DEBUG_", "=_", "DEBUG_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "LOCAL", "\\u", "DEV", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "INTERN", "AL", "\\u", "IPS", "_", "=_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "DIR", "NAME_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "trick", " ", "to", " ", "get", " ", "the", " ", "two", "-", "level", "s", " ", "up", " ", "director", "y", ",", " ", "whi", "ch", " ", "for", " ", "the", " ", "\"", "simple", "\"", " ", "project", " ", "shou", "ld", " ", "be", " ", "the", " ", "sat", "chm", "o", " ", "dir_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "most", " ", "\"", "normal", "\"", " ", "project", "s", ",", " ", "you", " ", "shou", "ld", " ", "direct", "ly", " ", "set", " ", "the", " ", "SAT", "CH", "MO", "\\u", "DIR", "NAME", ",", " ", "and", " ", "skip", " ", "the", " ", "trick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "parent_", "=_", "lambda_", "x_", ":_", "os_", "._", "path_", "._", "normpath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "x_", ",_", "'..'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SAT", "CH", "MO", "\\u", "DIR", "NAME_", "=_", "\\u", "parent_", "(_", "\\u", "parent_", "(_", "DIR", "NAME_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sinc", "e", " ", "we", " ", "don", "'", "t", " ", "have", " ", "any", " ", "custom", " ", "media", " ", "for", " ", "this", " ", "project", ",", " ", "lets", " ", "just", " ", "use", " ", "Sat", "chm", "o", "'", "s_", "\\u\\u\\uNL\\u\\u\\u_", "MEDIA", "\\u", "ROOT_", "=_", "os_", "._", "path_", "._", "join_", "(_", "SAT", "CH", "MO", "\\u", "DIR", "NAME_", ",_", "'", "static", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gettext", "\\u", "noop_", "=_", "lambda_", "s_", ":_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LANGUAGE", "\\u", "CODE_", "=_", "'", "en", "-", "us", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LANGUAGES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "en", "'_", ",_", "gettext", "\\u", "noop_", "(_", "'", "Eng", "lish", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "On", "ly", " ", "set", " ", "these", " ", "if", " ", "Sat", "chm", "o", " ", "is", " ", "part", " ", "of", " ", "anot", "her", " ", "Dj", "ang", "o", " ", "project_", "\\u\\u\\uNL\\u\\u\\u_", "#", "The", "se", " ", "are", " ", "used", " ", "whe", "n", " ", "load", "ing", " ", "the", " ", "test", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "SITE", "\\u", "NAME_", "=_", "\"", "simple", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "MEDIA", "\\u", "ROOT_", "=_", "os_", "._", "path_", "._", "join_", "(_", "SAT", "CH", "MO", "\\u", "DIR", "NAME_", ",_", "'", "static", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DJANGO", "\\u", "PROJECT_", "=_", "'", "simple", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DJANGO", "\\u", "SETTING", "S", "\\u", "MODULE_", "=_", "'", "simple", ".", "settings", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "simple", "\"", " ", "doe", "sn", "'", "t", " ", "have", " ", "any", " ", "custom", " ", "template", "s", ",", " ", "usual", "ly", " ", "you", "'", "d", " ", "have", " ", "one", " ", "here", " ", "for", " ", "your", " ", "site", "._", "\\u\\u\\uNL\\u\\u\\u_", "TEMPL", "ATE", "\\u", "DIRS_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "join_", "(_", "DIR", "NAME_", ",_", "\"", "template", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DATA", "BASE", "\\u", "ENGINE_", "=_", "'", "sql", "ite", "3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DATA", "BASE", "\\u", "NAME_", "=_", "os_", "._", "path_", "._", "join_", "(_", "DIR", "NAME_", ",_", "'", "simple", ".", "db", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SEC", "RET", "\\u", "KEY_", "=_", "'", "EXAMPLE", " ", "SEC", "RET", " ", "KEY", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#####", " ", "For", " ", "Ema", "il", " ", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "this", " ", "isn", "'", "t", " ", "set", " ", "in", " ", "your", " ", "settings", " ", "file", ",", " ", "you", " ", "can", " ", "set", " ", "these", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "#", "EMA", "IL", "\\u", "HOST", " ", "=", " ", "'", "host", " ", "here", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "EMA", "IL", "\\u", "PORT", " ", "=", " ", "587", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "EMA", "IL", "\\u", "HOST", "\\u", "USER", " ", "=", " ", "'", "your", " ", "user", " ", "here", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "EMA", "IL", "\\u", "HOST", "\\u", "PASS", "WORD", " ", "=", " ", "'", "your", " ", "password", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "EMA", "IL", "\\u", "USE", "\\u", "TLS", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "The", "se", " ", "are", " ", "used", " ", "whe", "n", " ", "load", "ing", " ", "the", " ", "test", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "SITE", "\\u", "DOMAIN_", "=_", "\"", "local", "host", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SITE", "\\u", "NAME_", "=_", "\"", "Simple", " ", "Sat", "chm", "o", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "not", " ", "suit", "able", " ", "for", " ", "deploy", "ment", ",", " ", "for", " ", "testi", "ng", " ", "only", ",", " ", "for", " ", "deploy", "ment", " ", "strong", "ly", " ", "consider", " ", "memcached", "._", "\\u\\u\\uNL\\u\\u\\u_", "CACHE", "\\u", "BACKEND_", "=_", "\"", "loc", "mem", ":///", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CACHE", "\\u", "TIMEOUT_", "=_", "60_", "*_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CACHE", "\\u", "PREFIX_", "=_", "\"", "Z", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ACCOUNT", "\\u", "ACTIVAT", "ION", "\\u", "DAYS_", "=_", "7_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Configure", " ", "logging_", "\\u\\u\\uNL\\u\\u\\u_", "LOG", "FILE_", "=_", "\"", "sat", "chm", "o", ".", "log", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "basic", "Config_", "(_", "level_", "=_", "logging_", "._", "DEBUG_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "format_", "=_", "'%", "(", "asc", "time", ")", "s", " ", "%", "(", "name", ")-", "1", "2s", " ", "%", "(", "level", "name", ")-", "8s", " ", "%", "(", "message", ")", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datefmt_", "=_", "'%", "a", ",", " ", "%", "d", " ", "%", "b", " ", "%", "Y", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "file", "Log", " ", "=", " ", "logg", "ing", ".", "File", "Handle", "r", "(", "os", ".", "path", ".", "join", "(", "DIR", "NAME", ",", " ", "LOG", "FILE", "),", " ", "'", "w", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "file", "Log", ".", "set", "Leve", "l", "(", "logg", "ing", ".", "DEBU", "G", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "the", " ", "handler", " ", "to", " ", "the", " ", "root", " ", "logger_", "\\u\\u\\uNL\\u\\u\\u_", "#", "logg", "ing", ".", "get", "Log", "ger", "(''", ").", "add", "Handle", "r", "(", "file", "Log", ")_", "\\u\\u\\uNL\\u\\u\\u_", "logging_", "._", "get", "Logger_", "(_", "'", "keyed", "cache", "'_", ")_", "._", "set", "Level_", "(_", "logging_", "._", "INFO_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "get", "Logger_", "(_", "'", "l10", "n", "'_", ")_", "._", "set", "Level_", "(_", "logging_", "._", "INFO_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "Sat", "chm", "o", " ", "Start", "ed", "\"_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
shinymud/ShinyMUD/tests/shinytest/lib/test_sport.py
[ { "content": " def test_shiny_area_format(self):\n \"\"\"Make sure the read/write formatters for ShinyAreaFormat work correctly.\n \"\"\"\n from shinymud.lib.sport_plugins.formatters.area_write_shiny_format import format as writeshiny\n from shinymud.lib.sport_plugins.formatters.area_read_shiny_format import format as readshiny\n area = self._create_area()\n area_txt = writeshiny(area)\n self.world.log.debug(area_txt)\n self.world.destroy_area(area.name, 'test')\n self.assertFalse(self.world.area_exists('foo'))\n readshiny(self.world, area_txt)\n \n self.assertTrue(self.world.area_exists('foo'))\n nufoo = self.world.get_area('foo')\n \n # Test to make sure all scripts are good\n self.assertEqual(len(nufoo.scripts.keys()), 1)\n s1 = nufoo.get_script('1')\n self.assertEqual('say ...', s1.body)\n self.assertEqual('bar', s1.name)\n \n # Test to make sure all items are good\n i1 = nufoo.get_item('1')\n self.assertEqual('chair', i1.name)\n self.assertTrue(i1.has_type('furniture'))\n self.assertEqual(i1.item_types['furniture'].capacity, 1)\n \n # Make sure the npcs come back good\n n1 = nufoo.get_npc('1')\n self.assertEqual('Link', n1.name)\n self.assertEqual('This little elf-man has some hearts tattooed on his arm.', n1.description)\n nevent = n1.events['hears'][0]\n self.assertEqual(nevent.event_trigger, 'hears')\n self.assertTrue(nevent.script is s1)\n self.assertEqual(nevent.condition, 'Gannon')\n \n # Go through the rooms...\n r1 = nufoo.get_room('1')\n r2 = nufoo.get_room('2')\n self.assertEqual('Room 1', r1.name)\n self.assertEqual('Cool room.', r1.description)\n self.assertTrue(r1.exits['north'].to_room is r2)\n self.assertTrue(r2.exits['south'].to_room is r1)\n self.assertTrue(r1.spawns['1'].spawn_object is i1)\n self.assertTrue(r2.spawns['1'].spawn_object is n1)\n \n # Make sure the spawns were reset properly\n self.assertEqual(len(r1.items), 1)\n self.assertEqual(len(r2.npcs), 1)", "metadata": "root.TestSport.test_shiny_area_format", "header": "['class', 'TestSport', '(', 'ShinyTestCase', ')', ':', '___EOS___']", "index": 6 }, { "content": " def test_shiny_player_format(self):\n from shinymud.lib.sport_plugins.formatters.player_write_shiny_format import format as writeshiny\n from shinymud.lib.sport_plugins.formatters.player_read_shiny_format import format as readshiny\n from shinymud.models.player import Player\n #create a playa\n sven = Player(('foo', 'bar'))\n sven.playerize({'name': 'sven', 'password': 'foo'})\n sven.permissions = 17\n sven.description = \"I'm pretty adorable.\"\n sven.title = 'Super Sven'\n sven.save()\n area = self._create_area()\n sven.item_add(area.get_item('1').load())\n \n txt = writeshiny(sven)\n self.world.log.debug(txt)\n \n sven.destruct()\n # Sven should have been taken out of the database...\n row = self.world.db.select('* from player where name=?', ['sven'])\n self.assertFalse(row)\n row = self.world.db.select('* from game_item where owner=?', [sven.dbid])\n self.assertFalse(row)\n \n result = readshiny(self.world, txt)\n self.world.log.debug(result)\n self.assertEqual(result, 'Character \"Sven\" has been successfully imported.')\n \n # Sven should now be in the database, but not online\n row = self.world.db.select('* from player where name=?', ['sven'])[0]\n self.assertTrue(row)\n self.assertFalse(self.world.get_player('sven'))\n \n isven = Player(('foo', 'bar'))\n isven.playerize(row)\n \n row = self.world.db.select('* from game_item where owner=?', [isven.dbid])\n self.assertTrue(row)\n \n # Make sure that all attributes we set got imported correctly\n self.assertEqual(sven.password, isven.password)\n self.assertEqual(sven.description, isven.description)\n self.assertEqual(sven.name, isven.name)\n self.assertEqual(sven.title, isven.title)\n self.assertEqual(sven.permissions, isven.permissions)\n \n # Make sure that the inventory was correctly loaded\n self.assertEqual(len(sven.inventory), len(isven.inventory))\n item = isven.inventory[0]\n self.world.log.debug(item.create_save_dict())\n self.world.log.debug(item.item_types)\n self.assertFalse(sven.inventory[0] is isven.inventory[0])\n self.assertEqual(item.name, 'chair')\n self.assertTrue(item.has_type('furniture'))\n self.assertEqual(item.item_types['furniture'].capacity, 5)", "metadata": "root.TestSport.test_shiny_player_format", "header": "['class', 'TestSport', '(', 'ShinyTestCase', ')', ':', '___EOS___']", "index": 136 } ]
[ { "span": "self.assertTrue(nevent.script is s1)", "start_line": 39, "start_column": 8, "end_line": 39, "end_column": 44 }, { "span": "self.assertTrue(r1.exits['north'].to_room is r2)", "start_line": 47, "start_column": 8, "end_line": 47, "end_column": 56 }, { "span": "self.assertTrue(r2.exits['south'].to_room is r1)", "start_line": 48, "start_column": 8, "end_line": 48, "end_column": 56 }, { "span": "self.assertTrue(r1.spawns['1'].spawn_object is i1)", "start_line": 49, "start_column": 8, "end_line": 49, "end_column": 58 }, { "span": "self.assertTrue(r2.spawns['1'].spawn_object is n1)", "start_line": 50, "start_column": 8, "end_line": 50, "end_column": 58 }, { "span": "self.assertFalse(sven.inventory[0] is isven.inventory[0])", "start_line": 187, "start_column": 8, "end_line": 187, "end_column": 65 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Sport", "_", "(_", "Shi", "ny", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "shin", "y", "\\u", "area", "\\u", "format_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Make", " ", "sure", " ", "the", " ", "read", "/", "write", " ", "formatter", "s", " ", "for", " ", "Shi", "ny", "Area", "Format", " ", "work", " ", "correct", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "shin", "ym", "ud_", "._", "lib_", "._", "sport", "\\u", "plugins_", "._", "formatters_", "._", "area", "\\u", "write", "\\u", "shin", "y", "\\u", "format_", "import_", "format_", "as_", "writes", "hin", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "shin", "ym", "ud_", "._", "lib_", "._", "sport", "\\u", "plugins_", "._", "formatters_", "._", "area", "\\u", "read", "\\u", "shin", "y", "\\u", "format_", "import_", "format_", "as_", "reads", "hin", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "area_", "=_", "self_", "._", "\\u", "create", "\\u", "area_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "area", "\\u", "txt_", "=_", "writes", "hin", "y_", "(_", "area_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "log_", "._", "debug_", "(_", "area", "\\u", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "destroy", "\\u", "area_", "(_", "area_", "._", "name_", ",_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "self_", "._", "world_", "._", "area", "\\u", "exists_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reads", "hin", "y_", "(_", "self_", "._", "world_", ",_", "area", "\\u", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "world_", "._", "area", "\\u", "exists_", "(_", "'", "foo", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nu", "foo_", "=_", "self_", "._", "world_", "._", "get", "\\u", "area_", "(_", "'", "foo", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "to", " ", "make", " ", "sure", " ", "all", " ", "scripts", " ", "are", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "nu", "foo_", "._", "scripts_", "._", "keys_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s1_", "=_", "nu", "foo_", "._", "get", "\\u", "script_", "(_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "say", " ", "...'_", ",_", "s1_", "._", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "bar", "'_", ",_", "s1_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "to", " ", "make", " ", "sure", " ", "all", " ", "items", " ", "are", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "i1_", "=_", "nu", "foo_", "._", "get", "\\u", "item_", "(_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "chair", "'_", ",_", "i1_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "i1_", "._", "has", "\\u", "type_", "(_", "'", "fur", "nit", "ure", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "i1_", "._", "item", "\\u", "types_", "[_", "'", "fur", "nit", "ure", "'_", "]_", "._", "capacity_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "npc", "s", " ", "come", " ", "back", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "n1_", "=_", "nu", "foo_", "._", "get", "\\u", "npc_", "(_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "Link", "'_", ",_", "n1_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "Thi", "s", " ", "litt", "le", " ", "elf", "-", "man", " ", "has", " ", "some", " ", "heart", "s", " ", "tat", "too", "ed", " ", "on", " ", "his", " ", "arm", ".'_", ",_", "n1_", "._", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "neve", "nt_", "=_", "n1_", "._", "events_", "[_", "'", "hear", "s", "'_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "neve", "nt_", "._", "event", "\\u", "trigger_", ",_", "'", "hear", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "neve", "nt_", "._", "script_", "is_", "s1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "neve", "nt_", "._", "condition_", ",_", "'", "Gan", "non", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Go", " ", "through", " ", "the", " ", "room", "s", "..._", "\\u\\u\\uNL\\u\\u\\u_", "r1_", "=_", "nu", "foo_", "._", "get", "\\u", "room_", "(_", "'", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r2_", "=_", "nu", "foo_", "._", "get", "\\u", "room_", "(_", "'", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "Room", " ", "1", "'_", ",_", "r1_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "Cool", " ", "room", ".'_", ",_", "r1_", "._", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "r1_", "._", "exits", "_", "[_", "'", "north", "'_", "]_", "._", "to", "\\u", "room_", "is_", "r2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "r2_", "._", "exits", "_", "[_", "'", "south", "'_", "]_", "._", "to", "\\u", "room_", "is_", "r1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "r1_", "._", "spawn", "s_", "[_", "'", "1", "'_", "]_", "._", "spawn", "\\u", "object_", "is_", "i1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "r2_", "._", "spawn", "s_", "[_", "'", "1", "'_", "]_", "._", "spawn", "\\u", "object_", "is_", "n1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "spawn", "s", " ", "wer", "e", " ", "reset", " ", "proper", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "r1_", "._", "items_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "r2_", "._", "npc", "s_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Sport", "_", "(_", "Shi", "ny", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "shin", "y", "\\u", "player", "\\u", "format_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "shin", "ym", "ud_", "._", "lib_", "._", "sport", "\\u", "plugins_", "._", "formatters_", "._", "player", "\\u", "write", "\\u", "shin", "y", "\\u", "format_", "import_", "format_", "as_", "writes", "hin", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "shin", "ym", "ud_", "._", "lib_", "._", "sport", "\\u", "plugins_", "._", "formatters_", "._", "player", "\\u", "read", "\\u", "shin", "y", "\\u", "format_", "import_", "format_", "as_", "reads", "hin", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "shin", "ym", "ud_", "._", "models_", "._", "player_", "import_", "Player_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "create", " ", "a", " ", "play", "a_", "\\u\\u\\uNL\\u\\u\\u_", "sv", "en_", "=_", "Player_", "(_", "(_", "'", "foo", "'_", ",_", "'", "bar", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "player", "ize_", "(_", "{_", "'", "name", "'_", ":_", "'", "sv", "en", "'_", ",_", "'", "password", "'_", ":_", "'", "foo", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "permissions_", "=_", "17_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "description_", "=_", "\"", "I", "'", "m", " ", "pretty", " ", "ador", "able", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "title_", "=_", "'", "Super", " ", "Sv", "en", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "area_", "=_", "self_", "._", "\\u", "create", "\\u", "area_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sv", "en_", "._", "item", "\\u", "add_", "(_", "area_", "._", "get", "\\u", "item_", "(_", "'", "1", "'_", ")_", "._", "load_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "txt_", "=_", "writes", "hin", "y_", "(_", "sv", "en_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "log_", "._", "debug_", "(_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sv", "en_", "._", "destruct", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sv", "en", " ", "shou", "ld", " ", "have", " ", "bee", "n", " ", "take", "n", " ", "out", " ", "of", " ", "the", " ", "databa", "se", "..._", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "self_", "._", "world_", "._", "db_", "._", "select_", "(_", "'*", " ", "from", " ", "player", " ", "where", " ", "name", "=?'_", ",_", "[_", "'", "sv", "en", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "self_", "._", "world_", "._", "db_", "._", "select_", "(_", "'*", " ", "from", " ", "game", "\\u", "item", " ", "where", " ", "owner", "=?'_", ",_", "[_", "sv", "en_", "._", "dbid", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "reads", "hin", "y_", "(_", "self_", "._", "world_", ",_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "log_", "._", "debug_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result_", ",_", "'", "Char", "acte", "r", " ", "\"", "Sv", "en", "\"", " ", "has", " ", "bee", "n", " ", "success", "full", "y", " ", "import", "ed", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sv", "en", " ", "shou", "ld", " ", "now", " ", "be", " ", "in", " ", "the", " ", "databa", "se", ",", " ", "but", " ", "not", " ", "online_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "self_", "._", "world_", "._", "db_", "._", "select_", "(_", "'*", " ", "from", " ", "player", " ", "where", " ", "name", "=?'_", ",_", "[_", "'", "sv", "en", "'_", "]_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "self_", "._", "world_", "._", "get", "\\u", "player_", "(_", "'", "sv", "en", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "is", "ven", "_", "=_", "Player_", "(_", "(_", "'", "foo", "'_", ",_", "'", "bar", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "ven", "_", "._", "player", "ize_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "self_", "._", "world_", "._", "db_", "._", "select_", "(_", "'*", " ", "from", " ", "game", "\\u", "item", " ", "where", " ", "owner", "=?'_", ",_", "[_", "is", "ven", "_", "._", "dbid", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "row_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "tha", "t", " ", "all", " ", "attribute", "s", " ", "we", " ", "set", " ", "got", " ", "import", "ed", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "sv", "en_", "._", "password_", ",_", "is", "ven", "_", "._", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "sv", "en_", "._", "description_", ",_", "is", "ven", "_", "._", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "sv", "en_", "._", "name_", ",_", "is", "ven", "_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "sv", "en_", "._", "title_", ",_", "is", "ven", "_", "._", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "sv", "en_", "._", "permissions_", ",_", "is", "ven", "_", "._", "permissions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "tha", "t", " ", "the", " ", "inventor", "y", " ", "was", " ", "correct", "ly", " ", "loaded_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "sv", "en_", "._", "inventory_", ")_", ",_", "len_", "(_", "is", "ven", "_", "._", "inventory_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "is", "ven", "_", "._", "inventory_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "log_", "._", "debug_", "(_", "item_", "._", "create", "\\u", "save", "\\u", "dict_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "world_", "._", "log_", "._", "debug_", "(_", "item_", "._", "item", "\\u", "types_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "sv", "en_", "._", "inventory_", "[_", "0_", "]_", "is_", "is", "ven", "_", "._", "inventory_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "item_", "._", "name_", ",_", "'", "chair", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "item_", "._", "has", "\\u", "type_", "(_", "'", "fur", "nit", "ure", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "item_", "._", "item", "\\u", "types_", "[_", "'", "fur", "nit", "ure", "'_", "]_", "._", "capacity_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Testing equality to None
davidmcclure/textplot/test/text/test_tokenize.py
[ { "content": "def test_ignore_stopwords():\n\n \"\"\"\n Stopwords should be represented as None in the token list.\n \"\"\"\n\n t = Text('aa the bb an cc')\n\n assert t.tokens[0]['unstemmed'] == 'aa'\n assert t.tokens[1] == None\n assert t.tokens[2]['unstemmed'] == 'bb'\n assert t.tokens[3] == None\n assert t.tokens[4]['unstemmed'] == 'cc'\n assert len(t.tokens) == 5", "metadata": "root.test_ignore_stopwords", "header": "['module', '___EOS___']", "index": 31 } ]
[ { "span": "t.tokens[1] == None", "start_line": 40, "start_column": 11, "end_line": 40, "end_column": 30 }, { "span": "t.tokens[3] == None", "start_line": 42, "start_column": 11, "end_line": 42, "end_column": 30 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ignore", "\\u", "stopwords_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sto", "pw", "ords", " ", "shou", "ld", " ", "be", " ", "represent", "ed", " ", "as", " ", "Non", "e", " ", "in", " ", "the", " ", "token", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "Text_", "(_", "'", "aa", " ", "the", " ", "bb", " ", "an", " ", "cc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "t_", "._", "tokens_", "[_", "0_", "]_", "[_", "'", "unst", "emm", "ed", "'_", "]_", "==_", "'", "aa", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "tokens_", "[_", "1_", "]_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "tokens_", "[_", "2_", "]_", "[_", "'", "unst", "emm", "ed", "'_", "]_", "==_", "'", "bb", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "tokens_", "[_", "3_", "]_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "tokens_", "[_", "4_", "]_", "[_", "'", "unst", "emm", "ed", "'_", "]_", "==_", "'", "cc", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "t_", "._", "tokens_", ")_", "==_", "5_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
jansel/opentuner/opentuner/utils/stats.py
[ { "content": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n import adddeps\n\nimport argparse\nimport csv\nimport hashlib\nimport itertools\nimport logging\nimport math\nimport os\nimport sqlalchemy.orm.exc\nimport subprocess\nimport sys\n\nfrom collections import defaultdict\nfrom fn import _\nfrom fn import Stream\nfrom fn.iters import repeat\nfrom pprint import pprint\n\nimport opentuner\nfrom opentuner import resultsdb\nfrom opentuner.resultsdb.models import *\n\nlog = logging.getLogger('opentuner.utils.stats')\n\nargparser = argparse.ArgumentParser()\nargparser.add_argument('--label')\nargparser.add_argument('--stats', action='store_true',\n help=\"run in stats mode\")\nargparser.add_argument('--by-request-count', action='store_true',\n help='report stats by request count')\nargparser.add_argument('--stats-quanta', type=float, default=10,\n help=\"step size in seconds for binning with --stats\")\nargparser.add_argument('--stats-dir', default='stats',\n help=\"directory to output --stats to\")\nargparser.add_argument('--stats-input', default=\"opentuner.db\")\nargparser.add_argument('--min-runs', type=int, default=1,\n help=\"ignore series with less then N runs\")\n\nPCTSTEPS = map(_/20.0, xrange(21))\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n opentuner.tuningrunmain.init_logging()\n sys.exit(StatsMain(argparser.parse_args()).main())\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def mean(vals):\n n = 0.0\n d = 0.0\n for v in vals:\n if v is not None:\n n += v\n d += 1.0\n if d == 0.0:\n return None\n return n/d", "metadata": "root.mean", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def median(vals):\n vals = sorted(vals)\n a = (len(vals)-1)/2\n b = (len(vals))/2\n return (vals[a]+vals[b])/2.0", "metadata": "root.median", "header": "['module', '___EOS___']", "index": 55 }, { "content": "def percentile(vals, pct):\n vals = sorted(vals)\n pos = (len(vals)-1) * pct\n a = int(math.floor(pos))\n b = min(len(vals) - 1, a + 1)\n return (1.0-(pos-a))*vals[a] + (pos-a)*vals[b]", "metadata": "root.percentile", "header": "['module', '___EOS___']", "index": 61 }, { "content": "def variance(vals):\n vals = filter(lambda x: x is not None, vals)\n avg = mean(vals)\n if avg is None:\n return None\n if avg in (float('inf'), float('-inf')):\n return avg\n return mean(map((_ - avg) ** 2, vals))", "metadata": "root.variance", "header": "['module', '___EOS___']", "index": 68 }, { "content": "def stddev(vals):\n var = variance(vals)\n if var is None:\n return None\n return math.sqrt(var)", "metadata": "root.stddev", "header": "['module', '___EOS___']", "index": 77 }, { "content": "def hash_args(x):\n d = dict(vars(x))\n for k in ('database', 'results_log', 'results_log_details'):\n d[k] = None\n return hashlib.sha256(str(sorted(d.items()))).hexdigest()[:20]", "metadata": "root.hash_args", "header": "['module', '___EOS___']", "index": 83 }, { "content": "def run_label(tr, short = False):\n techniques = ','.join(tr.args.technique)\n if not tr.name or tr.name=='unnamed':\n if short:\n return techniques\n else:\n return \"%s_%s\" % (techniques, hash_args(tr.args)[:6])\n else:\n return tr.name", "metadata": "root.run_label", "header": "['module', '___EOS___']", "index": 89 }, { "content": "def run_dir(base, tr):\n return os.path.join(base,\n tr.program.project,\n tr.program.name.split('/')[-1],\n tr.program_version.version[:16])", "metadata": "root.run_dir", "header": "['module', '___EOS___']", "index": 99 }, { "content": "class StatsMain(object):\n\n\n\n\n\n\n\n\n", "metadata": "root.StatsMain", "header": "['module', '___EOS___']", "index": 105 }, { "content": " def __init__(self, args):\n self.args = args\n path = args.stats_input\n self.dbs = list()\n for f in os.listdir(path):\n if 'journal' in f:\n continue\n try:\n e, sm = resultsdb.connect('sqlite:///'+os.path.join(path, f))\n self.dbs.append(sm())\n except:\n log.error('failed to load database: %s', \n os.path.join(path, f),\n exc_info=True)", "metadata": "root.StatsMain.__init__", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 106 }, { "content": " def main(self):\n dir_label_runs = defaultdict(lambda: defaultdict(list))\n for session in self.dbs:\n q = (session.query(resultsdb.models.TuningRun)\n .filter_by(state='COMPLETE')\n .order_by('name'))\n\n if self.args.label:\n q = q.filter(TuningRun.name.in_(\n map(str.strip,self.args.label.split(','))))\n\n for tr in q:\n d = run_dir(self.args.stats_dir, tr)\n d = os.path.normpath(d)\n dir_label_runs[d][run_label(tr)].append((tr, session))\n\n summary_report = defaultdict(lambda: defaultdict(list))\n for d, label_runs in dir_label_runs.iteritems():\n if not os.path.isdir(d):\n os.makedirs(d)\n session = label_runs.values()[0][0][1]\n objective = label_runs.values()[0][0][0].objective\n all_run_ids = map(_[0].id, itertools.chain(*label_runs.values()))\n q = (session.query(Result)\n .filter(Result.tuning_run_id.in_(all_run_ids))\n .filter(Result.time < float('inf'))\n .filter_by(was_new_best=True, state='OK'))\n total = q.count()\n if total == 0: \n continue\n q = objective.filter_acceptable(q)\n acceptable = q.count()\n q = q.order_by(*objective.result_order_by_terms())\n best = q.limit(1).one()\n worst = q.offset(acceptable-1).limit(1).one()\n\n map(len, label_runs.values())\n\n log.info(\"%s -- best %.4f / worst %.f4 \"\n \"-- %d of %d acceptable -- %d techniques with %d to %d runs\",\n d,\n best.time,\n worst.time,\n acceptable,\n total,\n len(label_runs.values()),\n min(map(len, label_runs.values())),\n max(map(len, label_runs.values())))\n\n for label, runs in sorted(label_runs.items()):\n if len(runs) < self.args.min_runs:\n print len(runs) ,self.args.min_runs\n continue\n log.debug('%s/%s has %d runs %s',d, label, len(runs), runs[0][0].args.technique)\n self.combined_stats_over_time(d, label, runs, objective, worst, best)\n\n final_scores = list()\n for run, session in runs:\n try:\n final = (session.query(Result)\n .filter_by(tuning_run=run,\n configuration=run.final_config)\n .limit(1)\n .one())\n except sqlalchemy.orm.exc.NoResultFound:\n continue\n final_scores.append(objective.stats_quality_score(final, worst, best))\n final_scores.sort()\n if final_scores:\n norm = objective.stats_quality_score(best, worst, best)\n if norm > 0.00001:\n summary_report[d][run_label(run, short=True)] = (\n percentile(final_scores, 0.5) / norm,\n percentile(final_scores, 0.1) / norm,\n percentile(final_scores, 0.9) / norm,\n )\n else:\n summary_report[d][run_label(run, short=True)] = (\n percentile(final_scores, 0.5) + norm + 1.0,\n percentile(final_scores, 0.1) + norm + 1.0,\n percentile(final_scores, 0.9) + norm + 1.0,\n )\n\n\n with open(self.args.stats_dir+ \"/summary.dat\", 'w') as o:\n # make summary report\n keys = sorted(reduce(set.union,\n [set(x.keys()) for x in summary_report.values()],\n set()))\n print >>o, '#####',\n for k in keys:\n print >>o, k,\n print >>o\n for d, label_vals in sorted(summary_report.items()):\n print >>o, d.split('/')[-2],\n for k in keys:\n if k in label_vals:\n print >>o, '-', label_vals[k][0], label_vals[k][1], label_vals[k][2],\n else:\n print >>o, '-', '-', '-', '-',\n print >>o\n\n if keys:\n plotcmd = [\"\"\"1 w lines lt 1 lc rgb \"black\" notitle\"\"\",\n \"\"\"'summary.dat' using 3:4:5:xtic(1) ti \"%s\" \"\"\" % keys[0]]\n for n, k in enumerate(keys[1:]):\n plotcmd.append(\"\"\"'' using %d:%d:%d ti \"%s\" \"\"\" % (\n 4*n + 7,\n 4*n + 8,\n 4*n + 9,\n k))\n self.gnuplot_summary_file(self.args.stats_dir, 'summary', plotcmd)\n\n\n\n for d, label_runs in dir_label_runs.iteritems():\n labels = [k for k,v in label_runs.iteritems()\n if len(v)>=self.args.min_runs]\n self.gnuplot_file(d,\n \"medianperfe\",\n ['\"%s_percentiles.dat\" using 1:12:4:18 with errorbars title \"%s\"' % (l,l) for l in labels])\n self.gnuplot_file(d,\n \"meanperfe\",\n ['\"%s_percentiles.dat\" using 1:21:4:18 with errorbars title \"%s\"' % (l,l) for l in labels])\n self.gnuplot_file(d,\n \"medianperfl\",\n ['\"%s_percentiles.dat\" using 1:12 with lines title \"%s\"' % (l,l) for l in labels])\n self.gnuplot_file(d,\n \"meanperfl\",\n ['\"%s_percentiles.dat\" using 1:21 with lines title \"%s\"' % (l,l) for l in labels])\n\n # print\n # print \"10% Scores\", d\n # pprint(self.technique_scores(d, labels, '0.1'))\n # print\n # print \"90% Scores\", d\n # pprint(self.technique_scores(d, labels, '0.9'))\n # print\n # print \"Mean Scores\", d\n # pprint(self.technique_scores(d, labels, 'mean'))\n print\n print \"Median Scores\", d\n pprint(self.technique_scores(d, labels, '0.5'))", "metadata": "root.StatsMain.main", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 121 }, { "content": " def technique_scores(self, directory, labels, ykey, xkey='#sec', factor=10.0):\n max_duration = None\n min_value = float('inf')\n for label in labels:\n try:\n dr = csv.DictReader(open(os.path.join(directory,label+\"_percentiles.dat\")), delimiter=' ', lineterminator='\\n')\n lastrow = list(dr)[-1]\n max_duration = max(max_duration, float(lastrow[xkey]))\n min_value = min(min_value, float(lastrow[ykey]))\n except:\n log.exception(\"failed computing score\")\n\n scores = list()\n\n for label in labels:\n try:\n dr = csv.DictReader(open(os.path.join(directory,label+\"_percentiles.dat\")), delimiter=' ', lineterminator='\\n')\n score = 0.0\n lastsec = 0.0\n value = float('inf')\n for row in dr:\n duration = float(row[xkey]) - lastsec\n lastsec = float(row[xkey])\n value = float(row[ykey])\n score += duration * (value - min_value)\n score += (factor*max_duration - lastsec) * (value - min_value)\n scores.append((score, label))\n except:\n log.exception(\"failed computing score\")\n\n return sorted(scores)", "metadata": "root.StatsMain.technique_scores", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 266 }, { "content": " def combined_stats_over_time(self,\n output_dir,\n label,\n runs,\n objective,\n worst,\n best,\n ):\n \"\"\"\n combine stats_over_time() vectors for multiple runs\n \"\"\"\n\n #extract_fn = lambda dr: objective.stats_quality_score(dr.result, worst, best)\n extract_fn = _.result.time\n combine_fn = min\n no_data = 999\n\n log.debug(\"writing stats for %s to %s\", label, output_dir)\n by_run = [self.stats_over_time(session, run, extract_fn, combine_fn, no_data)\n for run, session in runs]\n max_len = max(map(len, by_run))\n\n by_run_streams = [Stream() << x << repeat(x[-1], max_len-len(x))\n for x in by_run]\n by_quanta = zip(*by_run_streams[:])\n\n def data_file(suffix, headers, value_function):\n with open(os.path.join(output_dir, label+suffix), 'w') as fd:\n out = csv.writer(fd, delimiter=' ', lineterminator='\\n')\n out.writerow(['#sec'] + headers)\n for quanta, values in enumerate(by_quanta):\n sec = quanta*self.args.stats_quanta\n out.writerow([sec] + value_function(values))\n\n #data_file('_details.dat',\n # map(lambda x: 'run%d'%x, xrange(max_len)),\n # list)\n #self.gnuplot_file(output_dir,\n # label+'_details',\n # [('\"'+label+'_details.dat\"'\n # ' using 1:%d'%i +\n # ' with lines'\n # ' title \"Run %d\"'%i)\n # for i in xrange(max_len)])\n\n data_file('_mean.dat',\n ['#sec', 'mean', 'stddev'],\n lambda values: [mean(values), stddev(values)])\n self.gnuplot_file(output_dir,\n label+'_mean',\n ['\"'+label+'_mean.dat\" using 1:2 with lines title \"Mean\"'])\n\n def extract_percentiles(values):\n values = sorted(values)\n return ([values[int(round(p*(len(values)-1)))] for p in PCTSTEPS]\n + [mean(values)])\n data_file(\"_percentiles.dat\", PCTSTEPS + ['mean'], extract_percentiles)\n self.gnuplot_file(output_dir,\n label+'_percentiles',\n reversed([\n '\"'+label+'_percentiles.dat\" using 1:2 with lines title \"0%\"',\n # '\"\" using 1:3 with lines title \"5%\"',\n '\"\" using 1:4 with lines title \"10%\"',\n # '\"\" using 1:5 with lines title \"25%\"',\n '\"\" using 1:6 with lines title \"20%\"',\n # '\"\" using 1:7 with lines title \"35%\"',\n '\"\" using 1:8 with lines title \"30%\"',\n # '\"\" using 1:9 with lines title \"45%\"',\n '\"\" using 1:10 with lines title \"40%\"',\n # '\"\" using 1:11 with lines title \"55%\"',\n '\"\" using 1:12 with lines title \"50%\"',\n # '\"\" using 1:13 with lines title \"65%\"',\n '\"\" using 1:14 with lines title \"70%\"',\n # '\"\" using 1:15 with lines title \"75%\"',\n '\"\" using 1:16 with lines title \"80%\"',\n # '\"\" using 1:17 with lines title \"85%\"',\n '\"\" using 1:18 with lines title \"90%\"',\n # '\"\" using 1:19 with lines title \"95%\"',\n '\"'+label+'_percentiles.dat\" using 1:20 with lines title \"100%\"',\n ]))", "metadata": "root.StatsMain.combined_stats_over_time", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 299 }, { "content": " def gnuplot_file(self, output_dir, prefix, plotcmd):\n with open(os.path.join(output_dir, prefix+'.gnuplot'), 'w') as fd:\n print >>fd, 'set terminal postscript eps enhanced color'\n print >>fd, 'set output \"%s\"' % (prefix+'.eps')\n print >>fd, 'set ylabel \"Execution Time (seconds)\"'\n print >>fd, 'set xlabel \"Autotuning Time (seconds)\"'\n print >>fd, 'plot', ',\\\\\\n'.join(plotcmd)\n\n try:\n subprocess.call(['gnuplot', prefix+'.gnuplot'], cwd=output_dir, stdin=None)\n except OSError:\n log.error(\"command gnuplot not found\")", "metadata": "root.StatsMain.gnuplot_file", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 380 }, { "content": " def gnuplot_summary_file(self, output_dir, prefix, plotcmd):\n with open(os.path.join(output_dir, prefix+'.gnuplot'), 'w') as fd:\n print >>fd, 'set terminal postscript eps enhanced color'\n print >>fd, 'set output \"%s\"' % (prefix+'.eps')\n print >>fd, '''\nset boxwidth 0.9\nset style fill solid 1.00 border 0\nset style histogram errorbars gap 2 lw 1\nset style data histograms\nset xtics rotate by -45\nset bars 0.5\nset yrange [0:20]\n\nset yrange [0:10]\nset key out vert top left\nset size 1.5,1\nset ytics 1\n\n'''\n print >>fd, 'plot', ',\\\\\\n'.join(plotcmd)\n subprocess.call(['gnuplot', prefix+'.gnuplot'], cwd=output_dir, stdin=None)", "metadata": "root.StatsMain.gnuplot_summary_file", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 393 }, { "content": " def stats_over_time(self,\n session,\n run,\n extract_fn,\n combine_fn,\n no_data = None):\n \"\"\"\n return reduce(combine_fn, map(extract_fn, data)) for each quanta of the\n tuning run\n \"\"\"\n value_by_quanta = [ no_data ]\n start_date = run.start_date\n\n subq = (session.query(Result.id)\n .filter_by(tuning_run = run, was_new_best = True, state='OK'))\n\n q = (session.query(DesiredResult)\n .join(Result)\n .filter(DesiredResult.state=='COMPLETE',\n DesiredResult.tuning_run == run,\n DesiredResult.result_id.in_(subq.subquery()))\n .order_by(DesiredResult.request_date))\n\n first_id = None\n for dr in q:\n if first_id is None:\n first_id = dr.id\n td = (dr.request_date - start_date)\n duration = td.seconds + (td.days * 24 * 3600.0)\n if self.args.by_request_count:\n quanta = dr.id - first_id\n else:\n quanta = int(duration / self.args.stats_quanta)\n while len(value_by_quanta) <= quanta:\n value_by_quanta.append(value_by_quanta[-1])\n\n if value_by_quanta[-1] is no_data:\n value_by_quanta[-1] = extract_fn(dr)\n else:\n value_by_quanta[-1] = combine_fn(value_by_quanta[-1], extract_fn(dr))\n\n return value_by_quanta", "metadata": "root.StatsMain.stats_over_time", "header": "['class', 'StatsMain', '(', 'object', ')', ':', '___EOS___']", "index": 416 } ]
[ { "span": "import adddeps", "start_line": 3, "start_column": 2, "end_line": 3, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "add", "deps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "csv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "itertools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sqlalchemy_", "._", "orm_", "._", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "collections_", "import_", "defaultdict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fn_", "import_", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fn_", "import_", "Stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fn_", "._", "iters_", "import_", "repeat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pprint_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "opent", "une", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "opent", "une", "r_", "import_", "results", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "opent", "une", "r_", "._", "results", "db_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "'", "opent", "une", "r", ".", "util", "s", ".", "stats", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "argparser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "label", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "stats", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "run", " ", "in", " ", "stats", " ", "mode", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "by", "-", "request", "-", "count", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "report", " ", "stats", " ", "by", " ", "request", " ", "count", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "stats", "-", "quant", "a", "'_", ",_", "type_", "=_", "float_", ",_", "default_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "step", " ", "size", " ", "in", " ", "second", "s", " ", "for", " ", "binning", " ", "with", " ", "--", "stats", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "stats", "-", "dir", "'_", ",_", "default_", "=_", "'", "stats", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "director", "y", " ", "to", " ", "output", " ", "--", "stats", " ", "to", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "stats", "-", "input", "'_", ",_", "default_", "=_", "\"", "opent", "une", "r", ".", "db", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argparser_", "._", "add", "\\u", "argument_", "(_", "'--", "min", "-", "runs", "'_", ",_", "type_", "=_", "int_", ",_", "default_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "ignore", " ", "series", " ", "with", " ", "less", " ", "then", " ", "N", " ", "runs", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "PC", "TST", "EPS", "_", "=_", "map_", "(_", "\\u_", "/_", "20.0_", ",_", "xrange_", "(_", "21_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opent", "une", "r_", "._", "tuning", "run", "main_", "._", "init", "\\u", "logging_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "Stat", "s", "Main_", "(_", "argparser_", "._", "parse", "\\u", "args_", "(_", ")_", ")_", "._", "main_", "(_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "mean_", "(_", "vals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "v_", "in_", "vals_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "v_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "+=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "+=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "d_", "==_", "0.0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "n_", "/_", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "median_", "(_", "vals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "sorted_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "(_", "len_", "(_", "vals_", ")_", "-_", "1_", ")_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "(_", "len_", "(_", "vals_", ")_", ")_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "vals_", "[_", "a_", "]_", "+_", "vals_", "[_", "b_", "]_", ")_", "/_", "2.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "percentile_", "(_", "vals_", ",_", "pct_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "sorted_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pos_", "=_", "(_", "len_", "(_", "vals_", ")_", "-_", "1_", ")_", "*_", "pct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "int_", "(_", "math_", "._", "floor_", "(_", "pos_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "min_", "(_", "len_", "(_", "vals_", ")_", "-_", "1_", ",_", "a_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "1.0_", "-_", "(_", "pos_", "-_", "a_", ")_", ")_", "*_", "vals_", "[_", "a_", "]_", "+_", "(_", "pos_", "-_", "a_", ")_", "*_", "vals_", "[_", "b_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "variance_", "(_", "vals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "filter_", "(_", "lambda_", "x_", ":_", "x_", "is_", "not_", "None_", ",_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg_", "=_", "mean_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "avg_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "avg_", "in_", "(_", "float_", "(_", "'", "inf", "'_", ")_", ",_", "float_", "(_", "'-", "inf", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "avg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "mean_", "(_", "map_", "(_", "(_", "\\u_", "-_", "avg_", ")_", "**_", "2_", ",_", "vals_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "stddev_", "(_", "vals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "var_", "=_", "variance_", "(_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "var_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "math_", "._", "sqrt_", "(_", "var_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "hash", "\\u", "args_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "dict_", "(_", "vars_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "(_", "'", "databa", "se", "'_", ",_", "'", "results", "\\u", "log", "'_", ",_", "'", "results", "\\u", "log", "\\u", "deta", "il", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "[_", "k_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "hashlib_", "._", "sha256_", "(_", "str_", "(_", "sorted_", "(_", "d_", "._", "items_", "(_", ")_", ")_", ")_", ")_", "._", "hexdigest_", "(_", ")_", "[_", ":_", "20_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "label_", "(_", "tr_", ",_", "short_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "technique", "s_", "=_", "','_", "._", "join_", "(_", "tr_", "._", "args_", "._", "technique", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "tr_", "._", "name_", "or_", "tr_", "._", "name_", "==_", "'", "unn", "ame", "d", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "short_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "technique", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", "\\u", "%", "s", "\"_", "%_", "(_", "technique", "s_", ",_", "hash", "\\u", "args_", "(_", "tr_", "._", "args_", ")_", "[_", ":_", "6_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "tr_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "dir_", "(_", "base_", ",_", "tr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "os_", "._", "path_", "._", "join_", "(_", "base_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tr_", "._", "program_", "._", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tr_", "._", "program_", "._", "name_", "._", "split_", "(_", "'/'_", ")_", "[_", "-_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tr_", "._", "program", "\\u", "version_", "._", "version_", "[_", ":_", "16_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "args_", "=_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "args_", "._", "stats", "\\u", "input_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dbs_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "journal", "'_", "in_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", ",_", "sm_", "=_", "results", "db_", "._", "connect_", "(_", "'", "sql", "ite", ":///", "'_", "+_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "f_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dbs_", "._", "append_", "(_", "sm_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "'", "fail", "ed", " ", "to", " ", "load", " ", "databa", "se", ":", " ", "%", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "f_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exc", "\\u", "info_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir\\u", "label", "\\u", "runs_", "=_", "defaultdict_", "(_", "lambda_", ":_", "defaultdict_", "(_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "session_", "in_", "self_", "._", "dbs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "(_", "session_", "._", "query_", "(_", "results", "db_", "._", "models_", "._", "Tuni", "ng", "Run_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter", "\\u", "by_", "(_", "state_", "=_", "'", "COMPLET", "E", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "args_", "._", "label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "q_", "._", "filter_", "(_", "Tuni", "ng", "Run_", "._", "name_", "._", "in\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "str_", "._", "strip_", ",_", "self_", "._", "args_", "._", "label_", "._", "split_", "(_", "','_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "tr_", "in_", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "run", "\\u", "dir_", "(_", "self_", "._", "args_", "._", "stats", "\\u", "dir_", ",_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "os_", "._", "path_", "._", "normpath_", "(_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dir\\u", "label", "\\u", "runs_", "[_", "d_", "]_", "[_", "run", "\\u", "label_", "(_", "tr_", ")_", "]_", "._", "append_", "(_", "(_", "tr_", ",_", "session_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "summar", "y", "\\u", "report_", "=_", "defaultdict_", "(_", "lambda_", ":_", "defaultdict_", "(_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "d_", ",_", "label", "\\u", "runs_", "in_", "dir\\u", "label", "\\u", "runs_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "d_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "=_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", "[_", "0_", "]_", "[_", "0_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "objective_", "=_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", "[_", "0_", "]_", "[_", "0_", "]_", "[_", "0_", "]_", "._", "objective_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "run", "\\u", "ids_", "=_", "map_", "(_", "\\u_", "[_", "0_", "]_", "._", "id_", ",_", "itertools_", "._", "chain_", "(_", "*_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "(_", "session_", "._", "query_", "(_", "Result_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter_", "(_", "Result_", "._", "tuning", "\\u", "run", "\\u", "id_", "._", "in\\u_", "(_", "all", "\\u", "run", "\\u", "ids_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter_", "(_", "Result_", "._", "time_", "<_", "float_", "(_", "'", "inf", "'_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter", "\\u", "by_", "(_", "was", "\\u", "new", "\\u", "best_", "=_", "True_", ",_", "state_", "=_", "'", "OK", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "=_", "q_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "total_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "q_", "=_", "objective_", "._", "filter", "\\u", "acceptabl", "e_", "(_", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "acceptabl", "e_", "=_", "q_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "q_", "._", "order", "\\u", "by_", "(_", "*_", "objective_", "._", "result", "\\u", "order", "\\u", "by", "\\u", "terms_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "best_", "=_", "q_", "._", "limit_", "(_", "1_", ")_", "._", "one_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "worst", "_", "=_", "q_", "._", "offset_", "(_", "acceptabl", "e_", "-_", "1_", ")_", "._", "limit_", "(_", "1_", ")_", "._", "one_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "len_", ",_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "._", "info_", "(_", "\"%", "s", " ", "--", " ", "best", " ", "%", ".4", "f", " ", "/", " ", "worst", " ", "%", ".", "f4", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"--", " ", "%", "d", " ", "of", " ", "%", "d", " ", "acceptabl", "e", " ", "--", " ", "%", "d", " ", "technique", "s", " ", "with", " ", "%", "d", " ", "to", " ", "%", "d", " ", "runs", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "best_", "._", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "worst", "_", "._", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "acceptabl", "e_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "total_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "min_", "(_", "map_", "(_", "len_", ",_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max_", "(_", "map_", "(_", "len_", ",_", "label", "\\u", "runs_", "._", "values_", "(_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "label_", ",_", "runs_", "in_", "sorted_", "(_", "label", "\\u", "runs_", "._", "items_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "runs_", ")_", "<_", "self_", "._", "args_", "._", "min", "\\u", "runs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "len_", "(_", "runs_", ")_", ",_", "self_", "._", "args_", "._", "min", "\\u", "runs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "debug_", "(_", "'%", "s", "/", "%", "s", " ", "has", " ", "%", "d", " ", "runs", " ", "%", "s", "'_", ",_", "d_", ",_", "label_", ",_", "len_", "(_", "runs_", ")_", ",_", "runs_", "[_", "0_", "]_", "[_", "0_", "]_", "._", "args_", "._", "technique", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "combin", "ed", "\\u", "stats", "\\u", "over", "\\u", "time_", "(_", "d_", ",_", "label_", ",_", "runs_", ",_", "objective_", ",_", "worst", "_", ",_", "best_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "final", "\\u", "scores_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "run_", ",_", "session_", "in_", "runs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "final_", "=_", "(_", "session_", "._", "query_", "(_", "Result_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter", "\\u", "by_", "(_", "tuning", "\\u", "run_", "=_", "run_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "configuration_", "=_", "run_", "._", "final", "\\u", "config_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "limit_", "(_", "1_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "one_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "sqlalchemy_", "._", "orm_", "._", "exc_", "._", "No", "Result", "Found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "final", "\\u", "scores_", "._", "append_", "(_", "objective_", "._", "stats", "\\u", "quali", "ty", "\\u", "score_", "(_", "final_", ",_", "worst", "_", ",_", "best_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "final", "\\u", "scores_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "final", "\\u", "scores_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "norm_", "=_", "objective_", "._", "stats", "\\u", "quali", "ty", "\\u", "score_", "(_", "best_", ",_", "worst", "_", ",_", "best_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "norm_", ">_", "0.00001", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "summar", "y", "\\u", "report_", "[_", "d_", "]_", "[_", "run", "\\u", "label_", "(_", "run_", ",_", "short_", "=_", "True_", ")_", "]_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.5_", ")_", "/_", "norm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.1_", ")_", "/_", "norm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.9_", ")_", "/_", "norm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "summar", "y", "\\u", "report_", "[_", "d_", "]_", "[_", "run", "\\u", "label_", "(_", "run_", ",_", "short_", "=_", "True_", ")_", "]_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.5_", ")_", "+_", "norm_", "+_", "1.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.1_", ")_", "+_", "norm_", "+_", "1.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "percentile_", "(_", "final", "\\u", "scores_", ",_", "0.9_", ")_", "+_", "norm_", "+_", "1.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "open_", "(_", "self_", "._", "args_", "._", "stats", "\\u", "dir_", "+_", "\"/", "summar", "y", ".", "dat", "\"_", ",_", "'", "w", "'_", ")_", "as_", "o_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "make", " ", "summar", "y", " ", "report_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "=_", "sorted_", "(_", "reduce_", "(_", "set_", "._", "union_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "set_", "(_", "x_", "._", "keys_", "(_", ")_", ")_", "for_", "x_", "in_", "summar", "y", "\\u", "report_", "._", "values_", "(_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "set_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "o_", ",_", "'#####", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "o_", ",_", "k_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "o_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "d_", ",_", "label", "\\u", "vals_", "in_", "sorted_", "(_", "summar", "y", "\\u", "report_", "._", "items_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "o_", ",_", "d_", "._", "split_", "(_", "'/'_", ")_", "[_", "-_", "2_", "]_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "k_", "in_", "label", "\\u", "vals_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "o_", ",_", "'-'_", ",_", "label", "\\u", "vals_", "[_", "k_", "]_", "[_", "0_", "]_", ",_", "label", "\\u", "vals_", "[_", "k_", "]_", "[_", "1_", "]_", ",_", "label", "\\u", "vals_", "[_", "k_", "]_", "[_", "2_", "]_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "o_", ",_", "'-'_", ",_", "'-'_", ",_", "'-'_", ",_", "'-'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "o_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plot", "cmd_", "=_", "[_", "\"\"\"", "1", " ", "w", " ", "lines", " ", "lt", " ", "1", " ", "lc", " ", "rgb", " ", "\"", "black", "\"", " ", "noti", "tle", "\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"'", "summar", "y", ".", "dat", "'", " ", "usi", "ng", " ", "3", ":", "4", ":", "5", ":", "xt", "ic", "(", "1", ")", " ", "ti", " ", "\"%", "s", "\"", " ", "\"\"\"_", "%_", "keys_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "n_", ",_", "k_", "in_", "enumerate_", "(_", "keys_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plot", "cmd_", "._", "append_", "(_", "\"\"\"'", "'", " ", "usi", "ng", " ", "%", "d", ":", "%", "d", ":", "%", "d", " ", "ti", " ", "\"%", "s", "\"", " ", "\"\"\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "4_", "*_", "n_", "+_", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "4_", "*_", "n_", "+_", "8_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "4_", "*_", "n_", "+_", "9_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "k_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "summar", "y", "\\u", "file_", "(_", "self_", "._", "args_", "._", "stats", "\\u", "dir_", ",_", "'", "summar", "y", "'_", ",_", "plot", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "d_", ",_", "label", "\\u", "runs_", "in_", "dir\\u", "label", "\\u", "runs_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labels_", "=_", "[_", "k_", "for_", "k_", ",_", "v_", "in_", "label", "\\u", "runs_", "._", "iteritems_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "v_", ")_", ">=_", "self_", "._", "args_", "._", "min", "\\u", "runs_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "median", "perf", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'\"", "%", "s", "\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "1", "2", ":", "4", ":", "1", "8", " ", "with", " ", "error", "bar", "s", " ", "title", " ", "\"%", "s", "\"'_", "%_", "(_", "l_", ",_", "l_", ")_", "for_", "l_", "in_", "labels_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "mean", "perf", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'\"", "%", "s", "\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "21", ":", "4", ":", "1", "8", " ", "with", " ", "error", "bar", "s", " ", "title", " ", "\"%", "s", "\"'_", "%_", "(_", "l_", ",_", "l_", ")_", "for_", "l_", "in_", "labels_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "median", "perf", "l", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'\"", "%", "s", "\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "1", "2", " ", "with", " ", "lines", " ", "title", " ", "\"%", "s", "\"'_", "%_", "(_", "l_", ",_", "l_", ")_", "for_", "l_", "in_", "labels_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "mean", "perf", "l", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'\"", "%", "s", "\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "21", " ", "with", " ", "lines", " ", "title", " ", "\"%", "s", "\"'_", "%_", "(_", "l_", ",_", "l_", ")_", "for_", "l_", "in_", "labels_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "\"", "10", "%", " ", "Score", "s", "\",", " ", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ppr", "int", "(", "self", ".", "technique", "\\u", "score", "s", "(", "d", ",", " ", "labels", ",", " ", "'", "0.", "1", "'))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "\"", "90", "%", " ", "Score", "s", "\",", " ", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ppr", "int", "(", "self", ".", "technique", "\\u", "score", "s", "(", "d", ",", " ", "labels", ",", " ", "'", "0.", "9", "'))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "\"", "Mea", "n", " ", "Score", "s", "\",", " ", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ppr", "int", "(", "self", ".", "technique", "\\u", "score", "s", "(", "d", ",", " ", "labels", ",", " ", "'", "mean", "'))", "_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Media", "n", " ", "Score", "s", "\"_", ",_", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pprint_", "(_", "self_", "._", "technique", "\\u", "scores_", "(_", "d_", ",_", "labels_", ",_", "'", "0.", "5", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "technique", "\\u", "scores_", "(_", "self_", ",_", "directory_", ",_", "labels_", ",_", "yk", "ey_", ",_", "xk", "ey_", "=_", "'#", "sec", "'_", ",_", "factor_", "=_", "10.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "max", "\\u", "duration_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "min", "\\u", "value_", "=_", "float_", "(_", "'", "inf", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "label_", "in_", "labels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dr_", "=_", "csv_", "._", "Dict", "Reader_", "(_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "directory_", ",_", "label_", "+_", "\"\\u", "percentile", "s", ".", "dat", "\"_", ")_", ")_", ",_", "delimiter_", "=_", "'", " ", "'_", ",_", "linet", "ermina", "tor_", "=_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lastr", "ow_", "=_", "list_", "(_", "dr_", ")_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "duration_", "=_", "max_", "(_", "max", "\\u", "duration_", ",_", "float_", "(_", "lastr", "ow_", "[_", "xk", "ey_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "min", "\\u", "value_", "=_", "min_", "(_", "min", "\\u", "value_", ",_", "float_", "(_", "lastr", "ow_", "[_", "yk", "ey_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "exception_", "(_", "\"", "fail", "ed", " ", "compu", "ting", " ", "score", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scores_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "label_", "in_", "labels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dr_", "=_", "csv_", "._", "Dict", "Reader_", "(_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "directory_", ",_", "label_", "+_", "\"\\u", "percentile", "s", ".", "dat", "\"_", ")_", ")_", ",_", "delimiter_", "=_", "'", " ", "'_", ",_", "linet", "ermina", "tor_", "=_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "score_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lasts", "ec_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "float_", "(_", "'", "inf", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "dr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "duration_", "=_", "float_", "(_", "row_", "[_", "xk", "ey_", "]_", ")_", "-_", "lasts", "ec_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lasts", "ec_", "=_", "float_", "(_", "row_", "[_", "xk", "ey_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "float_", "(_", "row_", "[_", "yk", "ey_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "score_", "+=_", "duration_", "*_", "(_", "value_", "-_", "min", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "score_", "+=_", "(_", "factor_", "*_", "max", "\\u", "duration_", "-_", "lasts", "ec_", ")_", "*_", "(_", "value_", "-_", "min", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "._", "append_", "(_", "(_", "score_", ",_", "label_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "exception_", "(_", "\"", "fail", "ed", " ", "compu", "ting", " ", "score", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "sorted_", "(_", "scores_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "combin", "ed", "\\u", "stats", "\\u", "over", "\\u", "time_", "(_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "output", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "runs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "objective_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "worst", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "best_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "combin", "e", " ", "stats", "\\u", "over", "\\u", "time", "()", " ", "vector", "s", " ", "for", " ", "multiple", " ", "runs", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "extract", "\\u", "fn", " ", "=", " ", "lambda", " ", "dr", ":", " ", "objecti", "ve", ".", "stats", "\\u", "quali", "ty", "\\u", "score", "(", "dr", ".", "result", ",", " ", "worst", ",", " ", "best", ")_", "\\u\\u\\uNL\\u\\u\\u_", "extract", "\\u", "fn_", "=_", "\\u_", "._", "result_", "._", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "combin", "e\\u", "fn_", "=_", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "no", "\\u", "data_", "=_", "999_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "._", "debug_", "(_", "\"", "writ", "ing", " ", "stats", " ", "for", " ", "%", "s", " ", "to", " ", "%", "s", "\"_", ",_", "label_", ",_", "output", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "by", "\\u", "run_", "=_", "[_", "self_", "._", "stats", "\\u", "over", "\\u", "time_", "(_", "session_", ",_", "run_", ",_", "extract", "\\u", "fn_", ",_", "combin", "e\\u", "fn_", ",_", "no", "\\u", "data_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "run_", ",_", "session_", "in_", "runs_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "len_", "=_", "max_", "(_", "map_", "(_", "len_", ",_", "by", "\\u", "run_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "by", "\\u", "run", "\\u", "streams_", "=_", "[_", "Stream_", "(_", ")_", "<<_", "x_", "<<_", "repeat_", "(_", "x_", "[_", "-_", "1_", "]_", ",_", "max", "\\u", "len_", "-_", "len_", "(_", "x_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "by", "\\u", "run_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "by", "\\u", "quant", "a_", "=_", "zip_", "(_", "*_", "by", "\\u", "run", "\\u", "streams_", "[_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "data\\u", "file_", "(_", "suffix_", ",_", "headers_", ",_", "value", "\\u", "function_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "output", "\\u", "dir_", ",_", "label_", "+_", "suffix_", ")_", ",_", "'", "w", "'_", ")_", "as_", "fd_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "=_", "csv_", "._", "writer_", "(_", "fd_", ",_", "delimiter_", "=_", "'", " ", "'_", ",_", "linet", "ermina", "tor_", "=_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "._", "writerow_", "(_", "[_", "'#", "sec", "'_", "]_", "+_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "quant", "a_", ",_", "values_", "in_", "enumerate_", "(_", "by", "\\u", "quant", "a_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sec_", "=_", "quant", "a_", "*_", "self_", "._", "args_", "._", "stats", "\\u", "quant", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "._", "writerow_", "(_", "[_", "sec_", "]_", "+_", "value", "\\u", "function_", "(_", "values_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "data\\u", "file", "('\\", "ude", "tails", ".", "dat", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "map", "(", "lambda", " ", "x", ":", " ", "'", "run", "%", "d", "'%", "x", ",", " ", "xran", "ge", "(", "max", "\\u", "len", "))", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "list", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "gnup", "lot", "\\u", "file", "(", "output", "\\u", "dir", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", "label", "+'", "\\u", "deta", "il", "s", "',", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", "[(", "'\"", "'+", "label", "+'", "\\u", "deta", "il", "s", ".", "dat", "\"'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "'", " ", "usi", "ng", " ", "1", ":", "%", "d", "'%", "i", " ", "+_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "'", " ", "with", " ", "lines", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "'", " ", "title", " ", "\"", "Run", " ", "%", "d", "\"'", "%", "i", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "i", " ", "in", " ", "xran", "ge", "(", "max", "\\u", "len", ")])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data\\u", "file_", "(_", "'\\u", "mean", ".", "dat", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'#", "sec", "'_", ",_", "'", "mean", "'_", ",_", "'", "stddev", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "values_", ":_", "[_", "mean_", "(_", "values_", ")_", ",_", "stddev_", "(_", "values_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "output", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "+_", "'\\u", "mean", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'\"'_", "+_", "label_", "+_", "'\\u", "mean", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "2", " ", "with", " ", "lines", " ", "title", " ", "\"", "Mea", "n", "\"'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "extract", "\\u", "percentile", "s_", "(_", "values_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "sorted_", "(_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "[_", "values_", "[_", "int_", "(_", "round_", "(_", "p_", "*_", "(_", "len_", "(_", "values_", ")_", "-_", "1_", ")_", ")_", ")_", "]_", "for_", "p_", "in_", "PC", "TST", "EPS", "_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "[_", "mean_", "(_", "values_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data\\u", "file_", "(_", "\"\\u", "percentile", "s", ".", "dat", "\"_", ",_", "PC", "TST", "EPS", "_", "+_", "[_", "'", "mean", "'_", "]_", ",_", "extract", "\\u", "percentile", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "gnup", "lot", "\\u", "file_", "(_", "output", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "+_", "'\\u", "percentile", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reversed_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'\"'_", "+_", "label_", "+_", "'\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "2", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "0", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "3", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "4", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "10", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "5", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "25", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "6", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "20", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "7", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "3", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "8", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "30", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "9", " ", " ", "with", " ", "lines", " ", "title", " ", "\"", "4", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "10", " ", "with", " ", "lines", " ", "title", " ", "\"", "40", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "11", " ", "with", " ", "lines", " ", "title", " ", "\"", "5", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "1", "2", " ", "with", " ", "lines", " ", "title", " ", "\"", "50", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "13", " ", "with", " ", "lines", " ", "title", " ", "\"", "6", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "14", " ", "with", " ", "lines", " ", "title", " ", "\"", "7", "0", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "15", " ", "with", " ", "lines", " ", "title", " ", "\"", "7", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "16", " ", "with", " ", "lines", " ", "title", " ", "\"", "80", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "1", "7", " ", "with", " ", "lines", " ", "title", " ", "\"", "85", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "1", "8", " ", "with", " ", "lines", " ", "title", " ", "\"", "90", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'\"", "\"", " ", " ", " ", " ", "usi", "ng", " ", "1", ":", "1", "9", " ", "with", " ", "lines", " ", "title", " ", "\"", "9", "5", "%", "\"',", "_", "\\u\\u\\uNL\\u\\u\\u_", "'\"'_", "+_", "label_", "+_", "'\\u", "percentile", "s", ".", "dat", "\"", " ", "usi", "ng", " ", "1", ":", "20", " ", "with", " ", "lines", " ", "title", " ", "\"", "100", "%", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gnup", "lot", "\\u", "file_", "(_", "self_", ",_", "output", "\\u", "dir_", ",_", "prefix_", ",_", "plot", "cmd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "output", "\\u", "dir_", ",_", "prefix_", "+_", "'.", "gnup", "lot", "'_", ")_", ",_", "'", "w", "'_", ")_", "as_", "fd_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "fd_", ",_", "'", "set", " ", "termina", "l", " ", "posts", "cript", " ", "eps", " ", "enhance", "d", " ", "color", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "set", " ", "output", " ", "\"%", "s", "\"'_", "%_", "(_", "prefix_", "+_", "'.", "eps", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "set", " ", "ylabel", " ", "\"", "Execut", "ion", " ", "Time", " ", "(", "second", "s", ")\"", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "set", " ", "xlabel", " ", "\"", "Auto", "tuning", " ", "Time", " ", "(", "second", "s", ")\"", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "plot", "'_", ",_", "',", "\\\\\\\\\\\\", "n", "'_", "._", "join_", "(_", "plot", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "call_", "(_", "[_", "'", "gnup", "lot", "'_", ",_", "prefix_", "+_", "'.", "gnup", "lot", "'_", "]_", ",_", "cwd_", "=_", "output", "\\u", "dir_", ",_", "stdin_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "\"", "command", " ", "gnup", "lot", " ", "not", " ", "found", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gnup", "lot", "\\u", "summar", "y", "\\u", "file_", "(_", "self_", ",_", "output", "\\u", "dir_", ",_", "prefix_", ",_", "plot", "cmd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "output", "\\u", "dir_", ",_", "prefix_", "+_", "'.", "gnup", "lot", "'_", ")_", ",_", "'", "w", "'_", ")_", "as_", "fd_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "fd_", ",_", "'", "set", " ", "termina", "l", " ", "posts", "cript", " ", "eps", " ", "enhance", "d", " ", "color", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "set", " ", "output", " ", "\"%", "s", "\"'_", "%_", "(_", "prefix_", "+_", "'.", "eps", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'''", "\\", "10", ";", "set", " ", "box", "widt", "h", " ", "0.", "9", "\\", "10", ";", "set", " ", "style", " ", "fill", " ", "solid", " ", "1.00", " ", "border", " ", "0", "\\", "10", ";", "set", " ", "style", " ", "histo", "gram", " ", "error", "bar", "s", " ", "gap", " ", "2", " ", "lw", " ", "1", "\\", "10", ";", "set", " ", "style", " ", "data", " ", "histograms", "\\", "10", ";", "set", " ", "xt", "ics", " ", "rota", "te", " ", "by", " ", "-", "4", "5", "\\", "10", ";", "set", " ", "bar", "s", " ", "0.", "5", "\\", "10", ";", "set", " ", "yra", "nge", " ", "[", "0", ":", "20", "]", "\\", "10", ";", "\\", "10", ";", "set", " ", "yra", "nge", " ", "[", "0", ":", "10", "]", "\\", "10", ";", "set", " ", "key", " ", "out", " ", "vert", " ", "top", " ", "left", "\\", "10", ";", "set", " ", "size", " ", "1.5", ",", "1", "\\", "10", ";", "set", " ", "yti", "cs", " ", "1", "\\", "10", ";", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "fd_", ",_", "'", "plot", "'_", ",_", "',", "\\\\\\\\\\\\", "n", "'_", "._", "join_", "(_", "plot", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "subprocess_", "._", "call_", "(_", "[_", "'", "gnup", "lot", "'_", ",_", "prefix_", "+_", "'.", "gnup", "lot", "'_", "]_", ",_", "cwd_", "=_", "output", "\\u", "dir_", ",_", "stdin_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stat", "s", "Main_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "stats", "\\u", "over", "\\u", "time_", "(_", "self_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "session_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "run_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extract", "\\u", "fn_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "combin", "e\\u", "fn_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "no", "\\u", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "reduce", "(", "combin", "e\\u", "fn", ",", " ", "map", "(", "extract", "\\u", "fn", ",", " ", "data", "))", " ", "for", " ", "each", " ", "quant", "a", " ", "of", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "tuning", " ", "run", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value", "\\u", "by", "\\u", "quant", "a_", "=_", "[_", "no", "\\u", "data_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "date_", "=_", "run_", "._", "start", "\\u", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sub", "q_", "=_", "(_", "session_", "._", "query_", "(_", "Result_", "._", "id_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter", "\\u", "by_", "(_", "tuning", "\\u", "run_", "=_", "run_", ",_", "was", "\\u", "new", "\\u", "best_", "=_", "True_", ",_", "state_", "=_", "'", "OK", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "q_", "=_", "(_", "session_", "._", "query_", "(_", "Des", "ired", "Result_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "join_", "(_", "Result_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter_", "(_", "Des", "ired", "Result_", "._", "state_", "==_", "'", "COMPLET", "E", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Des", "ired", "Result_", "._", "tuning", "\\u", "run_", "==_", "run_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Des", "ired", "Result_", "._", "result", "\\u", "id_", "._", "in\\u_", "(_", "sub", "q_", "._", "subquery", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "order", "\\u", "by_", "(_", "Des", "ired", "Result_", "._", "request", "\\u", "date_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "first", "\\u", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dr_", "in_", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "first", "\\u", "id_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "first", "\\u", "id_", "=_", "dr_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "td_", "=_", "(_", "dr_", "._", "request", "\\u", "date_", "-_", "start", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duration_", "=_", "td_", "._", "seconds_", "+_", "(_", "td_", "._", "days_", "*_", "24_", "*_", "3600.", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "args_", "._", "by", "\\u", "request", "\\u", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quant", "a_", "=_", "dr_", "._", "id_", "-_", "first", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quant", "a_", "=_", "int_", "(_", "duration_", "/_", "self_", "._", "args_", "._", "stats", "\\u", "quant", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "len_", "(_", "value", "\\u", "by", "\\u", "quant", "a_", ")_", "<=_", "quant", "a_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value", "\\u", "by", "\\u", "quant", "a_", "._", "append_", "(_", "value", "\\u", "by", "\\u", "quant", "a_", "[_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "value", "\\u", "by", "\\u", "quant", "a_", "[_", "-_", "1_", "]_", "is_", "no", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value", "\\u", "by", "\\u", "quant", "a_", "[_", "-_", "1_", "]_", "=_", "extract", "\\u", "fn_", "(_", "dr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value", "\\u", "by", "\\u", "quant", "a_", "[_", "-_", "1_", "]_", "=_", "combin", "e\\u", "fn_", "(_", "value", "\\u", "by", "\\u", "quant", "a_", "[_", "-_", "1_", "]_", ",_", "extract", "\\u", "fn_", "(_", "dr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "value", "\\u", "by", "\\u", "quant", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
benadida/helios-server/helios/models.py
[ { "content": "# -*- coding: utf-8 -*-\n\"\"\"\nData Objects for Helios.\n\nBen Adida\n([email protected])\n\"\"\"\n\nfrom django.db import models, transaction\nimport json\nfrom django.conf import settings\nfrom django.core.mail import send_mail\n\nimport datetime, logging, uuid, random, io\nimport bleach\n\nfrom crypto import electionalgs, algs, utils\nfrom helios import utils as heliosutils\nimport helios.views\n\nfrom helios import datatypes\n\n\n# useful stuff in helios_auth\nfrom helios_auth.models import User, AUTH_SYSTEMS\nfrom helios_auth.jsonfield import JSONField\nfrom helios.datatypes.djangofield import LDObjectField\n\nimport csv, copy\nimport unicodecsv\n\n\n \n\n##\n## UTF8 craziness for CSV\n##\n\n\n \n\n\n \n \n \n \n \n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class HeliosModel(models.Model, datatypes.LDObjectContainer):\n class Meta:\n abstract = True", "metadata": "root.HeliosModel", "header": "['module', '___EOS___']", "index": 31 }, { "content": "class Election(HeliosModel):\n admin = models.ForeignKey(User)\n \n uuid = models.CharField(max_length=50, null=False)\n\n # keep track of the type and version of election, which will help dispatch to the right\n # code, both for crypto and serialization\n # v3 and prior have a datatype of \"legacy/Election\"\n # v3.1 will still use legacy/Election\n # later versions, at some point will upgrade to \"2011/01/Election\"\n datatype = models.CharField(max_length=250, null=False, default=\"legacy/Election\")\n \n short_name = models.CharField(max_length=100)\n name = models.CharField(max_length=250)\n \n ELECTION_TYPES = (\n ('election', 'Election'),\n ('referendum', 'Referendum')\n )\n\n election_type = models.CharField(max_length=250, null=False, default='election', choices = ELECTION_TYPES)\n private_p = models.BooleanField(default=False, null=False)\n\n description = models.TextField()\n public_key = LDObjectField(type_hint = 'legacy/EGPublicKey',\n null=True)\n private_key = LDObjectField(type_hint = 'legacy/EGSecretKey',\n null=True)\n \n questions = LDObjectField(type_hint = 'legacy/Questions',\n null=True)\n \n # eligibility is a JSON field, which lists auth_systems and eligibility details for that auth_system, e.g.\n # [{'auth_system': 'cas', 'constraint': [{'year': 'u12'}, {'year':'u13'}]}, {'auth_system' : 'password'}, {'auth_system' : 'openid', 'constraint': [{'host':'http://myopenid.com'}]}]\n eligibility = LDObjectField(type_hint = 'legacy/Eligibility',\n null=True)\n\n # open registration?\n # this is now used to indicate the state of registration,\n # whether or not the election is frozen\n openreg = models.BooleanField(default=False)\n \n # featured election?\n featured_p = models.BooleanField(default=False)\n \n # voter aliases?\n use_voter_aliases = models.BooleanField(default=False)\n\n # auditing is not for everyone\n use_advanced_audit_features = models.BooleanField(default=True, null=False)\n\n # randomize candidate order?\n randomize_answer_order = models.BooleanField(default=False, null=False)\n \n # where votes should be cast\n cast_url = models.CharField(max_length = 500)\n\n # dates at which this was touched\n created_at = models.DateTimeField(auto_now_add=True)\n modified_at = models.DateTimeField(auto_now_add=True)\n \n # dates at which things happen for the election\n frozen_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n archived_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n \n # dates for the election steps, as scheduled\n # these are always UTC\n registration_starts_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n voting_starts_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n voting_ends_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n\n # if this is non-null, then a complaint period, where people can cast a quarantined ballot.\n # we do NOT call this a \"provisional\" ballot, since provisional implies that the voter has not\n # been qualified. We may eventually add this, but it can't be in the same CastVote table, which\n # is tied to a voter.\n complaint_period_ends_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n\n tallying_starts_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n \n # dates when things were forced to be performed\n voting_started_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n voting_extended_until = models.DateTimeField(auto_now_add=False, default=None, null=True)\n voting_ended_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n tallying_started_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n tallying_finished_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n tallies_combined_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n\n # we want to explicitly release results\n result_released_at = models.DateTimeField(auto_now_add=False, default=None, null=True)\n\n # the hash of all voters (stored for large numbers)\n voters_hash = models.CharField(max_length=100, null=True)\n \n # encrypted tally, each a JSON string\n # used only for homomorphic tallies\n encrypted_tally = LDObjectField(type_hint = 'legacy/Tally',\n null=True)\n\n # results of the election\n result = LDObjectField(type_hint = 'legacy/Result',\n null=True)\n\n # decryption proof, a JSON object\n # no longer needed since it's all trustees\n result_proof = JSONField(null=True)\n\n # help email\n help_email = models.EmailField(null=True)\n\n # downloadable election info\n election_info_url = models.CharField(max_length=300, null=True)\n\n # metadata for the election\n\n\n\n\n\n\n\n\n\n \n\n \n \n \n\n \n\n\n \n \n \n\n\n\n \n \n \n \n \n \n \n \n \n\n\n \n\n\n\n\n\n \n\n\n ", "metadata": "root.Election", "header": "['module', '___EOS___']", "index": 35 }, { "content": " @property\n def metadata(self):\n return {\n 'help_email': self.help_email or '[email protected]',\n 'private_p': self.private_p,\n 'use_advanced_audit_features': self.use_advanced_audit_features,\n 'randomize_answer_order': self.randomize_answer_order\n }", "metadata": "root.Election.metadata", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 148 }, { "content": " @property\n def pretty_type(self):\n return dict(self.ELECTION_TYPES)[self.election_type]", "metadata": "root.Election.pretty_type", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 157 }, { "content": " @property\n def num_cast_votes(self):\n return self.voter_set.exclude(vote=None).count()", "metadata": "root.Election.num_cast_votes", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 161 }, { "content": " @property\n def num_voters(self):\n return self.voter_set.count()", "metadata": "root.Election.num_voters", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 165 }, { "content": " @property\n def num_trustees(self):\n return self.trustee_set.count()", "metadata": "root.Election.num_trustees", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 169 }, { "content": " @property\n def last_alias_num(self):\n \"\"\"\n FIXME: we should be tracking alias number, not the V* alias which then\n makes things a lot harder\n \"\"\"\n if not self.use_voter_aliases:\n return None\n \n return heliosutils.one_val_raw_sql(\"select max(cast(substring(alias, 2) as integer)) from \" + Voter._meta.db_table + \" where election_id = %s\", [self.id]) or 0", "metadata": "root.Election.last_alias_num", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 173 }, { "content": " @property\n def encrypted_tally_hash(self):\n if not self.encrypted_tally:\n return None\n\n return utils.hash_b64(self.encrypted_tally.toJSON())", "metadata": "root.Election.encrypted_tally_hash", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 184 }, { "content": " @property\n def is_archived(self):\n return self.archived_at != None", "metadata": "root.Election.is_archived", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 191 }, { "content": " @property\n def description_bleached(self):\n return bleach.clean(self.description, tags = bleach.ALLOWED_TAGS + ['p', 'h4', 'h5', 'h3', 'h2', 'br', 'u'])", "metadata": "root.Election.description_bleached", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 195 }, { "content": " @classmethod\n def get_featured(cls):\n return cls.objects.filter(featured_p = True).order_by('short_name')", "metadata": "root.Election.get_featured", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 199 }, { "content": " @classmethod\n def get_or_create(cls, **kwargs):\n return cls.objects.get_or_create(short_name = kwargs['short_name'], defaults=kwargs)", "metadata": "root.Election.get_or_create", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 203 }, { "content": " @classmethod\n def get_by_user_as_admin(cls, user, archived_p=None, limit=None):\n query = cls.objects.filter(admin = user)\n if archived_p == True:\n query = query.exclude(archived_at= None)\n if archived_p == False:\n query = query.filter(archived_at= None)\n query = query.order_by('-created_at')\n if limit:\n return query[:limit]\n else:\n return query", "metadata": "root.Election.get_by_user_as_admin", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 207 }, { "content": " @classmethod\n def get_by_user_as_voter(cls, user, archived_p=None, limit=None):\n query = cls.objects.filter(voter__user = user)\n if archived_p == True:\n query = query.exclude(archived_at= None)\n if archived_p == False:\n query = query.filter(archived_at= None)\n query = query.order_by('-created_at')\n if limit:\n return query[:limit]\n else:\n return query", "metadata": "root.Election.get_by_user_as_voter", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 220 }, { "content": " @classmethod\n def get_by_uuid(cls, uuid):\n try:\n return cls.objects.select_related().get(uuid=uuid)\n except cls.DoesNotExist:\n return None", "metadata": "root.Election.get_by_uuid", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 233 }, { "content": " @classmethod\n def get_by_short_name(cls, short_name):\n try:\n return cls.objects.get(short_name=short_name)\n except cls.DoesNotExist:\n return None", "metadata": "root.Election.get_by_short_name", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 240 }, { "content": " def add_voters_file(self, uploaded_file):\n \"\"\"\n expects a django uploaded_file data structure, which has filename, content, size...\n \"\"\"\n # now we're just storing the content\n # random_filename = str(uuid.uuid4())\n # new_voter_file.voter_file.save(random_filename, uploaded_file)\n\n new_voter_file = VoterFile(election = self, voter_file_content = uploaded_file.read())\n new_voter_file.save()\n \n self.append_log(ElectionLog.VOTER_FILE_ADDED)\n return new_voter_file", "metadata": "root.Election.add_voters_file", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 247 }, { "content": " def user_eligible_p(self, user):\n \"\"\"\n Checks if a user is eligible for this election.\n \"\"\"\n # registration closed, then eligibility doesn't come into play\n if not self.openreg:\n return False\n \n if self.eligibility == None:\n return True\n \n # is the user eligible for one of these cases?\n for eligibility_case in self.eligibility:\n if user.is_eligible_for(eligibility_case):\n return True\n \n return False", "metadata": "root.Election.user_eligible_p", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 261 }, { "content": " def eligibility_constraint_for(self, user_type):\n if not self.eligibility:\n return []\n\n # constraints that are relevant\n relevant_constraints = [constraint['constraint'] for constraint in self.eligibility if constraint['auth_system'] == user_type and constraint.has_key('constraint')]\n if len(relevant_constraints) > 0:\n return relevant_constraints[0]\n else:\n return []", "metadata": "root.Election.eligibility_constraint_for", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 279 }, { "content": " def eligibility_category_id(self, user_type):\n \"when eligibility is by category, this returns the category_id\"\n if not self.eligibility:\n return None\n \n constraint_for = self.eligibility_constraint_for(user_type)\n if len(constraint_for) > 0:\n constraint = constraint_for[0]\n return AUTH_SYSTEMS[user_type].eligibility_category_id(constraint)\n else:\n return None", "metadata": "root.Election.eligibility_category_id", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 290 }, { "content": " @property\n def pretty_eligibility(self):\n if not self.eligibility:\n return \"Anyone can vote.\"\n else:\n return_val = \"<ul>\"\n \n for constraint in self.eligibility:\n if constraint.has_key('constraint'):\n for one_constraint in constraint['constraint']:\n return_val += \"<li>%s</li>\" % AUTH_SYSTEMS[constraint['auth_system']].pretty_eligibility(one_constraint)\n else:\n return_val += \"<li> any %s user</li>\" % constraint['auth_system']\n\n return_val += \"</ul>\"\n\n return return_val", "metadata": "root.Election.pretty_eligibility", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 302 }, { "content": " def voting_has_started(self):\n \"\"\"\n has voting begun? voting begins if the election is frozen, at the prescribed date or at the date that voting was forced to start\n \"\"\"\n return self.frozen_at != None and (self.voting_starts_at == None or (datetime.datetime.utcnow() >= (self.voting_started_at or self.voting_starts_at)))", "metadata": "root.Election.voting_has_started", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 320 }, { "content": " def voting_has_stopped(self):\n \"\"\"\n has voting stopped? if tally computed, yes, otherwise if we have passed the date voting was manually stopped at,\n or failing that the date voting was extended until, or failing that the date voting is scheduled to end at.\n \"\"\"\n voting_end = self.voting_ended_at or self.voting_extended_until or self.voting_ends_at\n return (voting_end != None and datetime.datetime.utcnow() >= voting_end) or self.encrypted_tally", "metadata": "root.Election.voting_has_stopped", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 326 }, { "content": " @property\n def issues_before_freeze(self):\n issues = []\n if self.questions == None or len(self.questions) == 0:\n issues.append(\n {'type': 'questions',\n 'action': \"add questions to the ballot\"}\n )\n \n trustees = Trustee.get_by_election(self)\n if len(trustees) == 0:\n issues.append({\n 'type': 'trustees',\n 'action': \"add at least one trustee\"\n })\n\n for t in trustees:\n if t.public_key == None:\n issues.append({\n 'type': 'trustee keypairs',\n 'action': 'have trustee %s generate a keypair' % t.name\n })\n\n if self.voter_set.count() == 0 and not self.openreg:\n issues.append({\n \"type\" : \"voters\",\n \"action\" : 'enter your voter list (or open registration to the public)'\n })\n\n return issues ", "metadata": "root.Election.issues_before_freeze", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 334 }, { "content": " def ready_for_tallying(self):\n return datetime.datetime.utcnow() >= self.tallying_starts_at", "metadata": "root.Election.ready_for_tallying", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 365 }, { "content": " def compute_tally(self):\n \"\"\"\n tally the election, assuming votes already verified\n \"\"\"\n tally = self.init_tally()\n for voter in self.voter_set.exclude(vote=None):\n tally.add_vote(voter.vote, verify_p=False)\n\n self.encrypted_tally = tally\n self.save() ", "metadata": "root.Election.compute_tally", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 368 }, { "content": " def ready_for_decryption(self):\n return self.encrypted_tally != None", "metadata": "root.Election.ready_for_decryption", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 379 }, { "content": " def ready_for_decryption_combination(self):\n \"\"\"\n do we have a tally from all trustees?\n \"\"\"\n for t in Trustee.get_by_election(self):\n if not t.decryption_factors:\n return False\n \n return True", "metadata": "root.Election.ready_for_decryption_combination", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 382 }, { "content": " def release_result(self):\n \"\"\"\n release the result that should already be computed\n \"\"\"\n if not self.result:\n return\n\n self.result_released_at = datetime.datetime.utcnow()", "metadata": "root.Election.release_result", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 392 }, { "content": " def combine_decryptions(self):\n \"\"\"\n combine all of the decryption results\n \"\"\"\n \n # gather the decryption factors\n trustees = Trustee.get_by_election(self)\n decryption_factors = [t.decryption_factors for t in trustees]\n \n self.result = self.encrypted_tally.decrypt_from_factors(decryption_factors, self.public_key)\n\n self.append_log(ElectionLog.DECRYPTIONS_COMBINED)\n\n self.save()", "metadata": "root.Election.combine_decryptions", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 401 }, { "content": " def generate_voters_hash(self):\n \"\"\"\n look up the list of voters, make a big file, and hash it\n \"\"\"\n\n # FIXME: for now we don't generate this voters hash:\n return\n\n if self.openreg:\n self.voters_hash = None\n else:\n voters = Voter.get_by_election(self)\n voters_json = utils.to_json([v.toJSONDict() for v in voters])\n self.voters_hash = utils.hash_b64(voters_json)", "metadata": "root.Election.generate_voters_hash", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 416 }, { "content": " def increment_voters(self):\n ## FIXME\n return 0", "metadata": "root.Election.increment_voters", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 431 }, { "content": " def increment_cast_votes(self):\n ## FIXME\n return 0", "metadata": "root.Election.increment_cast_votes", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 435 }, { "content": " def set_eligibility(self):\n \"\"\"\n if registration is closed and eligibility has not been\n already set, then this call sets the eligibility criteria\n based on the actual list of voters who are already there.\n\n This helps ensure that the login box shows the proper options.\n\n If registration is open but no voters have been added with password,\n then that option is also canceled out to prevent confusion, since\n those elections usually just use the existing login systems.\n \"\"\"\n\n # don't override existing eligibility\n if self.eligibility != None:\n return\n\n # enable this ONLY once the cast_confirm screen makes sense\n #if self.voter_set.count() == 0:\n # return\n\n auth_systems = copy.copy(settings.AUTH_ENABLED_AUTH_SYSTEMS)\n voter_types = [r['user__user_type'] for r in self.voter_set.values('user__user_type').distinct() if r['user__user_type'] != None]\n\n # password is now separate, not an explicit voter type\n if self.voter_set.filter(user=None).count() > 0:\n voter_types.append('password')\n else:\n # no password users, remove password from the possible auth systems\n if 'password' in auth_systems:\n auth_systems.remove('password') \n\n # closed registration: limit the auth_systems to just the ones\n # that have registered voters\n if not self.openreg:\n auth_systems = [vt for vt in voter_types if vt in auth_systems]\n\n self.eligibility = [{'auth_system': auth_system} for auth_system in auth_systems]\n self.save() ", "metadata": "root.Election.set_eligibility", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 439 }, { "content": " def freeze(self):\n \"\"\"\n election is frozen when the voter registration, questions, and trustees are finalized\n \"\"\"\n if len(self.issues_before_freeze) > 0:\n raise Exception(\"cannot freeze an election that has issues\")\n\n self.frozen_at = datetime.datetime.utcnow()\n \n # voters hash\n self.generate_voters_hash()\n\n self.set_eligibility()\n \n # public key for trustees\n trustees = Trustee.get_by_election(self)\n combined_pk = trustees[0].public_key\n for t in trustees[1:]:\n combined_pk = combined_pk * t.public_key\n \n self.public_key = combined_pk\n \n # log it\n self.append_log(ElectionLog.FROZEN)\n\n self.save()", "metadata": "root.Election.freeze", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 479 }, { "content": " def generate_trustee(self, params):\n \"\"\"\n generate a trustee including the secret key,\n thus a helios-based trustee\n \"\"\"\n # FIXME: generate the keypair\n keypair = params.generate_keypair()\n\n # create the trustee\n trustee = Trustee(election = self)\n trustee.uuid = str(uuid.uuid4())\n trustee.name = settings.DEFAULT_FROM_NAME\n trustee.email = settings.DEFAULT_FROM_EMAIL\n trustee.public_key = keypair.pk\n trustee.secret_key = keypair.sk\n \n # FIXME: is this at the right level of abstraction?\n trustee.public_key_hash = datatypes.LDObject.instantiate(trustee.public_key, datatype='legacy/EGPublicKey').hash\n\n trustee.pok = trustee.secret_key.prove_sk(algs.DLog_challenge_generator)\n\n trustee.save()", "metadata": "root.Election.generate_trustee", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 506 }, { "content": " def get_helios_trustee(self):\n trustees_with_sk = self.trustee_set.exclude(secret_key = None)\n if len(trustees_with_sk) > 0:\n return trustees_with_sk[0]\n else:\n return None", "metadata": "root.Election.get_helios_trustee", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 529 }, { "content": " def has_helios_trustee(self):\n return self.get_helios_trustee() != None", "metadata": "root.Election.has_helios_trustee", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 536 }, { "content": " def helios_trustee_decrypt(self):\n tally = self.encrypted_tally\n tally.init_election(self)\n\n trustee = self.get_helios_trustee()\n factors, proof = tally.decryption_factors_and_proofs(trustee.secret_key)\n\n trustee.decryption_factors = factors\n trustee.decryption_proofs = proof\n trustee.save()", "metadata": "root.Election.helios_trustee_decrypt", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 539 }, { "content": " def append_log(self, text):\n item = ElectionLog(election = self, log=text, at=datetime.datetime.utcnow())\n item.save()\n return item", "metadata": "root.Election.append_log", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 550 }, { "content": " def get_log(self):\n return self.electionlog_set.order_by('-at')", "metadata": "root.Election.get_log", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 555 }, { "content": " @property\n def url(self):\n return helios.views.get_election_url(self)", "metadata": "root.Election.url", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 558 }, { "content": " def init_tally(self):\n # FIXME: create the right kind of tally\n from helios.workflows import homomorphic\n return homomorphic.Tally(election=self)", "metadata": "root.Election.init_tally", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 562 }, { "content": " @property\n def registration_status_pretty(self):\n if self.openreg:\n return \"Open\"\n else:\n return \"Closed\"", "metadata": "root.Election.registration_status_pretty", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 567 }, { "content": " @classmethod\n def one_question_winner(cls, question, result, num_cast_votes):\n \"\"\"\n determining the winner for one question\n \"\"\"\n # sort the answers , keep track of the index\n counts = sorted(enumerate(result), key=lambda(x): x[1])\n counts.reverse()\n \n the_max = question['max'] or 1\n the_min = question['min'] or 0\n\n # if there's a max > 1, we assume that the top MAX win\n if the_max > 1:\n return [c[0] for c in counts[:the_max]]\n\n # if max = 1, then depends on absolute or relative\n if question['result_type'] == 'absolute':\n if counts[0][1] >= (num_cast_votes/2 + 1):\n return [counts[0][0]]\n else:\n return []\n else:\n # assumes that anything non-absolute is relative\n return [counts[0][0]] ", "metadata": "root.Election.one_question_winner", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 574 }, { "content": " @property\n def winners(self):\n \"\"\"\n Depending on the type of each question, determine the winners\n returns an array of winners for each question, aka an array of arrays.\n assumes that if there is a max to the question, that's how many winners there are.\n \"\"\"\n return [self.one_question_winner(self.questions[i], self.result[i], self.num_cast_votes) for i in range(len(self.questions))]", "metadata": "root.Election.winners", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 600 }, { "content": " @property\n def pretty_result(self):\n if not self.result:\n return None\n \n # get the winners\n winners = self.winners\n\n raw_result = self.result\n prettified_result = []\n\n # loop through questions\n for i in range(len(self.questions)):\n q = self.questions[i]\n pretty_question = []\n \n # go through answers\n for j in range(len(q['answers'])):\n a = q['answers'][j]\n count = raw_result[i][j]\n pretty_question.append({'answer': a, 'count': count, 'winner': (j in winners[i])})\n \n prettified_result.append({'question': q['short_name'], 'answers': pretty_question})\n\n return prettified_result", "metadata": "root.Election.pretty_result", "header": "['class', 'Election', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 609 }, { "content": "class ElectionLog(models.Model):\n \"\"\"\n a log of events for an election\n \"\"\"\n\n FROZEN = \"frozen\"\n VOTER_FILE_ADDED = \"voter file added\"\n DECRYPTIONS_COMBINED = \"decryptions combined\"\n\n election = models.ForeignKey(Election)\n log = models.CharField(max_length=500)\n at = models.DateTimeField(auto_now_add=True)", "metadata": "root.ElectionLog", "header": "['module', '___EOS___']", "index": 635 }, { "content": "def unicode_csv_reader(unicode_csv_data, dialect=csv.excel, **kwargs):\n # csv.py doesn't do Unicode; encode temporarily as UTF-8:\n csv_reader = csv.reader(utf_8_encoder(unicode_csv_data),\n dialect=dialect, **kwargs)\n for row in csv_reader:\n # decode UTF-8 back to Unicode, cell by cell:\n try:\n yield [unicode(cell, 'utf-8') for cell in row]\n except:\n yield [unicode(cell, 'latin-1') for cell in row] ", "metadata": "root.unicode_csv_reader", "header": "['module', '___EOS___']", "index": 652 }, { "content": "def utf_8_encoder(unicode_csv_data):\n for line in unicode_csv_data:\n # FIXME: this used to be line.encode('utf-8'),\n # need to figure out why this isn't consistent\n yield line", "metadata": "root.utf_8_encoder", "header": "['module', '___EOS___']", "index": 663 }, { "content": "class VoterFile(models.Model):\n \"\"\"\n A model to store files that are lists of voters to be processed\n \"\"\"\n # path where we store voter upload \n PATH = settings.VOTER_UPLOAD_REL_PATH\n\n election = models.ForeignKey(Election)\n\n # we move to storing the content in the DB\n voter_file = models.FileField(upload_to=PATH, max_length=250,null=True)\n voter_file_content = models.TextField(null=True)\n\n uploaded_at = models.DateTimeField(auto_now_add=True)\n processing_started_at = models.DateTimeField(auto_now_add=False, null=True)\n processing_finished_at = models.DateTimeField(auto_now_add=False, null=True)\n num_voters = models.IntegerField(null=True)\n\n ", "metadata": "root.VoterFile", "header": "['module', '___EOS___']", "index": 669 }, { "content": " def itervoters(self):\n if self.voter_file_content:\n if type(self.voter_file_content) == unicode:\n content = self.voter_file_content.encode('utf-8')\n else:\n content = self.voter_file_content\n\n # now we have to handle non-universal-newline stuff\n # we do this in a simple way: replace all \\r with \\n\n # then, replace all double \\n with single \\n\n # this should leave us with only \\n\n content = content.replace('\\r','\\n').replace('\\n\\n','\\n')\n\n voter_stream = io.BytesIO(content)\n else:\n voter_stream = open(self.voter_file.path, \"rU\")\n\n #reader = unicode_csv_reader(voter_stream)\n reader = unicodecsv.reader(voter_stream, encoding='utf-8')\n\n for voter_fields in reader:\n # bad line\n if len(voter_fields) < 1:\n continue\n \n return_dict = {'voter_id': voter_fields[0].strip()}\n\n if len(voter_fields) > 1:\n return_dict['email'] = voter_fields[1].strip()\n else:\n # assume single field means the email is the same field\n return_dict['email'] = voter_fields[0].strip()\n\n if len(voter_fields) > 2:\n return_dict['name'] = voter_fields[2].strip()\n else:\n return_dict['name'] = return_dict['email']\n\n yield return_dict", "metadata": "root.VoterFile.itervoters", "header": "['class', 'VoterFile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 687 }, { "content": " def process(self):\n self.processing_started_at = datetime.datetime.utcnow()\n self.save()\n\n election = self.election \n last_alias_num = election.last_alias_num\n\n num_voters = 0\n new_voters = []\n for voter in self.itervoters():\n num_voters += 1\n \n # does voter for this user already exist\n existing_voter = Voter.get_by_election_and_voter_id(election, voter['voter_id'])\n \n # create the voter\n if not existing_voter:\n voter_uuid = str(uuid.uuid4())\n existing_voter = Voter(uuid= voter_uuid, user = None, voter_login_id = voter['voter_id'],\n voter_name = voter['name'], voter_email = voter['email'], election = election)\n existing_voter.generate_password()\n new_voters.append(existing_voter)\n existing_voter.save()\n\n if election.use_voter_aliases:\n voter_alias_integers = range(last_alias_num+1, last_alias_num+1+num_voters)\n random.shuffle(voter_alias_integers)\n for i, voter in enumerate(new_voters):\n voter.alias = 'V%s' % voter_alias_integers[i]\n voter.save()\n\n self.num_voters = num_voters\n self.processing_finished_at = datetime.datetime.utcnow()\n self.save()\n\n return num_voters", "metadata": "root.VoterFile.process", "header": "['class', 'VoterFile', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 727 }, { "content": "class Voter(HeliosModel):\n election = models.ForeignKey(Election)\n \n # let's link directly to the user now\n # FIXME: delete this as soon as migrations are set up\n #name = models.CharField(max_length = 200, null=True)\n #voter_type = models.CharField(max_length = 100)\n #voter_id = models.CharField(max_length = 100)\n\n uuid = models.CharField(max_length = 50)\n\n # for users of type password, no user object is created\n # but a dynamic user object is created automatically\n user = models.ForeignKey('helios_auth.User', null=True)\n\n # if user is null, then you need a voter login ID and password\n voter_login_id = models.CharField(max_length = 100, null=True)\n voter_password = models.CharField(max_length = 100, null=True)\n voter_name = models.CharField(max_length = 200, null=True)\n voter_email = models.CharField(max_length = 250, null=True)\n \n # if election uses aliases\n alias = models.CharField(max_length = 100, null=True)\n \n # we keep a copy here for easy tallying\n vote = LDObjectField(type_hint = 'legacy/EncryptedVote',\n null=True)\n vote_hash = models.CharField(max_length = 100, null=True)\n cast_at = models.DateTimeField(auto_now_add=False, null=True)\n\n class Meta:\n unique_together = (('election', 'voter_login_id'))\n\n\n\n \n\n \n \n\n\n\n\n\n\n\n\n\n \n\n\n ", "metadata": "root.Voter", "header": "['module', '___EOS___']", "index": 766 }, { "content": " def __init__(self, *args, **kwargs):\n super(Voter, self).__init__(*args, **kwargs)\n\n # stub the user so code is not full of IF statements\n if not self.user:\n self.user = User(user_type='password', user_id=self.voter_email, name=self.voter_name)", "metadata": "root.Voter.__init__", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 799 }, { "content": " @classmethod\n @transaction.atomic\n def register_user_in_election(cls, user, election):\n voter_uuid = str(uuid.uuid4())\n voter = Voter(uuid= voter_uuid, user = user, election = election)\n\n # do we need to generate an alias?\n if election.use_voter_aliases:\n heliosutils.lock_row(Election, election.id)\n alias_num = election.last_alias_num + 1\n voter.alias = \"V%s\" % alias_num\n\n voter.save()\n return voter", "metadata": "root.Voter.register_user_in_election", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 806 }, { "content": " @classmethod\n def get_by_election(cls, election, cast=None, order_by='voter_login_id', after=None, limit=None):\n \"\"\"\n FIXME: review this for non-GAE?\n \"\"\"\n query = cls.objects.filter(election = election)\n \n # the boolean check is not stupid, this is ternary logic\n # none means don't care if it's cast or not\n if cast == True:\n query = query.exclude(cast_at = None)\n elif cast == False:\n query = query.filter(cast_at = None)\n\n # little trick to get around GAE limitation\n # order by uuid only when no inequality has been added\n if cast == None or order_by == 'cast_at' or order_by =='-cast_at':\n query = query.order_by(order_by)\n \n # if we want the list after a certain UUID, add the inequality here\n if after:\n if order_by[0] == '-':\n field_name = \"%s__gt\" % order_by[1:]\n else:\n field_name = \"%s__gt\" % order_by\n conditions = {field_name : after}\n query = query.filter (**conditions)\n \n if limit:\n query = query[:limit]\n \n return query", "metadata": "root.Voter.get_by_election", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 821 }, { "content": " @classmethod\n def get_all_by_election_in_chunks(cls, election, cast=None, chunk=100):\n return cls.get_by_election(election)", "metadata": "root.Voter.get_all_by_election_in_chunks", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 854 }, { "content": " @classmethod\n def get_by_election_and_voter_id(cls, election, voter_id):\n try:\n return cls.objects.get(election = election, voter_login_id = voter_id)\n except cls.DoesNotExist:\n return None", "metadata": "root.Voter.get_by_election_and_voter_id", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 858 }, { "content": " @classmethod\n def get_by_election_and_user(cls, election, user):\n try:\n return cls.objects.get(election = election, user = user)\n except cls.DoesNotExist:\n return None", "metadata": "root.Voter.get_by_election_and_user", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 865 }, { "content": " @classmethod\n def get_by_election_and_uuid(cls, election, uuid):\n query = cls.objects.filter(election = election, uuid = uuid)\n\n try:\n return query[0]\n except:\n return None", "metadata": "root.Voter.get_by_election_and_uuid", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 872 }, { "content": " @classmethod\n def get_by_user(cls, user):\n return cls.objects.select_related().filter(user = user).order_by('-cast_at')", "metadata": "root.Voter.get_by_user", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 881 }, { "content": " @property\n def datatype(self):\n return self.election.datatype.replace('Election', 'Voter')", "metadata": "root.Voter.datatype", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 885 }, { "content": " @property\n def vote_tinyhash(self):\n \"\"\"\n get the tinyhash of the latest castvote\n \"\"\"\n if not self.vote_hash:\n return None\n \n return CastVote.objects.get(vote_hash = self.vote_hash).vote_tinyhash", "metadata": "root.Voter.vote_tinyhash", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 889 }, { "content": " @property\n def election_uuid(self):\n return self.election.uuid", "metadata": "root.Voter.election_uuid", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 899 }, { "content": " @property\n def name(self):\n return self.user.name", "metadata": "root.Voter.name", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 903 }, { "content": " @property\n def voter_id(self):\n return self.user.user_id", "metadata": "root.Voter.voter_id", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 907 }, { "content": " @property\n def voter_id_hash(self):\n if self.voter_login_id:\n # for backwards compatibility with v3.0, and since it doesn't matter\n # too much if we hash the email or the unique login ID here.\n value_to_hash = self.voter_login_id\n else:\n value_to_hash = self.voter_id\n\n try:\n return utils.hash_b64(value_to_hash)\n except:\n try:\n return utils.hash_b64(value_to_hash.encode('latin-1'))\n except:\n return utils.hash_b64(value_to_hash.encode('utf-8')) ", "metadata": "root.Voter.voter_id_hash", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 911 }, { "content": " @property\n def voter_type(self):\n return self.user.user_type", "metadata": "root.Voter.voter_type", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 928 }, { "content": " @property\n def display_html_big(self):\n return self.user.display_html_big", "metadata": "root.Voter.display_html_big", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 932 }, { "content": " def send_message(self, subject, body):\n self.user.send_message(subject, body)", "metadata": "root.Voter.send_message", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 936 }, { "content": " def generate_password(self, length=10):\n if self.voter_password:\n raise Exception(\"password already exists\")\n \n self.voter_password = heliosutils.random_string(length, alphabet='abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789')", "metadata": "root.Voter.generate_password", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 939 }, { "content": " def store_vote(self, cast_vote):\n # only store the vote if it's cast later than the current one\n if self.cast_at and cast_vote.cast_at < self.cast_at:\n return\n\n self.vote = cast_vote.vote\n self.vote_hash = cast_vote.vote_hash\n self.cast_at = cast_vote.cast_at\n self.save()", "metadata": "root.Voter.store_vote", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 945 }, { "content": " def last_cast_vote(self):\n return CastVote(vote = self.vote, vote_hash = self.vote_hash, cast_at = self.cast_at, voter=self)", "metadata": "root.Voter.last_cast_vote", "header": "['class', 'Voter', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 955 }, { "content": "class CastVote(HeliosModel):\n # the reference to the voter provides the voter_uuid\n voter = models.ForeignKey(Voter)\n \n # the actual encrypted vote\n vote = LDObjectField(type_hint = 'legacy/EncryptedVote')\n\n # cache the hash of the vote\n vote_hash = models.CharField(max_length=100)\n\n # a tiny version of the hash to enable short URLs\n vote_tinyhash = models.CharField(max_length=50, null=True, unique=True)\n\n cast_at = models.DateTimeField(auto_now_add=True)\n\n # some ballots can be quarantined (this is not the same thing as provisional)\n quarantined_p = models.BooleanField(default=False, null=False)\n released_from_quarantine_at = models.DateTimeField(auto_now_add=False, null=True)\n\n # when is the vote verified?\n verified_at = models.DateTimeField(null=True)\n invalidated_at = models.DateTimeField(null=True)\n \n\n \n\n\n\n \n\n", "metadata": "root.CastVote", "header": "['module', '___EOS___']", "index": 959 }, { "content": " @property\n def datatype(self):\n return self.voter.datatype.replace('Voter', 'CastVote')", "metadata": "root.CastVote.datatype", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 982 }, { "content": " @property\n def voter_uuid(self):\n return self.voter.uuid ", "metadata": "root.CastVote.voter_uuid", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 986 }, { "content": " @property\n def voter_hash(self):\n return self.voter.hash", "metadata": "root.CastVote.voter_hash", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 990 }, { "content": " @property\n def is_quarantined(self):\n return self.quarantined_p and not self.released_from_quarantine_at", "metadata": "root.CastVote.is_quarantined", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 994 }, { "content": " def set_tinyhash(self):\n \"\"\"\n find a tiny version of the hash for a URL slug.\n \"\"\"\n safe_hash = self.vote_hash\n for c in ['/', '+']:\n safe_hash = safe_hash.replace(c,'')\n \n length = 8\n while True:\n vote_tinyhash = safe_hash[:length]\n if CastVote.objects.filter(vote_tinyhash = vote_tinyhash).count() == 0:\n break\n length += 1\n \n self.vote_tinyhash = vote_tinyhash", "metadata": "root.CastVote.set_tinyhash", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 998 }, { "content": " def save(self, *args, **kwargs):\n \"\"\"\n override this just to get a hook\n \"\"\"\n # not saved yet? then we generate a tiny hash\n if not self.vote_tinyhash:\n self.set_tinyhash()\n\n super(CastVote, self).save(*args, **kwargs)", "metadata": "root.CastVote.save", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 1015 }, { "content": " @classmethod\n def get_by_voter(cls, voter):\n return cls.objects.filter(voter = voter).order_by('-cast_at')", "metadata": "root.CastVote.get_by_voter", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 1025 }, { "content": " def verify_and_store(self):\n # if it's quarantined, don't let this go through\n if self.is_quarantined:\n raise Exception(\"cast vote is quarantined, verification and storage is delayed.\")\n\n result = self.vote.verify(self.voter.election)\n\n if result:\n self.verified_at = datetime.datetime.utcnow()\n else:\n self.invalidated_at = datetime.datetime.utcnow()\n \n # save and store the vote as the voter's last cast vote\n self.save()\n\n if result:\n self.voter.store_vote(self)\n \n return result", "metadata": "root.CastVote.verify_and_store", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 1029 }, { "content": " def issues(self, election):\n \"\"\"\n Look for consistency problems\n \"\"\"\n issues = []\n \n # check the election\n if self.vote.election_uuid != election.uuid:\n issues.append(\"the vote's election UUID does not match the election for which this vote is being cast\")\n \n return issues", "metadata": "root.CastVote.issues", "header": "['class', 'CastVote', '(', 'HeliosModel', ')', ':', '___NEWLINE___', '# the reference to the voter provides the voter_uuid', '___NL___', '___EOS___']", "index": 1049 }, { "content": "class AuditedBallot(models.Model):\n \"\"\"\n ballots for auditing\n \"\"\"\n election = models.ForeignKey(Election)\n raw_vote = models.TextField()\n vote_hash = models.CharField(max_length=100)\n added_at = models.DateTimeField(auto_now_add=True)\n\n", "metadata": "root.AuditedBallot", "header": "['module', '___EOS___']", "index": 1061 }, { "content": " @classmethod\n def get(cls, election, vote_hash):\n return cls.objects.get(election = election, vote_hash = vote_hash)", "metadata": "root.AuditedBallot.get", "header": "['class', 'AuditedBallot', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 1070 }, { "content": " @classmethod\n def get_by_election(cls, election, after=None, limit=None):\n query = cls.objects.filter(election = election).order_by('vote_hash')\n\n # if we want the list after a certain UUID, add the inequality here\n if after:\n query = query.filter(vote_hash__gt = after)\n\n if limit:\n query = query[:limit]\n\n return query", "metadata": "root.AuditedBallot.get_by_election", "header": "['class', 'AuditedBallot', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 1074 }, { "content": "class Trustee(HeliosModel):\n election = models.ForeignKey(Election)\n \n uuid = models.CharField(max_length=50)\n name = models.CharField(max_length=200)\n email = models.EmailField()\n secret = models.CharField(max_length=100)\n \n # public key\n public_key = LDObjectField(type_hint = 'legacy/EGPublicKey',\n null=True)\n public_key_hash = models.CharField(max_length=100)\n\n # secret key\n # if the secret key is present, this means\n # Helios is playing the role of the trustee.\n secret_key = LDObjectField(type_hint = 'legacy/EGSecretKey',\n null=True)\n \n # proof of knowledge of secret key\n pok = LDObjectField(type_hint = 'legacy/DLogProof',\n null=True)\n \n # decryption factors\n decryption_factors = LDObjectField(type_hint = datatypes.arrayOf(datatypes.arrayOf('core/BigInteger')),\n null=True)\n\n decryption_proofs = LDObjectField(type_hint = datatypes.arrayOf(datatypes.arrayOf('legacy/EGZKProof')),\n null=True)\n\n class Meta:\n unique_together = (('election', 'email'))\n \n \n\n \n\n\n ", "metadata": "root.Trustee", "header": "['module', '___EOS___']", "index": 1087 }, { "content": " def save(self, *args, **kwargs):\n \"\"\"\n override this just to get a hook\n \"\"\"\n # not saved yet?\n if not self.secret:\n self.secret = heliosutils.random_string(12)\n self.election.append_log(\"Trustee %s added\" % self.name)\n \n super(Trustee, self).save(*args, **kwargs)", "metadata": "root.Trustee.save", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1120 }, { "content": " @classmethod\n def get_by_election(cls, election):\n return cls.objects.filter(election = election)", "metadata": "root.Trustee.get_by_election", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1131 }, { "content": " @classmethod\n def get_by_uuid(cls, uuid):\n return cls.objects.get(uuid = uuid)", "metadata": "root.Trustee.get_by_uuid", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1135 }, { "content": " @classmethod\n def get_by_election_and_uuid(cls, election, uuid):\n return cls.objects.get(election = election, uuid = uuid)", "metadata": "root.Trustee.get_by_election_and_uuid", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1139 }, { "content": " @classmethod\n def get_by_election_and_email(cls, election, email):\n try:\n return cls.objects.get(election = election, email = email)\n except cls.DoesNotExist:\n return None", "metadata": "root.Trustee.get_by_election_and_email", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1143 }, { "content": " @property\n def datatype(self):\n return self.election.datatype.replace('Election', 'Trustee') ", "metadata": "root.Trustee.datatype", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1150 }, { "content": " def verify_decryption_proofs(self):\n \"\"\"\n verify that the decryption proofs match the tally for the election\n \"\"\"\n # verify_decryption_proofs(self, decryption_factors, decryption_proofs, public_key, challenge_generator):\n return self.election.encrypted_tally.verify_decryption_proofs(self.decryption_factors, self.decryption_proofs, self.public_key, algs.EG_fiatshamir_challenge_generator)", "metadata": "root.Trustee.verify_decryption_proofs", "header": "['class', 'Trustee', '(', 'HeliosModel', ')', ':', '___EOS___']", "index": 1154 } ]
[ { "span": "import json", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 11 }, { "span": "from django.core.mail import send_mail", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 38 }, { "span": "import datetime, logging, uuid, random, io", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 42 }, { "span": "from crypto import electionalgs, algs, utils", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Data", " ", "Object", "s", " ", "for", " ", "Heli", "os", ".", "\\", "10", ";", "\\", "10", ";", "Ben", " ", "Adi", "da", "\\", "10", ";", "(", "ben", "@", "adi", "da", ".", "net", ")", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", ",_", "transaction_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "mail_", "import_", "send", "\\u", "mail_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", ",_", "logging_", ",_", "uuid_", ",_", "random_", ",_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "ble", "ach", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "crypto_", "import_", "election", "alg", "s_", ",_", "alg", "s_", ",_", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "heli", "os_", "import_", "utils_", "as_", "heli", "osu", "tils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "heli", "os_", "._", "views_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "heli", "os_", "import_", "datatypes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "usef", "ul", " ", "stu", "ff", " ", "in", " ", "heli", "os", "\\u", "auth_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "heli", "os", "\\u", "auth_", "._", "models_", "import_", "User_", ",_", "AUTH", "\\u", "SYSTEM", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "heli", "os", "\\u", "auth_", "._", "jsonfi", "eld_", "import_", "JSO", "NF", "ield_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "heli", "os_", "._", "datatypes_", "._", "django", "field_", "import_", "LD", "Object", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "csv_", ",_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unicode", "csv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "UT", "F8", " ", "cra", "zin", "ess", " ", "for", " ", "CSV_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Heli", "os", "Model_", "(_", "models_", "._", "Model_", ",_", "datatypes_", "._", "LD", "Object", "Container_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "abstract_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "admin_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "User_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "uuid_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ",_", "null_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "keep", " ", "track", " ", "of", " ", "the", " ", "type", " ", "and", " ", "version", " ", "of", " ", "election", ",", " ", "whi", "ch", " ", "will", " ", "help", " ", "dispatch", " ", "to", " ", "the", " ", "right_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "code", ",", " ", "bot", "h", " ", "for", " ", "crypto", " ", "and", " ", "serialization_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "v", "3", " ", "and", " ", "prior", " ", "have", " ", "a", " ", "datatype", " ", "of", " ", "\"", "lega", "cy", "/", "Elect", "ion", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "v", "3.1", " ", "will", " ", "still", " ", "use", " ", "lega", "cy", "/", "Elect", "ion_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "late", "r", " ", "version", "s", ",", " ", "at", " ", "some", " ", "point", " ", "will", " ", "upgrade", " ", "to", " ", "\"", "2011", "/", "01", "/", "Elect", "ion", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "datatype_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "250_", ",_", "null_", "=_", "False_", ",_", "default_", "=_", "\"", "lega", "cy", "/", "Elect", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "short", "\\u", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "250_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ELECT", "ION", "\\u", "TYPES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "election", "'_", ",_", "'", "Elect", "ion", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "referen", "dum", "'_", ",_", "'", "Refer", "endu", "m", "'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "election", "\\u", "type_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "250_", ",_", "null_", "=_", "False_", ",_", "default_", "=_", "'", "election", "'_", ",_", "choices_", "=_", "ELECT", "ION", "\\u", "TYPES_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "private", "\\u", "p_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ",_", "null_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "models_", "._", "Text", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "public", "\\u", "key_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "EG", "Public", "Key", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "private", "\\u", "key_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "EG", "Sec", "ret", "Key", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "questions_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Questions", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "eli", "gib", "ilit", "y", " ", "is", " ", "a", " ", "JSO", "N", " ", "field", ",", " ", "whi", "ch", " ", "lists", " ", "auth", "\\u", "system", "s", " ", "and", " ", "eli", "gib", "ilit", "y", " ", "deta", "il", "s", " ", "for", " ", "tha", "t", " ", "auth", "\\u", "system", ",", " ", "e", ".", "g", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "[{", "'", "auth", "\\u", "system", "':", " ", "'", "cas", "',", " ", "'", "constraint", "':", " ", "[{", "'", "year", "':", " ", "'", "u1", "2", "'}", ",", " ", "{", "'", "year", "':", "'", "u1", "3", "'}", "]},", " ", "{", "'", "auth", "\\u", "system", "'", " ", ":", " ", "'", "password", "'}", ",", " ", "{", "'", "auth", "\\u", "system", "'", " ", ":", " ", "'", "openid", "',", " ", "'", "constraint", "':", " ", "[{", "'", "host", "':", "'", "http", "://", "myo", "pen", "id", ".", "com", "'}", "]}", "]_", "\\u\\u\\uNL\\u\\u\\u_", "eli", "gib", "ility_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Eli", "gib", "ilit", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "open", " ", "registration", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "now", " ", "used", " ", "to", " ", "indicat", "e", " ", "the", " ", "state", " ", "of", " ", "registration", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whe", "ther", " ", "or", " ", "not", " ", "the", " ", "election", " ", "is", " ", "frozen_", "\\u\\u\\uNL\\u\\u\\u_", "open", "reg_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "feature", "d", " ", "election", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "feature", "d\\u", "p_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "voter", " ", "alias", "es", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "voter", "\\u", "aliases_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "audit", "ing", " ", "is", " ", "not", " ", "for", " ", "everyone", "_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "advanced", "\\u", "audit", "\\u", "features_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "True_", ",_", "null_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "randomize", " ", "candidate", " ", "order", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "randomize", "\\u", "answer", "\\u", "order_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ",_", "null_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "where", " ", "vote", "s", " ", "shou", "ld", " ", "be", " ", "cast_", "\\u\\u\\uNL\\u\\u\\u_", "cast", "\\u", "url_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dates", " ", "at", " ", "whi", "ch", " ", "this", " ", "was", " ", "touche", "d_", "\\u\\u\\uNL\\u\\u\\u_", "created", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modifi", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dates", " ", "at", " ", "whi", "ch", " ", "thing", "s", " ", "happ", "en", " ", "for", " ", "the", " ", "election_", "\\u\\u\\uNL\\u\\u\\u_", "frozen", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "archived", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dates", " ", "for", " ", "the", " ", "election", " ", "step", "s", ",", " ", "as", " ", "schedule", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "these", " ", "are", " ", "alw", "ay", "s", " ", "UTC_", "\\u\\u\\uNL\\u\\u\\u_", "registration", "\\u", "starts", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voting", "\\u", "starts", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voting", "\\u", "ends", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "this", " ", "is", " ", "non", "-", "null", ",", " ", "then", " ", "a", " ", "complaint", " ", "period", ",", " ", "where", " ", "people", " ", "can", " ", "cast", " ", "a", " ", "quar", "antin", "ed", " ", "ballot", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "do", " ", "NOT", " ", "call", " ", "this", " ", "a", " ", "\"", "provision", "al", "\"", " ", "ballot", ",", " ", "sinc", "e", " ", "provision", "al", " ", "implies", " ", "tha", "t", " ", "the", " ", "voter", " ", "has", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bee", "n", " ", "qualified", ".", " ", "We", " ", "may", " ", "eventual", "ly", " ", "add", " ", "this", ",", " ", "but", " ", "it", " ", "can", "'", "t", " ", "be", " ", "in", " ", "the", " ", "same", " ", "Cast", "Vote", " ", "table", ",", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "tied", " ", "to", " ", "a", " ", "voter", "._", "\\u\\u\\uNL\\u\\u\\u_", "complaint", "\\u", "period", "\\u", "ends", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tally", "ing", "\\u", "starts", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dates", " ", "whe", "n", " ", "thing", "s", " ", "wer", "e", " ", "forced", " ", "to", " ", "be", " ", "perform", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "voting", "\\u", "start", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voting", "\\u", "extend", "ed", "\\u", "until_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voting", "\\u", "ende", "d\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tally", "ing", "\\u", "start", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tally", "ing", "\\u", "finish", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tall", "ies", "\\u", "combin", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "want", " ", "to", " ", "explicit", "ly", " ", "release", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "result", "\\u", "released", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "default_", "=_", "None_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "hash", " ", "of", " ", "all", " ", "voter", "s", " ", "(", "store", "d", " ", "for", " ", "large", " ", "numbers", ")_", "\\u\\u\\uNL\\u\\u\\u_", "voter", "s", "\\u", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encrypt", "ed", " ", "tally", ",", " ", "each", " ", "a", " ", "JSO", "N", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "used", " ", "only", " ", "for", " ", "homo", "morphi", "c", " ", "tall", "ies_", "\\u\\u\\uNL\\u\\u\\u_", "encrypt", "ed", "\\u", "tally", "_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Tal", "ly", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "results", " ", "of", " ", "the", " ", "election_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Result", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "decrypt", "ion", " ", "proof", ",", " ", "a", " ", "JSO", "N", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "no", " ", "long", "er", " ", "need", "ed", " ", "sinc", "e", " ", "it", "'", "s", " ", "all", " ", "trust", "ees", "_", "\\u\\u\\uNL\\u\\u\\u_", "result", "\\u", "proof", "_", "=_", "JSO", "NF", "ield_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "help", " ", "email_", "\\u\\u\\uNL\\u\\u\\u_", "help", "\\u", "email_", "=_", "models_", "._", "Ema", "il", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "download", "able", " ", "election", " ", "info_", "\\u\\u\\uNL\\u\\u\\u_", "election", "\\u", "info", "\\u", "url_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "300_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "metadata", " ", "for", " ", "the", " ", "election_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "metadata_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "help", "\\u", "email", "'_", ":_", "self_", "._", "help", "\\u", "email_", "or_", "'", "help", "@", "heli", "os", "voting", ".", "org", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "private", "\\u", "p", "'_", ":_", "self_", "._", "private", "\\u", "p_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "use", "\\u", "advanced", "\\u", "audit", "\\u", "features", "'_", ":_", "self_", "._", "use", "\\u", "advanced", "\\u", "audit", "\\u", "features_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "randomize", "\\u", "answer", "\\u", "order", "'_", ":_", "self_", "._", "randomize", "\\u", "answer", "\\u", "order_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "pretty", "\\u", "type_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "self_", "._", "ELECT", "ION", "\\u", "TYPES_", ")_", "[_", "self_", "._", "election", "\\u", "type_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "num", "\\u", "cast", "\\u", "votes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "voter", "\\u", "set_", "._", "exclude_", "(_", "vote_", "=_", "None_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "num", "\\u", "voter", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "voter", "\\u", "set_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "num", "\\u", "trust", "ees", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "trust", "ee", "\\u", "set_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "last", "\\u", "alias", "\\u", "num_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "FIX", "ME", ":", " ", "we", " ", "shou", "ld", " ", "be", " ", "track", "ing", " ", "alias", " ", "number", ",", " ", "not", " ", "the", " ", "V", "*", " ", "alias", " ", "whi", "ch", " ", "then", "\\", "10", ";", " ", " ", " ", " ", "make", "s", " ", "thing", "s", " ", "a", " ", "lot", " ", "hard", "er", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "use", "\\u", "voter", "\\u", "aliases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "heli", "osu", "tils_", "._", "one", "\\u", "val", "\\u", "raw", "\\u", "sql_", "(_", "\"", "select", " ", "max", "(", "cast", "(", "substring", "(", "alias", ",", " ", "2", ")", " ", "as", " ", "integ", "er", "))", " ", "from", " ", "\"_", "+_", "Vote", "r_", "._", "\\u", "meta_", "._", "db", "\\u", "table_", "+_", "\"", " ", "where", " ", "election", "\\u", "id", " ", "=", " ", "%", "s", "\"_", ",_", "[_", "self_", "._", "id_", "]_", ")_", "or_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "encrypt", "ed", "\\u", "tally", "\\u", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "utils_", "._", "hash", "\\u", "b64", "_", "(_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "._", "to", "JSON_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "is", "\\u", "archived", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "archived", "\\u", "at_", "!=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "description", "\\u", "ble", "ache", "d_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "ble", "ach", "_", "._", "clean_", "(_", "self_", "._", "description_", ",_", "tags_", "=_", "ble", "ach", "_", "._", "ALLOWED", "\\u", "TAGS_", "+_", "[_", "'", "p", "'_", ",_", "'", "h", "4", "'_", ",_", "'", "h5", "'_", ",_", "'", "h", "3", "'_", ",_", "'", "h2", "'_", ",_", "'", "br", "'_", ",_", "'", "u", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "feature", "d_", "(_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "filter_", "(_", "feature", "d\\u", "p_", "=_", "True_", ")_", "._", "order", "\\u", "by_", "(_", "'", "short", "\\u", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "or", "\\u", "create_", "(_", "cls_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "short", "\\u", "name_", "=_", "kwargs_", "[_", "'", "short", "\\u", "name", "'_", "]_", ",_", "defaults_", "=_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "user", "\\u", "as", "\\u", "admin_", "(_", "cls_", ",_", "user_", ",_", "archived", "\\u", "p_", "=_", "None_", ",_", "limit_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "admin_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "archived", "\\u", "p_", "==_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "exclude_", "(_", "archived", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "archived", "\\u", "p_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "filter_", "(_", "archived", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "query_", "._", "order", "\\u", "by_", "(_", "'-", "created", "\\u", "at", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "query_", "[_", ":_", "limit_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "user", "\\u", "as", "\\u", "voter", "_", "(_", "cls_", ",_", "user_", ",_", "archived", "\\u", "p_", "=_", "None_", ",_", "limit_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "voter", "\\u\\u", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "archived", "\\u", "p_", "==_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "exclude_", "(_", "archived", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "archived", "\\u", "p_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "filter_", "(_", "archived", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "query_", "._", "order", "\\u", "by_", "(_", "'-", "created", "\\u", "at", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "query_", "[_", ":_", "limit_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "uuid_", "(_", "cls_", ",_", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "select", "\\u", "related_", "(_", ")_", "._", "get_", "(_", "uuid_", "=_", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "short", "\\u", "name_", "(_", "cls_", ",_", "short", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "short", "\\u", "name_", "=_", "short", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "voter", "s", "\\u", "file_", "(_", "self_", ",_", "uploade", "d\\u", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "expect", "s", " ", "a", " ", "django", " ", "uploade", "d\\u", "file", " ", "data", " ", "structure", ",", " ", "whi", "ch", " ", "has", " ", "filename", ",", " ", "content", ",", " ", "size", "...", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "now", " ", "we", "'", "re", " ", "just", " ", "stor", "ing", " ", "the", " ", "content_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "random", "\\u", "filename", " ", "=", " ", "str", "(", "uuid", ".", "uuid", "4", "())", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "new", "\\u", "voter", "\\u", "file", ".", "voter", "\\u", "file", ".", "save", "(", "random", "\\u", "filename", ",", " ", "uploade", "d\\u", "file", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "voter", "\\u", "file_", "=_", "Vote", "r", "File_", "(_", "election_", "=_", "self_", ",_", "voter", "\\u", "file", "\\u", "content_", "=_", "uploade", "d\\u", "file_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "voter", "\\u", "file_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "append", "\\u", "log_", "(_", "Elect", "ion", "Log_", "._", "VO", "TER", "\\u", "FILE", "\\u", "ADD", "ED_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "new", "\\u", "voter", "\\u", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "user", "\\u", "eligible", "\\u", "p_", "(_", "self_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", "s", " ", "if", " ", "a", " ", "user", " ", "is", " ", "eligible", " ", "for", " ", "this", " ", "election", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "registration", " ", "close", "d", ",", " ", "then", " ", "eli", "gib", "ilit", "y", " ", "doe", "sn", "'", "t", " ", "come", " ", "int", "o", " ", "play_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "open", "reg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "eli", "gib", "ility_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "the", " ", "user", " ", "eligible", " ", "for", " ", "one", " ", "of", " ", "these", " ", "case", "s", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "eli", "gib", "ilit", "y", "\\u", "case_", "in_", "self_", "._", "eli", "gib", "ility_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "user_", "._", "is", "\\u", "eligible", "\\u", "for_", "(_", "eli", "gib", "ilit", "y", "\\u", "case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "eli", "gib", "ilit", "y", "\\u", "constraint", "\\u", "for_", "(_", "self_", ",_", "user", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "eli", "gib", "ility_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "constraint", "s", " ", "tha", "t", " ", "are", " ", "rele", "van", "t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rele", "van", "t", "\\u", "constraints_", "=_", "[_", "constraint_", "[_", "'", "constraint", "'_", "]_", "for_", "constraint_", "in_", "self_", "._", "eli", "gib", "ility_", "if_", "constraint_", "[_", "'", "auth", "\\u", "system", "'_", "]_", "==_", "user", "\\u", "type_", "and_", "constraint_", "._", "has", "\\u", "key_", "(_", "'", "constraint", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "rele", "van", "t", "\\u", "constraints_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "rele", "van", "t", "\\u", "constraints_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "eli", "gib", "ilit", "y", "\\u", "category", "\\u", "id_", "(_", "self_", ",_", "user", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "whe", "n", " ", "eli", "gib", "ilit", "y", " ", "is", " ", "by", " ", "category", ",", " ", "this", " ", "return", "s", " ", "the", " ", "category", "\\u", "id", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "eli", "gib", "ility_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "constraint", "\\u", "for_", "=_", "self_", "._", "eli", "gib", "ilit", "y", "\\u", "constraint", "\\u", "for_", "(_", "user", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "constraint", "\\u", "for_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "constraint_", "=_", "constraint", "\\u", "for_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "AUTH", "\\u", "SYSTEM", "S_", "[_", "user", "\\u", "type_", "]_", "._", "eli", "gib", "ilit", "y", "\\u", "category", "\\u", "id_", "(_", "constraint_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "pretty", "\\u", "eli", "gib", "ility_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "eli", "gib", "ility_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Any", "one", " ", "can", " ", "vote", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "val_", "=_", "\"<", "ul", ">\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "constraint_", "in_", "self_", "._", "eli", "gib", "ility_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "constraint_", "._", "has", "\\u", "key_", "(_", "'", "constraint", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "one", "\\u", "constraint_", "in_", "constraint_", "[_", "'", "constraint", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "val_", "+=_", "\"<", "li", ">", "%", "s", "</", "li", ">\"_", "%_", "AUTH", "\\u", "SYSTEM", "S_", "[_", "constraint_", "[_", "'", "auth", "\\u", "system", "'_", "]_", "]_", "._", "pretty", "\\u", "eli", "gib", "ility_", "(_", "one", "\\u", "constraint_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "val_", "+=_", "\"<", "li", ">", " ", "any", " ", "%", "s", " ", "user", "</", "li", ">\"_", "%_", "constraint_", "[_", "'", "auth", "\\u", "system", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return", "\\u", "val_", "+=_", "\"<", "/", "ul", ">\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "return", "\\u", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "voting", "\\u", "has", "\\u", "started_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "has", " ", "voting", " ", "beg", "un", "?", " ", "voting", " ", "begins", " ", "if", " ", "the", " ", "election", " ", "is", " ", "frozen", ",", " ", "at", " ", "the", " ", "presc", "ribe", "d", " ", "date", " ", "or", " ", "at", " ", "the", " ", "date", " ", "tha", "t", " ", "voting", " ", "was", " ", "forced", " ", "to", " ", "start", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "frozen", "\\u", "at_", "!=_", "None_", "and_", "(_", "self_", "._", "voting", "\\u", "starts", "\\u", "at_", "==_", "None_", "or_", "(_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ">=_", "(_", "self_", "._", "voting", "\\u", "start", "ed", "\\u", "at_", "or_", "self_", "._", "voting", "\\u", "starts", "\\u", "at_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "voting", "\\u", "has", "\\u", "stopped_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "has", " ", "voting", " ", "stopp", "ed", "?", " ", "if", " ", "tally", " ", "compute", "d", ",", " ", "ye", "s", ",", " ", "other", "wis", "e", " ", "if", " ", "we", " ", "have", " ", "pass", "ed", " ", "the", " ", "date", " ", "voting", " ", "was", " ", "manu", "ally", " ", "stopp", "ed", " ", "at", ",", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "faili", "ng", " ", "tha", "t", " ", "the", " ", "date", " ", "voting", " ", "was", " ", "extend", "ed", " ", "unti", "l", ",", " ", "or", " ", "faili", "ng", " ", "tha", "t", " ", "the", " ", "date", " ", "voting", " ", "is", " ", "schedule", "d", " ", "to", " ", "end", " ", "at", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voting", "\\u", "end_", "=_", "self_", "._", "voting", "\\u", "ende", "d\\u", "at_", "or_", "self_", "._", "voting", "\\u", "extend", "ed", "\\u", "until_", "or_", "self_", "._", "voting", "\\u", "ends", "\\u", "at_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "voting", "\\u", "end_", "!=_", "None_", "and_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ">=_", "voting", "\\u", "end_", ")_", "or_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "issue", "s", "\\u", "bef", "ore", "\\u", "freeze_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "questions_", "==_", "None_", "or_", "len_", "(_", "self_", "._", "questions_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "type", "'_", ":_", "'", "question", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "\"", "add", " ", "question", "s", " ", "to", " ", "the", " ", "ballot", "\"_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "trust", "ees", "_", "=_", "Trust", "ee_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "trust", "ees", "_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "trust", "ees", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "\"", "add", " ", "at", " ", "leas", "t", " ", "one", " ", "trust", "ee", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "t_", "in_", "trust", "ees", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "._", "public", "\\u", "key_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "trust", "ee", " ", "keypairs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "'", "have", " ", "trust", "ee", " ", "%", "s", " ", "generat", "e", " ", "a", " ", "keypa", "ir", "'_", "%_", "t_", "._", "name_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "voter", "\\u", "set_", "._", "count_", "(_", ")_", "==_", "0_", "and_", "not_", "self_", "._", "open", "reg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "voter", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "action", "\"_", ":_", "'", "enter", " ", "your", " ", "voter", " ", "list", " ", "(", "or", " ", "open", " ", "registration", " ", "to", " ", "the", " ", "public", ")'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "issues_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "y", "\\u", "for", "\\u", "tally", "ing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ">=_", "self_", "._", "tally", "ing", "\\u", "starts", "\\u", "at_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "compute", "\\u", "tally", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "tally", " ", "the", " ", "election", ",", " ", "ass", "umi", "ng", " ", "vote", "s", " ", "alr", "ead", "y", " ", "verifie", "d", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tally", "_", "=_", "self_", "._", "init", "\\u", "tally", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "voter", "_", "in_", "self_", "._", "voter", "\\u", "set_", "._", "exclude_", "(_", "vote_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tally", "_", "._", "add", "\\u", "vote_", "(_", "voter", "_", "._", "vote_", ",_", "verify", "\\u", "p_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "=_", "tally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "y", "\\u", "for", "\\u", "decrypt", "ion_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "!=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "y", "\\u", "for", "\\u", "decrypt", "ion", "\\u", "combination_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "do", " ", "we", " ", "have", " ", "a", " ", "tally", " ", "from", " ", "all", " ", "trust", "ees", "?", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", "in_", "Trust", "ee_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "t_", "._", "decrypt", "ion", "\\u", "factors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "release", "\\u", "result_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "release", " ", "the", " ", "result", " ", "tha", "t", " ", "shou", "ld", " ", "alr", "ead", "y", " ", "be", " ", "compute", "d", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "result", "\\u", "released", "\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "combin", "e\\u", "decrypt", "ions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "combin", "e", " ", "all", " ", "of", " ", "the", " ", "decrypt", "ion", " ", "results", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "gather", " ", "the", " ", "decrypt", "ion", " ", "factors_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ees", "_", "=_", "Trust", "ee_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "decrypt", "ion", "\\u", "factors_", "=_", "[_", "t_", "._", "decrypt", "ion", "\\u", "factors_", "for_", "t_", "in_", "trust", "ees", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "result_", "=_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "._", "decrypt", "\\u", "from", "\\u", "factors_", "(_", "decrypt", "ion", "\\u", "factors_", ",_", "self_", "._", "public", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "append", "\\u", "log_", "(_", "Elect", "ion", "Log_", "._", "DEC", "RY", "PTION", "S", "\\u", "COMBI", "NED", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "voter", "s", "\\u", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "look", " ", "up", " ", "the", " ", "list", " ", "of", " ", "voter", "s", ",", " ", "make", " ", "a", " ", "big", " ", "file", ",", " ", "and", " ", "hash", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "for", " ", "now", " ", "we", " ", "don", "'", "t", " ", "generat", "e", " ", "this", " ", "voter", "s", " ", "hash", ":_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "open", "reg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "voter", "s", "\\u", "hash_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "s_", "=_", "Vote", "r_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "s", "\\u", "json_", "=_", "utils_", "._", "to", "\\u", "json_", "(_", "[_", "v_", "._", "to", "JSO", "ND", "ict_", "(_", ")_", "for_", "v_", "in_", "voter", "s_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "voter", "s", "\\u", "hash_", "=_", "utils_", "._", "hash", "\\u", "b64", "_", "(_", "voter", "s", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "increment", "\\u", "voter", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "FIX", "ME_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "increment", "\\u", "cast", "\\u", "votes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "FIX", "ME_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "eli", "gib", "ility_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "registration", " ", "is", " ", "close", "d", " ", "and", " ", "eli", "gib", "ilit", "y", " ", "has", " ", "not", " ", "bee", "n", "\\", "10", ";", " ", " ", " ", " ", "alr", "ead", "y", " ", "set", ",", " ", "then", " ", "this", " ", "call", " ", "sets", " ", "the", " ", "eli", "gib", "ilit", "y", " ", "crite", "ria", "\\", "10", ";", " ", " ", " ", " ", "based", " ", "on", " ", "the", " ", "actual", " ", "list", " ", "of", " ", "voter", "s", " ", "who", " ", "are", " ", "alr", "ead", "y", " ", "there", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "helps", " ", "ensure", " ", "tha", "t", " ", "the", " ", "login", " ", "box", " ", "show", "s", " ", "the", " ", "proper", " ", "options", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "registration", " ", "is", " ", "open", " ", "but", " ", "no", " ", "voter", "s", " ", "have", " ", "bee", "n", " ", "adde", "d", " ", "with", " ", "password", ",", "\\", "10", ";", " ", " ", " ", " ", "then", " ", "tha", "t", " ", "option", " ", "is", " ", "als", "o", " ", "cancel", "ed", " ", "out", " ", "to", " ", "prevent", " ", "confusion", ",", " ", "sinc", "e", "\\", "10", ";", " ", " ", " ", " ", "tho", "se", " ", "election", "s", " ", "usual", "ly", " ", "just", " ", "use", " ", "the", " ", "exist", "ing", " ", "login", " ", "system", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "'", "t", " ", "override", " ", "exist", "ing", " ", "eli", "gib", "ility_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "eli", "gib", "ility_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "enable", " ", "this", " ", "ONL", "Y", " ", "onc", "e", " ", "the", " ", "cast", "\\u", "confirm", " ", "screen", " ", "make", "s", " ", "sense_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "self", ".", "voter", "\\u", "set", ".", "count", "()", " ", "==", " ", "0", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "return_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "auth", "\\u", "systems_", "=_", "copy_", "._", "copy_", "(_", "settings_", "._", "AUTH", "\\u", "ENABLE", "D", "\\u", "AUTH", "\\u", "SYSTEM", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "\\u", "types_", "=_", "[_", "r_", "[_", "'", "user", "\\u\\u", "user", "\\u", "type", "'_", "]_", "for_", "r_", "in_", "self_", "._", "voter", "\\u", "set_", "._", "values_", "(_", "'", "user", "\\u\\u", "user", "\\u", "type", "'_", ")_", "._", "distinct_", "(_", ")_", "if_", "r_", "[_", "'", "user", "\\u\\u", "user", "\\u", "type", "'_", "]_", "!=_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "password", " ", "is", " ", "now", " ", "separate", ",", " ", "not", " ", "an", " ", "explicit", " ", "voter", " ", "type_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "voter", "\\u", "set_", "._", "filter_", "(_", "user_", "=_", "None_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "\\u", "types_", "._", "append_", "(_", "'", "password", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "no", " ", "password", " ", "users", ",", " ", "remove", " ", "password", " ", "from", " ", "the", " ", "possib", "le", " ", "auth", " ", "systems_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "password", "'_", "in_", "auth", "\\u", "systems_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "auth", "\\u", "systems_", "._", "remove_", "(_", "'", "password", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "close", "d", " ", "registration", ":", " ", "limit", " ", "the", " ", "auth", "\\u", "system", "s", " ", "to", " ", "just", " ", "the", " ", "ones_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "have", " ", "register", "ed", " ", "voter", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "open", "reg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "auth", "\\u", "systems_", "=_", "[_", "vt_", "for_", "vt_", "in_", "voter", "\\u", "types_", "if_", "vt_", "in_", "auth", "\\u", "systems_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "eli", "gib", "ility_", "=_", "[_", "{_", "'", "auth", "\\u", "system", "'_", ":_", "auth", "\\u", "system_", "}_", "for_", "auth", "\\u", "system_", "in_", "auth", "\\u", "systems_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "freeze_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "election", " ", "is", " ", "frozen", " ", "whe", "n", " ", "the", " ", "voter", " ", "registration", ",", " ", "question", "s", ",", " ", "and", " ", "trust", "ees", " ", "are", " ", "finalize", "d", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "issue", "s", "\\u", "bef", "ore", "\\u", "freeze_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "cann", "ot", " ", "freez", "e", " ", "an", " ", "election", " ", "tha", "t", " ", "has", " ", "issue", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "frozen", "\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "voter", "s", " ", "hash_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "generat", "e\\u", "voter", "s", "\\u", "hash_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "set\\u", "eli", "gib", "ility_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "public", " ", "key", " ", "for", " ", "trust", "ees", "_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ees", "_", "=_", "Trust", "ee_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "combin", "ed", "\\u", "pk_", "=_", "trust", "ees", "_", "[_", "0_", "]_", "._", "public", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "t_", "in_", "trust", "ees", "_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "combin", "ed", "\\u", "pk_", "=_", "combin", "ed", "\\u", "pk_", "*_", "t_", "._", "public", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "public", "\\u", "key_", "=_", "combin", "ed", "\\u", "pk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "log", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "append", "\\u", "log_", "(_", "Elect", "ion", "Log_", "._", "FR", "OZ", "EN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "trust", "ee_", "(_", "self_", ",_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "generat", "e", " ", "a", " ", "trust", "ee", " ", "inclu", "ding", " ", "the", " ", "secret", " ", "key", ",", "\\", "10", ";", " ", " ", " ", " ", "thu", "s", " ", "a", " ", "heli", "os", "-", "based", " ", "trust", "ee", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "generat", "e", " ", "the", " ", "keypair_", "\\u\\u\\uNL\\u\\u\\u_", "keypair_", "=_", "params_", "._", "generat", "e\\u", "keypair_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "the", " ", "trust", "ee_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "=_", "Trust", "ee_", "(_", "election_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "uuid_", "=_", "str_", "(_", "uuid_", "._", "uuid4_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "name_", "=_", "settings_", "._", "DEF", "AUL", "T", "\\u", "FROM", "\\u", "NAME_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "email_", "=_", "settings_", "._", "DEF", "AUL", "T", "\\u", "FROM", "\\u", "EMAIL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "public", "\\u", "key_", "=_", "keypair_", "._", "pk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "secret", "\\u", "key_", "=_", "keypair_", "._", "sk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "is", " ", "this", " ", "at", " ", "the", " ", "right", " ", "level", " ", "of", " ", "abstract", "ion", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "._", "public", "\\u", "key", "\\u", "hash_", "=_", "datatypes_", "._", "LD", "Object_", "._", "instantiate", "_", "(_", "trust", "ee_", "._", "public", "\\u", "key_", ",_", "datatype_", "=_", "'", "lega", "cy", "/", "EG", "Public", "Key", "'_", ")_", "._", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "._", "po", "k_", "=_", "trust", "ee_", "._", "secret", "\\u", "key_", "._", "prove", "\\u", "sk_", "(_", "alg", "s_", "._", "DL", "og", "\\u", "chall", "enge", "\\u", "generator_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "heli", "os", "\\u", "trust", "ee_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trust", "ees", "\\u", "with", "\\u", "sk_", "=_", "self_", "._", "trust", "ee", "\\u", "set_", "._", "exclude_", "(_", "secret", "\\u", "key_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "trust", "ees", "\\u", "with", "\\u", "sk_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "trust", "ees", "\\u", "with", "\\u", "sk_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "\\u", "heli", "os", "\\u", "trust", "ee_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "get", "\\u", "heli", "os", "\\u", "trust", "ee_", "(_", ")_", "!=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "heli", "os", "\\u", "trust", "ee", "\\u", "decrypt_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tally", "_", "=_", "self_", "._", "encrypt", "ed", "\\u", "tally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tally", "_", "._", "init", "\\u", "election_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "=_", "self_", "._", "get", "\\u", "heli", "os", "\\u", "trust", "ee_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "factors_", ",_", "proof", "_", "=_", "tally", "_", "._", "decrypt", "ion", "\\u", "factor", "s", "\\u", "and", "\\u", "proof", "s_", "(_", "trust", "ee_", "._", "secret", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "trust", "ee_", "._", "decrypt", "ion", "\\u", "factors_", "=_", "factors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "decrypt", "ion", "\\u", "proof", "s_", "=_", "proof", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trust", "ee_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "append", "\\u", "log_", "(_", "self_", ",_", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "=_", "Elect", "ion", "Log_", "(_", "election_", "=_", "self_", ",_", "log_", "=_", "text_", ",_", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "log_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "election", "log", "\\u", "set_", "._", "order", "\\u", "by_", "(_", "'-", "at", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "heli", "os_", "._", "views_", "._", "get", "\\u", "election", "\\u", "url_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init", "\\u", "tally", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "create", " ", "the", " ", "right", " ", "kind", " ", "of", " ", "tally", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "heli", "os_", "._", "workflows_", "import_", "homo", "morphi", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "homo", "morphi", "c_", "._", "Tal", "ly_", "(_", "election_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "registration", "\\u", "status", "\\u", "pretty_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "open", "reg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Open", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Clos", "ed", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "one", "\\u", "question", "\\u", "winner_", "(_", "cls_", ",_", "question_", ",_", "result_", ",_", "num", "\\u", "cast", "\\u", "votes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "determini", "ng", " ", "the", " ", "winner", " ", "for", " ", "one", " ", "question", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "sort", " ", "the", " ", "answer", "s", " ", ",", " ", "keep", " ", "track", " ", "of", " ", "the", " ", "index_", "\\u\\u\\uNL\\u\\u\\u_", "counts_", "=_", "sorted_", "(_", "enumerate_", "(_", "result_", ")_", ",_", "key_", "=_", "lambda_", "(_", "x_", ")_", ":_", "x_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "counts_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "the", "\\u", "max_", "=_", "question_", "[_", "'", "max", "'_", "]_", "or_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "the", "\\u", "min_", "=_", "question_", "[_", "'", "min", "'_", "]_", "or_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "there", "'", "s", " ", "a", " ", "max", " ", ">", " ", "1", ",", " ", "we", " ", "assume", " ", "tha", "t", " ", "the", " ", "top", " ", "MAX", " ", "win_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "the", "\\u", "max_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "c_", "[_", "0_", "]_", "for_", "c_", "in_", "counts_", "[_", ":_", "the", "\\u", "max_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "max", " ", "=", " ", "1", ",", " ", "then", " ", "depend", "s", " ", "on", " ", "abs", "olute", " ", "or", " ", "relative_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "question_", "[_", "'", "result", "\\u", "type", "'_", "]_", "==_", "'", "abs", "olute", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "counts_", "[_", "0_", "]_", "[_", "1_", "]_", ">=_", "(_", "num", "\\u", "cast", "\\u", "votes_", "/_", "2_", "+_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "counts_", "[_", "0_", "]_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "assume", "s", " ", "tha", "t", " ", "anyt", "hing", " ", "non", "-", "abs", "olute", " ", "is", " ", "relative_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "counts_", "[_", "0_", "]_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "winner", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Depend", "ing", " ", "on", " ", "the", " ", "type", " ", "of", " ", "each", " ", "question", ",", " ", "dete", "rmin", "e", " ", "the", " ", "winner", "s", "\\", "10", ";", " ", " ", " ", " ", "return", "s", " ", "an", " ", "array", " ", "of", " ", "winner", "s", " ", "for", " ", "each", " ", "question", ",", " ", "aka", " ", "an", " ", "array", " ", "of", " ", "arrays", ".", "\\", "10", ";", " ", " ", " ", " ", "assume", "s", " ", "tha", "t", " ", "if", " ", "there", " ", "is", " ", "a", " ", "max", " ", "to", " ", "the", " ", "question", ",", " ", "tha", "t", "'", "s", " ", "how", " ", "many", " ", "winner", "s", " ", "there", " ", "are", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "self_", "._", "one", "\\u", "question", "\\u", "winner_", "(_", "self_", "._", "questions_", "[_", "i_", "]_", ",_", "self_", "._", "result_", "[_", "i_", "]_", ",_", "self_", "._", "num", "\\u", "cast", "\\u", "votes_", ")_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "self_", "._", "questions_", ")_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Elect", "ion_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "pretty", "\\u", "result_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "winner", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "winner", "s_", "=_", "self_", "._", "winner", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "raw", "\\u", "result_", "=_", "self_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pret", "tif", "ied", "\\u", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "loop", " ", "through", " ", "questions_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "self_", "._", "questions_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "q_", "=_", "self_", "._", "questions_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pretty", "\\u", "question_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "go", " ", "through", " ", "answers_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "len_", "(_", "q_", "[_", "'", "answer", "s", "'_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "=_", "q_", "[_", "'", "answer", "s", "'_", "]_", "[_", "j_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "raw", "\\u", "result_", "[_", "i_", "]_", "[_", "j_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pretty", "\\u", "question_", "._", "append_", "(_", "{_", "'", "answer", "'_", ":_", "a_", ",_", "'", "count", "'_", ":_", "count_", ",_", "'", "winner", "'_", ":_", "(_", "j_", "in_", "winner", "s_", "[_", "i_", "]_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pret", "tif", "ied", "\\u", "result_", "._", "append_", "(_", "{_", "'", "question", "'_", ":_", "q_", "[_", "'", "short", "\\u", "name", "'_", "]_", ",_", "'", "answer", "s", "'_", ":_", "pretty", "\\u", "question_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "pret", "tif", "ied", "\\u", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Elect", "ion", "Log_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "a", " ", "log", " ", "of", " ", "events", " ", "for", " ", "an", " ", "election", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "FR", "OZ", "EN_", "=_", "\"", "frozen", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VO", "TER", "\\u", "FILE", "\\u", "ADD", "ED_", "=_", "\"", "voter", " ", "file", " ", "adde", "d", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DEC", "RY", "PTION", "S", "\\u", "COMBI", "NED", "_", "=_", "\"", "decrypt", "ion", "s", " ", "combin", "ed", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "election_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Elect", "ion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unicode", "\\u", "csv", "\\u", "reader_", "(_", "unicode", "\\u", "csv", "\\u", "data_", ",_", "dialect_", "=_", "csv_", "._", "excel_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "csv", ".", "py", " ", "doe", "sn", "'", "t", " ", "do", " ", "Unic", "ode", ";", " ", "encode", " ", "temporar", "il", "y", " ", "as", " ", "UT", "F", "-", "8", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "csv", "\\u", "reader_", "=_", "csv_", "._", "reader_", "(_", "utf", "\\u", "8", "\\u", "encoder_", "(_", "unicode", "\\u", "csv", "\\u", "data_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dialect_", "=_", "dialect_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "csv", "\\u", "reader_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "decode", " ", "UT", "F", "-", "8", " ", "back", " ", "to", " ", "Unic", "ode", ",", " ", "cell", " ", "by", " ", "cell", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "[_", "unicode_", "(_", "cell_", ",_", "'", "utf", "-", "8", "'_", ")_", "for_", "cell_", "in_", "row_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "[_", "unicode_", "(_", "cell_", ",_", "'", "latin", "-1", "'_", ")_", "for_", "cell_", "in_", "row_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "utf", "\\u", "8", "\\u", "encoder_", "(_", "unicode", "\\u", "csv", "\\u", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "line_", "in_", "unicode", "\\u", "csv", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "this", " ", "used", " ", "to", " ", "be", " ", "line", ".", "encode", "('", "utf", "-", "8", "')", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "figure", " ", "out", " ", "wh", "y", " ", "this", " ", "isn", "'", "t", " ", "consistent", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Vote", "r", "File_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "A", " ", "model", " ", "to", " ", "store", " ", "files", " ", "tha", "t", " ", "are", " ", "lists", " ", "of", " ", "voter", "s", " ", "to", " ", "be", " ", "process", "ed", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "path", " ", "where", " ", "we", " ", "store", " ", "voter", " ", "upload", " _", "\\u\\u\\uNL\\u\\u\\u_", "PATH_", "=_", "settings_", "._", "VO", "TER", "\\u", "UPLOAD", "\\u", "REL", "\\u", "PATH_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "election_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Elect", "ion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "move", " ", "to", " ", "stor", "ing", " ", "the", " ", "content", " ", "in", " ", "the", " ", "DB_", "\\u\\u\\uNL\\u\\u\\u_", "voter", "\\u", "file_", "=_", "models_", "._", "File", "Field_", "(_", "upload", "\\u", "to_", "=_", "PATH_", ",_", "max", "\\u", "length_", "=_", "250_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "\\u", "file", "\\u", "content_", "=_", "models_", "._", "Text", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "uploade", "d\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "ing", "\\u", "start", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "ing", "\\u", "finish", "ed", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "voter", "s_", "=_", "models_", "._", "Integer", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r", "File_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "iter", "voter", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "voter", "\\u", "file", "\\u", "content_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "self_", "._", "voter", "\\u", "file", "\\u", "content_", ")_", "==_", "unicode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "self_", "._", "voter", "\\u", "file", "\\u", "content_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "self_", "._", "voter", "\\u", "file", "\\u", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "we", " ", "have", " ", "to", " ", "handle", " ", "non", "-", "universal", "-", "newline", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "do", " ", "this", " ", "in", " ", "a", " ", "simple", " ", "way", ":", " ", "replace", " ", "all", " ", "\\\\", "r", " ", "with", " ", "\\\\", "n_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", ",", " ", "replace", " ", "all", " ", "double", " ", "\\\\", "n", " ", "with", " ", "single", " ", "\\\\", "n_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "shou", "ld", " ", "lea", "ve", " ", "us", " ", "with", " ", "only", " ", "\\\\", "n_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "content_", "=_", "content_", "._", "replace_", "(_", "'\\\\", "r", "'_", ",_", "'\\\\", "n", "'_", ")_", "._", "replace_", "(_", "'\\\\", "n", "\\\\", "n", "'_", ",_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "voter", "\\u", "stream_", "=_", "io_", "._", "Byte", "s", "IO_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "\\u", "stream_", "=_", "open_", "(_", "self_", "._", "voter", "\\u", "file_", "._", "path_", ",_", "\"", "r", "U", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "reader", " ", "=", " ", "unicode", "\\u", "csv", "\\u", "reader", "(", "voter", "\\u", "stream", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reader_", "=_", "unicode", "csv_", "._", "reader_", "(_", "voter", "\\u", "stream_", ",_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "voter", "\\u", "fields_", "in_", "reader_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bad", " ", "line_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "voter", "\\u", "fields_", ")_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return", "\\u", "dict_", "=_", "{_", "'", "voter", "\\u", "id", "'_", ":_", "voter", "\\u", "fields_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "voter", "\\u", "fields_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "dict_", "[_", "'", "email", "'_", "]_", "=_", "voter", "\\u", "fields_", "[_", "1_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "assume", " ", "single", " ", "field", " ", "means", " ", "the", " ", "email", " ", "is", " ", "the", " ", "same", " ", "field_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "dict_", "[_", "'", "email", "'_", "]_", "=_", "voter", "\\u", "fields_", "[_", "0_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "voter", "\\u", "fields_", ")_", ">_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "dict_", "[_", "'", "name", "'_", "]_", "=_", "voter", "\\u", "fields_", "[_", "2_", "]_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return", "\\u", "dict_", "[_", "'", "name", "'_", "]_", "=_", "return", "\\u", "dict_", "[_", "'", "email", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "return", "\\u", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r", "File_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "process", "ing", "\\u", "start", "ed", "\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "election_", "=_", "self_", "._", "election_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "alias", "\\u", "num_", "=_", "election_", "._", "last", "\\u", "alias", "\\u", "num_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "voter", "s_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "voter", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "voter", "_", "in_", "self_", "._", "iter", "voter", "s_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num", "\\u", "voter", "s_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "doe", "s", " ", "voter", " ", "for", " ", "this", " ", "user", " ", "alr", "ead", "y", " ", "exist_", "\\u\\u\\uNL\\u\\u\\u_", "exist", "ing", "\\u", "voter", "_", "=_", "Vote", "r_", "._", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "voter", "\\u", "id_", "(_", "election_", ",_", "voter", "_", "[_", "'", "voter", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "the", " ", "voter", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "exist", "ing", "\\u", "voter", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "\\u", "uuid_", "=_", "str_", "(_", "uuid_", "._", "uuid4_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exist", "ing", "\\u", "voter", "_", "=_", "Vote", "r_", "(_", "uuid_", "=_", "voter", "\\u", "uuid_", ",_", "user_", "=_", "None_", ",_", "voter", "\\u", "login", "\\u", "id_", "=_", "voter", "_", "[_", "'", "voter", "\\u", "id", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "voter", "\\u", "name_", "=_", "voter", "_", "[_", "'", "name", "'_", "]_", ",_", "voter", "\\u", "email_", "=_", "voter", "_", "[_", "'", "email", "'_", "]_", ",_", "election_", "=_", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exist", "ing", "\\u", "voter", "_", "._", "generat", "e\\u", "password_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "voter", "s_", "._", "append_", "(_", "exist", "ing", "\\u", "voter", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exist", "ing", "\\u", "voter", "_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "election_", "._", "use", "\\u", "voter", "\\u", "aliases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "\\u", "alias", "\\u", "integers_", "=_", "range_", "(_", "last", "\\u", "alias", "\\u", "num_", "+_", "1_", ",_", "last", "\\u", "alias", "\\u", "num_", "+_", "1_", "+_", "num", "\\u", "voter", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "random_", "._", "shuffle_", "(_", "voter", "\\u", "alias", "\\u", "integers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "voter", "_", "in_", "enumerate_", "(_", "new", "\\u", "voter", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "_", "._", "alias_", "=_", "'", "V", "%", "s", "'_", "%_", "voter", "\\u", "alias", "\\u", "integers_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "num", "\\u", "voter", "s_", "=_", "num", "\\u", "voter", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "process", "ing", "\\u", "finish", "ed", "\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "num", "\\u", "voter", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "election_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Elect", "ion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "link", " ", "direct", "ly", " ", "to", " ", "the", " ", "user", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "delete", " ", "this", " ", "as", " ", "soo", "n", " ", "as", " ", "migrati", "ons", " ", "are", " ", "set", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "#", "name", " ", "=", " ", "model", "s", ".", "Char", "Field", "(", "max", "\\u", "length", " ", "=", " ", "200", ",", " ", "null", "=", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "voter", "\\u", "type", " ", "=", " ", "model", "s", ".", "Char", "Field", "(", "max", "\\u", "length", " ", "=", " ", "100", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "voter", "\\u", "id", " ", "=", " ", "model", "s", ".", "Char", "Field", "(", "max", "\\u", "length", " ", "=", " ", "100", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "uuid_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "users", " ", "of", " ", "type", " ", "password", ",", " ", "no", " ", "user", " ", "object", " ", "is", " ", "created_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "a", " ", "dynami", "c", " ", "user", " ", "object", " ", "is", " ", "created", " ", "automati", "call", "y_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "'", "heli", "os", "\\u", "auth", ".", "User", "'_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "user", " ", "is", " ", "null", ",", " ", "then", " ", "you", " ", "need", " ", "a", " ", "voter", " ", "login", " ", "ID", " ", "and", " ", "password_", "\\u\\u\\uNL\\u\\u\\u_", "voter", "\\u", "login", "\\u", "id_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "\\u", "password_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "\\u", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "200_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "\\u", "email_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "250_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "election", " ", "use", "s", " ", "aliases_", "\\u\\u\\uNL\\u\\u\\u_", "alias_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "keep", " ", "a", " ", "copy", " ", "here", " ", "for", " ", "easy", " ", "tally", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "vote_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Encrypt", "ed", "Vote", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vote", "\\u", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cast", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unique", "\\u", "together_", "=_", "(_", "(_", "'", "election", "'_", ",_", "'", "voter", "\\u", "login", "\\u", "id", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Vote", "r_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "stub", " ", "the", " ", "user", " ", "so", " ", "code", " ", "is", " ", "not", " ", "full", " ", "of", " ", "IF", " ", "statements_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "User_", "(_", "user", "\\u", "type_", "=_", "'", "password", "'_", ",_", "user", "\\u", "id_", "=_", "self_", "._", "voter", "\\u", "email_", ",_", "name_", "=_", "self_", "._", "voter", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "transaction_", "._", "atomic_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "register", "\\u", "user", "\\u", "in", "\\u", "election_", "(_", "cls_", ",_", "user_", ",_", "election_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "\\u", "uuid_", "=_", "str_", "(_", "uuid_", "._", "uuid4_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "_", "=_", "Vote", "r_", "(_", "uuid_", "=_", "voter", "\\u", "uuid_", ",_", "user_", "=_", "user_", ",_", "election_", "=_", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "do", " ", "we", " ", "need", " ", "to", " ", "generat", "e", " ", "an", " ", "alias", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "election_", "._", "use", "\\u", "voter", "\\u", "aliases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "heli", "osu", "tils_", "._", "lock", "\\u", "row_", "(_", "Elect", "ion_", ",_", "election_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alias", "\\u", "num_", "=_", "election_", "._", "last", "\\u", "alias", "\\u", "num_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "voter", "_", "._", "alias_", "=_", "\"", "V", "%", "s", "\"_", "%_", "alias", "\\u", "num_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "voter", "_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "voter", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election_", "(_", "cls_", ",_", "election_", ",_", "cast_", "=_", "None_", ",_", "order", "\\u", "by_", "=_", "'", "voter", "\\u", "login", "\\u", "id", "'_", ",_", "after_", "=_", "None_", ",_", "limit_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "FIX", "ME", ":", " ", "review", " ", "this", " ", "for", " ", "non", "-", "GA", "E", "?", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "election_", "=_", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "boolean", " ", "check", " ", "is", " ", "not", " ", "stu", "pid", ",", " ", "this", " ", "is", " ", "tern", "ary", " ", "logic_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "none", " ", "means", " ", "don", "'", "t", " ", "care", " ", "if", " ", "it", "'", "s", " ", "cast", " ", "or", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cast_", "==_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "exclude_", "(_", "cast", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "cast_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "filter_", "(_", "cast", "\\u", "at_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "litt", "le", " ", "trick", " ", "to", " ", "get", " ", "aro", "und", " ", "GA", "E", " ", "limit", "ation_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "order", " ", "by", " ", "uuid", " ", "only", " ", "whe", "n", " ", "no", " ", "inequal", "it", "y", " ", "has", " ", "bee", "n", " ", "added_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cast_", "==_", "None_", "or_", "order", "\\u", "by_", "==_", "'", "cast", "\\u", "at", "'_", "or_", "order", "\\u", "by_", "==_", "'-", "cast", "\\u", "at", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "order", "\\u", "by_", "(_", "order", "\\u", "by_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "want", " ", "the", " ", "list", " ", "after", " ", "a", " ", "cert", "ain", " ", "UU", "ID", ",", " ", "add", " ", "the", " ", "inequal", "it", "y", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "after_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "order", "\\u", "by_", "[_", "0_", "]_", "==_", "'-'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "name_", "=_", "\"%", "s", "\\u\\u", "gt", "\"_", "%_", "order", "\\u", "by_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "name_", "=_", "\"%", "s", "\\u\\u", "gt", "\"_", "%_", "order", "\\u", "by_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "conditions_", "=_", "{_", "field", "\\u", "name_", ":_", "after_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "query_", "._", "filter_", "(_", "**_", "conditions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "[_", ":_", "limit_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "all", "\\u", "by", "\\u", "election", "\\u", "in", "\\u", "chunks_", "(_", "cls_", ",_", "election_", ",_", "cast_", "=_", "None_", ",_", "chunk_", "=_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "get", "\\u", "by", "\\u", "election_", "(_", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "voter", "\\u", "id_", "(_", "cls_", ",_", "election_", ",_", "voter", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "election_", "=_", "election_", ",_", "voter", "\\u", "login", "\\u", "id_", "=_", "voter", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "user_", "(_", "cls_", ",_", "election_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "election_", "=_", "election_", ",_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "uuid_", "(_", "cls_", ",_", "election_", ",_", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "election_", "=_", "election_", ",_", "uuid_", "=_", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "query_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "user_", "(_", "cls_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "select", "\\u", "related_", "(_", ")_", "._", "filter_", "(_", "user_", "=_", "user_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "cast", "\\u", "at", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "datatype_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "election_", "._", "datatype_", "._", "replace_", "(_", "'", "Elect", "ion", "'_", ",_", "'", "Vote", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "vote", "\\u", "tiny", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "get", " ", "the", " ", "tiny", "hash", " ", "of", " ", "the", " ", "late", "st", " ", "cast", "vote", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "vote", "\\u", "hash_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Cast", "Vote", "_", "._", "objects_", "._", "get_", "(_", "vote", "\\u", "hash_", "=_", "self_", "._", "vote", "\\u", "hash_", ")_", "._", "vote", "\\u", "tiny", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "election", "\\u", "uuid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "election_", "._", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "user_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voter", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "user_", "._", "user", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voter", "\\u", "id", "\\u", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "voter", "\\u", "login", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "for", " ", "back", "ward", "s", " ", "compatibility", " ", "with", " ", "v", "3.0", ",", " ", "and", " ", "sinc", "e", " ", "it", " ", "doe", "sn", "'", "t", " ", "matte", "r_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "too", " ", "muc", "h", " ", "if", " ", "we", " ", "hash", " ", "the", " ", "email", " ", "or", " ", "the", " ", "unique", " ", "login", " ", "ID", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value", "\\u", "to", "\\u", "hash_", "=_", "self_", "._", "voter", "\\u", "login", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value", "\\u", "to", "\\u", "hash_", "=_", "self_", "._", "voter", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "utils_", "._", "hash", "\\u", "b64", "_", "(_", "value", "\\u", "to", "\\u", "hash_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "utils_", "._", "hash", "\\u", "b64", "_", "(_", "value", "\\u", "to", "\\u", "hash_", "._", "encode_", "(_", "'", "latin", "-1", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "utils_", "._", "hash", "\\u", "b64", "_", "(_", "value", "\\u", "to", "\\u", "hash_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voter", "\\u", "type_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "user_", "._", "user", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "display", "\\u", "html", "\\u", "big_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "user_", "._", "display", "\\u", "html", "\\u", "big_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "message_", "(_", "self_", ",_", "subject_", ",_", "body_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "._", "send", "\\u", "message_", "(_", "subject_", ",_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e\\u", "password_", "(_", "self_", ",_", "length_", "=_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "voter", "\\u", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "password", " ", "alr", "ead", "y", " ", "exist", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "voter", "\\u", "password_", "=_", "heli", "osu", "tils_", "._", "random", "\\u", "string_", "(_", "length_", ",_", "alphabet_", "=_", "'", "abcdefg", "hij", "km", "nop", "qr", "stu", "vw", "xyz", "ABCDE", "FG", "HI", "JK", "LM", "NP", "QR", "STU", "VW", "XY", "Z2", "3456", "789", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "store", "\\u", "vote_", "(_", "self_", ",_", "cast", "\\u", "vote_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "only", " ", "store", " ", "the", " ", "vote", " ", "if", " ", "it", "'", "s", " ", "cast", " ", "late", "r", " ", "than", " ", "the", " ", "current", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "cast", "\\u", "at_", "and_", "cast", "\\u", "vote_", "._", "cast", "\\u", "at_", "<_", "self_", "._", "cast", "\\u", "at_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "vote_", "=_", "cast", "\\u", "vote_", "._", "vote_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vote", "\\u", "hash_", "=_", "cast", "\\u", "vote_", "._", "vote", "\\u", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cast", "\\u", "at_", "=_", "cast", "\\u", "vote_", "._", "cast", "\\u", "at_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vote", "r_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "last", "\\u", "cast", "\\u", "vote_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Cast", "Vote", "_", "(_", "vote_", "=_", "self_", "._", "vote_", ",_", "vote", "\\u", "hash_", "=_", "self_", "._", "vote", "\\u", "hash_", ",_", "cast", "\\u", "at_", "=_", "self_", "._", "cast", "\\u", "at_", ",_", "voter", "_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "voter", "_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Vote", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "actual", " ", "encrypt", "ed", " ", "vote_", "\\u\\u\\uNL\\u\\u\\u_", "vote_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "Encrypt", "ed", "Vote", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cache", " ", "the", " ", "hash", " ", "of", " ", "the", " ", "vote_", "\\u\\u\\uNL\\u\\u\\u_", "vote", "\\u", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "tiny", " ", "version", " ", "of", " ", "the", " ", "hash", " ", "to", " ", "enable", " ", "short", " ", "URL", "s_", "\\u\\u\\uNL\\u\\u\\u_", "vote", "\\u", "tiny", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ",_", "null_", "=_", "True_", ",_", "unique_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cast", "\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "some", " ", "ballot", "s", " ", "can", " ", "be", " ", "quar", "antin", "ed", " ", "(", "this", " ", "is", " ", "not", " ", "the", " ", "same", " ", "thing", " ", "as", " ", "provision", "al", ")_", "\\u\\u\\uNL\\u\\u\\u_", "quar", "antin", "ed", "\\u", "p_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ",_", "null_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "released", "\\u", "from", "\\u", "quar", "antin", "e\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "False_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whe", "n", " ", "is", " ", "the", " ", "vote", " ", "verifie", "d", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "verifie", "d\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "invalidate", "d\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "datatype_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "voter", "_", "._", "datatype_", "._", "replace_", "(_", "'", "Vote", "r", "'_", ",_", "'", "Cast", "Vote", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voter", "\\u", "uuid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "voter", "_", "._", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "voter", "\\u", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "voter", "_", "._", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "is", "\\u", "quar", "antin", "ed_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "quar", "antin", "ed", "\\u", "p_", "and_", "not_", "self_", "._", "released", "\\u", "from", "\\u", "quar", "antin", "e\\u", "at_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "tiny", "hash_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "find", " ", "a", " ", "tiny", " ", "version", " ", "of", " ", "the", " ", "hash", " ", "for", " ", "a", " ", "URL", " ", "slug", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "hash_", "=_", "self_", "._", "vote", "\\u", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "[_", "'/'_", ",_", "'+'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "safe", "\\u", "hash_", "=_", "safe", "\\u", "hash_", "._", "replace_", "(_", "c_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "length_", "=_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vote", "\\u", "tiny", "hash_", "=_", "safe", "\\u", "hash_", "[_", ":_", "length_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "Cast", "Vote", "_", "._", "objects_", "._", "filter_", "(_", "vote", "\\u", "tiny", "hash_", "=_", "vote", "\\u", "tiny", "hash_", ")_", "._", "count_", "(_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "length_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "vote", "\\u", "tiny", "hash_", "=_", "vote", "\\u", "tiny", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "override", " ", "this", " ", "just", " ", "to", " ", "get", " ", "a", " ", "hook", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", " ", "saved", " ", "ye", "t", "?", " ", "then", " ", "we", " ", "generat", "e", " ", "a", " ", "tiny", " ", "hash_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "vote", "\\u", "tiny", "hash_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set\\u", "tiny", "hash_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "Cast", "Vote", "_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "voter", "_", "(_", "cls_", ",_", "voter", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "filter_", "(_", "voter", "_", "=_", "voter", "_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "cast", "\\u", "at", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "verify", "\\u", "and", "\\u", "store_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "it", "'", "s", " ", "quar", "antin", "ed", ",", " ", "don", "'", "t", " ", "let", " ", "this", " ", "go", " ", "through_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "is", "\\u", "quar", "antin", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"", "cast", " ", "vote", " ", "is", " ", "quar", "antin", "ed", ",", " ", "verification", " ", "and", " ", "storage", " ", "is", " ", "delayed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "self_", "._", "vote_", "._", "verify_", "(_", "self_", "._", "voter", "_", "._", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "verifie", "d\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "invalidate", "d\\u", "at_", "=_", "datetime_", "._", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "save", " ", "and", " ", "store", " ", "the", " ", "vote", " ", "as", " ", "the", " ", "voter", "'", "s", " ", "last", " ", "cast", " ", "vote_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "voter", "_", "._", "store", "\\u", "vote_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cast", "Vote", "_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "reference", " ", "to", " ", "the", " ", "voter", " ", "provide", "s", " ", "the", " ", "voter", "\\u", "uuid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "issues_", "(_", "self_", ",_", "election_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Look", " ", "for", " ", "consiste", "nc", "y", " ", "problem", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "issues_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "the", " ", "election_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "vote_", "._", "election", "\\u", "uuid_", "!=_", "election_", "._", "uuid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "._", "append_", "(_", "\"", "the", " ", "vote", "'", "s", " ", "election", " ", "UU", "ID", " ", "doe", "s", " ", "not", " ", "match", " ", "the", " ", "election", " ", "for", " ", "whi", "ch", " ", "this", " ", "vote", " ", "is", " ", "bei", "ng", " ", "cast", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "issues_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Audi", "ted", "Ball", "ot_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "ballot", "s", " ", "for", " ", "audit", "ing", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "election_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Elect", "ion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raw", "\\u", "vote_", "=_", "models_", "._", "Text", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vote", "\\u", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "adde", "d\\u", "at_", "=_", "models_", "._", "Date", "Time", "Field_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Audi", "ted", "Ball", "ot_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get_", "(_", "cls_", ",_", "election_", ",_", "vote", "\\u", "hash_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "election_", "=_", "election_", ",_", "vote", "\\u", "hash_", "=_", "vote", "\\u", "hash_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Audi", "ted", "Ball", "ot_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election_", "(_", "cls_", ",_", "election_", ",_", "after_", "=_", "None_", ",_", "limit_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "election_", "=_", "election_", ")_", "._", "order", "\\u", "by_", "(_", "'", "vote", "\\u", "hash", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "want", " ", "the", " ", "list", " ", "after", " ", "a", " ", "cert", "ain", " ", "UU", "ID", ",", " ", "add", " ", "the", " ", "inequal", "it", "y", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "after_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "._", "filter_", "(_", "vote", "\\u", "hash", "\\u\\u", "gt_", "=_", "after_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "query_", "[_", ":_", "limit_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "election_", "=_", "models_", "._", "Fore", "ign", "Key_", "(_", "Elect", "ion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "uuid_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "email_", "=_", "models_", "._", "Ema", "il", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "secret_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "public", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "key_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "EG", "Public", "Key", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "public", "\\u", "key", "\\u", "hash_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "secret", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "secret", " ", "key", " ", "is", " ", "presen", "t", ",", " ", "this", " ", "means_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Heli", "os", " ", "is", " ", "play", "ing", " ", "the", " ", "role", " ", "of", " ", "the", " ", "trust", "ee", "._", "\\u\\u\\uNL\\u\\u\\u_", "secret", "\\u", "key_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "EG", "Sec", "ret", "Key", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "proof", " ", "of", " ", "knowledge", " ", "of", " ", "secret", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "po", "k_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "'", "lega", "cy", "/", "DL", "og", "Pro", "of", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "decrypt", "ion", " ", "factors_", "\\u\\u\\uNL\\u\\u\\u_", "decrypt", "ion", "\\u", "factors_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "datatypes_", "._", "array", "Of_", "(_", "datatypes_", "._", "array", "Of_", "(_", "'", "core", "/", "Big", "Integer", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "decrypt", "ion", "\\u", "proof", "s_", "=_", "LD", "Object", "Field_", "(_", "type", "\\u", "hint_", "=_", "datatypes_", "._", "array", "Of_", "(_", "datatypes_", "._", "array", "Of_", "(_", "'", "lega", "cy", "/", "EG", "ZK", "Pro", "of", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unique", "\\u", "together_", "=_", "(_", "(_", "'", "election", "'_", ",_", "'", "email", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "override", " ", "this", " ", "just", " ", "to", " ", "get", " ", "a", " ", "hook", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", " ", "saved", " ", "ye", "t", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "secret_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "secret_", "=_", "heli", "osu", "tils_", "._", "random", "\\u", "string_", "(_", "12_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "election_", "._", "append", "\\u", "log_", "(_", "\"", "Trust", "ee", " ", "%", "s", " ", "adde", "d", "\"_", "%_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "Trust", "ee_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election_", "(_", "cls_", ",_", "election_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "filter_", "(_", "election_", "=_", "election_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "uuid_", "(_", "cls_", ",_", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "uuid_", "=_", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "uuid_", "(_", "cls_", ",_", "election_", ",_", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "election_", "=_", "election_", ",_", "uuid_", "=_", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "by", "\\u", "election", "\\u", "and", "\\u", "email_", "(_", "cls_", ",_", "election_", ",_", "email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "objects_", "._", "get_", "(_", "election_", "=_", "election_", ",_", "email_", "=_", "email_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "datatype_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "election_", "._", "datatype_", "._", "replace_", "(_", "'", "Elect", "ion", "'_", ",_", "'", "Trust", "ee", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Trust", "ee_", "(_", "Heli", "os", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "verify", "\\u", "decrypt", "ion", "\\u", "proof", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "verify", " ", "tha", "t", " ", "the", " ", "decrypt", "ion", " ", "proof", "s", " ", "match", " ", "the", " ", "tally", " ", "for", " ", "the", " ", "election", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "verify", "\\u", "decrypt", "ion", "\\u", "proof", "s", "(", "self", ",", " ", "decrypt", "ion", "\\u", "factor", "s", ",", " ", "decrypt", "ion", "\\u", "proof", "s", ",", " ", "public", "\\u", "key", ",", " ", "chall", "enge", "\\u", "generat", "or", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "election_", "._", "encrypt", "ed", "\\u", "tally", "_", "._", "verify", "\\u", "decrypt", "ion", "\\u", "proof", "s_", "(_", "self_", "._", "decrypt", "ion", "\\u", "factors_", ",_", "self_", "._", "decrypt", "ion", "\\u", "proof", "s_", ",_", "self_", "._", "public", "\\u", "key_", ",_", "alg", "s_", "._", "EG",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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
jumoconnect/openjumo/jumodjango/mailer/content.py
[ { "content": "from mailer.models import Email\n\nfrom etc.func import salted_hash\nfrom etc.view_helpers import url_with_qs\nfrom django.core.urlresolvers import reverse\nfrom django.template.loader import render_to_string\nimport settings\nimport inspect\nimport random\nimport sys\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Using inspect so we don't have to add new notifications manually\n# Just make sure you add type to all new NotificationEmail classes\nnotifications = dict((cls.type, cls) for name, cls in inspect.getmembers(sys.modules[__name__])\n if inspect.isclass(cls)\n and issubclass(cls, NotificationEmail)\n and hasattr(cls, 'type'))\n\n\npubs = dict((cls.publication, cls) for name, cls in inspect.getmembers(sys.modules[__name__])\n if inspect.isclass(cls)\n and issubclass(cls, EmailTextHTML)\n and hasattr(cls, 'publication'))\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class EmailTypes:\n JUMO_READER = 'news_email'\n FOLLOW = 'follow'\n MOST_ACTIVE = 'most_active'\n COMMENT = 'comment'\n RESET_PASSWORD = 'reset_password'\n CLAIM_ORG = 'claim_org'\n POSTED_ON_PROFILE = 'posted_on_profile'\n DONATION_FAILURE = 'donation_failure'", "metadata": "root.EmailTypes", "header": "['module', '___EOS___']", "index": 11 }, { "content": "class EmailTextHTML(object):\n \"\"\"Proxy to Email model\"\"\"\n headers = {}\n\n", "metadata": "root.EmailTextHTML", "header": "['module', '___EOS___']", "index": 21 }, { "content": " def __init__(self, type, user=None, email_address=None, subject='', update_next_email_time=False, **kw):\n hostname = settings.HTTP_HOST\n email_address = email_address if email_address else user.email\n unsub_code = salted_hash(email_address)\n kw.update(dict(hostname=hostname,\n subject=subject,\n user=user,\n unsub_code=unsub_code))\n self.subject = subject\n self.template_args = kw\n self.text_content = render_to_string('email/txt/%s.txt' % type, kw)\n self.html_content = render_to_string('email/html/%s.html' % type, kw)\n self.user = user\n self.update_next_email_time=update_next_email_time\n\n # Lock that down\n if settings.EMAIL_REAL_PEOPLE or email_address.endswith('@jumo.com'):\n self.to = email_address\n else:\n self.to = '[email protected]'\n self.from_address = 'Jumo <[email protected]>'", "metadata": "root.EmailTextHTML.__init__", "header": "['class', 'EmailTextHTML', '(', 'object', ')', ':', '___EOS___']", "index": 25 }, { "content": " def send(self):\n msg = Email(subject=self.subject, body=self.text_content, html=self.html_content,\n user=self.user, recipient=self.to, from_address=self.from_address,\n headers = self.headers)\n msg.send(self.update_next_email_time)", "metadata": "root.EmailTextHTML.send", "header": "['class', 'EmailTextHTML', '(', 'object', ')', ':', '___EOS___']", "index": 47 }, { "content": "class JumoReaderEmail(EmailTextHTML):\n headers = {'X-SMTPAPI': '{\"category\": \"Jumo Reader\"}'}\n publication = 'reader'\n publication_id = 1\n user_sub_field = 'email_stream_frequency'\n\n", "metadata": "root.JumoReaderEmail", "header": "['module', '___EOS___']", "index": 53 }, { "content": " def _get_random_stats(self, user):\n issues = [issue for issue in user.get_all_issues_following if issue.get_all_statistics]\n stats = [issue.get_all_statistics for issue in issues]\n flat_stats = [y for x in stats for y in x]\n\n random.shuffle(flat_stats)\n return flat_stats", "metadata": "root.JumoReaderEmail._get_random_stats", "header": "['class', 'JumoReaderEmail', '(', 'EmailTextHTML', ')', ':', '___EOS___']", "index": 59 }, { "content": " def __init__(self, user, **kw):\n random_stats = self._get_random_stats(user)[:1]\n super(JumoReaderEmail, self).__init__(type=EmailTypes.JUMO_READER,\n user=user,\n subject='Jumo Reader | Top News on the Issues You Care About',\n update_next_email_time=True,\n random_stats = random_stats,\n publication_id = self.publication_id,\n **kw)", "metadata": "root.JumoReaderEmail.__init__", "header": "['class', 'JumoReaderEmail', '(', 'EmailTextHTML', ')', ':', '___EOS___']", "index": 67 }, { "content": "class NotificationEmail(EmailTextHTML):\n \"\"\"Important: make sure you add a type member to any subclasses\"\"\"\n publication = 'notifications'\n publication_id = 2\n", "metadata": "root.NotificationEmail", "header": "['module', '___EOS___']", "index": 77 }, { "content": " def __init__(self, type, subject, user, entity, **kw):\n type='notifications/%s' % type\n super(NotificationEmail, self).__init__(type=type,\n user=user,\n subject=subject,\n entity=entity,\n publication_id = self.publication_id,\n **kw)", "metadata": "root.NotificationEmail.__init__", "header": "['class', 'NotificationEmail', '(', 'EmailTextHTML', ')', ':', '___EOS___']", "index": 82 }, { "content": "class FollowEmail(NotificationEmail):\n type = EmailTypes.FOLLOW\n", "metadata": "root.FollowEmail", "header": "['module', '___EOS___']", "index": 91 }, { "content": " def __init__(self, user, entity, **kw):\n super(FollowEmail, self).__init__(type = self.type,\n subject = '%s started following you on Jumo' % entity.get_name.title(),\n user = user,\n entity = entity)", "metadata": "root.FollowEmail.__init__", "header": "['class', 'FollowEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 94 }, { "content": "class BadgeEmail(NotificationEmail):\n type = EmailTypes.MOST_ACTIVE", "metadata": "root.BadgeEmail", "header": "['module', '___EOS___']", "index": 101 }, { "content": " def __init__(self, user, entity, **kw):\n super(BadgeEmail, self).__init__(type = self.type,\n subject = \"You are now a top advocate for %s on Jumo\" % entity.get_name.title(),\n user = user,\n entity = entity)", "metadata": "root.BadgeEmail.__init__", "header": "['class', 'BadgeEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 103 }, { "content": "class CommentEmail(NotificationEmail):\n \"\"\"\n e = EmailMessage('Jumo | %s commented on your Jumo story!' % request.user.get_name, 'Hi %s,\\n\\n%s commented on a story you posted on Jumo.\\n\\n\"%s\"\\n\\nView or reply by following the link below:\\nhttp://jumo.com/story/%s\\n\\nThanks,\\nThe Jumo Team' % (fi.poster.get_name, request.user.get_name, request.POST['comment'], fi.id), '[email protected]', [fi.poster.email])\n e.send_now = True\n e.send()\n \"\"\"\n\n type = EmailTypes.COMMENT", "metadata": "root.CommentEmail", "header": "['module', '___EOS___']", "index": 109 }, { "content": " def __init__(self, user, entity, feed_item, comment):\n super(CommentEmail, self).__init__(type = self.type,\n subject = \"%s commented on your Jumo story\" % entity.get_name.title(),\n user = user,\n entity = entity,\n feed_item = feed_item,\n comment = comment)", "metadata": "root.CommentEmail.__init__", "header": "['class', 'CommentEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 117 }, { "content": "class PostedOnProfileEmail(NotificationEmail):\n \"\"\"\n Hi Kristen Titus,\n\n Matt Langer posted to your Jumo profile:\n\n \"HEADLINE: Man eats hot dogs for dinner. Support childhood obesity.\"\n\n View or reply by following the link below:\n http://www.jumo.com/user/4cd8937ca70f66b06ac5b9d7\n\n Thanks,\n The Jumo Team\n \"\"\"\n type = EmailTypes.POSTED_ON_PROFILE", "metadata": "root.PostedOnProfileEmail", "header": "['module', '___EOS___']", "index": 125 }, { "content": " def __init__(self, user, entity, feed_item):\n super(PostedOnProfileEmail, self).__init__(type=self.type,\n subject = \"%s posted to your Jumo profile\" % entity.get_name.title(),\n user = user,\n entity = entity,\n feed_item = feed_item,\n )", "metadata": "root.PostedOnProfileEmail.__init__", "header": "['class', 'PostedOnProfileEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 140 }, { "content": "class ResetPasswordEmail(NotificationEmail):\n \"\"\"\"e = EmailMessage('Reset your password on Jumo.', 'Hi %s,\\n\\nClick the following link to be automatically logged into Jumo: http://jumo.com/reset_password/%s\\n\\nthe Jumo team' % (u.first_name, pr.uid), '[email protected]', [email])\"\"\"\n type = EmailTypes.RESET_PASSWORD", "metadata": "root.ResetPasswordEmail", "header": "['module', '___EOS___']", "index": 149 }, { "content": " def __init__(self, user, entity, password_reset_id):\n super(ResetPasswordEmail, self).__init__(type=self.type,\n subject = \"Reset your password on Jumo\",\n user = user,\n entity = None,\n password_reset_id = password_reset_id\n )", "metadata": "root.ResetPasswordEmail.__init__", "header": "['class', 'ResetPasswordEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 152 }, { "content": "class ClaimOrgEmail(NotificationEmail):\n \"\"\"\"e = EmailMessage('Become the administrator of %s on Jumo.' % o.get_name, 'Hi %s,\\n\\nClick the following link to verify your affiliation with %s: http://jumo.com/org/claim/%s/confirm/%s\\n\\nthe Jumo team' % (request.user.first_name, o.get_name, o.id, o.claim_token), '[email protected]', [info['email']])\"\"\"\n type = EmailTypes.CLAIM_ORG", "metadata": "root.ClaimOrgEmail", "header": "['module', '___EOS___']", "index": 160 }, { "content": " def __init__(self, user, entity, org_claim_token):\n super(ClaimOrgEmail, self).__init__(type=self.type,\n subject = \"Become the administrator of %s on Jumo\" % entity.get_name.title(),\n user = user,\n entity = entity,\n org_claim_token = org_claim_token,\n )", "metadata": "root.ClaimOrgEmail.__init__", "header": "['class', 'ClaimOrgEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 163 }, { "content": "class DonationFailureEmail(NotificationEmail):\n type = EmailTypes.DONATION_FAILURE", "metadata": "root.DonationFailureEmail", "header": "['module', '___EOS___']", "index": 172 }, { "content": " def __init__(self, user, entity):\n super(DonationFailureEmail,self).__init__(type=self.type,\n subject='Jumo Billing | Charge Unsucessful',\n user = user,\n entity = entity)", "metadata": "root.DonationFailureEmail.__init__", "header": "['class', 'DonationFailureEmail', '(', 'NotificationEmail', ')', ':', '___EOS___']", "index": 174 }, { "content": "class JumoUpdateEmail(EmailTextHTML):\n publication = 'updates'\n publication_id = 3\n user_sub_field = 'enable_jumo_updates'", "metadata": "root.JumoUpdateEmail", "header": "['module', '___EOS___']", "index": 181 }, { "content": "class UserDefinedEmail(EmailTextHTML):", "metadata": "root.UserDefinedEmail", "header": "['module', '___EOS___']", "index": 187 }, { "content": " def __init__(self, type, user_or_donor, message, **kw):\n super(UserDefinedEmail, self).__init__(type=type,\n email_address=user_or_donor.email,\n subject=message.subject,\n publication_id = message.publication_id,\n message=message,\n **kw\n )", "metadata": "root.UserDefinedEmail.__init__", "header": "['class', 'UserDefinedEmail', '(', 'EmailTextHTML', ')', ':', '___EOS___']", "index": 188 } ]
[ { "span": "from etc.view_helpers import url_with_qs", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 40 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "mailer", "_", "._", "models_", "import_", "Email_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "etc", "_", "._", "func_", "import_", "salt", "ed", "\\u", "hash_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "etc", "_", "._", "view", "\\u", "helpers_", "import_", "url", "\\u", "with", "\\u", "qs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "loader_", "import_", "render", "\\u", "to", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "ing", " ", "inspect", " ", "so", " ", "we", " ", "don", "'", "t", " ", "have", " ", "to", " ", "add", " ", "new", " ", "notification", "s", " ", "manu", "ally", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ju", "st", " ", "make", " ", "sure", " ", "you", " ", "add", " ", "type", " ", "to", " ", "all", " ", "new", " ", "Notifi", "cation", "Ema", "il", " ", "classes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "notifications_", "=_", "dict_", "(_", "(_", "cls_", "._", "type_", ",_", "cls_", ")_", "for_", "name_", ",_", "cls_", "in_", "inspect_", "._", "getmember", "s_", "(_", "sys_", "._", "modules_", "[_", "\\u\\u", "name\\u\\u_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "inspect_", "._", "iscl", "ass_", "(_", "cls_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "issubclass_", "(_", "cls_", ",_", "Notifi", "cation", "Email_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "hasattr_", "(_", "cls_", ",_", "'", "type", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pubs", "_", "=_", "dict_", "(_", "(_", "cls_", "._", "publicat", "ion_", ",_", "cls_", ")_", "for_", "name_", ",_", "cls_", "in_", "inspect_", "._", "getmember", "s_", "(_", "sys_", "._", "modules_", "[_", "\\u\\u", "name\\u\\u_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "inspect_", "._", "iscl", "ass_", "(_", "cls_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "issubclass_", "(_", "cls_", ",_", "Ema", "il", "Text", "HTML_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "hasattr_", "(_", "cls_", ",_", "'", "publicat", "ion", "'_", ")_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Ema", "il", "Types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "JU", "MO", "\\u", "READ", "ER_", "=_", "'", "news", "\\u", "email", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "FOL", "LOW_", "=_", "'", "follow", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "MOS", "T", "\\u", "ACTIVE_", "=_", "'", "most", "\\u", "active", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "COMMENT_", "=_", "'", "comment", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RESE", "T", "\\u", "PASSWORD_", "=_", "'", "reset", "\\u", "password", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CLA", "IM", "\\u", "ORG", "_", "=_", "'", "claim", "\\u", "org", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "POST", "ED", "\\u", "ON", "\\u", "PROFILE", "_", "=_", "'", "poste", "d\\u", "on", "\\u", "profile", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DON", "ATION", "\\u", "FAILURE_", "=_", "'", "donation", "\\u", "fail", "ure", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Ema", "il", "Text", "HTML_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pro", "xy", " ", "to", " ", "Ema", "il", " ", "model", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ema", "il", "Text", "HTML_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "type_", ",_", "user_", "=_", "None_", ",_", "email", "\\u", "address_", "=_", "None_", ",_", "subject_", "=_", "''_", ",_", "update", "\\u", "next", "\\u", "email", "\\u", "time_", "=_", "False_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostname_", "=_", "settings_", "._", "HTTP", "\\u", "HOST_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "email", "\\u", "address_", "=_", "email", "\\u", "address_", "if_", "email", "\\u", "address_", "else_", "user_", "._", "email_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uns", "ub", "\\u", "code_", "=_", "salt", "ed", "\\u", "hash_", "(_", "email", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "dict_", "(_", "hostname_", "=_", "hostname_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "subject_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "uns", "ub", "\\u", "code_", "=_", "uns", "ub", "\\u", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "subject_", "=_", "subject_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "template", "\\u", "args_", "=_", "kw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "text", "\\u", "content_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "'", "email", "/", "txt", "/", "%", "s", ".", "txt", "'_", "%_", "type_", ",_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "html", "\\u", "content_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "'", "email", "/", "html", "/", "%", "s", ".", "html", "'_", "%_", "type_", ",_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "user_", "=_", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "\\u", "next", "\\u", "email", "\\u", "time_", "=_", "update", "\\u", "next", "\\u", "email", "\\u", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Lock", " ", "tha", "t", " ", "down_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "settings_", "._", "EMA", "IL", "\\u", "REAL", "\\u", "PE", "OP", "LE_", "or_", "email", "\\u", "address_", "._", "endswith_", "(_", "'@", "ju", "mo", ".", "com", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "to_", "=_", "email", "\\u", "address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "to_", "=_", "'", "ju", "mode", "v", "@", "gma", "il", ".", "com", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "from", "\\u", "address_", "=_", "'", "Jum", "o", " ", "<", "no", "-", "repl", "y", "@", "ju", "mo", ".", "com", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ema", "il", "Text", "HTML_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "Email_", "(_", "subject_", "=_", "self_", "._", "subject_", ",_", "body_", "=_", "self_", "._", "text", "\\u", "content_", ",_", "html_", "=_", "self_", "._", "html", "\\u", "content_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "self_", "._", "user_", ",_", "recipient_", "=_", "self_", "._", "to_", ",_", "from", "\\u", "address_", "=_", "self_", "._", "from", "\\u", "address_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "self_", "._", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "._", "send_", "(_", "self_", "._", "update", "\\u", "next", "\\u", "email", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Jum", "o", "Read", "er", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "headers_", "=_", "{_", "'", "X", "-", "SMT", "PAP", "I", "'_", ":_", "'{", "\"", "category", "\":", " ", "\"", "Jum", "o", " ", "Read", "er", "\"}'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion_", "=_", "'", "reader", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "sub\\u", "field_", "=_", "'", "email", "\\u", "stream", "\\u", "freque", "nc", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Jum", "o", "Read", "er", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "get", "\\u", "random", "\\u", "stats_", "(_", "self_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "issues_", "=_", "[_", "issue_", "for_", "issue_", "in_", "user_", "._", "get", "\\u", "all", "\\u", "issue", "s", "\\u", "following_", "if_", "issue_", "._", "get", "\\u", "all", "\\u", "statistics_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stats_", "=_", "[_", "issue_", "._", "get", "\\u", "all", "\\u", "statistics_", "for_", "issue_", "in_", "issues_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flat", "\\u", "stats_", "=_", "[_", "y_", "for_", "x_", "in_", "stats_", "for_", "y_", "in_", "x_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "random_", "._", "shuffle_", "(_", "flat", "\\u", "stats_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "flat", "\\u", "stats_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Jum", "o", "Read", "er", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "random", "\\u", "stats_", "=_", "self_", "._", "\\u", "get", "\\u", "random", "\\u", "stats_", "(_", "user_", ")_", "[_", ":_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Jum", "o", "Read", "er", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "Ema", "il", "Types_", "._", "JU", "MO", "\\u", "READ", "ER_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "'", "Jum", "o", " ", "Read", "er", " ", "|", " ", "Top", " ", "News", " ", "on", " ", "the", " ", "Issues", " ", "You", " ", "Care", " ", "Abo", "ut", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "next", "\\u", "email", "\\u", "time_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "random", "\\u", "stats_", "=_", "random", "\\u", "stats_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "self_", "._", "publicat", "ion", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Notifi", "cation", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Importa", "nt", ":", " ", "make", " ", "sure", " ", "you", " ", "add", " ", "a", " ", "type", " ", "member", " ", "to", " ", "any", " ", "subclasses", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion_", "=_", "'", "notification", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Notifi", "cation", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "type_", ",_", "subject_", ",_", "user_", ",_", "entity_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", "=_", "'", "notification", "s", "/", "%", "s", "'_", "%_", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Notifi", "cation", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "subject_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "self_", "._", "publicat", "ion", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Follow", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", "=_", "Ema", "il", "Types_", "._", "FOL", "LOW_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Follow", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Follow", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "'%", "s", " ", "start", "ed", " ", "follow", "ing", " ", "you", " ", "on", " ", "Jum", "o", "'_", "%_", "entity_", "._", "get", "\\u", "name_", "._", "title_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Badge", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", "=_", "Ema", "il", "Types_", "._", "MOS", "T", "\\u", "ACTIVE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Badge", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Badge", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"", "You", " ", "are", " ", "now", " ", "a", " ", "top", " ", "adv", "ocat", "e", " ", "for", " ", "%", "s", " ", "on", " ", "Jum", "o", "\"_", "%_", "entity_", "._", "get", "\\u", "name_", "._", "title_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Comme", "nt", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "e", " ", "=", " ", "Ema", "il", "Messag", "e", "('", "Jum", "o", " ", "|", " ", "%", "s", " ", "commente", "d", " ", "on", " ", "your", " ", "Jum", "o", " ", "stor", "y", "!'", " ", "%", " ", "request", ".", "user", ".", "get", "\\u", "name", ",", " ", "'", "Hi", " ", "%", "s", ",\\\\", "n", "\\\\", "n", "%", "s", " ", "commente", "d", " ", "on", " ", "a", " ", "stor", "y", " ", "you", " ", "poste", "d", " ", "on", " ", "Jum", "o", ".\\\\", "n", "\\\\", "n", "\"%", "s", "\"\\\\", "n", "\\\\", "n", "View", " ", "or", " ", "repl", "y", " ", "by", " ", "follow", "ing", " ", "the", " ", "link", " ", "belo", "w", ":\\\\", "nh", "ttp", "://", "ju", "mo", ".", "com", "/", "stor", "y", "/", "%", "s", "\\\\", "n", "\\\\", "n", "Thanks", ",\\\\", "n", "The", " ", "Jum", "o", " ", "Tea", "m", "'", " ", "%", " ", "(", "fi", ".", "poster", ".", "get", "\\u", "name", ",", " ", "request", ".", "user", ".", "get", "\\u", "name", ",", " ", "request", ".", "POST", "['", "comment", "']", ",", " ", "fi", ".", "id", "),", " ", "'", "no", "-", "repl", "y", "@", "ju", "mo", ".", "com", "',", " ", "[", "fi", ".", "poster", ".", "email", "])", "\\", "10", ";", " ", " ", "e", ".", "send", "\\u", "now", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", "e", ".", "send", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "type_", "=_", "Ema", "il", "Types_", "._", "COMMENT_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Comme", "nt", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "feed", "\\u", "item_", ",_", "comment_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Comme", "nt", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"%", "s", " ", "commente", "d", " ", "on", " ", "your", " ", "Jum", "o", " ", "stor", "y", "\"_", "%_", "entity_", "._", "get", "\\u", "name_", "._", "title_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "feed", "\\u", "item_", "=_", "feed", "\\u", "item_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "comment_", "=_", "comment_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Post", "ed", "On", "Profil", "e", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Hi", " ", "Kr", "iste", "n", " ", "Tit", "us", ",", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Matt", " ", "Lang", "er", " ", "poste", "d", " ", "to", " ", "your", " ", "Jum", "o", " ", "profile", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"", "HEAD", "LINE", ":", " ", "Man", " ", "eat", "s", " ", "hot", " ", "dog", "s", " ", "for", " ", "din", "ner", ".", " ", "Supp", "ort", " ", "child", "hood", " ", "obe", "sity", ".\"", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "View", " ", "or", " ", "repl", "y", " ", "by", " ", "follow", "ing", " ", "the", " ", "link", " ", "belo", "w", ":", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "ju", "mo", ".", "com", "/", "user", "/", "4c", "d8", "937", "ca", "7", "0f", "6", "6b", "0", "6a", "c5", "b9", "d7", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thanks", ",", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "Jum", "o", " ", "Tea", "m", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type_", "=_", "Ema", "il", "Types_", "._", "POST", "ED", "\\u", "ON", "\\u", "PROFILE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Post", "ed", "On", "Profil", "e", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "feed", "\\u", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Post", "ed", "On", "Profil", "e", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"%", "s", " ", "poste", "d", " ", "to", " ", "your", " ", "Jum", "o", " ", "profile", "\"_", "%_", "entity_", "._", "get", "\\u", "name_", "._", "title_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "feed", "\\u", "item_", "=_", "feed", "\\u", "item_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Reset", "Passw", "ord", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\"", "e", " ", "=", " ", "Ema", "il", "Messag", "e", "('", "Reset", " ", "your", " ", "password", " ", "on", " ", "Jum", "o", ".'", ",", " ", "'", "Hi", " ", "%", "s", ",\\\\", "n", "\\\\", "n", "Click", " ", "the", " ", "follow", "ing", " ", "link", " ", "to", " ", "be", " ", "automati", "call", "y", " ", "logged", " ", "int", "o", " ", "Jum", "o", ":", " ", "http", "://", "ju", "mo", ".", "com", "/", "reset", "\\u", "password", "/", "%", "s", "\\\\", "n", "\\\\", "nthe", " ", "Jum", "o", " ", "team", "'", " ", "%", " ", "(", "u", ".", "first", "\\u", "name", ",", " ", "pr", ".", "uid", "),", " ", "'", "no", "-", "repl", "y", "@", "ju", "mo", ".", "com", "',", " ", "[", "email", "])", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type_", "=_", "Ema", "il", "Types_", "._", "RESE", "T", "\\u", "PASSWORD_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Reset", "Passw", "ord", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "password", "\\u", "reset", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Reset", "Passw", "ord", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"", "Reset", " ", "your", " ", "password", " ", "on", " ", "Jum", "o", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password", "\\u", "reset", "\\u", "id_", "=_", "password", "\\u", "reset", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Cla", "im", "Org", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\"", "e", " ", "=", " ", "Ema", "il", "Messag", "e", "('", "Be", "come", " ", "the", " ", "administrat", "or", " ", "of", " ", "%", "s", " ", "on", " ", "Jum", "o", ".'", " ", "%", " ", "o", ".", "get", "\\u", "name", ",", " ", "'", "Hi", " ", "%", "s", ",\\\\", "n", "\\\\", "n", "Click", " ", "the", " ", "follow", "ing", " ", "link", " ", "to", " ", "verify", " ", "your", " ", "affiliation", " ", "with", " ", "%", "s", ":", " ", "http", "://", "ju", "mo", ".", "com", "/", "org", "/", "claim", "/", "%", "s", "/", "confirm", "/", "%", "s", "\\\\", "n", "\\\\", "nthe", " ", "Jum", "o", " ", "team", "'", " ", "%", " ", "(", "request", ".", "user", ".", "first", "\\u", "name", ",", " ", "o", ".", "get", "\\u", "name", ",", " ", "o", ".", "id", ",", " ", "o", ".", "claim", "\\u", "token", "),", " ", "'", "no", "-", "repl", "y", "@", "ju", "mo", ".", "com", "',", " ", "[", "info", "['", "email", "']]", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type_", "=_", "Ema", "il", "Types_", "._", "CLA", "IM", "\\u", "ORG", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cla", "im", "Org", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ",_", "org", "\\u", "claim", "\\u", "token_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Cla", "im", "Org", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"", "Be", "come", " ", "the", " ", "administrat", "or", " ", "of", " ", "%", "s", " ", "on", " ", "Jum", "o", "\"_", "%_", "entity_", "._", "get", "\\u", "name_", "._", "title_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "org", "\\u", "claim", "\\u", "token_", "=_", "org", "\\u", "claim", "\\u", "token_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Dona", "tion", "Fail", "ure", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type_", "=_", "Ema", "il", "Types_", "._", "DON", "ATION", "\\u", "FAILURE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dona", "tion", "Fail", "ure", "Email_", "(_", "Notifi", "cation", "Email_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "user_", ",_", "entity_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Dona", "tion", "Fail", "ure", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "self_", "._", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "'", "Jum", "o", " ", "Bill", "ing", " ", "|", " ", "Charge", " ", "Unsu", "cess", "ful", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity_", "=_", "entity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Jum", "o", "Update", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "publicat", "ion_", "=_", "'", "update", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "sub\\u", "field_", "=_", "'", "enable", "\\u", "ju", "mo", "\\u", "update", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "User", "Define", "d", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "Define", "d", "Email_", "(_", "Ema", "il", "Text", "HTML_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "type_", ",_", "user", "\\u", "or", "\\u", "donor", "_", ",_", "message_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "User", "Define", "d", "Email_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "type_", "=_", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "email", "\\u", "address_", "=_", "user", "\\u", "or", "\\u", "donor", "_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "message_", "._", "subject_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publicat", "ion", "\\u", "id_", "=_", "message_", "._", "publicat", "ion", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "message_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kw_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/test/test_distsim.py
[ { "content": " def test_3_access(self):\n logging.debug('')\n logging.debug('test_access')\n\n # This 'spook' creation is only for testing.\n # Normally the protector would run with regular credentials\n # in effect at the proprietary site.\n user = 'i am a spy@'+socket.gethostname()\n key_pair = get_key_pair(user)\n data = '\\n'.join([user, '0', key_pair.publickey().exportKey()])\n hash = hashlib.sha256(data).digest()\n signature = key_pair.sign(hash, get_random_bytes)\n spook = Credentials((data, signature, None))\n\n credentials = get_credentials()\n allowed_users = {credentials.user: credentials.public_key,\n spook.user: spook.public_key}\n factory = self.start_factory(allowed_users=allowed_users)\n\n # Create model and run it.\n saved = get_credentials()\n set_credentials(spook)\n box = factory.create(_MODULE+'.ProtectedBox',\n allowed_users=allowed_users)\n set_credentials(saved)\n\n model = set_as_top(Model(box))\n model.run()\n\n # Check results.\n for width in range(1, 2):\n for height in range(1, 3):\n for depth in range(1, 4):\n case = model.recorders[0].cases.pop(0)\n self.assertEqual(case.get_output('volume'),\n width*height*depth)\n\n # Check access protections.\n try:\n i = model.box.secret\n except RemoteError as exc:\n msg = \"RoleError: No __getattribute__ access to 'secret' by role 'user'\"\n logging.debug('msg: %s', msg)\n logging.debug('exc: %s', exc)\n self.assertTrue(msg in str(exc))\n else:\n self.fail('Expected RemoteError')\n\n try:\n model.box.proprietary_method()\n except RemoteError as exc:\n msg = \"RoleError: proprietary_method(): No access for role 'user'\"\n logging.debug('msg: %s', msg)\n logging.debug('exc: %s', exc)\n self.assertTrue(msg in str(exc))\n else:\n self.fail('Expected RemoteError')\n\n saved = get_credentials()\n set_credentials(spook)\n try:\n i = model.box.secret\n model.box.proprietary_method()\n finally:\n # Reset credentials to allow factory shutdown.\n set_credentials(saved)", "metadata": "root.TestCase.test_3_access", "header": "['class', 'TestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 506 } ]
[ { "span": "i ", "start_line": 545, "start_column": 12, "end_line": 545, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "3", "\\u", "access_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "debug_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "test\\u", "access", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "'", "spoo", "k", "'", " ", "creati", "on", " ", "is", " ", "only", " ", "for", " ", "testi", "ng", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Normal", "ly", " ", "the", " ", "protect", "or", " ", "wou", "ld", " ", "run", " ", "with", " ", "regular", " ", "credentials_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "effect", " ", "at", " ", "the", " ", "prop", "rie", "tar", "y", " ", "site", "._", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "'", "i", " ", "am", " ", "a", " ", "spy", "@'_", "+_", "socket_", "._", "gethostname_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key", "\\u", "pair_", "=_", "get", "\\u", "key", "\\u", "pair_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "'\\\\", "n", "'_", "._", "join_", "(_", "[_", "user_", ",_", "'", "0", "'_", ",_", "key", "\\u", "pair_", "._", "public", "key_", "(_", ")_", "._", "export", "Key_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hash_", "=_", "hashlib_", "._", "sha256_", "(_", "data_", ")_", "._", "digest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signature_", "=_", "key", "\\u", "pair_", "._", "sign_", "(_", "hash_", ",_", "get", "\\u", "random", "\\u", "bytes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "spoo", "k_", "=_", "Credentials_", "(_", "(_", "data_", ",_", "signature_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "credentials_", "=_", "get", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "ed", "\\u", "users_", "=_", "{_", "credentials_", "._", "user_", ":_", "credentials_", "._", "public", "\\u", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "spoo", "k_", "._", "user_", ":_", "spoo", "k_", "._", "public", "\\u", "key_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "factory_", "=_", "self_", "._", "start", "\\u", "factory_", "(_", "allow", "ed", "\\u", "users_", "=_", "allow", "ed", "\\u", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "model", " ", "and", " ", "run", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "saved_", "=_", "get", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "credentials_", "(_", "spoo", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "box_", "=_", "factory_", "._", "create_", "(_", "\\u", "MODULE_", "+_", "'.", "Protect", "ed", "Box", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "ed", "\\u", "users_", "=_", "allow", "ed", "\\u", "users_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "credentials_", "(_", "saved_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "set\\u", "as", "\\u", "top_", "(_", "Model_", "(_", "box_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "results", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "width_", "in_", "range_", "(_", "1_", ",_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "height_", "in_", "range_", "(_", "1_", ",_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "depth_", "in_", "range_", "(_", "1_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "case_", "=_", "model_", "._", "recorde", "rs_", "[_", "0_", "]_", "._", "cases_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "case_", "._", "get", "\\u", "output_", "(_", "'", "volume", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "width_", "*_", "height_", "*_", "depth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "access", " ", "protection", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "model_", "._", "box_", "._", "secret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Remo", "te", "Error_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"", "Ro", "le", "Error", ":", " ", "No", " ", "\\u\\u", "getattr", "ibut", "e\\u", "\\u", " ", "access", " ", "to", " ", "'", "secret", "'", " ", "by", " ", "role", " ", "'", "user", "'\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "msg", ":", " ", "%", "s", "'_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "exc", ":", " ", "%", "s", "'_", ",_", "exc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "msg_", "in_", "str_", "(_", "exc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "'", "Expect", "ed", " ", "Remo", "te", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "._", "box_", "._", "prop", "rie", "tar", "y", "\\u", "method_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Remo", "te", "Error_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"", "Ro", "le", "Error", ":", " ", "prop", "rie", "tar", "y", "\\u", "method", "():", " ", "No", " ", "access", " ", "for", " ", "role", " ", "'", "user", "'\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "msg", ":", " ", "%", "s", "'_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "'", "exc", ":", " ", "%", "s", "'_", ",_", "exc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "msg_", "in_", "str_", "(_", "exc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "'", "Expect", "ed", " ", "Remo", "te", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "saved_", "=_", "get", "\\u", "credentials_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "credentials_", "(_", "spoo", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "model_", "._", "box_", "._", "secret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "._", "box_", "._", "prop", "rie", "tar", "y", "\\u", "method_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLIN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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
mimecuvalo/helloworld/models/base.py
[ { "content": "from autumn.model import Model\nfrom autumn import validators\nfrom autumn.db.relations import ForeignKey\n\nimport validators as custom_validators\n\n\n\n\"\"\"\nclass content_access(Model):\n content = ForeignKey('content')\n user = ForeignKey('users')\n\n class Meta:\n defaults = {'has_access': 1}\n validations = {'content': validators.Number(),\n 'user': validators.Number(),\n 'has_access': validators.Number(),\n }\n\nclass resource_access(Model):\n user = ForeignKey('users')\n\n class Meta:\n defaults = {'has_access': 1}\n validations = {'url': custom_validators.Path(),\n 'user': validators.Number(),\n 'has_access': validators.Number(),\n }\n\"\"\"\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class content(Model):\n #user = ForeignKey('users')\n\n class Meta:\n defaults = {'count': 0,\n 'count_robot': 0,\n 'favorites': 0,\n 'shares': 0,\n 'comments_count': 0,\n 'comments_updated': None,\n 'order': 0,\n 'album': '',\n 'thumb': '',\n 'style': '',\n 'title': '',\n 'price': 0.00,\n 'date_start': None,\n 'date_end': None,\n 'date_repeats': 0,\n 'template': '',\n 'sort_type': '',\n 'redirect': 0,\n 'forum': 0,\n 'hidden': 0,\n 'favorited': 0,\n 'is_spam': 0,\n 'deleted': 0,\n 'thread': '',\n 'thread_user': '',\n 'avatar': '',\n 'view': '',\n 'code': '',}\n validations = {'section': (custom_validators.UnicodeString(1, 255),\n custom_validators.Id()),\n 'album': (custom_validators.UnicodeString(0, 255),\n custom_validators.IdOrNull()),\n 'name': (custom_validators.UnicodeString(1, 255),\n custom_validators.Id()),\n 'username': (custom_validators.UnicodeString(1, 255),\n custom_validators.Alphanumeric()),\n 'date_created': custom_validators.Datetime(),\n 'date_updated': custom_validators.Datetime(),\n 'date_start': custom_validators.DatetimeOrNull(),\n 'date_end': custom_validators.DatetimeOrNull(),\n 'date_repeats': validators.Number(),\n 'count': validators.Number(),\n 'count_robot': validators.Number(),\n 'favorites': validators.Number(),\n 'shares': validators.Number(),\n 'comments_count': validators.Number(),\n 'price': validators.Number(),\n 'hidden': custom_validators.Boolean(),\n }", "metadata": "root.content", "header": "['module', '___EOS___']", "index": 6 }, { "content": "class content_remote(Model):\n class Meta:\n defaults = {'type': '',\n 'from_user': '',\n 'local_content_name': '',\n 'username': '',\n 'creator': '',\n 'title': '',\n 'post_id': '',\n 'read': '0',\n 'is_spam': 0,\n 'favorited': 0,\n 'deleted': 0,\n 'date_updated': None,\n 'comments_count': 0,\n 'comments_updated': None,\n 'thread': '',\n 'avatar': '',\n 'link': '',\n 'view': '',}\n validations = {'to_username': (custom_validators.UnicodeString(1, 255),\n custom_validators.Alphanumeric()),\n 'type': validators.String(),\n 'date_created': custom_validators.Datetime(),\n 'date_updated': custom_validators.DatetimeOrNull(),\n 'comments_count': validators.Number(),\n 'comments_updated': custom_validators.DatetimeOrNull(),\n }", "metadata": "root.content_remote", "header": "['module', '___EOS___']", "index": 60 }, { "content": "class users(Model):\n class Meta:\n defaults = {'title': '',\n 'description': '',\n 'hostname': '',\n 'name': '',\n 'google_analytics': '',\n 'license': '',\n 'tipjar': '',\n 'sidebar_ad': '',\n 'currency': '',\n 'newsletter_endpoint': '',\n 'favicon': '',\n 'theme': '',\n 'logo': '',\n 'magic_key': '',\n 'extra_head_html': '',\n 'extra_body_end_html': '',\n 'theme_title': '',\n 'theme_link': '',\n 'theme_author': '',\n 'theme_author_link': '',\n 'adult_content': 0,\n 'twitter': '',\n 'facebook': '',\n 'google': '',\n 'tumblr': '',}\n validations = {'username': (custom_validators.UnicodeString(1, 255),\n custom_validators.Alphanumeric()),\n 'name': custom_validators.UnicodeString(0, 255),\n 'email': validators.String(1, 255),\n 'author': custom_validators.Boolean(),\n 'superuser': custom_validators.Boolean(),\n 'title': custom_validators.UnicodeString(0, 255),\n 'adult_content': custom_validators.Boolean(),\n 'magic_key': validators.String(),\n 'private_key': validators.String(),\n }", "metadata": "root.users", "header": "['module', '___EOS___']", "index": 112 }, { "content": "class users_remote(Model):\n class Meta:\n defaults = {'username': '',\n 'name': '',\n 'order': 0,\n 'magic_key': '',\n 'avatar': '',\n 'favicon': '',\n 'salmon_url': '',\n 'webmention_url': '',\n 'hub_url': '',\n 'feed_url': '',\n 'sort_type': '',\n 'follower': 0,\n 'following': 0, }\n validations = {'local_username': (custom_validators.UnicodeString(1, 255),\n custom_validators.Alphanumeric()),\n 'username': custom_validators.UnicodeString(0, 255),\n 'name': custom_validators.UnicodeString(0, 255),\n 'profile_url': validators.String(),\n 'follower': custom_validators.Boolean(),\n 'following': custom_validators.Boolean(),\n }", "metadata": "root.users_remote", "header": "['module', '___EOS___']", "index": 151 } ]
[ { "span": "from autumn.db.relations import ForeignKey", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 42 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "aut", "umn", "_", "._", "model_", "import_", "Model_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aut", "umn", "_", "import_", "validators_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aut", "umn", "_", "._", "db_", "._", "relations_", "import_", "Fore", "ign", "Key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "validators_", "as_", "custom", "\\u", "validators_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "class", " ", "content", "\\u", "access", "(", "Model", "):", "\\", "10", ";", " ", " ", "content", " ", "=", " ", "Fore", "ign", "Key", "('", "content", "')", "\\", "10", ";", " ", " ", "user", " ", "=", " ", "Fore", "ign", "Key", "('", "users", "')", "\\", "10", ";", "\\", "10", ";", " ", " ", "class", " ", "Meta", ":", "\\", "10", ";", " ", " ", " ", " ", "default", "s", " ", "=", " ", "{", "'", "has", "\\u", "access", "':", " ", "1", "}", "\\", "10", ";", " ", " ", " ", " ", "validation", "s", " ", "=", " ", "{", "'", "content", "':", " ", "validator", "s", ".", "Number", "()", ",", "\\", "10", ";", " ", "'", "user", "':", " ", "validator", "s", ".", "Number", "()", ",", "\\", "10", ";", " ", "'", "has", "\\u", "access", "':", " ", "validator", "s", ".", "Number", "()", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", "class", " ", "resource", "\\u", "access", "(", "Model", "):", "\\", "10", ";", " ", " ", "user", " ", "=", " ", "Fore", "ign", "Key", "('", "users", "')", "\\", "10", ";", "\\", "10", ";", " ", " ", "class", " ", "Meta", ":", "\\", "10", ";", " ", " ", " ", " ", "default", "s", " ", "=", " ", "{", "'", "has", "\\u", "access", "':", " ", "1", "}", "\\", "10", ";", " ", " ", " ", " ", "validation", "s", " ", "=", " ", "{", "'", "url", "':", " ", "custom", "\\u", "validator", "s", ".", "Path", "()", ",", "\\", "10", ";", " ", "'", "user", "':", " ", "validator", "s", ".", "Number", "()", ",", "\\", "10", ";", " ", "'", "has", "\\u", "access", "':", " ", "validator", "s", ".", "Number", "()", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "}", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "content_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "user", " ", "=", " ", "Fore", "ign", "Key", "('", "users", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "defaults_", "=_", "{_", "'", "count", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "count", "\\u", "robot", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "favorites", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "share", "s", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "count", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "update", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "order", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "album", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "thumb", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "style", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "'_", ":_", "0.00_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "start", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "end", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "repeat", "s", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "template", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sort", "\\u", "type", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "redirec", "t", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "forum", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hidden", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "favorite", "d", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "spam", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "d", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "thread", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "thread", "\\u", "user", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "avat", "ar", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "view", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "'_", ":_", "''_", ",_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation", "s_", "=_", "{_", "'", "section", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Id_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "album", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "0_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Id", "Or", "Null_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Id_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Al", "phan", "ume", "ric", "_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "created", "'_", ":_", "custom", "\\u", "validators_", "._", "Datetime_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "update", "d", "'_", ":_", "custom", "\\u", "validators_", "._", "Datetime_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "start", "'_", ":_", "custom", "\\u", "validators_", "._", "Date", "time", "Or", "Null_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "end", "'_", ":_", "custom", "\\u", "validators_", "._", "Date", "time", "Or", "Null_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "repeat", "s", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "count", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "count", "\\u", "robot", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "favorites", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "share", "s", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "count", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hidden", "'_", ":_", "custom", "\\u", "validators_", "._", "Boolean_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "content", "\\u", "remote_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "defaults_", "=_", "{_", "'", "type", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "from", "\\u", "user", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "\\u", "content", "\\u", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "creat", "or", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "post", "\\u", "id", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "read", "'_", ":_", "'", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "spam", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "favorite", "d", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "d", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "update", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "count", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "update", "d", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "thread", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "avat", "ar", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "link", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "view", "'_", ":_", "''_", ",_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation", "s_", "=_", "{_", "'", "to", "\\u", "user", "name", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Al", "phan", "ume", "ric", "_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "validators_", "._", "String_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "created", "'_", ":_", "custom", "\\u", "validators_", "._", "Datetime_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "update", "d", "'_", ":_", "custom", "\\u", "validators_", "._", "Date", "time", "Or", "Null_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "count", "'_", ":_", "validators_", "._", "Number_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "s", "\\u", "update", "d", "'_", ":_", "custom", "\\u", "validators_", "._", "Date", "time", "Or", "Null_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "users_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "defaults_", "=_", "{_", "'", "title", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "host", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "google", "\\u", "analytics", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "license", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tip", "jar", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sidebar", "\\u", "ad", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "curr", "ency", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "newsletter", "\\u", "endpoint", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fav", "icon", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "them", "e", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "logo", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "magic", "\\u", "key", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "extra", "\\u", "head", "\\u", "html", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "extra", "\\u", "body", "\\u", "end", "\\u", "html", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "them", "e\\u", "title", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "them", "e\\u", "link", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "them", "e\\u", "author", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "them", "e\\u", "author", "\\u", "link", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adult", "\\u", "content", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "twit", "ter", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "facebook", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "google", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tum", "bl", "r", "'_", ":_", "''_", ",_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation", "s_", "=_", "{_", "'", "user", "name", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Al", "phan", "ume", "ric", "_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "0_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "email", "'_", ":_", "validators_", "._", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "custom", "\\u", "validators_", "._", "Boolean_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "super", "user", "'_", ":_", "custom", "\\u", "validators_", "._", "Boolean_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "0_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adult", "\\u", "content", "'_", ":_", "custom", "\\u", "validators_", "._", "Boolean_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "magic", "\\u", "key", "'_", ":_", "validators_", "._", "String_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "private", "\\u", "key", "'_", ":_", "validators_", "._", "String_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "users", "\\u", "remote_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "defaults_", "=_", "{_", "'", "user", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "order", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "magic", "\\u", "key", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "avat", "ar", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fav", "icon", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sal", "mon", "\\u", "url", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "webm", "enti", "on", "\\u", "url", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hub", "\\u", "url", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "feed", "\\u", "url", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sort", "\\u", "type", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "follower", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "follow", "ing", "'_", ":_", "0_", ",_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation", "s_", "=_", "{_", "'", "local", "\\u", "user", "name", "'_", ":_", "(_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "1_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "validators_", "._", "Al", "phan", "ume", "ric", "_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "0_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "custom", "\\u", "validators_", "._", "Unic", "ode", "String_", "(_", "0_", ",_", "255_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "profile", "\\u", "url", "'_", ":_", "validators_", "._", "String_", "(_", ")_", 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
JamesMilnerUK/Loxo/loxoapi.py
[ { "content": "from pymongo import MongoClient, GEO2D, DESCENDING, errors\nfrom flask import Flask, make_response, request, Blueprint, render_template, redirect, url_for, send_from_directory\nfrom bson.json_util import dumps\nfrom werkzeug.utils import secure_filename\nfrom ast import literal_eval\nfrom bson.son import SON\nimport json\nimport os\n\nfrom loxoutils import *\nfrom loxostats import *\nfrom loxoerrors import *\n\n# Flask Setup\nDB_DOWN = False\nUPLOAD_FOLDER = 'uploads'\nALLOWED_EXTENSIONS = set(['kml', 'zip', 'geojson', 'csv', \"png\"])\n\napp = Flask(__name__)\napp.register_blueprint(stats_api, url_prefix='/loxo/<database>/collections/<dataset>/stats')\napp.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER\n\n\n# MongoDB Setup\ntry:\n mdb_port = 27017\n host = os.environ.get('LOXO_DB_1_PORT_27017_TCP_ADDR', 'localhost')\n client = MongoClient(host, mdb_port, serverSelectionTimeoutMS=1) #Checks to see if MDB is up\n client.server_info()\n\nexcept errors.ServerSelectionTimeoutError as err:\n DB_DOWN = True\n print \"MongoDB is down :\", err\n\n\n#API Endpoints\n\n\n\n\n\n\n\n\n\n\n\n\n#Retrieve by ID\n\n## Error handling\napply_error_handling(app)\n\n\nif __name__ == '__main__':\n\n if DB_DOWN == False:\n if host == 'localhost':\n\n app.run(host='localhost')\n else:\n # DOCKER\n app.run(host='0.0.0.0')", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@app.route('/')\[email protected]('/loxo/')\ndef loxo():\n \"\"\"Return the Loxo welcome message, point to documentation.\"\"\"\n return render_template('index.html')", "metadata": "root.loxo", "header": "['module', '___EOS___']", "index": 37 }, { "content": "@app.route('/loxo/viewer')\ndef viewer():\n \"\"\"Show a map to view the GeoJSON returned from a Loxo endpoint\"\"\"\n return render_template('viewer.html')", "metadata": "root.viewer", "header": "['module', '___EOS___']", "index": 44 }, { "content": "@app.route('/loxo/upload', methods=['GET', 'POST'])\ndef upload_file():\n if request.method == 'POST':\n file = request.files['file']\n if file and allowed_file(file.filename, ALLOWED_EXTENSIONS):\n filename = secure_filename(file.filename)\n file_location = os.path.join(app.config['UPLOAD_FOLDER'], filename)\n print \"file location\", file_location\n file.save(file_location)\n saved_file = url_for('uploaded_file', filename=filename)\n\n endpoint_name = os.path.splitext(filename)[0]\n database = request.form.get(\"database\")\n if not database:\n print request.form[\"database\"]\n raise InvalidUsage(\"Database name was not provided\", 400, '{ \"error\" : \"database was not provided\" }')\n else:\n handle_file(database, file_location, endpoint_name, host)\n\n return redirect('/loxo/' + database + '/collections/' + endpoint_name)\n\n return render_template('upload.html')", "metadata": "root.upload_file", "header": "['module', '___EOS___']", "index": 50 }, { "content": "@app.route('/loxo/uploads/<filename>')\ndef uploaded_file(filename):\n return send_from_directory(app.config['UPLOAD_FOLDER'], filename)", "metadata": "root.uploaded_file", "header": "['module', '___EOS___']", "index": 74 }, { "content": "@app.route('/loxo/<database>/index/spatial', methods=['GET'])\ndef index_collections(database):\n \"\"\"Peform Spatial Indexing on the Collections\"\"\"\n db = client[database]\n for collection in db.collection_names(include_system_collections=False):\n print \"Indexing \", collection, \"with a \", GEO2D, \" index.\"\n db[collection].create_index( [(\"geometry.coordinates\", GEO2D)], background=True )\n return make_response( json.dumps({\"Spatial Index\": \"Finished\"}) )", "metadata": "root.index_collections", "header": "['module', '___EOS___']", "index": 79 }, { "content": "@app.route('/loxo/<database>/collections/<dataset>', methods=['GET'])\ndef get_data_by_value(database, dataset):\n \"\"\"Return a dataset, based on parameters passed\"\"\"\n db = client[database]\n collection = db[dataset]\n\n if len(request.args) == 0:\n feature_collection = find_features(collection, {})\n return make_response(create_feature_collection(feature_collection))\n\n else:\n property = request.args.get(\"property\")\n within_proximity = request.args.get(\"withinProximity\")\n within_donut = request.args.get(\"withinDonut\")\n within_polygon = request.args.get(\"withinPolygon\")\n k_nearest = request.args.get(\"kNearest\")\n\n # Handle Requests\n if property:\n get_property = \"properties.\" + property\n return_features = find_features(collection, {get_property : request.args.get(\"value\")})\n feature_collection = create_feature_collection(return_features)\n return make_response( feature_collection )\n\n if within_proximity and not property:\n args = within_proximity.split(\",\")\n lng = float(args[0])\n lat = float(args[1])\n proximity_radius = abs(float(args[2]))\n print proximity_radius\n proximity_radius_query = [[lng, lat], meters_to_radians(proximity_radius)]\n find = {\"geometry.coordinates\": {\"$geoWithin\": {\"$centerSphere\": proximity_radius_query }}}\n return_features = find_features(collection, find)\n feature_collection = create_feature_collection(return_features)\n return make_response( feature_collection )\n\n if within_donut and not property:\n args = within_donut.split(\",\")\n lng = float(args[0])\n lat = float(args[1])\n donut_min = meters_to_radians(abs(float(args[2])))\n donut_max = meters_to_radians(abs(float(args[3])))\n donut_query = { \"$nearSphere\": [lng, lat], \"$minDistance\" : donut_min, \"$maxDistance\": donut_max}\n find = { \"geometry.coordinates\": donut_query}\n return_features = find_features(collection, find) # Exclude the id field\n feature_collection = create_feature_collection(return_features)\n return make_response( feature_collection )\n\n if within_polygon and not property:\n\n #polygon = [ [0.0 , 0.0], [-180.0 , 0.0], [-180.0 , 90.0], [0.0 , 90.0] ]\n polygon = literal_eval(within_polygon) # http://stackoverflow.com/questions/1894269/convert-string-representation-of-list-to-list-in-python\n find = { \"geometry.coordinates\": {\"$geoWithin\": {\"$polygon\": polygon }} }\n return_features = find_features(collection, find)\n feature_collection = create_feature_collection(return_features)\n return make_response( feature_collection )\n\n if k_nearest and not property:\n args = k_nearest.split(\",\")\n lng = float(args[0])\n lat = float(args[1])\n distance_radius = abs(float(args[2]))\n #query = [{\"$geoNear\":{ \"near\": [lat, lng], \"distanceField\": \"distance\", \"maxDistance\": distance_radius}}]\n\n result = db.command(SON([('geoNear', dataset), ('near', [lng, lat]), ('num', distance_radius)]))[\"results\"]\n feature_type = \"Feature\"\n results = []\n\n for parent_obj in result:\n print parent_obj\n print parent_obj[\"obj\"]\n print type(parent_obj)\n obj = parent_obj[\"obj\"]\n feature = { }\n feature[\"geometry\"] = obj[\"geometry\"]\n feature[\"type\"] = feature_type\n feature[\"properties\"] = obj[\"properties\"]\n feature[\"properties\"][\"kNeartestDistance\"] = parent_obj[\"dis\"]\n results.append(feature)\n\n return create_feature_collection(results)\n\n\n if within_proximity and property or within_proximity and property:\n return \"Sorry, property AND proximity searching not currently supported\"", "metadata": "root.get_data_by_value", "header": "['module', '___EOS___']", "index": 89 }, { "content": "@app.route('/loxo/<database>/collections/<dataset>/<int:id>', methods=['GET'])\ndef get_data_by_id(database, dataset, id):\n db = client[database]\n collection = db[dataset]\n get_property = \"properties.loxo_id\"\n return_feature = find_features(collection, {get_property : id})\n return make_response( return_feature )", "metadata": "root.get_data_by_id", "header": "['module', '___EOS___']", "index": 176 } ]
[ { "span": "from pymongo import MongoClient, GEO2D, DESCENDING, errors", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 58 }, { "span": "from flask import Flask, make_response, request, Blueprint, render_template, redirect, url_for, send_from_directory", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 115 }, { "span": "from bson.json_util import dumps", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 32 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "pymongo_", "import_", "Mon", "go", "Client_", ",_", "GEO", "2", "D_", ",_", "DESC", "ENDING_", ",_", "errors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "import_", "Flask_", ",_", "make", "\\u", "response_", ",_", "request_", ",_", "Blueprint_", ",_", "render", "\\u", "template_", ",_", "redirect_", ",_", "url", "\\u", "for_", ",_", "send", "\\u", "from", "\\u", "directory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bson_", "._", "json", "\\u", "util_", "import_", "dumps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "werkzeug_", "._", "utils_", "import_", "secure", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ast_", "import_", "literal", "\\u", "eval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bson_", "._", "son_", "import_", "SON", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lo", "xo", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lo", "xo", "stats_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lo", "xo", "errors_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fla", "sk", " ", "Setup_", "\\u\\u\\uNL\\u\\u\\u_", "DB", "\\u", "DOWN_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "UPLOAD", "\\u", "FOLDER_", "=_", "'", "uploads", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ALLOWED", "\\u", "EXTENSIONS_", "=_", "set_", "(_", "[_", "'", "kml", "'_", ",_", "'", "zip", "'_", ",_", "'", "geo", "json", "'_", ",_", "'", "csv", "'_", ",_", "\"", "png", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "Flask_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "register", "\\u", "blueprint_", "(_", "stats", "\\u", "api_", ",_", "url", "\\u", "prefix_", "=_", "'/", "lo", "xo", "/", "<", "databa", "se", ">/", "collection", "s", "/", "<", "dataset", ">/", "stats", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "config_", "[_", "'", "UPLOAD", "\\u", "FOLDER", "'_", "]_", "=_", "UPLOAD", "\\u", "FOLDER_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mon", "go", "DB", " ", "Setup_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mdb", "\\u", "port_", "=_", "27017", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "'", "LO", "XO", "\\u", "DB", "\\u", "1", "\\u", "PORT", "\\u", "27017", "\\u", "TC", "P", "\\u", "ADDR", "'_", ",_", "'", "local", "host", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "Mon", "go", "Client_", "(_", "host_", ",_", "mdb", "\\u", "port_", ",_", "server", "Selecti", "on", "Time", "out", "MS_", "=_", "1_", ")_", "#", "Check", "s", " ", "to", " ", "see", " ", "if", " ", "MD", "B", " ", "is", " ", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "server", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "errors_", "._", "Server", "Selecti", "on", "Time", "out", "Error_", "as_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "DB", "\\u", "DOWN_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Mon", "go", "DB", " ", "is", " ", "down", " ", ":\"_", ",_", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "API", " ", "Endpoints", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Retrieve", " ", "by", " ", "ID_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Error", " ", "handling", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "appl", "y", "\\u", "error", "\\u", "handling", "_", "(_", "app_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "DB", "\\u", "DOWN_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "host_", "==_", "'", "local", "host", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "app_", "._", "run_", "(_", "host_", "=_", "'", "local", "host", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "DOCKER", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "app_", "._", "run_", "(_", "host_", "=_", "'", "0.", "0.", "0.", "0", "'_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "lo", "xo", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "the", " ", "Lo", "xo", " ", "welcome", " ", "message", ",", " ", "point", " ", "to", " ", "documentation", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "index", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "viewer", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "viewer_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Show", " ", "a", " ", "map", " ", "to", " ", "view", " ", "the", " ", "Geo", "JSO", "N", " ", "return", "ed", " ", "from", " ", "a", " ", "Lo", "xo", " ", "endpoint", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "viewer", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "upload", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", ",_", "'", "POST", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "upload", "\\u", "file_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file_", "=_", "request_", "._", "files_", "[_", "'", "file", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "file_", "and_", "allow", "ed", "\\u", "file_", "(_", "file_", "._", "filename_", ",_", "ALLOWED", "\\u", "EXTENSIONS_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "secure", "\\u", "filename_", "(_", "file_", "._", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "location_", "=_", "os_", "._", "path_", "._", "join_", "(_", "app_", "._", "config_", "[_", "'", "UPLOAD", "\\u", "FOLDER", "'_", "]_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "file", " ", "location", "\"_", ",_", "file", "\\u", "location_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "._", "save_", "(_", "file", "\\u", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "saved", "\\u", "file_", "=_", "url", "\\u", "for_", "(_", "'", "uploade", "d\\u", "file", "'_", ",_", "filename_", "=_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "endpoint", "\\u", "name_", "=_", "os_", "._", "path_", "._", "splitext_", "(_", "filename_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "database_", "=_", "request_", "._", "form_", "._", "get_", "(_", "\"", "databa", "se", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "database_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "request_", "._", "form_", "[_", "\"", "databa", "se", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Inva", "lid", "Usage_", "(_", "\"", "Databa", "se", " ", "name", " ", "was", " ", "not", " ", "provided", "\"_", ",_", "400_", ",_", "'{", " ", "\"", "error", "\"", " ", ":", " ", "\"", "databa", "se", " ", "was", " ", "not", " ", "provided", "\"", " ", "}'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handle", "\\u", "file_", "(_", "database_", ",_", "file", "\\u", "location_", ",_", "endpoint", "\\u", "name_", ",_", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "redirect_", "(_", "'/", "lo", "xo", "/'_", "+_", "database_", "+_", "'/", "collection", "s", "/'_", "+_", "endpoint", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "upload", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "uploads", "/", "<", "filename", ">'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "uploade", "d\\u", "file_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "send", "\\u", "from", "\\u", "directory_", "(_", "app_", "._", "config_", "[_", "'", "UPLOAD", "\\u", "FOLDER", "'_", "]_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "<", "databa", "se", ">/", "index", "/", "spat", "ial", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "index", "\\u", "collections_", "(_", "database_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pe", "form", " ", "Spa", "tial", " ", "Index", "ing", " ", "on", " ", "the", " ", "Collections", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "client_", "[_", "database_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "collection_", "in_", "db_", "._", "collection", "\\u", "names_", "(_", "include", "\\u", "system", "\\u", "collections_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Index", "ing", " ", "\"_", ",_", "collection_", ",_", "\"", "with", " ", "a", " ", "\"_", ",_", "GEO", "2", "D_", ",_", "\"", " ", "index", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "[_", "collection_", "]_", "._", "create", "\\u", "index_", "(_", "[_", "(_", "\"", "geom", "etry", ".", "coordinate", "s", "\"_", ",_", "GEO", "2", "D_", ")_", "]_", ",_", "background_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "json_", "._", "dumps_", "(_", "{_", "\"", "Spa", "tial", " ", "Index", "\"_", ":_", "\"", "Finish", "ed", "\"_", "}_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "<", "databa", "se", ">/", "collection", "s", "/", "<", "dataset", ">'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "data\\u", "by", "\\u", "value_", "(_", "database_", ",_", "dataset_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "a", " ", "dataset", ",", " ", "based", " ", "on", " ", "parameter", "s", " ", "pass", "ed", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "client_", "[_", "database_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collection_", "=_", "db_", "[_", "dataset_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "args_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "feature", "\\u", "collection_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "create", "\\u", "feature", "\\u", "collection_", "(_", "feature", "\\u", "collection_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "property_", "=_", "request_", "._", "args_", "._", "get_", "(_", "\"", "property", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "within", "\\u", "proxim", "ity_", "=_", "request_", "._", "args_", "._", "get_", "(_", "\"", "within", "Proxi", "mit", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "within", "\\u", "don", "ut_", "=_", "request_", "._", "args_", "._", "get_", "(_", "\"", "within", "Don", "ut", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "within", "\\u", "polygon_", "=_", "request_", "._", "args_", "._", "get_", "(_", "\"", "within", "Polygon", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k", "\\u", "nearest_", "=_", "request_", "._", "args_", "._", "get_", "(_", "\"", "k", "Near", "est", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Handle", " ", "Requests_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "get", "\\u", "property_", "=_", "\"", "proper", "ties", ".\"_", "+_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return", "\\u", "features_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "{_", "get", "\\u", "property_", ":_", "request_", "._", "args_", "._", "get_", "(_", "\"", "value", "\"_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature", "\\u", "collection_", "=_", "create", "\\u", "feature", "\\u", "collection_", "(_", "return", "\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "feature", "\\u", "collection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "within", "\\u", "proxim", "ity_", "and_", "not_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "within", "\\u", "proxim", "ity_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lng_", "=_", "float_", "(_", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lat_", "=_", "float_", "(_", "args_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "proxim", "it", "y", "\\u", "radius_", "=_", "abs_", "(_", "float_", "(_", "args_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "proxim", "it", "y", "\\u", "radius_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "proxim", "it", "y", "\\u", "radi", "us", "\\u", "query_", "=_", "[_", "[_", "lng_", ",_", "lat_", "]_", ",_", "mete", "rs", "\\u", "to", "\\u", "radians_", "(_", "proxim", "it", "y", "\\u", "radius_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "find_", "=_", "{_", "\"", "geom", "etry", ".", "coordinate", "s", "\"_", ":_", "{_", "\"$", "geo", "With", "in", "\"_", ":_", "{_", "\"$", "center", "Sphere", "\"_", ":_", "proxim", "it", "y", "\\u", "radi", "us", "\\u", "query_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return", "\\u", "features_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "find_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature", "\\u", "collection_", "=_", "create", "\\u", "feature", "\\u", "collection_", "(_", "return", "\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "feature", "\\u", "collection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "within", "\\u", "don", "ut_", "and_", "not_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "within", "\\u", "don", "ut_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lng_", "=_", "float_", "(_", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lat_", "=_", "float_", "(_", "args_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "ut", "\\u", "min_", "=_", "mete", "rs", "\\u", "to", "\\u", "radians_", "(_", "abs_", "(_", "float_", "(_", "args_", "[_", "2_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "ut", "\\u", "max_", "=_", "mete", "rs", "\\u", "to", "\\u", "radians_", "(_", "abs_", "(_", "float_", "(_", "args_", "[_", "3_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "don", "ut", "\\u", "query_", "=_", "{_", "\"$", "near", "Sphere", "\"_", ":_", "[_", "lng_", ",_", "lat_", "]_", ",_", "\"$", "min", "Distan", "ce", "\"_", ":_", "don", "ut", "\\u", "min_", ",_", "\"$", "max", "Distan", "ce", "\"_", ":_", "don", "ut", "\\u", "max_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "find_", "=_", "{_", "\"", "geom", "etry", ".", "coordinate", "s", "\"_", ":_", "don", "ut", "\\u", "query_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return", "\\u", "features_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "find_", ")_", "#", " ", "Exclude", " ", "the", " ", "id", " ", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature", "\\u", "collection_", "=_", "create", "\\u", "feature", "\\u", "collection_", "(_", "return", "\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "feature", "\\u", "collection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "within", "\\u", "polygon_", "and_", "not_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "poly", "gon", " ", "=", " ", "[", " ", "[", "0.", "0", " ", ",", " ", "0.", "0", "],", " ", "[-", "180", ".0", " ", ",", " ", "0.", "0", "],", " ", "[-", "180", ".0", " ", ",", " ", "90.", "0", "],", " ", "[", "0.", "0", " ", ",", " ", "90.", "0", "]", " ", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "polygon_", "=_", "literal", "\\u", "eval_", "(_", "within", "\\u", "polygon_", ")_", "#", " ", "http", "://", "stack", "overflow", ".", "com", "/", "question", "s", "/", "189", "426", "9", "/", "convert", "-", "string", "-", "represent", "ation", "-", "of", "-", "list", "-", "to", "-", "list", "-", "in", "-", "python_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "find_", "=_", "{_", "\"", "geom", "etry", ".", "coordinate", "s", "\"_", ":_", "{_", "\"$", "geo", "With", "in", "\"_", ":_", "{_", "\"$", "poly", "gon", "\"_", ":_", "polygon_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return", "\\u", "features_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "find_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature", "\\u", "collection_", "=_", "create", "\\u", "feature", "\\u", "collection_", "(_", "return", "\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "feature", "\\u", "collection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "k", "\\u", "nearest_", "and_", "not_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "k", "\\u", "nearest_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lng_", "=_", "float_", "(_", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lat_", "=_", "float_", "(_", "args_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "distance", "\\u", "radius_", "=_", "abs_", "(_", "float_", "(_", "args_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "query", " ", "=", " ", "[{", "\"$", "geo", "Near", "\":{", " ", "\"", "near", "\":", " ", "[", "lat", ",", " ", "ln", "g", "],", " ", "\"", "distance", "Field", "\":", " ", "\"", "distance", "\",", " ", "\"", "max", "Distan", "ce", "\":", " ", "distance", "\\u", "radi", "us", "}}", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "db_", "._", "command_", "(_", "SON", "_", "(_", "[_", "(_", "'", "geo", "Near", "'_", ",_", "dataset_", ")_", ",_", "(_", "'", "near", "'_", ",_", "[_", "lng_", ",_", "lat_", "]_", ")_", ",_", "(_", "'", "num", "'_", ",_", "distance", "\\u", "radius_", ")_", "]_", ")_", ")_", "[_", "\"", "results", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature", "\\u", "type_", "=_", "\"", "Feature", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "parent", "\\u", "obj_", "in_", "result_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "parent", "\\u", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "parent", "\\u", "obj_", "[_", "\"", "obj", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "type_", "(_", "parent", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "=_", "parent", "\\u", "obj_", "[_", "\"", "obj", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature_", "[_", "\"", "geom", "etry", "\"_", "]_", "=_", "obj_", "[_", "\"", "geom", "etry", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature_", "[_", "\"", "type", "\"_", "]_", "=_", "feature", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature_", "[_", "\"", "proper", "ties", "\"_", "]_", "=_", "obj_", "[_", "\"", "proper", "ties", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "feature_", "[_", "\"", "proper", "ties", "\"_", "]_", "[_", "\"", "k", "Near", "test", "Distan", "ce", "\"_", "]_", "=_", "parent", "\\u", "obj_", "[_", "\"", "dis", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "._", "append_", "(_", "feature_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "create", "\\u", "feature", "\\u", "collection_", "(_", "results_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "within", "\\u", "proxim", "ity_", "and_", "property_", "or_", "within", "\\u", "proxim", "ity_", "and_", "property_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "So", "rr", "y", ",", " ", "property", " ", "AND", " ", "proxim", "it", "y", " ", "search", "ing", " ", "not", " ", "currentl", "y", " ", "support", "ed", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "lo", "xo", "/", "<", "databa", "se", ">/", "collection", "s", "/", "<", "dataset", ">/", "<", "int", ":", "id", ">'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "data\\u", "by", "\\u", "id_", "(_", "database_", ",_", "dataset_", ",_", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "=_", "client_", "[_", "database_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collection_", "=_", "db_", "[_", "dataset_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "get", "\\u", "property_", "=_", "\"", "proper", "ties", ".", "lo", "xo", "\\u", "id", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return", "\\u", "feature_", "=_", "find", "\\u", "features_", "(_", "collection_", ",_", "{_", "get", "\\u", "property_", ":_", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "response_", "(_", "return", "\\u", "feature_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
algorhythms/HackerRankAlgorithms/Stock Maximize.py
[ { "content": "# -*- coding: utf-8 -*-\n\"\"\"\nProblem Statement\n\nYour algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange\nToothpicks Inc. (WOT) will be for the next N days.\n\nEach day, you can either buy one share of WOT, sell any number of shares of WOT that you own, or not make any\ntransaction at all. What is the maximum profit you can obtain with an optimum trading strategy?\n\"\"\"\n__author__ = 'Danyang'\n\n\n\n\nif __name__ == \"__main__\":\n import sys\n\n f = open(\"0.in\", \"r\")\n # f = sys.stdin\n solution = Solution()\n testcases = int(f.readline().strip())\n\n for t in xrange(testcases):\n # construct cipher\n N = int(f.readline().strip())\n A = map(int, f.readline().strip().split(' '))\n cipher = N, A\n # solve\n s = \"%s\\n\" % (solution.solve(cipher))\n print s,\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Solution(object):", "metadata": "root.Solution", "header": "['module', '___EOS___']", "index": 13 }, { "content": " def solve(self, cipher):\n \"\"\"\n Buy one, sell many\n\n dp: get the largest from right\n f[i] = max(a_i, f[i+1])\n :param cipher: the cipher\n \"\"\"\n N, A = cipher\n f = [0 for _ in A]\n f[N - 1] = A[N - 1]\n for i in xrange(N - 2, -1, -1):\n f[i] = max(A[i], f[i + 1])\n\n profit = 0\n for i in xrange(N - 1):\n profit += max(0, f[i + 1] - A[i])\n\n return profit", "metadata": "root.Solution.solve", "header": "['class', 'Solution', '(', 'object', ')', ':', '___EOS___']", "index": 14 } ]
[ { "span": "import sys", "start_line": 36, "start_column": 4, "end_line": 36, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Prob", "lem", " ", "State", "ment", "\\", "10", ";", "\\", "10", ";", "You", "r", " ", "algo", "rit", "hms", " ", "have", " ", "bec", "ome", " ", "so", " ", "good", " ", "at", " ", "predicti", "ng", " ", "the", " ", "market", " ", "tha", "t", " ", "you", " ", "now", " ", "know", " ", "what", " ", "the", " ", "share", " ", "price", " ", "of", " ", "Wood", "en", " ", "Ora", "nge", "\\", "10", ";", "Too", "th", "picks", " ", "Inc", ".", " ", "(", "WO", "T", ")", " ", "will", " ", "be", " ", "for", " ", "the", " ", "next", " ", "N", " ", "day", "s", ".", "\\", "10", ";", "\\", "10", ";", "Ea", "ch", " ", "day", ",", " ", "you", " ", "can", " ", "eit", "her", " ", "buy", " ", "one", " ", "share", " ", "of", " ", "WO", "T", ",", " ", "sell", " ", "any", " ", "number", " ", "of", " ", "share", "s", " ", "of", " ", "WO", "T", " ", "tha", "t", " ", "you", " ", "own", ",", " ", "or", " ", "not", " ", "make", " ", "any", "\\", "10", ";", "transaction", " ", "at", " ", "all", ".", " ", "What", " ", "is", " ", "the", " ", "maxim", "um", " ", "profit", " ", "you", " ", "can", " ", "obtain", " ", "with", " ", "an", " ", "optim", "um", " ", "trading", " ", "strat", "eg", "y", "?", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "'", "Dan", "yan", "g", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "open_", "(_", "\"", "0.", "in", "\"_", ",_", "\"", "r", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "f", " ", "=", " ", "sys", ".", "stdin_", "\\u\\u\\uNL\\u\\u\\u_", "solution_", "=_", "Solution_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "testcases", "_", "=_", "int_", "(_", "f_", "._", "readline_", "(_", ")_", "._", "strip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "t_", "in_", "xrange_", "(_", "testcases", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "construct", " ", "cipher_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "N_", "=_", "int_", "(_", "f_", "._", "readline_", "(_", ")_", "._", "strip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "map_", "(_", "int_", ",_", "f_", "._", "readline_", "(_", ")_", "._", "strip_", "(_", ")_", "._", "split_", "(_", "'", " ", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cipher_", "=_", "N_", ",_", "A_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "solve_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "\"%", "s", "\\\\", "n", "\"_", "%_", "(_", "solution_", "._", "solve_", "(_", "cipher_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "s_", ",_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Solution_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Solution_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "solve_", "(_", "self_", ",_", "cipher_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Bu", "y", " ", "one", ",", " ", "sell", " ", "many", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "dp", ":", " ", "get", " ", "the", " ", "large", "st", " ", "from", " ", "right", "\\", "10", ";", " ", " ", " ", " ", "f", "[", "i", "]", " ", "=", " ", "max", "(", "a", "\\u", "i", ",", " ", "f", "[", "i", "+", "1", "])", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "cipher", ":", " ", "the", " ", "cipher", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "N_", ",_", "A_", "=_", "cipher_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "[_", "0_", "for_", "\\u_", "in_", "A_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "[_", "N_", "-_", "1_", "]_", "=_", "A_", "[_", "N_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "N_", "-_", "2_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "[_", "i_", "]_", "=_", "max_", "(_", "A_", "[_", "i_", "]_", ",_", "f_", "[_", "i_", "+_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "profit", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "N_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "profit", "_", "+=_", "max_", "(_", "0_", ",_", "f_", "[_", "i_", "+_", "1_", "]_", "-_", "A_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDED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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
fp7-ofelia/ocf/expedient/src/python/plugins/openflow/tests/manual_test/manual.py
[ { "content": "import sys\nfrom os.path import dirname, join\nSRC_DIR = join(dirname(__file__), '../../../')\nsys.path.append(SRC_DIR)\n\nfrom unittest import TestCase\nfrom expedient.common.tests.commands import call_env_command, Env\nfrom openflow.tests import test_settings\nfrom expedient.common.tests.utils import wrap_xmlrpc_call\nimport xmlrpclib\nimport random\nfrom pprint import pprint\nimport logging\n\nlogger = logging.getLogger(\"manual_test\")\n\nSCHEME = \"https\" if test_settings.USE_HTTPS else \"http\"\n\n\nif __name__ == '__main__':\n import unittest\n unittest.main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ManualTests(TestCase):\n \n \n \n ", "metadata": "root.ManualTests", "header": "['module', '___EOS___']", "index": 18 }, { "content": " def setUp(self):\n \"\"\"\n Load up a DB for the OM.\n Create a client to talk to the OM.\n \"\"\"\n \n \n call_env_command(test_settings.OM_PROJECT_DIR, \"flush\",\n interactive=False)\n self.om_env = Env(test_settings.OM_PROJECT_DIR)\n self.om_env.switch_to()\n \n from openflow.optin_manager.dummyfv.models import DummyFV\n from openflow.optin_manager.xmlrpc_server.models import FVServerProxy\n from openflow.optin_manager.users.models import UserProfile\n from django.contrib.auth.models import User \n\n # Create the clearinghouse user\n username = \"clearinghouse\"\n password = \"password\"\n u = User.objects.create(username=username)\n u.set_password(password)\n u.save()\n \n profile = UserProfile.get_or_create_profile(u) \n profile.is_clearinghouse_user = True\n profile.save()\n self.om_client = xmlrpclib.ServerProxy(\n SCHEME + \"://%s:%s@%s:%s/xmlrpc/xmlrpc/\" % (\n username, password, test_settings.HOST, test_settings.OM_PORT\n )\n )\n \n #creat admin user: use this to look at DBs through admin interface\n username = \"admin\"\n password = \"password\"\n u = User.objects.create(username=username, is_superuser=True,\n is_staff=True, is_active=True)\n u.set_password(password)\n u.save()\n profile = UserProfile.get_or_create_profile(u) \n profile.is_net_admin = True\n profile.supervisor = u\n profile.max_priority_level = 7000\n profile.save() \n \n \n # Create dummy FVs\n for i in range(test_settings.NUM_DUMMY_FVS):\n fv = DummyFV.objects.create()\n # Load up a fake topology in the Dummy FV\n fv.populateTopology(10, 20, use_random=test_settings.USE_RANDOM)\n \n # create fake users for the Dummy FV\n username = \"om%s\" % i\n password = \"password\"\n u = User.objects.create(username=username)\n u.set_password(password)\n u.save()\n\n # Create the FV proxy connection\n FVServerProxy.objects.create(\n name=\"Flowvisor %s\" % i,\n username=username,\n password=password,\n url = SCHEME+\"://%s:%s/dummyfv/%s/xmlrpc/\" % (\n test_settings.HOST, test_settings.OM_PORT, fv.id,\n ),\n )", "metadata": "root.ManualTests.setUp", "header": "['class', 'ManualTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 20 }, { "content": " def test_case1(self):\n from django.contrib.auth.models import User\n from openflow.optin_manager.opts.models import UserFlowSpace,Experiment, ExperimentFLowSpace\n\n # create a second experiemnt \n username = \"user\"\n password = \"password\"\n u = User.objects.create(username=username, is_active=True)\n u.set_password(password)\n u.save()\n self.user_ip_src_s = random.randint(0,0x80000000) & 0xFFFF0000\n self.user_ip_src_e = random.randint(0x80000000,0xFFFFFFFF) & 0xFFFF0000\n #assign flowspace to user\n adm = User.objects.get(username=\"admin\")\n ufs = UserFlowSpace(user=u, ip_src_s=self.user_ip_src_s,\n ip_src_e=self.user_ip_src_e,approver=adm)\n ufs.save()\n \n Experiment.objects.all().delete()\n ExperimentFLowSpace.objects.all().delete()\n \n exp = Experiment.objects.create(slice_id=\"first_id\", project_name=\"first_project\",\n project_desc=\"project description\", slice_name=\"first slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:01\",\n ip_src_s=0x05866000, \n ip_src_e=0xa0000000, \n ) \n \n exp = Experiment.objects.create(slice_id=\"second_id\", project_name=\"second_project\",\n project_desc=\"project description\", slice_name=\"second slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:02\",\n ip_src_s=0x00123456, \n ip_src_e=0x90123456, \n ) \n \n exp = Experiment.objects.create(slice_id=\"third_id\", project_name=\"third_project\",\n project_desc=\"project description\", slice_name=\"third slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:03\",\n ip_src_s=0x00333456, \n ip_src_e=0x95123456, \n ) ", "metadata": "root.ManualTests.test_case1", "header": "['class', 'ManualTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 90 }, { "content": " def test_case2(self):\n from django.contrib.auth.models import User\n from openflow.optin_manager.opts.models import UserFlowSpace,Experiment, ExperimentFLowSpace\n\n # create a second experiemnt \n username = \"user\"\n password = \"password\"\n u = User.objects.create(username=username, is_active=True)\n u.set_password(password)\n u.save()\n\n adm = User.objects.get(username=\"admin\")\n\n # create a second experiemnt \n username = \"user2\"\n password = \"password\"\n u = User.objects.create(username=username, is_active=True)\n u.set_password(password)\n u.save()\n\n \n Experiment.objects.all().delete()\n ExperimentFLowSpace.objects.all().delete()\n \n exp = Experiment.objects.create(slice_id=\"first_id\", project_name=\"first_project\",\n project_desc=\"project description\", slice_name=\"first slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:01\",\n ip_src_s=0x05866000, \n ip_src_e=0xa0000000, \n ) \n \n exp = Experiment.objects.create(slice_id=\"second_id\", project_name=\"second_project\",\n project_desc=\"project description\", slice_name=\"second slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:02\",\n ip_src_s=0x00123456, \n ip_src_e=0x90123456, \n ) \n \n exp = Experiment.objects.create(slice_id=\"third_id\", project_name=\"third_project\",\n project_desc=\"project description\", slice_name=\"third slice\",\n slice_desc=\"slice description\", controller_url=\"http://controller.com\",\n owner_email=\"owner email\", owner_password=\"owner password\") \n expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid=\"00:00:00:00:00:00:03\",\n ip_src_s=0x00333456, \n ip_src_e=0x95123456, \n ) ", "metadata": "root.ManualTests.test_case2", "header": "['class', 'ManualTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 139 } ]
[ { "span": "from expedient.common.tests.utils import wrap_xmlrpc_call", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 57 }, { "span": "from pprint import pprint", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "._", "path_", "import_", "dirname_", ",_", "join_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SR", "C", "\\u", "DIR_", "=_", "join_", "(_", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "'../../", "..", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "SR", "C", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "unittest_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "tests_", "._", "commands_", "import_", "call", "\\u", "env", "\\u", "command_", ",_", "Env_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openf", "low_", "._", "tests_", "import_", "test\\u", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "tests_", "._", "utils_", "import_", "wrap", "\\u", "xmlrpc", "\\u", "call_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "xmlrpclib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pprint_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\"", "manu", "al", "\\u", "test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SCHEME", "_", "=_", "\"", "https", "\"_", "if_", "test\\u", "settings_", "._", "USE", "\\u", "HTTP", "S_", "else_", "\"", "http", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unittest_", "._", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Manu", "al", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Manu", "al", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Load", " ", "up", " ", "a", " ", "DB", " ", "for", " ", "the", " ", "OM", ".", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "client", " ", "to", " ", "talk", " ", "to", " ", "the", " ", "OM", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "call", "\\u", "env", "\\u", "command_", "(_", "test\\u", "settings_", "._", "OM", "\\u", "PROJECT", "\\u", "DIR_", ",_", "\"", "flush", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "interactive_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "om", "\\u", "env_", "=_", "Env_", "(_", "test\\u", "settings_", "._", "OM", "\\u", "PROJECT", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "om", "\\u", "env_", "._", "switch", "\\u", "to_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "openf", "low_", "._", "opti", "n", "\\u", "manager_", "._", "dummy", "fv_", "._", "models_", "import_", "Du", "mm", "y", "FV", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openf", "low_", "._", "opti", "n", "\\u", "manager_", "._", "xmlrpc", "\\u", "server_", "._", "models_", "import_", "FV", "Server", "Proxy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openf", "low_", "._", "opti", "n", "\\u", "manager_", "._", "users_", "._", "models_", "import_", "User", "Profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "clear", "ing", "house", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "clear", "ing", "house", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "profile_", "=_", "User", "Profile_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "profile_", "(_", "u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "is", "\\u", "clear", "ing", "house", "\\u", "user_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "om", "\\u", "client_", "=_", "xmlrpclib_", "._", "Server", "Proxy_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "SCHEME", "_", "+_", "\":", "//", "%", "s", ":", "%", "s", "@", "%", "s", ":", "%", "s", "/", "xmlrpc", "/", "xmlrpc", "/\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", ",_", "password_", ",_", "test\\u", "settings_", "._", "HOST_", ",_", "test\\u", "settings_", "._", "OM", "\\u", "PORT_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "creat", " ", "admin", " ", "user", ":", " ", "use", " ", "this", " ", "to", " ", "look", " ", "at", " ", "DB", "s", " ", "through", " ", "admin", " ", "interface_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "admin", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ",_", "is", "\\u", "superuser_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "staff_", "=_", "True_", ",_", "is", "\\u", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "=_", "User", "Profile_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "profile_", "(_", "u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "is", "\\u", "net", "\\u", "admin_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "supervisor", "_", "=_", "u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "max", "\\u", "priorit", "y", "\\u", "level_", "=_", "7000", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "dummy", " ", "FV", "s_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "test\\u", "settings_", "._", "NUM", "\\u", "DUMMY", "\\u", "FV", "S_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fv_", "=_", "Du", "mm", "y", "FV", "_", "._", "objects_", "._", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Load", " ", "up", " ", "a", " ", "fake", " ", "topo", "log", "y", " ", "in", " ", "the", " ", "Du", "mm", "y", " ", "FV", "_", "\\u\\u\\uNL\\u\\u\\u_", "fv_", "._", "populate", "Topology", "_", "(_", "10_", ",_", "20_", ",_", "use", "\\u", "random_", "=_", "test\\u", "settings_", "._", "USE", "\\u", "RANDOM", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "fake", " ", "users", " ", "for", " ", "the", " ", "Du", "mm", "y", " ", "FV", "_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "om", "%", "s", "\"_", "%_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "FV", " ", "proxy", " ", "connection_", "\\u\\u\\uNL\\u\\u\\u_", "FV", "Server", "Proxy_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "\"", "Flow", "visor", " ", "%", "s", "\"_", "%_", "i_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "password_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "SCHEME", "_", "+_", "\":", "//", "%", "s", ":", "%", "s", "/", "dummy", "fv", "/", "%", "s", "/", "xmlrpc", "/\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "settings_", "._", "HOST_", ",_", "test\\u", "settings_", "._", "OM", "\\u", "PORT_", ",_", "fv_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manu", "al", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "case", "1_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openf", "low_", "._", "opti", "n", "\\u", "manager_", "._", "opts_", "._", "models_", "import_", "User", "Flow", "Space_", ",_", "Experiment_", ",_", "Experiment", "FL", "ow", "Space_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "second", " ", "expe", "rie", "mnt", " _", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "user", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ",_", "is", "\\u", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "user", "\\u", "ip", "\\u", "src", "\\u", "s_", "=_", "random_", "._", "randint_", "(_", "0_", ",_", "0x80000", "000_", ")_", "&_", "0xFFFF", "0000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "user", "\\u", "ip", "\\u", "src", "\\u", "e_", "=_", "random_", "._", "randint_", "(_", "0x80000", "000_", ",_", "0xFFFFFFFF", "_", ")_", "&_", "0xFFFF", "0000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "assign", " ", "flow", "space", " ", "to", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "adm", "_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "username_", "=_", "\"", "admin", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uf", "s_", "=_", "User", "Flow", "Space_", "(_", "user_", "=_", "u_", ",_", "ip", "\\u", "src", "\\u", "s_", "=_", "self_", "._", "user", "\\u", "ip", "\\u", "src", "\\u", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "self_", "._", "user", "\\u", "ip", "\\u", "src", "\\u", "e_", ",_", "approve", "r_", "=_", "adm", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uf", "s_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Experiment_", "._", "objects_", "._", "all_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "all_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "first", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "first", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "first", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "01", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x05", "866", "000_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0xa", "0000000", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "second", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "second", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "second", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "02", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x001", "23456", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0x90", "12345", "6_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "third", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "third", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "third", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "03", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x003", "334", "56_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0x95", "12345", "6_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Manu", "al", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "case", "2_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openf", "low_", "._", "opti", "n", "\\u", "manager_", "._", "opts_", "._", "models_", "import_", "User", "Flow", "Space_", ",_", "Experiment_", ",_", "Experiment", "FL", "ow", "Space_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "second", " ", "expe", "rie", "mnt", " _", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "user", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ",_", "is", "\\u", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "adm", "_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "username_", "=_", "\"", "admin", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "second", " ", "expe", "rie", "mnt", " _", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "\"", "user", "2", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "password", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "=_", "User_", "._", "objects_", "._", "create_", "(_", "username_", "=_", "username_", ",_", "is", "\\u", "active_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "set\\u", "password_", "(_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Experiment_", "._", "objects_", "._", "all_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "all_", "(_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "first", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "first", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "first", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "01", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x05", "866", "000_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0xa", "0000000", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "second", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "second", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "second", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "02", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x001", "23456", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0x90", "12345", "6_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp_", "=_", "Experiment_", "._", "objects_", "._", "create_", "(_", "slice", "\\u", "id_", "=_", "\"", "third", "\\u", "id", "\"_", ",_", "project", "\\u", "name_", "=_", "\"", "third", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project", "\\u", "desc_", "=_", "\"", "project", " ", "description", "\"_", ",_", "slice", "\\u", "name_", "=_", "\"", "third", " ", "slice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice", "\\u", "desc_", "=_", "\"", "slice", " ", "description", "\"_", ",_", "controlle", "r", "\\u", "url_", "=_", "\"", "http", "://", "controlle", "r", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "email_", "=_", "\"", "owner", " ", "email", "\"_", ",_", "owner", "\\u", "password_", "=_", "\"", "owner", " ", "password", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "fs_", "=_", "Experiment", "FL", "ow", "Space_", "._", "objects_", "._", "create_", "(_", "exp_", "=_", "exp_", ",_", "dpid_", "=_", "\"", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "00", ":", "03", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "s_", "=_", "0x003", "334", "56_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ip", "\\u", "src", "\\u", "e_", "=_", "0x95", "12345",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 2, 2 ]
Except block handles 'BaseException'
datadesk/python-documentcloud/documentcloud/__init__.py
[ { "content": " def is_url(self, string):\n \"\"\"\n Test if a pdf being submitted is a valid URL\n \"\"\"\n try:\n urlparse(string, rule=\"IRI\")\n return True\n except:\n return False", "metadata": "root.DocumentClient.is_url", "header": "['class', 'DocumentClient', '(', 'BaseDocumentCloudClient', ')', ':', '___EOS___']", "index": 181 }, { "content": " @credentials_required\n def upload(\n self, pdf, title=None, source=None, description=None,\n related_article=None, published_url=None, access='private',\n project=None, data=None, secure=False, force_ocr=False\n ):\n \"\"\"\n Upload a PDF or other image file to DocumentCloud.\n\n You can submit either a pdf opened as a file object or a path\n to a pdf file.\n\n Example usage:\n\n # From a file path\n >> documentcloud.documents.upload(\n >> \"/home/ben/sample.pdf\",\n >> \"sample title\"\n >>)\n\n # From a file object\n >> pdf = open(path, 'rb')\n >> documentcloud.documents.upload(pdf, \"sample title\")\n\n Returns the document that's created as a Document object.\n\n Based on code developed by Mitchell Kotler and\n refined by Christopher Groskopf.\n \"\"\"\n # Required pdf parameter\n if hasattr(pdf, 'read'):\n try:\n size = os.fstat(pdf.fileno()).st_size\n except:\n size = 0\n params = {'file': pdf}\n opener = MultipartPostHandler\n elif self.is_url(pdf):\n size = 0\n params = {'file': pdf}\n opener = PostHandler # URL uploads don't need MultiPart\n else:\n size = os.path.getsize(pdf)\n params = {'file': open(pdf, 'rb')}\n opener = MultipartPostHandler\n # Enforce file size limit of the DocumentCloud API\n if size >= 399999999:\n raise ValueError(\"The pdf you have submitted is over the \\\nDocumentCloud API's 400MB file size limit. Split it into smaller pieces \\\nand try again.\")\n # Optional parameters\n if title:\n params['title'] = title\n else:\n # Set it to the file name\n if hasattr(pdf, 'read'):\n params['title'] = pdf.name.split(os.sep)[-1].split(\".\")[0]\n else:\n params['title'] = pdf.split(os.sep)[-1].split(\".\")[0]\n if source:\n params['source'] = source\n if description:\n params['description'] = description\n if related_article:\n params['related_article'] = related_article\n if published_url:\n params['published_url'] = published_url\n if access:\n params['access'] = access\n if project:\n params['project'] = project\n if data:\n for key, value in list(data.items()):\n is_valid_data_keyword(key)\n params['data[%s]' % key] = value\n if secure:\n params['secure'] = 'true'\n if force_ocr:\n params['force_ocr'] = 'true'\n # Make the request\n response = self._make_request(\n self.BASE_URI + 'upload.json',\n params,\n opener=opener\n )\n return self.get(json.loads(response.decode(\"utf-8\"))['id'])", "metadata": "root.DocumentClient.upload", "header": "['class', 'DocumentClient', '(', 'BaseDocumentCloudClient', ')', ':', '___EOS___']", "index": 275 } ]
[ { "span": "except:", "start_line": 188, "start_column": 8, "end_line": 188, "end_column": 15 }, { "span": "except:", "start_line": 308, "start_column": 12, "end_line": 308, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Document", "Client_", "(_", "Base", "Document", "Cloud", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "url_", "(_", "self_", ",_", "string_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "if", " ", "a", " ", "pdf", " ", "bei", "ng", " ", "submitted", " ", "is", " ", "a", " ", "valid", " ", "URL", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urlparse_", "(_", "string_", ",_", "rule_", "=_", "\"", "IRI", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Document", "Client_", "(_", "Base", "Document", "Cloud", "Client_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "cred", "ential", "s", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "upload_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", ",_", "pdf_", ",_", "title_", "=_", "None_", ",_", "source_", "=_", "None_", ",_", "description_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "relate", "d\\u", "article_", "=_", "None_", ",_", "publi", "shed", "\\u", "url_", "=_", "None_", ",_", "access_", "=_", "'", "private", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "None_", ",_", "data_", "=_", "None_", ",_", "secure_", "=_", "False_", ",_", "force", "\\u", "ocr", "_", "=_", "False_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Upload", " ", "a", " ", "PD", "F", " ", "or", " ", "other", " ", "image", " ", "file", " ", "to", " ", "Document", "Cloud", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "can", " ", "submit", " ", "eit", "her", " ", "a", " ", "pdf", " ", "opene", "d", " ", "as", " ", "a", " ", "file", " ", "object", " ", "or", " ", "a", " ", "path", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "a", " ", "pdf", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ple", " ", "usage", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Fro", "m", " ", "a", " ", "file", " ", "path", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "document", "cloud", ".", "document", "s", ".", "upload", "(", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", " ", "\"/", "home", "/", "ben", "/", "sample", ".", "pdf", "\",", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", " ", "\"", "sample", " ", "title", "\"", "\\", "10", ";", " ", " ", " ", " ", ">>", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Fro", "m", " ", "a", " ", "file", " ", "object", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "pdf", " ", "=", " ", "open", "(", "path", ",", " ", "'", "rb", "')", "\\", "10", ";", " ", " ", " ", " ", ">>", " ", "document", "cloud", ".", "document", "s", ".", "upload", "(", "pdf", ",", " ", "\"", "sample", " ", "title", "\")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "document", " ", "tha", "t", "'", "s", " ", "created", " ", "as", " ", "a", " ", "Document", " ", "object", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "on", " ", "code", " ", "develop", "ed", " ", "by", " ", "Mit", "che", "ll", " ", "Ko", "tle", "r", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "refine", "d", " ", "by", " ", "Christ", "oph", "er", " ", "Gro", "sko", "pf", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Requ", "ired", " ", "pdf", " ", "parameter_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hasattr_", "(_", "pdf_", ",_", "'", "read", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "os_", "._", "fsta", "t_", "(_", "pdf_", "._", "fileno_", "(_", ")_", ")_", "._", "st", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "{_", "'", "file", "'_", ":_", "pdf_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opener_", "=_", "Multipart", "Post", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "is", "\\u", "url_", "(_", "pdf_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "{_", "'", "file", "'_", ":_", "pdf_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opener_", "=_", "Post", "Handler_", "#", " ", "URL", " ", "uploads", " ", "don", "'", "t", " ", "need", " ", "Multi", "Part_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "os_", "._", "path_", "._", "getsize_", "(_", "pdf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "{_", "'", "file", "'_", ":_", "open_", "(_", "pdf_", ",_", "'", "rb", "'_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "opener_", "=_", "Multipart", "Post", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Enf", "orce", " ", "file", " ", "size", " ", "limit", " ", "of", " ", "the", " ", "Document", "Cloud", " ", "API_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "size_", ">=_", "399", "999999", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "The", " ", "pdf", " ", "you", " ", "have", " ", "submitted", " ", "is", " ", "over", " ", "the", " ", "\\\\", "\\", "10", ";", "Document", "Cloud", " ", "API", "'", "s", " ", "400", "MB", " ", "file", " ", "size", " ", "limit", ".", " ", "Split", " ", "it", " ", "int", "o", " ", "small", "er", " ", "piece", "s", " ", "\\\\", "\\", "10", ";", "and", " ", "try", " ", "again", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Optio", "nal", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "title_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "title", "'_", "]_", "=_", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Set", " ", "it", " ", "to", " ", "the", " ", "file", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "pdf_", ",_", "'", "read", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "title", "'_", "]_", "=_", "pdf_", "._", "name_", "._", "split_", "(_", "os_", "._", "sep_", ")_", "[_", "-_", "1_", "]_", "._", "split_", "(_", "\".\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "title", "'_", "]_", "=_", "pdf_", "._", "split_", "(_", "os_", "._", "sep_", ")_", "[_", "-_", "1_", "]_", "._", "split_", "(_", "\".\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "source_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "source", "'_", "]_", "=_", "source_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "description_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "description", "'_", "]_", "=_", "description_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "relate", "d\\u", "article_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "relate", "d\\u", "article", "'_", "]_", "=_", "relate", "d\\u", "article_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "publi", "shed", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "publi", "shed", "\\u", "url", "'_", "]_", "=_", "publi", "shed", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "access_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "access", "'_", "]_", "=_", "access_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "project_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "project", "'_", "]_", "=_", "project_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "list_", "(_", "data_", "._", "items_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "\\u", "valid", "\\u", "data\\u", "keyword_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "[_", "'", "data", "[", "%", "s", "]'_", "%_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "secure_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "secure", "'_", "]_", "=_", "'", "true", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "force", "\\u", "ocr", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "force", "\\u", "ocr", "'_", "]_", "=_", "'", "true", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "self_", "._", "\\u", "make", "\\u", "request_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "BASE", "\\u", "URI_", "+_", "'", "upload", ".", "json", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "opener_", "=_", "opener_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "get_", "(_", "json_", "._", "loads_", "(_", "response_", "._", "decode_", "(_", "\"", "utf", "-", "8", "\"_", ")_", ")_", "[_", "'", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
greenmoss/PyWavefront/pywavefront/__init__.py
[ { "content": " def parse_f(self, args):\n if (len(self.tex_coords) > 1) and (len(self.normals) == 1): \n # does the spec allow for texture coordinates without normals?\n # if we allow this condition, the user will get a black screen\n # which is really confusing\n raise PywavefrontException('Found texture coordinates, but no normals')\n\n if self.mesh is None:\n self.mesh = mesh.Mesh()\n self.wavefront.add_mesh(self.mesh)\n if self.material is None:\n self.material = material.Material()\n self.mesh.add_material(self.material)\n\n # For fan triangulation, remember first and latest vertices\n v1 = None\n vlast = None\n points = []\n for i, v in enumerate(args[0:]):\n if type(v) is bytes:\n v = v.decode()\n v_index, t_index, n_index = \\\n (list(map(int, [j or 0 for j in v.split('/')])) + [0, 0])[:3]\n if v_index < 0:\n v_index += len(self.vertices) - 1\n if t_index < 0:\n t_index += len(self.tex_coords) - 1\n if n_index < 0:\n n_index += len(self.normals) - 1\n vertex = list(self.tex_coords[t_index]) + \\\n list(self.normals[n_index]) + \\\n list(self.vertices[v_index]) \n\n if i >= 3:\n # Triangulate\n self.material.vertices += v1 + vlast\n self.material.vertices += vertex\n\n if i == 0:\n v1 = vertex\n vlast = vertex", "metadata": "root.ObjParser.parse_f", "header": "['class', 'ObjParser', '(', 'parser', '.', 'Parser', ')', ':', '___EOS___']", "index": 108 } ]
[ { "span": "points ", "start_line": 125, "start_column": 8, "end_line": 125, "end_column": 14 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Obj", "Parser_", "(_", "parser_", "._", "Parser_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "\\u", "f_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "len_", "(_", "self_", "._", "tex", "\\u", "coords_", ")_", ">_", "1_", ")_", "and_", "(_", "len_", "(_", "self_", "._", "normals_", ")_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "doe", "s", " ", "the", " ", "spec", " ", "allow", " ", "for", " ", "textu", "re", " ", "coordinate", "s", " ", "with", "out", " ", "normal", "s", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "allow", " ", "this", " ", "condition", ",", " ", "the", " ", "user", " ", "will", " ", "get", " ", "a", " ", "black", " ", "screen_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whi", "ch", " ", "is", " ", "reall", "y", " ", "conf", "using_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Py", "wavef", "ront", "Exception_", "(_", "'", "Foun", "d", " ", "textu", "re", " ", "coordinate", "s", ",", " ", "but", " ", "no", " ", "normal", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "mesh_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mesh_", "=_", "mesh_", "._", "Mesh_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wavef", "ront", "_", "._", "add", "\\u", "mesh_", "(_", "self_", "._", "mesh_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "material_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "material_", "=_", "material_", "._", "Material_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "mesh_", "._", "add", "\\u", "material_", "(_", "self_", "._", "material_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "fan", " ", "triang", "ulation", ",", " ", "remember", " ", "first", " ", "and", " ", "late", "st", " ", "vertices_", "\\u\\u\\uNL\\u\\u\\u_", "v1_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vla", "st_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "points_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "v_", "in_", "enumerate_", "(_", "args_", "[_", "0_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "v_", ")_", "is_", "bytes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "v_", "._", "decode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "v", "\\u", "index_", ",_", "t", "\\u", "index_", ",_", "n", "\\u", "index_", "=_", "(_", "list_", "(_", "map_", "(_", "int_", ",_", "[_", "j_", "or_", "0_", "for_", "j_", "in_", "v_", "._", "split_", "(_", "'/'_", ")_", "]_", ")_", ")_", "+_", "[_", "0_", ",_", "0_", "]_", ")_", "[_", ":_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "v", "\\u", "index_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v", "\\u", "index_", "+=_", "len_", "(_", "self_", "._", "vertices_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "t", "\\u", "index_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t", "\\u", "index_", "+=_", "len_", "(_", "self_", "._", "tex", "\\u", "coords_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "n", "\\u", "index_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n", "\\u", "index_", "+=_", "len_", "(_", "self_", "._", "normals_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vertex_", "=_", "list_", "(_", "self_", "._", "tex", "\\u", "coords_", "[_", "t", "\\u", "index_", "]_", ")_", "+_", "list_", "(_", "self_", "._", "normals_", "[_", "n", "\\u", "index_", "]_", ")_", "+_", "list_", "(_", "self_", "._", "vertices_", "[_", "v", "\\u", "index_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "i_", ">=_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tria", "ngul", "ate_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "material_", "._", "vertices_", "+=_", "v1_", "+_", "vla", "st_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "material_", "._", "vertices_", "+=_", "vertex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "i_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v1_", "=_", "vertex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vla", "st_", "=_", "vertex_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
nlloyd/SubliminalCollaborator/libs/twisted/web/_newclient.py
[ { "content": "def _callAppFunction(function):\n \"\"\"\n Call C{function}. If it raises an exception, log it with a minimal\n description of the source.\n\n @return: C{None}\n \"\"\"\n try:\n function()\n except:\n log.err(None, \"Unexpected exception from %s\" % (\n fullyQualifiedName(function),))", "metadata": "root._callAppFunction", "header": "['module', '___EOS___']", "index": 182 }, { "content": " def connectionLost(self, reason):\n if self.bodyDecoder is not None:\n try:\n try:\n self.bodyDecoder.noMoreData()\n except PotentialDataLoss:\n self.response._bodyDataFinished(Failure())\n except _DataLoss:\n self.response._bodyDataFinished(\n Failure(ResponseFailed([reason, Failure()],\n self.response)))\n else:\n self.response._bodyDataFinished()\n except:\n # Handle exceptions from both the except suites and the else\n # suite. Those functions really shouldn't raise exceptions,\n # but maybe there's some buggy application code somewhere\n # making things difficult.\n log.err()\n elif self.state != DONE:\n if self._everReceivedData:\n exceptionClass = ResponseFailed\n else:\n exceptionClass = ResponseNeverReceived\n self._responseDeferred.errback(Failure(exceptionClass([reason])))\n del self._responseDeferred", "metadata": "root.HTTPClientParser.connectionLost", "header": "['class', 'HTTPClientParser', '(', 'HTTPParser', ')', ':', '___EOS___']", "index": 514 }, { "content": " def _writeToContentLength(self, transport):\n \"\"\"\n Write this request to the given transport using content-length to frame\n the body.\n \"\"\"\n self._writeHeaders(\n transport,\n 'Content-Length: %d\\r\\n' % (self.bodyProducer.length,))\n\n # This Deferred is used to signal an error in the data written to the\n # encoder below. It can only errback and it will only do so before too\n # many bytes have been written to the encoder and before the producer\n # Deferred fires.\n finishedConsuming = Deferred()\n\n # This makes sure the producer writes the correct number of bytes for\n # the request body.\n encoder = LengthEnforcingConsumer(\n self.bodyProducer, transport, finishedConsuming)\n\n transport.registerProducer(self.bodyProducer, True)\n\n finishedProducing = self.bodyProducer.startProducing(encoder)\n\n def combine(consuming, producing):\n # This Deferred is returned and will be fired when the first of\n # consuming or producing fires.\n ultimate = Deferred()\n\n # Keep track of what has happened so far. This initially\n # contains None, then an integer uniquely identifying what\n # sequence of events happened. See the callbacks and errbacks\n # defined below for the meaning of each value.\n state = [None]\n\n def ebConsuming(err):\n if state == [None]:\n # The consuming Deferred failed first. This means the\n # overall writeTo Deferred is going to errback now. The\n # producing Deferred should not fire later (because the\n # consumer should have called stopProducing on the\n # producer), but if it does, a callback will be ignored\n # and an errback will be logged.\n state[0] = 1\n ultimate.errback(err)\n else:\n # The consuming Deferred errbacked after the producing\n # Deferred fired. This really shouldn't ever happen.\n # If it does, I goofed. Log the error anyway, just so\n # there's a chance someone might notice and complain.\n log.err(\n err,\n \"Buggy state machine in %r/[%d]: \"\n \"ebConsuming called\" % (self, state[0]))\n\n def cbProducing(result):\n if state == [None]:\n # The producing Deferred succeeded first. Nothing will\n # ever happen to the consuming Deferred. Tell the\n # encoder we're done so it can check what the producer\n # wrote and make sure it was right.\n state[0] = 2\n try:\n encoder._noMoreWritesExpected()\n except:\n # Fail the overall writeTo Deferred - something the\n # producer did was wrong.\n ultimate.errback()\n else:\n # Success - succeed the overall writeTo Deferred.\n ultimate.callback(None)\n # Otherwise, the consuming Deferred already errbacked. The\n # producing Deferred wasn't supposed to fire, but it did\n # anyway. It's buggy, but there's not really anything to be\n # done about it. Just ignore this result.\n\n def ebProducing(err):\n if state == [None]:\n # The producing Deferred failed first. This means the\n # overall writeTo Deferred is going to errback now.\n # Tell the encoder that we're done so it knows to reject\n # further writes from the producer (which should not\n # happen, but the producer may be buggy).\n state[0] = 3\n encoder._allowNoMoreWrites()\n ultimate.errback(err)\n else:\n # The producing Deferred failed after the consuming\n # Deferred failed. It shouldn't have, so it's buggy.\n # Log the exception in case anyone who can fix the code\n # is watching.\n log.err(err, \"Producer is buggy\")\n\n consuming.addErrback(ebConsuming)\n producing.addCallbacks(cbProducing, ebProducing)\n\n return ultimate\n\n d = combine(finishedConsuming, finishedProducing)\n def f(passthrough):\n # Regardless of what happens with the overall Deferred, once it\n # fires, the producer registered way up above the definition of\n # combine should be unregistered.\n transport.unregisterProducer()\n return passthrough\n d.addBoth(f)\n return d", "metadata": "root.Request._writeToContentLength", "header": "['class', 'Request', ':', '___EOS___']", "index": 620 }, { "content": " def _finishResponse_WAITING(self, rest):\n # Currently the rest parameter is ignored. Don't forget to use it if\n # we ever add support for pipelining. And maybe check what trailers\n # mean.\n if self._state == 'WAITING':\n self._state = 'QUIESCENT'\n else:\n # The server sent the entire response before we could send the\n # whole request. That sucks. Oh well. Fire the request()\n # Deferred with the response. But first, make sure that if the\n # request does ever finish being written that it won't try to fire\n # that Deferred.\n self._state = 'TRANSMITTING_AFTER_RECEIVING_RESPONSE'\n self._responseDeferred.chainDeferred(self._finishedRequest)\n\n # This will happen if we're being called due to connection being lost;\n # if so, no need to disconnect parser again, or to call\n # _quiescentCallback.\n if self._parser is None:\n return\n\n reason = ConnectionDone(\"synthetic!\")\n connHeaders = self._parser.connHeaders.getRawHeaders('connection', ())\n if (('close' in connHeaders) or self._state != \"QUIESCENT\" or\n not self._currentRequest.persistent):\n self._giveUp(Failure(reason))\n else:\n # We call the quiescent callback first, to ensure connection gets\n # added back to connection pool before we finish the request.\n try:\n self._quiescentCallback(self)\n except:\n # If callback throws exception, just log it and disconnect;\n # keeping persistent connections around is an optimisation:\n log.err()\n self.transport.loseConnection()\n self._disconnectParser(reason)", "metadata": "root.HTTP11ClientProtocol._finishResponse_WAITING", "header": "['class', 'HTTP11ClientProtocol', '(', 'Protocol', ')', ':', '___EOS___']", "index": 1334 }, { "content": " def dataReceived(self, bytes):\n \"\"\"\n Handle some stuff from some place.\n \"\"\"\n try:\n self._parser.dataReceived(bytes)\n except:\n self._giveUp(Failure())", "metadata": "root.HTTP11ClientProtocol.dataReceived", "header": "['class', 'HTTP11ClientProtocol', '(', 'Protocol', ')', ':', '___EOS___']", "index": 1411 } ]
[ { "span": "except:", "start_line": 191, "start_column": 4, "end_line": 191, "end_column": 11 }, { "span": "except:", "start_line": 527, "start_column": 12, "end_line": 527, "end_column": 19 }, { "span": "except:", "start_line": 684, "start_column": 20, "end_line": 684, "end_column": 27 }, { "span": "except:", "start_line": 1365, "start_column": 12, "end_line": 1365, "end_column": 19 }, { "span": "except:", "start_line": 1417, "start_column": 8, "end_line": 1417, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "call", "App", "Function_", "(_", "function_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "C", "{", "function", "}.", " ", " ", "If", " ", "it", " ", "raise", "s", " ", "an", " ", "exception", ",", " ", "log", " ", "it", " ", "with", " ", "a", " ", "minima", "l", "\\", "10", ";", " ", " ", " ", " ", "description", " ", "of", " ", "the", " ", "source", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "Non", "e", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "function_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "err_", "(_", "None_", ",_", "\"", "Une", "xpe", "cte", "d", " ", "exception", " ", "from", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "full", "y", "Qualifi", "ed", "Name_", "(_", "function_", ")_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Client", "Parser_", "(_", "HTTP", "Parser_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "Lost", "_", "(_", "self_", ",_", "reason_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "body", "Decoder_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "body", "Decoder_", "._", "no", "Mor", "e", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Pot", "ential", "Data", "Loss_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "response_", "._", "\\u", "body", "Data", "Finished_", "(_", "Failure_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "\\u", "Data", "Loss_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "response_", "._", "\\u", "body", "Data", "Finished_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Failure_", "(_", "Respons", "e", "Failed_", "(_", "[_", "reason_", ",_", "Failure_", "(_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "response_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "response_", "._", "\\u", "body", "Data", "Finished_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Handle", " ", "exception", "s", " ", "from", " ", "bot", "h", " ", "the", " ", "except", " ", "suites", " ", "and", " ", "the", " ", "else_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "suit", "e", ".", " ", " ", "Tho", "se", " ", "function", "s", " ", "reall", "y", " ", "shou", "ld", "n", "'", "t", " ", "raise", " ", "exception", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "may", "be", " ", "there", "'", "s", " ", "some", " ", "bug", "gy", " ", "applica", "tion", " ", "code", " ", "some", "where_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mak", "ing", " ", "thing", "s", " ", "difficult", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "err_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "state_", "!=_", "DONE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "ever", "Receive", "d", "Data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exception", "Class_", "=_", "Respons", "e", "Failed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exception", "Class_", "=_", "Respons", "e", "Never", "Received_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "response", "Deferred_", "._", "errback", "_", "(_", "Failure_", "(_", "exception", "Class_", "(_", "[_", "reason_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "\\u", "response", "Deferred_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Request_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "write", "To", "Conten", "t", "Length_", "(_", "self_", ",_", "transport_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Write", " ", "this", " ", "request", " ", "to", " ", "the", " ", "give", "n", " ", "transport", " ", "usi", "ng", " ", "content", "-", "length", " ", "to", " ", "frame", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "body", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "write", "Headers_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "transport_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Conten", "t", "-", "Length", ":", " ", "%", "d", "\\\\", "r", "\\\\", "n", "'_", "%_", "(_", "self_", "._", "body", "Producer_", "._", "length_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "Defe", "rre", "d", " ", "is", " ", "used", " ", "to", " ", "signal", " ", "an", " ", "error", " ", "in", " ", "the", " ", "data", " ", "writt", "en", " ", "to", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encode", "r", " ", "belo", "w", ".", " ", " ", "It", " ", "can", " ", "only", " ", "errback", " ", "and", " ", "it", " ", "will", " ", "only", " ", "do", " ", "so", " ", "bef", "ore", " ", "too", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "many", " ", "bytes", " ", "have", " ", "bee", "n", " ", "writt", "en", " ", "to", " ", "the", " ", "encode", "r", " ", "and", " ", "bef", "ore", " ", "the", " ", "producer_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Defe", "rre", "d", " ", "fires", "._", "\\u\\u\\uNL\\u\\u\\u_", "finish", "ed", "Consu", "ming", "_", "=_", "Deferred_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "make", "s", " ", "sure", " ", "the", " ", "producer", " ", "writes", " ", "the", " ", "correct", " ", "number", " ", "of", " ", "bytes", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "request", " ", "body", "._", "\\u\\u\\uNL\\u\\u\\u_", "encoder_", "=_", "Length", "Enf", "orc", "ing", "Consumer_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "body", "Producer_", ",_", "transport_", ",_", "finish", "ed", "Consu", "ming", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "transport_", "._", "register", "Producer_", "(_", "self_", "._", "body", "Producer_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "finish", "ed", "Produ", "cing", "_", "=_", "self_", "._", "body", "Producer_", "._", "start", "Produ", "cing", "_", "(_", "encoder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "combine_", "(_", "consum", "ing_", ",_", "produc", "ing_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "Defe", "rre", "d", " ", "is", " ", "return", "ed", " ", "and", " ", "will", " ", "be", " ", "fired", " ", "whe", "n", " ", "the", " ", "first", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "consum", "ing", " ", "or", " ", "produc", "ing", " ", "fires", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ultima", "te_", "=_", "Deferred_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Keep", " ", "track", " ", "of", " ", "what", " ", "has", " ", "happ", "ened", " ", "so", " ", "far", ".", " ", " ", "Thi", "s", " ", "initially", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contain", "s", " ", "Non", "e", ",", " ", "then", " ", "an", " ", "integ", "er", " ", "unique", "ly", " ", "identify", "ing", " ", "what_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sequence", " ", "of", " ", "events", " ", "happ", "ened", ".", " ", " ", "See", " ", "the", " ", "callback", "s", " ", "and", " ", "errback", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defin", "ed", " ", "belo", "w", " ", "for", " ", "the", " ", "meaning", " ", "of", " ", "each", " ", "value", "._", "\\u\\u\\uNL\\u\\u\\u_", "state_", "=_", "[_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "eb", "Consu", "ming", "_", "(_", "err_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "state_", "==_", "[_", "None_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "consum", "ing", " ", "Defe", "rre", "d", " ", "fail", "ed", " ", "first", ".", " ", " ", "Thi", "s", " ", "means", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "over", "all", " ", "write", "To", " ", "Defe", "rre", "d", " ", "is", " ", "goi", "ng", " ", "to", " ", "errback", " ", "now", ".", " ", " ", "The", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "produc", "ing", " ", "Defe", "rre", "d", " ", "shou", "ld", " ", "not", " ", "fire", " ", "late", "r", " ", "(", "bec", "aus", "e", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "consume", "r", " ", "shou", "ld", " ", "have", " ", "call", "ed", " ", "stop", "Produ", "cing", " ", "on", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "producer", "),", " ", "but", " ", "if", " ", "it", " ", "doe", "s", ",", " ", "a", " ", "callback", " ", "will", " ", "be", " ", "ignored_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "an", " ", "errback", " ", "will", " ", "be", " ", "logged", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "state_", "[_", "0_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ultima", "te_", "._", "errback", "_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "consum", "ing", " ", "Defe", "rre", "d", " ", "errback", "ed", " ", "after", " ", "the", " ", "produc", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Defe", "rre", "d", " ", "fired", ".", " ", " ", "Thi", "s", " ", "reall", "y", " ", "shou", "ld", "n", "'", "t", " ", "ever", " ", "happ", "en", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "it", " ", "doe", "s", ",", " ", "I", " ", "goo", "fed", ".", " ", " ", "Log", " ", "the", " ", "error", " ", "anyway", ",", " ", "just", " ", "so_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "there", "'", "s", " ", "a", " ", "chan", "ce", " ", "some", "one", " ", "mig", "ht", " ", "notice", " ", "and", " ", "compl", "ain", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "log_", "._", "err_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "err_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Bug", "gy", " ", "state", " ", "machine", " ", "in", " ", "%", "r", "/", "[", "%", "d", "]:", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "eb", "Consu", "ming", " ", "call", "ed", "\"_", "%_", "(_", "self_", ",_", "state_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cb", "Produ", "cing", "_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "state_", "==_", "[_", "None_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "produc", "ing", " ", "Defe", "rre", "d", " ", "succe", "eded", " ", "first", ".", " ", " ", "Not", "hing", " ", "will", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ever", " ", "happ", "en", " ", "to", " ", "the", " ", "consum", "ing", " ", "Defe", "rre", "d", ".", " ", " ", "Tell", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "encode", "r", " ", "we", "'", "re", " ", "don", "e", " ", "so", " ", "it", " ", "can", " ", "check", " ", "what", " ", "the", " ", "producer_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wrote", " ", "and", " ", "make", " ", "sure", " ", "it", " ", "was", " ", "right", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "state_", "[_", "0_", "]_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "encoder_", "._", "\\u", "no", "Mor", "e", "Write", "s", "Expect", "ed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fail", " ", "the", " ", "over", "all", " ", "write", "To", " ", "Defe", "rre", "d", " ", "-", " ", "somet", "hing", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "producer", " ", "did", " ", "was", " ", "wrong", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "ultima", "te_", "._", "errback", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Success", " ", "-", " ", "succe", "ed", " ", "the", " ", "over", "all", " ", "write", "To", " ", "Defe", "rre", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "ultima", "te_", "._", "callback_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ot", "her", "wis", "e", ",", " ", "the", " ", "consum", "ing", " ", "Defe", "rre", "d", " ", "alr", "ead", "y", " ", "errback", "ed", ".", " ", " ", "The", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "produc", "ing", " ", "Defe", "rre", "d", " ", "was", "n", "'", "t", " ", "supposed", " ", "to", " ", "fire", ",", " ", "but", " ", "it", " ", "did_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "anyway", ".", " ", " ", "It", "'", "s", " ", "bug", "gy", ",", " ", "but", " ", "there", "'", "s", " ", "not", " ", "reall", "y", " ", "anyt", "hing", " ", "to", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "e", " ", "abo", "ut", " ", "it", ".", " ", " ", "Ju", "st", " ", "ignore", " ", "this", " ", "result", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "eb", "Produ", "cing", "_", "(_", "err_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "state_", "==_", "[_", "None_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "produc", "ing", " ", "Defe", "rre", "d", " ", "fail", "ed", " ", "first", ".", " ", " ", "Thi", "s", " ", "means", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "over", "all", " ", "write", "To", " ", "Defe", "rre", "d", " ", "is", " ", "goi", "ng", " ", "to", " ", "errback", " ", "now", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tell", " ", "the", " ", "encode", "r", " ", "tha", "t", " ", "we", "'", "re", " ", "don", "e", " ", "so", " ", "it", " ", "knows", " ", "to", " ", "reject_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fur", "ther", " ", "writes", " ", "from", " ", "the", " ", "producer", " ", "(", "whi", "ch", " ", "shou", "ld", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "happ", "en", ",", " ", "but", " ", "the", " ", "producer", " ", "may", " ", "be", " ", "bug", "gy", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "state_", "[_", "0_", "]_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encoder_", "._", "\\u", "allow", "No", "Mor", "e", "Write", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ultima", "te_", "._", "errback", "_", "(_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "produc", "ing", " ", "Defe", "rre", "d", " ", "fail", "ed", " ", "after", " ", "the", " ", "consum", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Defe", "rre", "d", " ", "fail", "ed", ".", " ", " ", "It", " ", "shou", "ld", "n", "'", "t", " ", "have", ",", " ", "so", " ", "it", "'", "s", " ", "bug", "gy", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "the", " ", "exception", " ", "in", " ", "case", " ", "any", "one", " ", "who", " ", "can", " ", "fix", " ", "the", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "watch", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "log_", "._", "err_", "(_", "err_", ",_", "\"", "Producer", " ", "is", " ", "bug", "gy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "consum", "ing_", "._", "add", "Errback_", "(_", "eb", "Consu", "ming", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "produc", "ing_", "._", "add", "Callbacks_", "(_", "cb", "Produ", "cing", "_", ",_", "eb", "Produ", "cing", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "ultima", "te_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "=_", "combine_", "(_", "finish", "ed", "Consu", "ming", "_", ",_", "finish", "ed", "Produ", "cing", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "f_", "(_", "passthrough", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Reg", "ard", "less", " ", "of", " ", "what", " ", "happ", "ens", " ", "with", " ", "the", " ", "over", "all", " ", "Defe", "rre", "d", ",", " ", "onc", "e", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fires", ",", " ", "the", " ", "producer", " ", "register", "ed", " ", "way", " ", "up", " ", "above", " ", "the", " ", "definit", "ion", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "combin", "e", " ", "shou", "ld", " ", "be", " ", "unregister", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "transport_", "._", "unregister", "Producer_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "passthrough", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "d_", "._", "add", "Bot", "h_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "11", "Client", "Protocol_", "(_", "Protocol_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "finish", "Respons", "e\\u", "WAIT", "ING_", "(_", "self_", ",_", "rest_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Curr", "ent", "ly", " ", "the", " ", "rest", " ", "parameter", " ", "is", " ", "ignore", "d", ".", " ", "Don", "'", "t", " ", "forget", " ", "to", " ", "use", " ", "it", " ", "if_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "ever", " ", "add", " ", "support", " ", "for", " ", "pipe", "lin", "ing", ".", " ", "And", " ", "may", "be", " ", "check", " ", "what", " ", "trailer", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mean", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "state_", "==_", "'", "WAIT", "ING", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "state_", "=_", "'", "QUI", "ESC", "ENT", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "server", " ", "sent", " ", "the", " ", "entire", " ", "response", " ", "bef", "ore", " ", "we", " ", "coul", "d", " ", "send", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whole", " ", "request", ".", " ", " ", "Tha", "t", " ", "suc", "ks", ".", " ", " ", "Oh", " ", "well", ".", " ", " ", "Fire", " ", "the", " ", "request", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Defe", "rre", "d", " ", "with", " ", "the", " ", "response", ".", " ", " ", "Bu", "t", " ", "first", ",", " ", "make", " ", "sure", " ", "tha", "t", " ", "if", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "request", " ", "doe", "s", " ", "ever", " ", "finish", " ", "bei", "ng", " ", "writt", "en", " ", "tha", "t", " ", "it", " ", "won", "'", "t", " ", "try", " ", "to", " ", "fire_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "Defe", "rre", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "state_", "=_", "'", "TRANS", "MIT", "TIN", "G", "\\u", "AFTER", "\\u", "REC", "EI", "VING", "\\u", "RESPONSE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "response", "Deferred_", "._", "chain", "Deferred_", "(_", "self_", "._", "\\u", "finish", "ed", "Request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "happ", "en", " ", "if", " ", "we", "'", "re", " ", "bei", "ng", " ", "call", "ed", " ", "due", " ", "to", " ", "connecti", "on", " ", "bei", "ng", " ", "lost", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "so", ",", " ", "no", " ", "need", " ", "to", " ", "discon", "nect", " ", "parser", " ", "again", ",", " ", "or", " ", "to", " ", "call_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\\u", "quie", "scen", "t", "Call", "back", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "parser_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reason_", "=_", "Connect", "ion", "Done_", "(_", "\"", "synthetic", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn", "Headers_", "=_", "self_", "._", "\\u", "parser_", "._", "conn", "Headers_", "._", "get", "Ra", "w", "Headers_", "(_", "'", "connecti", "on", "'_", ",_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "'", "close", "'_", "in_", "conn", "Headers_", ")_", "or_", "self_", "._", "\\u", "state_", "!=_", "\"", "QUI", "ESC", "ENT", "\"_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "self_", "._", "\\u", "current", "Request_", "._", "persistent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "give", "Up_", "(_", "Failure_", "(_", "reason_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "call", " ", "the", " ", "quie", "scen", "t", " ", "callback", " ", "first", ",", " ", "to", " ", "ensure", " ", "connecti", "on", " ", "gets", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "adde", "d", " ", "back", " ", "to", " ", "connecti", "on", " ", "pool", " ", "bef", "ore", " ", "we", " ", "finish", " ", "the", " ", "request", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "quie", "scen", "t", "Callback_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "callback", " ", "throw", "s", " ", "exception", ",", " ", "just", " ", "log", " ", "it", " ", "and", " ", "discon", "nect", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "keep", "ing", " ", "persiste", "nt", " ", "connections", " ", "aro", "und", " ", "is", " ", "an", " ", "optimis", "ation", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "err_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "._", "lose", "Connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "discon", "nect", "Parser_", "(_", "reason_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "11", "Client", "Protocol_", "(_", "Protocol_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "data", "Received_", "(_", "self_", ",_", "bytes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Handle", " ", "some", " ", "stu", "ff", " ", "from", " ", "some", " ", "place", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "parser_", "._", "data", "Received_", "(_", "bytes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "give", "Up_", "(_", "Failure_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
srinikom/leveldb-server/leveldb-server.py
[ { "content": " def run(self):\n self.socket.connect('inproc://backend')\n while self.running:\n try:\n msg = self.socket.recv_multipart()\n except zmq.ZMQError:\n self.running = False\n continue\n\n self.processing = True\n if len(msg) != 3:\n value = 'None'\n reply = [msg[0], value]\n self.socket.send_multipart(reply)\n continue\n id = msg[0]\n op = msg[1]\n data = json.loads(msg[2])\n reply = [id]\n if op == 'get':\n try:\n value = self.db.Get(data)\n except:\n value = \"\"\n reply.append(value)\n \n elif op == 'put':\n try:\n self.db.Put(data[0], data[1])\n value = \"True\"\n except:\n value = \"\"\n reply.append(value)\n \n elif op == 'delete':\n self.db.Delete(data)\n value = \"\"\n reply.append(value)\n \n elif op == 'range':\n start = data[0]\n end = data[1]\n if start and end:\n try:\n arr = []\n for value in self.db.RangeIter(start, end):\n arr.append({value[0]: value[1]})\n reply.append(json.dumps(arr))\n except:\n value = \"\"\n reply.append(value)\n else:\n try:\n arr = []\n for value in self.db.RangeIter():\n arr.append({value[0]: value[1]})\n reply.append(json.dumps(arr))\n except:\n value = \"\"\n reply.append(value)\n else:\n value = \"\"\n reply.append(value)\n self.socket.send_multipart(reply)\n self.processing = False", "metadata": "root.workerThread.run", "header": "['class', 'workerThread', '(', 'threading', '.', 'Thread', ')', ':', '___EOS___']", "index": 22 } ]
[ { "span": "except:", "start_line": 44, "start_column": 16, "end_line": 44, "end_column": 23 }, { "span": "except:", "start_line": 52, "start_column": 16, "end_line": 52, "end_column": 23 }, { "span": "except:", "start_line": 70, "start_column": 20, "end_line": 70, "end_column": 27 }, { "span": "except:", "start_line": 79, "start_column": 20, "end_line": 79, "end_column": 27 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "worker", "Thread_", "(_", "threading_", "._", "Thread_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "socket_", "._", "connect_", "(_", "'", "inpr", "oc", "://", "back", "end", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "self_", "._", "running_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "self_", "._", "socket_", "._", "recv", "\\u", "multipart_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "zmq_", "._", "ZM", "QE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "running_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "processing_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "msg_", ")_", "!=_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "'", "Non", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "=_", "[_", "msg_", "[_", "0_", "]_", ",_", "value_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "send", "\\u", "multipart_", "(_", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "id_", "=_", "msg_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "op_", "=_", "msg_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "msg_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "=_", "[_", "id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "op_", "==_", "'", "get", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "self_", "._", "db_", "._", "Get_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "op_", "==_", "'", "put", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "db_", "._", "Put", "_", "(_", "data_", "[_", "0_", "]_", ",_", "data_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "\"", "Tru", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "op_", "==_", "'", "delete", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "db_", "._", "Delete_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "op_", "==_", "'", "range", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "data_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end_", "=_", "data_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "start_", "and_", "end_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "arr_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "self_", "._", "db_", "._", "Range", "Iter_", "(_", "start_", ",_", "end_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "arr_", "._", "append_", "(_", "{_", "value_", "[_", "0_", "]_", ":_", "value_", "[_", "1_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "append_", "(_", "json_", "._", "dumps_", "(_", "arr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "arr_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "self_", "._", "db_", "._", "Range", "Iter_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "arr_", "._", "append_", "(_", "{_", "value_", "[_", "0_", "]_", ":_", "value_", "[_", "1_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "append_", "(_", "json_", "._", "dumps_", "(_", "arr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "append_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "socket_", "._", "send", "\\u", "multipart_", "(_", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "processing_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
ImageEngine/gaffer/python/GafferUITest/EventSignalCombinerTest.py
[ { "content": "\tdef testShortCutting( self ) :\n\n\t\ts = GafferUI.Gadget.ButtonSignal()\n\t\tc1 = s.connect( self.trueSlot )\n\t\tc2 = s.connect( self.falseSlot )\n\n\t\tself.assertEqual( self.trueSlotCalled, False )\n\t\tself.assertEqual( self.falseSlotCalled, False )\n\n\t\tself.assertEqual( s( None, GafferUI.ButtonEvent() ), True )\n\n\t\tself.assertEqual( self.trueSlotCalled, True )\n\t\tself.assertEqual( self.falseSlotCalled, False )", "metadata": "root.EventSignalCombinerTest.testShortCutting", "header": "['class', 'EventSignalCombinerTest', '(', 'GafferUITest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 71 }, { "content": "\tdef testNoShortCutting( self ) :\n\n\t\ts = GafferUI.Gadget.ButtonSignal()\n\t\tc1 = s.connect( self.falseSlot )\n\t\tc2 = s.connect( self.trueSlot )\n\n\t\tself.assertEqual( self.trueSlotCalled, False )\n\t\tself.assertEqual( self.falseSlotCalled, False )\n\n\t\tself.assertEqual( s( None, GafferUI.ButtonEvent() ), True )\n\n\t\tself.assertEqual( self.trueSlotCalled, True )\n\t\tself.assertEqual( self.falseSlotCalled, True )", "metadata": "root.EventSignalCombinerTest.testNoShortCutting", "header": "['class', 'EventSignalCombinerTest', '(', 'GafferUITest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 85 }, { "content": "\tdef testExceptionHandling( self ) :\n\n\t\t# We don't want exceptions in one slot to prevent the\n\t\t# invocation of other slots. But we do want the errors from\n\t\t# those slots being printed to stderr.\n\n\t\ts = GafferUI.Gadget.ButtonSignal()\n\t\tc1 = s.connect( self.exceptionSlot )\n\t\tc2 = s.connect( self.trueSlot )\n\n\t\tself.assertEqual( self.exceptionSlotCalled, False )\n\t\tself.assertEqual( self.trueSlotCalled, False )\n\n\t\ttmpStdErr = StringIO.StringIO()\n\t\tsys.stderr = tmpStdErr\n\t\ttry :\n\t\t\tself.assertEqual( s( None, GafferUI.ButtonEvent() ), True )\n\t\tfinally :\n\t\t\tsys.stderr = sys.__stderr__\n\n\t\tself.assert_( \"oops\" in tmpStdErr.getvalue() )\n\t\tself.assertEqual( self.exceptionSlotCalled, True )\n\t\tself.assertEqual( self.trueSlotCalled, True )", "metadata": "root.EventSignalCombinerTest.testExceptionHandling", "header": "['class', 'EventSignalCombinerTest', '(', 'GafferUITest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 99 } ]
[ { "span": "c1 ", "start_line": 74, "start_column": 2, "end_line": 74, "end_column": 4 }, { "span": "c2 ", "start_line": 75, "start_column": 2, "end_line": 75, "end_column": 4 }, { "span": "c1 ", "start_line": 88, "start_column": 2, "end_line": 88, "end_column": 4 }, { "span": "c2 ", "start_line": 89, "start_column": 2, "end_line": 89, "end_column": 4 }, { "span": "c1 ", "start_line": 106, "start_column": 2, "end_line": 106, "end_column": 4 }, { "span": "c2 ", "start_line": 107, "start_column": 2, "end_line": 107, "end_column": 4 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Event", "Signal", "Combine", "r", "Test_", "(_", "Ga", "ffer", "UI", "Test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Short", "Cut", "ting_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "UI_", "._", "Ga", "dget", "_", "._", "Butt", "on", "Signal_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c1_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "true", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c2_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "fal", "se", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "fal", "se", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "(_", "None_", ",_", "Ga", "ffer", "UI_", "._", "Butt", "on", "Event_", "(_", ")_", ")_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "fal", "se", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Event", "Signal", "Combine", "r", "Test_", "(_", "Ga", "ffer", "UI", "Test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "No", "Short", "Cut", "ting_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "UI_", "._", "Ga", "dget", "_", "._", "Butt", "on", "Signal_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c1_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "fal", "se", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c2_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "true", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "fal", "se", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "(_", "None_", ",_", "Ga", "ffer", "UI_", "._", "Butt", "on", "Event_", "(_", ")_", ")_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "fal", "se", "Slot", "Call", "ed_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Event", "Signal", "Combine", "r", "Test_", "(_", "Ga", "ffer", "UI", "Test_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Except", "ion", "Hand", "ling_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "don", "'", "t", " ", "want", " ", "exception", "s", " ", "in", " ", "one", " ", "slot", " ", "to", " ", "prevent", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "invocation", " ", "of", " ", "other", " ", "slot", "s", ".", " ", "Bu", "t", " ", "we", " ", "do", " ", "want", " ", "the", " ", "error", "s", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tho", "se", " ", "slot", "s", " ", "bei", "ng", " ", "printed", " ", "to", " ", "std", "err", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "s_", "=_", "Ga", "ffer", "UI_", "._", "Ga", "dget", "_", "._", "Butt", "on", "Signal_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c1_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "exception", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c2_", "=_", "s_", "._", "connect_", "(_", "self_", "._", "true", "Slot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "exception", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tmp", "Std", "Err_", "=_", "String", "IO_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "=_", "tmp", "Std", "Err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "self_", "._", "assert", "Equal_", "(_", "s_", "(_", "None_", ",_", "Ga", "ffer", "UI_", "._", "Butt", "on", "Event_", "(_", ")_", ")_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "sys_", "._", "stderr_", "=_", "sys_", "._", "\\u\\u", "std", "err", "\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert\\u_", "(_", "\"", "oop", "s", "\"_", "in_", "tmp", "Std", "Err_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "exception", "Slot", "Call", "ed_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "true", "Slot", "Call", "ed_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2 ]
Unused import
Bolton-and-Menk-GIS/restapi/restapi/requests/packages/urllib3/filepost.py
[ { "content": "# urllib3/filepost.py\n# Copyright 2008-2013 Andrey Petrov and contributors (see CONTRIBUTORS.txt)\n#\n# This module is part of urllib3 and is released under\n# the MIT License: http://www.opensource.org/licenses/mit-license.php\n\nimport codecs\nimport mimetypes\n\nfrom uuid import uuid4\nfrom io import BytesIO\n\nfrom .packages import six\nfrom .packages.six import b\nfrom .fields import RequestField\n\nwriter = codecs.lookup('utf-8')[3]\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def choose_boundary():\n \"\"\"\n Our embarassingly-simple replacement for mimetools.choose_boundary.\n \"\"\"\n return uuid4().hex", "metadata": "root.choose_boundary", "header": "['module', '___EOS___']", "index": 19 }, { "content": "def iter_field_objects(fields):\n \"\"\"\n Iterate over fields.\n\n Supports list of (k, v) tuples and dicts, and lists of\n :class:`~urllib3.fields.RequestField`.\n\n \"\"\"\n if isinstance(fields, dict):\n i = six.iteritems(fields)\n else:\n i = iter(fields)\n\n for field in i:\n if isinstance(field, RequestField):\n yield field\n else:\n yield RequestField.from_tuples(*field)", "metadata": "root.iter_field_objects", "header": "['module', '___EOS___']", "index": 26 }, { "content": "def iter_fields(fields):\n \"\"\"\n .. deprecated:: 1.6\n\n Iterate over fields.\n\n The addition of :class:`~urllib3.fields.RequestField` makes this function\n obsolete. Instead, use :func:`iter_field_objects`, which returns\n :class:`~urllib3.fields.RequestField` objects.\n\n Supports list of (k, v) tuples and dicts.\n \"\"\"\n if isinstance(fields, dict):\n return ((k, v) for k, v in six.iteritems(fields))\n\n return ((k, v) for k, v in fields)", "metadata": "root.iter_fields", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def encode_multipart_formdata(fields, boundary=None):\n \"\"\"\n Encode a dictionary of ``fields`` using the multipart/form-data MIME format.\n\n :param fields:\n Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).\n\n :param boundary:\n If not specified, then a random boundary will be generated using\n :func:`mimetools.choose_boundary`.\n \"\"\"\n body = BytesIO()\n if boundary is None:\n boundary = choose_boundary()\n\n for field in iter_field_objects(fields):\n body.write(b('--%s\\r\\n' % (boundary)))\n\n writer(body).write(field.render_headers())\n data = field.data\n\n if isinstance(data, int):\n data = str(data) # Backwards compatibility\n\n if isinstance(data, six.text_type):\n writer(body).write(data)\n else:\n body.write(data)\n\n body.write(b'\\r\\n')\n\n body.write(b('--%s--\\r\\n' % (boundary)))\n\n content_type = str('multipart/form-data; boundary=%s' % boundary)\n\n return body.getvalue(), content_type", "metadata": "root.encode_multipart_formdata", "header": "['module', '___EOS___']", "index": 64 } ]
[ { "span": "import mimetypes", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "url", "lib", "3", "/", "filep", "ost", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2008", "-", "2013", " ", "Andre", "y", " ", "Pet", "rov", " ", "and", " ", "contributor", "s", " ", "(", "see", " ", "CONTRIB", "UTO", "RS", ".", "txt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "module", " ", "is", " ", "part", " ", "of", " ", "url", "lib", "3", " ", "and", " ", "is", " ", "released", " ", "under", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "MIT", " ", "License", ":", " ", "http", "://", "www", ".", "opens", "ource", ".", "org", "/", "license", "s", "/", "mit", "-", "license", ".", "php", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "mimetypes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "uuid_", "import_", "uuid4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "io_", "import_", "Byte", "s", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "packages_", "import_", "six_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "packages_", "._", "six_", "import_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "fields_", "import_", "Request", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "writer_", "=_", "codecs_", "._", "lookup_", "(_", "'", "utf", "-", "8", "'_", ")_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "choose", "\\u", "boundary_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Ou", "r", " ", "emb", "ara", "ssi", "ngl", "y", "-", "simple", " ", "replace", "ment", " ", "for", " ", "mime", "tool", "s", ".", "choose", "\\u", "bound", "ary", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "uuid4_", "(_", ")_", "._", "hex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "iter", "\\u", "field", "\\u", "objects_", "(_", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Iterat", "e", " ", "over", " ", "fields", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Supp", "orts", " ", "list", " ", "of", " ", "(", "k", ",", " ", "v", ")", " ", "tuple", "s", " ", "and", " ", "dict", "s", ",", " ", "and", " ", "lists", " ", "of", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "~", "url", "lib", "3", ".", "fields", ".", "Request", "Field", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "fields_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "six_", "._", "iteritems_", "(_", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "iter_", "(_", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "field_", "in_", "i_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "field_", ",_", "Request", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Request", "Field_", "._", "from", "\\u", "tuples_", "(_", "*_", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "iter", "\\u", "fields_", "(_", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "depre", "cated", "::", " ", "1.6", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Iterat", "e", " ", "over", " ", "fields", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "addition", " ", "of", " ", ":", "class", ":`", "~", "url", "lib", "3", ".", "fields", ".", "Request", "Field", "`", " ", "make", "s", " ", "this", " ", "function", "\\", "10", ";", " ", " ", " ", " ", "obsolete", ".", " ", "Ins", "tea", "d", ",", " ", "use", " ", ":", "func", ":`", "iter", "\\u", "field", "\\u", "object", "s", "`", ",", " ", "whi", "ch", " ", "return", "s", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "~", "url", "lib", "3", ".", "fields", ".", "Request", "Field", "`", " ", "object", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Supp", "orts", " ", "list", " ", "of", " ", "(", "k", ",", " ", "v", ")", " ", "tuple", "s", " ", "and", " ", "dict", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "fields_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "six_", "._", "iteritems_", "(_", "fields_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "encode", "\\u", "multip", "art", "\\u", "form", "data_", "(_", "fields_", ",_", "boundary_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Encode", " ", "a", " ", "dictionar", "y", " ", "of", " ", "``", "fields", "``", " ", "usi", "ng", " ", "the", " ", "multip", "art", "/", "form", "-", "data", " ", "MIME", " ", "format", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "fields", ":", "\\", "10", ";", " ", " ", " ", " ", "Dict", "ionar", "y", " ", "of", " ", "fields", " ", "or", " ", "list", " ", "of", " ", "(", "key", ",", " ", ":", "class", ":`", "~", "url", "lib", "3", ".", "fields", ".", "Request", "Field", "`)", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "bound", "ary", ":", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "not", " ", "specified", ",", " ", "then", " ", "a", " ", "random", " ", "bound", "ary", " ", "will", " ", "be", " ", "generat", "ed", " ", "usi", "ng", "\\", "10", ";", " ", " ", " ", " ", ":", "func", ":`", "mime", "tool", "s", ".", "choose", "\\u", "bound", "ary", "`.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "Byte", "s", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "boundary_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "boundary_", "=_", "choose", "\\u", "boundary_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "field_", "in_", "iter", "\\u", "field", "\\u", "objects_", "(_", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "._", "write_", "(_", "b_", "(_", "'--", "%", "s", "\\\\", "r", "\\\\", "n", "'_", "%_", "(_", "boundary_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "writer_", "(_", "body_", ")_", "._", "write_", "(_", "field_", "._", "render", "\\u", "headers_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "field_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "data_", ",_", "int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "str_", "(_", "data_", ")_", "#", " ", "Backward", "s", " ", "compatibility", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "data_", ",_", "six_", "._", "text", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "writer_", "(_", "body_", ")_", "._", "write_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "._", "write_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "body_", "._", "write_", "(_", "b", "'\\\\", "r", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "body_", "._", "write_", "(_", "b_", "(_", "'--", "%", "s", "--", "\\\\", "r", "\\\\", "n", "'_", "%_", "(_", "boundary_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "str_", "(_", "'", "multip", "art", "/", "form", "-", "data", ";", " ", "bound", "ary", "=", "%", "s", "'_", "%_", "boundary_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "body_", "._", "getvalue_", "(_", ")_", ",_", "content", "\\u", "type_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
clips/pattern/pattern/server/cherrypy/cherrypy/_cpcompat_subprocess.py
[ { "content": "# subprocess - Subprocesses with accessible I/O streams\n#\n# For more information about this module, see PEP 324.\n#\n# This module should remain compatible with Python 2.2, see PEP 291.\n#\n# Copyright (c) 2003-2005 by Peter Astrand <[email protected]>\n#\n# Licensed to PSF under a Contributor Agreement.\n# See http://www.python.org/2.4/license for licensing details.\n\nr\"\"\"subprocess - Subprocesses with accessible I/O streams\n\nThis module allows you to spawn processes, connect to their\ninput/output/error pipes, and obtain their return codes. This module\nintends to replace several other, older modules and functions, like:\n\nos.system\nos.spawn*\nos.popen*\npopen2.*\ncommands.*\n\nInformation about how the subprocess module can be used to replace these\nmodules and functions can be found below.\n\n\n\nUsing the subprocess module\n===========================\nThis module defines one class called Popen:\n\nclass Popen(args, bufsize=0, executable=None,\n stdin=None, stdout=None, stderr=None,\n preexec_fn=None, close_fds=False, shell=False,\n cwd=None, env=None, universal_newlines=False,\n startupinfo=None, creationflags=0):\n\n\nArguments are:\n\nargs should be a string, or a sequence of program arguments. The\nprogram to execute is normally the first item in the args sequence or\nstring, but can be explicitly set by using the executable argument.\n\nOn UNIX, with shell=False (default): In this case, the Popen class\nuses os.execvp() to execute the child program. args should normally\nbe a sequence. A string will be treated as a sequence with the string\nas the only item (the program to execute).\n\nOn UNIX, with shell=True: If args is a string, it specifies the\ncommand string to execute through the shell. If args is a sequence,\nthe first item specifies the command string, and any additional items\nwill be treated as additional shell arguments.\n\nOn Windows: the Popen class uses CreateProcess() to execute the child\nprogram, which operates on strings. If args is a sequence, it will be\nconverted to a string using the list2cmdline method. Please note that\nnot all MS Windows applications interpret the command line the same\nway: The list2cmdline is designed for applications using the same\nrules as the MS C runtime.\n\nbufsize, if given, has the same meaning as the corresponding argument\nto the built-in open() function: 0 means unbuffered, 1 means line\nbuffered, any other positive value means use a buffer of\n(approximately) that size. A negative bufsize means to use the system\ndefault, which usually means fully buffered. The default value for\nbufsize is 0 (unbuffered).\n\nstdin, stdout and stderr specify the executed programs' standard\ninput, standard output and standard error file handles, respectively.\nValid values are PIPE, an existing file descriptor (a positive\ninteger), an existing file object, and None. PIPE indicates that a\nnew pipe to the child should be created. With None, no redirection\nwill occur; the child's file handles will be inherited from the\nparent. Additionally, stderr can be STDOUT, which indicates that the\nstderr data from the applications should be captured into the same\nfile handle as for stdout.\n\nIf preexec_fn is set to a callable object, this object will be called\nin the child process just before the child is executed.\n\nIf close_fds is true, all file descriptors except 0, 1 and 2 will be\nclosed before the child process is executed.\n\nif shell is true, the specified command will be executed through the\nshell.\n\nIf cwd is not None, the current directory will be changed to cwd\nbefore the child is executed.\n\nIf env is not None, it defines the environment variables for the new\nprocess.\n\nIf universal_newlines is true, the file objects stdout and stderr are\nopened as a text files, but lines may be terminated by any of '\\n',\nthe Unix end-of-line convention, '\\r', the Macintosh convention or\n'\\r\\n', the Windows convention. All of these external representations\nare seen as '\\n' by the Python program. Note: This feature is only\navailable if Python is built with universal newline support (the\ndefault). Also, the newlines attribute of the file objects stdout,\nstdin and stderr are not updated by the communicate() method.\n\nThe startupinfo and creationflags, if given, will be passed to the\nunderlying CreateProcess() function. They can specify things such as\nappearance of the main window and priority for the new process.\n(Windows only)\n\n\nThis module also defines some shortcut functions:\n\ncall(*popenargs, **kwargs):\n Run command with arguments. Wait for command to complete, then\n return the returncode attribute.\n\n The arguments are the same as for the Popen constructor. Example:\n\n retcode = call([\"ls\", \"-l\"])\n\ncheck_call(*popenargs, **kwargs):\n Run command with arguments. Wait for command to complete. If the\n exit code was zero then return, otherwise raise\n CalledProcessError. The CalledProcessError object will have the\n return code in the returncode attribute.\n\n The arguments are the same as for the Popen constructor. Example:\n\n check_call([\"ls\", \"-l\"])\n\ncheck_output(*popenargs, **kwargs):\n Run command with arguments and return its output as a byte string.\n\n If the exit code was non-zero it raises a CalledProcessError. The\n CalledProcessError object will have the return code in the returncode\n attribute and output in the output attribute.\n\n The arguments are the same as for the Popen constructor. Example:\n\n output = check_output([\"ls\", \"-l\", \"/dev/null\"])\n\n\nExceptions\n----------\nExceptions raised in the child process, before the new program has\nstarted to execute, will be re-raised in the parent. Additionally,\nthe exception object will have one extra attribute called\n'child_traceback', which is a string containing traceback information\nfrom the childs point of view.\n\nThe most common exception raised is OSError. This occurs, for\nexample, when trying to execute a non-existent file. Applications\nshould prepare for OSErrors.\n\nA ValueError will be raised if Popen is called with invalid arguments.\n\ncheck_call() and check_output() will raise CalledProcessError, if the\ncalled process returns a non-zero return code.\n\n\nSecurity\n--------\nUnlike some other popen functions, this implementation will never call\n/bin/sh implicitly. This means that all characters, including shell\nmetacharacters, can safely be passed to child processes.\n\n\nPopen objects\n=============\nInstances of the Popen class have the following methods:\n\npoll()\n Check if child process has terminated. Returns returncode\n attribute.\n\nwait()\n Wait for child process to terminate. Returns returncode attribute.\n\ncommunicate(input=None)\n Interact with process: Send data to stdin. Read data from stdout\n and stderr, until end-of-file is reached. Wait for process to\n terminate. The optional input argument should be a string to be\n sent to the child process, or None, if no data should be sent to\n the child.\n\n communicate() returns a tuple (stdout, stderr).\n\n Note: The data read is buffered in memory, so do not use this\n method if the data size is large or unlimited.\n\nThe following attributes are also available:\n\nstdin\n If the stdin argument is PIPE, this attribute is a file object\n that provides input to the child process. Otherwise, it is None.\n\nstdout\n If the stdout argument is PIPE, this attribute is a file object\n that provides output from the child process. Otherwise, it is\n None.\n\nstderr\n If the stderr argument is PIPE, this attribute is file object that\n provides error output from the child process. Otherwise, it is\n None.\n\npid\n The process ID of the child process.\n\nreturncode\n The child return code. A None value indicates that the process\n hasn't terminated yet. A negative value -N indicates that the\n child was terminated by signal N (UNIX only).\n\n\nReplacing older functions with the subprocess module\n====================================================\nIn this section, \"a ==> b\" means that b can be used as a replacement\nfor a.\n\nNote: All functions in this section fail (more or less) silently if\nthe executed program cannot be found; this module raises an OSError\nexception.\n\nIn the following examples, we assume that the subprocess module is\nimported with \"from subprocess import *\".\n\n\nReplacing /bin/sh shell backquote\n---------------------------------\noutput=`mycmd myarg`\n==>\noutput = Popen([\"mycmd\", \"myarg\"], stdout=PIPE).communicate()[0]\n\n\nReplacing shell pipe line\n-------------------------\noutput=`dmesg | grep hda`\n==>\np1 = Popen([\"dmesg\"], stdout=PIPE)\np2 = Popen([\"grep\", \"hda\"], stdin=p1.stdout, stdout=PIPE)\noutput = p2.communicate()[0]\n\n\nReplacing os.system()\n---------------------\nsts = os.system(\"mycmd\" + \" myarg\")\n==>\np = Popen(\"mycmd\" + \" myarg\", shell=True)\npid, sts = os.waitpid(p.pid, 0)\n\nNote:\n\n* Calling the program through the shell is usually not required.\n\n* It's easier to look at the returncode attribute than the\n exitstatus.\n\nA more real-world example would look like this:\n\ntry:\n retcode = call(\"mycmd\" + \" myarg\", shell=True)\n if retcode < 0:\n print >>sys.stderr, \"Child was terminated by signal\", -retcode\n else:\n print >>sys.stderr, \"Child returned\", retcode\nexcept OSError, e:\n print >>sys.stderr, \"Execution failed:\", e\n\n\nReplacing os.spawn*\n-------------------\nP_NOWAIT example:\n\npid = os.spawnlp(os.P_NOWAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\")\n==>\npid = Popen([\"/bin/mycmd\", \"myarg\"]).pid\n\n\nP_WAIT example:\n\nretcode = os.spawnlp(os.P_WAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\")\n==>\nretcode = call([\"/bin/mycmd\", \"myarg\"])\n\n\nVector example:\n\nos.spawnvp(os.P_NOWAIT, path, args)\n==>\nPopen([path] + args[1:])\n\n\nEnvironment example:\n\nos.spawnlpe(os.P_NOWAIT, \"/bin/mycmd\", \"mycmd\", \"myarg\", env)\n==>\nPopen([\"/bin/mycmd\", \"myarg\"], env={\"PATH\": \"/usr/bin\"})\n\n\nReplacing os.popen*\n-------------------\npipe = os.popen(\"cmd\", mode='r', bufsize)\n==>\npipe = Popen(\"cmd\", shell=True, bufsize=bufsize, stdout=PIPE).stdout\n\npipe = os.popen(\"cmd\", mode='w', bufsize)\n==>\npipe = Popen(\"cmd\", shell=True, bufsize=bufsize, stdin=PIPE).stdin\n\n\n(child_stdin, child_stdout) = os.popen2(\"cmd\", mode, bufsize)\n==>\np = Popen(\"cmd\", shell=True, bufsize=bufsize,\n stdin=PIPE, stdout=PIPE, close_fds=True)\n(child_stdin, child_stdout) = (p.stdin, p.stdout)\n\n\n(child_stdin,\n child_stdout,\n child_stderr) = os.popen3(\"cmd\", mode, bufsize)\n==>\np = Popen(\"cmd\", shell=True, bufsize=bufsize,\n stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)\n(child_stdin,\n child_stdout,\n child_stderr) = (p.stdin, p.stdout, p.stderr)\n\n\n(child_stdin, child_stdout_and_stderr) = os.popen4(\"cmd\", mode,\n bufsize)\n==>\np = Popen(\"cmd\", shell=True, bufsize=bufsize,\n stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)\n(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)\n\nOn Unix, os.popen2, os.popen3 and os.popen4 also accept a sequence as\nthe command to execute, in which case arguments will be passed\ndirectly to the program without shell intervention. This usage can be\nreplaced as follows:\n\n(child_stdin, child_stdout) = os.popen2([\"/bin/ls\", \"-l\"], mode,\n bufsize)\n==>\np = Popen([\"/bin/ls\", \"-l\"], bufsize=bufsize, stdin=PIPE, stdout=PIPE)\n(child_stdin, child_stdout) = (p.stdin, p.stdout)\n\nReturn code handling translates as follows:\n\npipe = os.popen(\"cmd\", 'w')\n...\nrc = pipe.close()\nif rc is not None and rc % 256:\n print \"There were some errors\"\n==>\nprocess = Popen(\"cmd\", 'w', shell=True, stdin=PIPE)\n...\nprocess.stdin.close()\nif process.wait() != 0:\n print \"There were some errors\"\n\n\nReplacing popen2.*\n------------------\n(child_stdout, child_stdin) = popen2.popen2(\"somestring\", bufsize, mode)\n==>\np = Popen([\"somestring\"], shell=True, bufsize=bufsize\n stdin=PIPE, stdout=PIPE, close_fds=True)\n(child_stdout, child_stdin) = (p.stdout, p.stdin)\n\nOn Unix, popen2 also accepts a sequence as the command to execute, in\nwhich case arguments will be passed directly to the program without\nshell intervention. This usage can be replaced as follows:\n\n(child_stdout, child_stdin) = popen2.popen2([\"mycmd\", \"myarg\"], bufsize,\n mode)\n==>\np = Popen([\"mycmd\", \"myarg\"], bufsize=bufsize,\n stdin=PIPE, stdout=PIPE, close_fds=True)\n(child_stdout, child_stdin) = (p.stdout, p.stdin)\n\nThe popen2.Popen3 and popen2.Popen4 basically works as subprocess.Popen,\nexcept that:\n\n* subprocess.Popen raises an exception if the execution fails\n* the capturestderr argument is replaced with the stderr argument.\n* stdin=PIPE and stdout=PIPE must be specified.\n* popen2 closes all filedescriptors by default, but you have to specify\n close_fds=True with subprocess.Popen.\n\"\"\"\n\nimport sys\nmswindows = (sys.platform == \"win32\")\n\nimport os\nimport types\nimport traceback\nimport gc\nimport signal\nimport errno\n\ntry:\n set\nexcept NameError:\n from sets import Set as set\n\n# Exception classes used by this module.\n\n\nif mswindows:\n import threading\n import msvcrt\n import _subprocess\nelse:\n import select\n _has_poll = hasattr(select, 'poll')\n import fcntl\n import pickle\n\n # When select or poll has indicated that the file is writable,\n # we can write up to _PIPE_BUF bytes without risk of blocking.\n # POSIX defines PIPE_BUF as >= 512.\n _PIPE_BUF = getattr(select, 'PIPE_BUF', 512)\n\n\n__all__ = [\"Popen\", \"PIPE\", \"STDOUT\", \"call\", \"check_call\",\n \"check_output\", \"CalledProcessError\"]\n\nif mswindows:\n from _subprocess import CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP, \\\n STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, \\\n STD_ERROR_HANDLE, SW_HIDE, \\\n STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW\n\n __all__.extend([\"CREATE_NEW_CONSOLE\", \"CREATE_NEW_PROCESS_GROUP\",\n \"STD_INPUT_HANDLE\", \"STD_OUTPUT_HANDLE\",\n \"STD_ERROR_HANDLE\", \"SW_HIDE\",\n \"STARTF_USESTDHANDLES\", \"STARTF_USESHOWWINDOW\"])\ntry:\n MAXFD = os.sysconf(\"SC_OPEN_MAX\")\nexcept:\n MAXFD = 256\n\n_active = []\n\n\nPIPE = -1\nSTDOUT = -2\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n if mswindows:\n _demo_windows()\n else:\n _demo_posix()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def _close_fds(self, but):\n if hasattr(os, 'closerange'):\n os.closerange(3, but)\n os.closerange(but + 1, MAXFD)\n else:\n for i in xrange(3, MAXFD):\n if i == but:\n continue\n try:\n os.close(i)\n except:\n pass", "metadata": "root.Popen._close_fds", "header": "['class', 'Popen', '(', 'object', ')', ':', '___EOS___']", "index": 1102 }, { "content": " def _execute_child(self, args, executable, preexec_fn, close_fds,\n cwd, env, universal_newlines,\n startupinfo, creationflags, shell,\n p2cread, p2cwrite,\n c2pread, c2pwrite,\n errread, errwrite):\n \"\"\"Execute program (POSIX version)\"\"\"\n\n if isinstance(args, types.StringTypes):\n args = [args]\n else:\n args = list(args)\n\n if shell:\n args = [\"/bin/sh\", \"-c\"] + args\n if executable:\n args[0] = executable\n\n if executable is None:\n executable = args[0]\n\n # For transferring possible exec failure from child to parent\n # The first char specifies the exception type: 0 means\n # OSError, 1 means some other error.\n errpipe_read, errpipe_write = self.pipe_cloexec()\n try:\n try:\n gc_was_enabled = gc.isenabled()\n # Disable gc to avoid bug where gc -> file_dealloc ->\n # write to stderr -> hang. http://bugs.python.org/issue1336\n gc.disable()\n try:\n self.pid = os.fork()\n except:\n if gc_was_enabled:\n gc.enable()\n raise\n self._child_created = True\n if self.pid == 0:\n # Child\n try:\n # Close parent's pipe ends\n if p2cwrite is not None:\n os.close(p2cwrite)\n if c2pread is not None:\n os.close(c2pread)\n if errread is not None:\n os.close(errread)\n os.close(errpipe_read)\n\n # When duping fds, if there arises a situation\n # where one of the fds is either 0, 1 or 2, it\n # is possible that it is overwritten (#12607).\n if c2pwrite == 0:\n c2pwrite = os.dup(c2pwrite)\n if errwrite == 0 or errwrite == 1:\n errwrite = os.dup(errwrite)\n\n # Dup fds for child\n def _dup2(a, b):\n # dup2() removes the CLOEXEC flag but\n # we must do it ourselves if dup2()\n # would be a no-op (issue #10806).\n if a == b:\n self._set_cloexec_flag(a, False)\n elif a is not None:\n os.dup2(a, b)\n _dup2(p2cread, 0)\n _dup2(c2pwrite, 1)\n _dup2(errwrite, 2)\n\n # Close pipe fds. Make sure we don't close the\n # same fd more than once, or standard fds.\n closed = set([None])\n for fd in [p2cread, c2pwrite, errwrite]:\n if fd not in closed and fd > 2:\n os.close(fd)\n closed.add(fd)\n\n # Close all other fds, if asked for\n if close_fds:\n self._close_fds(but=errpipe_write)\n\n if cwd is not None:\n os.chdir(cwd)\n\n if preexec_fn:\n preexec_fn()\n\n if env is None:\n os.execvp(executable, args)\n else:\n os.execvpe(executable, args, env)\n\n except:\n exc_type, exc_value, tb = sys.exc_info()\n # Save the traceback and attach it to the exception object\n exc_lines = traceback.format_exception(exc_type,\n exc_value,\n tb)\n exc_value.child_traceback = ''.join(exc_lines)\n os.write(errpipe_write, pickle.dumps(exc_value))\n\n # This exitcode won't be reported to applications, so it\n # really doesn't matter what we return.\n os._exit(255)\n\n # Parent\n if gc_was_enabled:\n gc.enable()\n finally:\n # be sure the FD is closed no matter what\n os.close(errpipe_write)\n\n if p2cread is not None and p2cwrite is not None:\n os.close(p2cread)\n if c2pwrite is not None and c2pread is not None:\n os.close(c2pwrite)\n if errwrite is not None and errread is not None:\n os.close(errwrite)\n\n # Wait for exec to fail or succeed; possibly raising exception\n # Exception limited to 1M\n data = _eintr_retry_call(os.read, errpipe_read, 1048576)\n finally:\n # be sure the FD is closed no matter what\n os.close(errpipe_read)\n\n if data != \"\":\n try:\n _eintr_retry_call(os.waitpid, self.pid, 0)\n except OSError as e:\n if e.errno != errno.ECHILD:\n raise\n child_exception = pickle.loads(data)\n for fd in (p2cwrite, c2pread, errread):\n if fd is not None:\n os.close(fd)\n raise child_exception", "metadata": "root.Popen._execute_child", "header": "['class', 'Popen', '(', 'object', ')', ':', '___EOS___']", "index": 1116 } ]
[ { "span": "except:", "start_line": 459, "start_column": 0, "end_line": 459, "end_column": 7 }, { "span": "except:", "start_line": 1112, "start_column": 20, "end_line": 1112, "end_column": 27 }, { "span": "except:", "start_line": 1210, "start_column": 24, "end_line": 1210, "end_column": 31 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "subproc", "ess", " ", "-", " ", "Subproces", "ses", " ", "with", " ", "accessible", " ", "I", "/", "O", " ", "streams_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "more", " ", "informati", "on", " ", "abo", "ut", " ", "this", " ", "module", ",", " ", "see", " ", "PE", "P", " ", "324", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "module", " ", "shou", "ld", " ", "rema", "in", " ", "compatible", " ", "with", " ", "Pyth", "on", " ", "2.2", ",", " ", "see", " ", "PE", "P", " ", "291", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2003", "-", "2005", " ", "by", " ", "Peter", " ", "Ast", "rand", " ", "<", "astr", "and", "@", "lys", "ator", ".", "li", "u", ".", "se", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "PSF", " ", "under", " ", "a", " ", "Contributor", " ", "Agreement", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "http", "://", "www", ".", "python", ".", "org", "/", "2.4", "/", "license", " ", "for", " ", "lice", "nsi", "ng", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "r", "\"\"\"", "subproc", "ess", " ", "-", " ", "Subproces", "ses", " ", "with", " ", "accessible", " ", "I", "/", "O", " ", "stream", "s", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "module", " ", "allow", "s", " ", "you", " ", "to", " ", "spawn", " ", "process", "es", ",", " ", "connect", " ", "to", " ", "thei", "r", "\\", "10", ";", "input", "/", "output", "/", "error", " ", "pipe", "s", ",", " ", "and", " ", "obtain", " ", "thei", "r", " ", "return", " ", "codes", ".", " ", " ", "Thi", "s", " ", "module", "\\", "10", ";", "inten", "ds", " ", "to", " ", "replace", " ", "sever", "al", " ", "other", ",", " ", "older", " ", "module", "s", " ", "and", " ", "function", "s", ",", " ", "like", ":", "\\", "10", ";", "\\", "10", ";", "os", ".", "system", "\\", "10", ";", "os", ".", "spawn", "*", "\\", "10", ";", "os", ".", "popen", "*", "\\", "10", ";", "popen", "2", ".*", "\\", "10", ";", "command", "s", ".*", "\\", "10", ";", "\\", "10", ";", "Information", " ", "abo", "ut", " ", "how", " ", "the", " ", "subproc", "ess", " ", "module", " ", "can", " ", "be", " ", "used", " ", "to", " ", "replace", " ", "these", "\\", "10", ";", "module", "s", " ", "and", " ", "function", "s", " ", "can", " ", "be", " ", "found", " ", "belo", "w", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Us", "ing", " ", "the", " ", "subproc", "ess", " ", "module", "\\", "10", ";", "==============", "============", "=", "\\", "10", ";", "Thi", "s", " ", "module", " ", "defin", "es", " ", "one", " ", "class", " ", "call", "ed", " ", "Pop", "en", ":", "\\", "10", ";", "\\", "10", ";", "class", " ", "Pop", "en", "(", "args", ",", " ", "buf", "size", "=", "0", ",", " ", "executable", "=", "Non", "e", ",", "\\", "10", ";", " ", " ", " ", " ", "std", "in", "=", "Non", "e", ",", " ", "stdout", "=", "Non", "e", ",", " ", "std", "err", "=", "Non", "e", ",", "\\", "10", ";", " ", " ", " ", " ", "pree", "xec", "\\u", "fn", "=", "Non", "e", ",", " ", "close", "\\u", "fds", "=", "Fal", "se", ",", " ", "shell", "=", "Fal", "se", ",", "\\", "10", ";", " ", " ", " ", " ", "cw", "d", "=", "Non", "e", ",", " ", "env", "=", "Non", "e", ",", " ", "universal", "\\u", "newline", "s", "=", "Fal", "se", ",", "\\", "10", ";", " ", " ", " ", " ", "start", "upi", "nfo", "=", "Non", "e", ",", " ", "creati", "onf", "lags", "=", "0", "):", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Arg", "ument", "s", " ", "are", ":", "\\", "10", ";", "\\", "10", ";", "args", " ", "shou", "ld", " ", "be", " ", "a", " ", "string", ",", " ", "or", " ", "a", " ", "sequence", " ", "of", " ", "program", " ", "argu", "ment", "s", ".", " ", " ", "The", "\\", "10", ";", "program", " ", "to", " ", "execute", " ", "is", " ", "normal", "ly", " ", "the", " ", "first", " ", "item", " ", "in", " ", "the", " ", "args", " ", "sequence", " ", "or", "\\", "10", ";", "string", ",", " ", "but", " ", "can", " ", "be", " ", "explicit", "ly", " ", "set", " ", "by", " ", "usi", "ng", " ", "the", " ", "executable", " ", "argu", "ment", ".", "\\", "10", ";", "\\", "10", ";", "On", " ", "UNIX", ",", " ", "with", " ", "shell", "=", "Fal", "se", " ", "(", "default", "):", " ", "In", " ", "this", " ", "case", ",", " ", "the", " ", "Pop", "en", " ", "class", "\\", "10", ";", "use", "s", " ", "os", ".", "exec", "vp", "()", " ", "to", " ", "execute", " ", "the", " ", "child", " ", "program", ".", " ", " ", "args", " ", "shou", "ld", " ", "normal", "ly", "\\", "10", ";", "be", " ", "a", " ", "sequence", ".", " ", " ", "A", " ", "string", " ", "will", " ", "be", " ", "treat", "ed", " ", "as", " ", "a", " ", "sequence", " ", "with", " ", "the", " ", "string", "\\", "10", ";", "as", " ", "the", " ", "only", " ", "item", " ", "(", "the", " ", "program", " ", "to", " ", "execute", ").", "\\", "10", ";", "\\", "10", ";", "On", " ", "UNIX", ",", " ", "with", " ", "shell", "=", "Tru", "e", ":", " ", "If", " ", "args", " ", "is", " ", "a", " ", "string", ",", " ", "it", " ", "speci", "fie", "s", " ", "the", "\\", "10", ";", "command", " ", "string", " ", "to", " ", "execute", " ", "through", " ", "the", " ", "shell", ".", " ", " ", "If", " ", "args", " ", "is", " ", "a", " ", "sequence", ",", "\\", "10", ";", "the", " ", "first", " ", "item", " ", "speci", "fie", "s", " ", "the", " ", "command", " ", "string", ",", " ", "and", " ", "any", " ", "addition", "al", " ", "items", "\\", "10", ";", "will", " ", "be", " ", "treat", "ed", " ", "as", " ", "addition", "al", " ", "shell", " ", "argu", "ment", "s", ".", "\\", "10", ";", "\\", "10", ";", "On", " ", "Window", "s", ":", " ", "the", " ", "Pop", "en", " ", "class", " ", "use", "s", " ", "Creat", "e", "Process", "()", " ", "to", " ", "execute", " ", "the", " ", "child", "\\", "10", ";", "program", ",", " ", "whi", "ch", " ", "operate", "s", " ", "on", " ", "string", "s", ".", " ", " ", "If", " ", "args", " ", "is", " ", "a", " ", "sequence", ",", " ", "it", " ", "will", " ", "be", "\\", "10", ";", "convert", "ed", " ", "to", " ", "a", " ", "string", " ", "usi", "ng", " ", "the", " ", "list", "2c", "mdl", "ine", " ", "method", ".", " ", " ", "Ple", "ase", " ", "note", " ", "tha", "t", "\\", "10", ";", "not", " ", "all", " ", "MS", " ", "Window", "s", " ", "applica", "tion", "s", " ", "interpret", " ", "the", " ", "command", " ", "line", " ", "the", " ", "same", "\\", "10", ";", "way", ":", " ", "The", " ", "list", "2c", "mdl", "ine", " ", "is", " ", "design", "ed", " ", "for", " ", "applica", "tion", "s", " ", "usi", "ng", " ", "the", " ", "same", "\\", "10", ";", "rule", "s", " ", "as", " ", "the", " ", "MS", " ", "C", " ", "runt", "ime", ".", "\\", "10", ";", "\\", "10", ";", "buf", "size", ",", " ", "if", " ", "give", "n", ",", " ", "has", " ", "the", " ", "same", " ", "meaning", " ", "as", " ", "the", " ", "correspond", "ing", " ", "argu", "ment", "\\", "10", ";", "to", " ", "the", " ", "bui", "lt", "-", "in", " ", "open", "()", " ", "function", ":", " ", "0", " ", "means", " ", "unb", "uffe", "red", ",", " ", "1", " ", "means", " ", "line", "\\", "10", ";", "buffered", ",", " ", "any", " ", "other", " ", "posit", "ive", " ", "value", " ", "means", " ", "use", " ", "a", " ", "buffer", " ", "of", "\\", "10", ";", "(", "approximate", "ly", ")", " ", "tha", "t", " ", "size", ".", " ", " ", "A", " ", "negati", "ve", " ", "buf", "size", " ", "means", " ", "to", " ", "use", " ", "the", " ", "system", "\\", "10", ";", "default", ",", " ", "whi", "ch", " ", "usual", "ly", " ", "means", " ", "full", "y", " ", "buffered", ".", " ", " ", "The", " ", "default", " ", "value", " ", "for", "\\", "10", ";", "buf", "size", " ", "is", " ", "0", " ", "(", "unb", "uffe", "red", ").", "\\", "10", ";", "\\", "10", ";", "std", "in", ",", " ", "stdout", " ", "and", " ", "std", "err", " ", "speci", "fy", " ", "the", " ", "executed", " ", "program", "s", "'", " ", "standard", "\\", "10", ";", "input", ",", " ", "standard", " ", "output", " ", "and", " ", "standard", " ", "error", " ", "file", " ", "handle", "s", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", "Valid", " ", "values", " ", "are", " ", "PIPE", ",", " ", "an", " ", "exist", "ing", " ", "file", " ", "descrip", "tor", " ", "(", "a", " ", "posit", "ive", "\\", "10", ";", "integ", "er", "),", " ", "an", " ", "exist", "ing", " ", "file", " ", "object", ",", " ", "and", " ", "Non", "e", ".", " ", " ", "PIPE", " ", "indicat", "es", " ", "tha", "t", " ", "a", "\\", "10", ";", "new", " ", "pipe", " ", "to", " ", "the", " ", "child", " ", "shou", "ld", " ", "be", " ", "created", ".", " ", " ", "With", " ", "Non", "e", ",", " ", "no", " ", "redirection", "\\", "10", ";", "will", " ", "occur", ";", " ", "the", " ", "child", "'", "s", " ", "file", " ", "handle", "s", " ", "will", " ", "be", " ", "inherited", " ", "from", " ", "the", "\\", "10", ";", "parent", ".", " ", " ", "Addition", "ally", ",", " ", "std", "err", " ", "can", " ", "be", " ", "STD", "OUT", ",", " ", "whi", "ch", " ", "indicat", "es", " ", "tha", "t", " ", "the", "\\", "10", ";", "std", "err", " ", "data", " ", "from", " ", "the", " ", "applica", "tion", "s", " ", "shou", "ld", " ", "be", " ", "captured", " ", "int", "o", " ", "the", " ", "same", "\\", "10", ";", "file", " ", "handle", " ", "as", " ", "for", " ", "stdout", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "pree", "xec", "\\u", "fn", " ", "is", " ", "set", " ", "to", " ", "a", " ", "calla", "ble", " ", "object", ",", " ", "this", " ", "object", " ", "will", " ", "be", " ", "call", "ed", "\\", "10", ";", "in", " ", "the", " ", "child", " ", "process", " ", "just", " ", "bef", "ore", " ", "the", " ", "child", " ", "is", " ", "executed", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "close", "\\u", "fds", " ", "is", " ", "true", ",", " ", "all", " ", "file", " ", "descrip", "tors", " ", "except", " ", "0", ",", " ", "1", " ", "and", " ", "2", " ", "will", " ", "be", "\\", "10", ";", "close", "d", " ", "bef", "ore", " ", "the", " ", "child", " ", "process", " ", "is", " ", "executed", ".", "\\", "10", ";", "\\", "10", ";", "if", " ", "shell", " ", "is", " ", "true", ",", " ", "the", " ", "specified", " ", "command", " ", "will", " ", "be", " ", "executed", " ", "through", " ", "the", "\\", "10", ";", "shell", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "cw", "d", " ", "is", " ", "not", " ", "Non", "e", ",", " ", "the", " ", "current", " ", "director", "y", " ", "will", " ", "be", " ", "change", "d", " ", "to", " ", "cw", "d", "\\", "10", ";", "bef", "ore", " ", "the", " ", "child", " ", "is", " ", "executed", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "env", " ", "is", " ", "not", " ", "Non", "e", ",", " ", "it", " ", "defin", "es", " ", "the", " ", "environ", "ment", " ", "variab", "les", " ", "for", " ", "the", " ", "new", "\\", "10", ";", "process", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "universal", "\\u", "newline", "s", " ", "is", " ", "true", ",", " ", "the", " ", "file", " ", "object", "s", " ", "stdout", " ", "and", " ", "std", "err", " ", "are", "\\", "10", ";", "opene", "d", " ", "as", " ", "a", " ", "text", " ", "files", ",", " ", "but", " ", "lines", " ", "may", " ", "be", " ", "terminate", "d", " ", "by", " ", "any", " ", "of", " ", "'\\\\", "n", "',", "\\", "10", ";", "the", " ", "Uni", "x", " ", "end", "-", "of", "-", "line", " ", "convention", ",", " ", "'\\\\", "r", "',", " ", "the", " ", "Mac", "int", "osh", " ", "convention", " ", "or", "\\", "10", ";'", "\\\\", "r", "\\\\", "n", "',", " ", "the", " ", "Window", "s", " ", "convention", ".", " ", " ", "All", " ", "of", " ", "these", " ", "external", " ", "representations", "\\", "10", ";", "are", " ", "see", "n", " ", "as", " ", "'\\\\", "n", "'", " ", "by", " ", "the", " ", "Pyth", "on", " ", "program", ".", " ", " ", "Not", "e", ":", " ", "Thi", "s", " ", "feature", " ", "is", " ", "only", "\\", "10", ";", "avail", "able", " ", "if", " ", "Pyth", "on", " ", "is", " ", "bui", "lt", " ", "with", " ", "universal", " ", "newline", " ", "support", " ", "(", "the", "\\", "10", ";", "default", ").", " ", " ", "Al", "so", ",", " ", "the", " ", "newline", "s", " ", "attribute", " ", "of", " ", "the", " ", "file", " ", "object", "s", " ", "stdout", ",", "\\", "10", ";", "std", "in", " ", "and", " ", "std", "err", " ", "are", " ", "not", " ", "update", "d", " ", "by", " ", "the", " ", "communi", "cate", "()", " ", "method", ".", "\\", "10", ";", "\\", "10", ";", "The", " ", "start", "upi", "nfo", " ", "and", " ", "creati", "onf", "lags", ",", " ", "if", " ", "give", "n", ",", " ", "will", " ", "be", " ", "pass", "ed", " ", "to", " ", "the", "\\", "10", ";", "underl", "ying", " ", "Creat", "e", "Process", "()", " ", "function", ".", " ", " ", "The", "y", " ", "can", " ", "speci", "fy", " ", "thing", "s", " ", "suc", "h", " ", "as", "\\", "10", ";", "appearance", " ", "of", " ", "the", " ", "main", " ", "window", " ", "and", " ", "priorit", "y", " ", "for", " ", "the", " ", "new", " ", "process", ".", "\\", "10", ";", "(", "Window", "s", " ", "only", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "module", " ", "als", "o", " ", "defin", "es", " ", "some", " ", "shortcut", " ", "function", "s", ":", "\\", "10", ";", "\\", "10", ";", "call", "(*", "popen", "args", ",", " ", "**", "kwarg", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "command", " ", "with", " ", "argu", "ment", "s", ".", " ", " ", "Wait", " ", "for", " ", "command", " ", "to", " ", "complete", ",", " ", "then", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "the", " ", "return", "code", " ", "attribute", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "same", " ", "as", " ", "for", " ", "the", " ", "Pop", "en", " ", "construct", "or", ".", " ", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "ret", "code", " ", "=", " ", "call", "([", "\"", "ls", "\",", " ", "\"-", "l", "\"]", ")", "\\", "10", ";", "\\", "10", ";", "check", "\\u", "call", "(*", "popen", "args", ",", " ", "**", "kwarg", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "command", " ", "with", " ", "argu", "ment", "s", ".", " ", " ", "Wait", " ", "for", " ", "command", " ", "to", " ", "complete", ".", " ", " ", "If", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "exit", " ", "code", " ", "was", " ", "zero", " ", "then", " ", "return", ",", " ", "other", "wis", "e", " ", "raise", "\\", "10", ";", " ", " ", " ", " ", "Call", "ed", "Process", "Error", ".", " ", " ", "The", " ", "Call", "ed", "Process", "Error", " ", "object", " ", "will", " ", "have", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "code", " ", "in", " ", "the", " ", "return", "code", " ", "attribute", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "same", " ", "as", " ", "for", " ", "the", " ", "Pop", "en", " ", "construct", "or", ".", " ", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "check", "\\u", "call", "([", "\"", "ls", "\",", " ", "\"-", "l", "\"]", ")", "\\", "10", ";", "\\", "10", ";", "check", "\\u", "output", "(*", "popen", "args", ",", " ", "**", "kwarg", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "command", " ", "with", " ", "argu", "ment", "s", " ", "and", " ", "return", " ", "its", " ", "output", " ", "as", " ", "a", " ", "byte", " ", "string", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "exit", " ", "code", " ", "was", " ", "non", "-", "zero", " ", "it", " ", "raise", "s", " ", "a", " ", "Call", "ed", "Process", "Error", ".", " ", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "Call", "ed", "Process", "Error", " ", "object", " ", "will", " ", "have", " ", "the", " ", "return", " ", "code", " ", "in", " ", "the", " ", "return", "code", "\\", "10", ";", " ", " ", " ", " ", "attribute", " ", "and", " ", "output", " ", "in", " ", "the", " ", "output", " ", "attribute", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "same", " ", "as", " ", "for", " ", "the", " ", "Pop", "en", " ", "construct", "or", ".", " ", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "output", " ", "=", " ", "check", "\\u", "output", "([", "\"", "ls", "\",", " ", "\"-", "l", "\",", " ", "\"/", "dev", "/", "null", "\"]", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Except", "ion", "s", "\\", "10", ";", "----------", "\\", "10", ";", "Except", "ion", "s", " ", "raise", "d", " ", "in", " ", "the", " ", "child", " ", "process", ",", " ", "bef", "ore", " ", "the", " ", "new", " ", "program", " ", "has", "\\", "10", ";", "start", "ed", " ", "to", " ", "execute", ",", " ", "will", " ", "be", " ", "re", "-", "raise", "d", " ", "in", " ", "the", " ", "parent", ".", " ", " ", "Addition", "ally", ",", "\\", "10", ";", "the", " ", "exception", " ", "object", " ", "will", " ", "have", " ", "one", " ", "extra", " ", "attribute", " ", "call", "ed", "\\", "10", ";'", "child", "\\u", "traceback", "',", " ", "whi", "ch", " ", "is", " ", "a", " ", "string", " ", "contain", "ing", " ", "traceback", " ", "informati", "on", "\\", "10", ";", "from", " ", "the", " ", "child", "s", " ", "point", " ", "of", " ", "view", ".", "\\", "10", ";", "\\", "10", ";", "The", " ", "most", " ", "common", " ", "exception", " ", "raise", "d", " ", "is", " ", "OSE", "rror", ".", " ", " ", "Thi", "s", " ", "occur", "s", ",", " ", "for", "\\", "10", ";", "example", ",", " ", "whe", "n", " ", "try", "ing", " ", "to", " ", "execute", " ", "a", " ", "non", "-", "existen", "t", " ", "file", ".", " ", " ", "Applica", "tion", "s", "\\", "10", ";", "shou", "ld", " ", "prepar", "e", " ", "for", " ", "OSE", "rror", "s", ".", "\\", "10", ";", "\\", "10", ";", "A", " ", "Value", "Error", " ", "will", " ", "be", " ", "raise", "d", " ", "if", " ", "Pop", "en", " ", "is", " ", "call", "ed", " ", "with", " ", "invalid", " ", "argu", "ment", "s", ".", "\\", "10", ";", "\\", "10", ";", "check", "\\u", "call", "()", " ", "and", " ", "check", "\\u", "output", "()", " ", "will", " ", "raise", " ", "Call", "ed", "Process", "Error", ",", " ", "if", " ", "the", "\\", "10", ";", "call", "ed", " ", "process", " ", "return", "s", " ", "a", " ", "non", "-", "zero", " ", "return", " ", "code", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Secur", "it", "y", "\\", "10", ";", "--------", "\\", "10", ";", "Unli", "ke", " ", "some", " ", "other", " ", "popen", " ", "function", "s", ",", " ", "this", " ", "implementation", " ", "will", " ", "neve", "r", " ", "call", "\\", "10", ";", "/", "bin", "/", "sh", " ", "implicit", "ly", ".", " ", " ", "Thi", "s", " ", "means", " ", "tha", "t", " ", "all", " ", "character", "s", ",", " ", "inclu", "ding", " ", "shell", "\\", "10", ";", "meta", "character", "s", ",", " ", "can", " ", "safe", "ly", " ", "be", " ", "pass", "ed", " ", "to", " ", "child", " ", "process", "es", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Pop", "en", " ", "object", "s", "\\", "10", ";", "============", "=", "\\", "10", ";", "Insta", "nce", "s", " ", "of", " ", "the", " ", "Pop", "en", " ", "class", " ", "have", " ", "the", " ", "follow", "ing", " ", "method", "s", ":", "\\", "10", ";", "\\", "10", ";", "poll", "()", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "if", " ", "child", " ", "process", " ", "has", " ", "terminate", "d", ".", " ", " ", "Return", "s", " ", "return", "code", "\\", "10", ";", " ", " ", " ", " ", "attribute", ".", "\\", "10", ";", "\\", "10", ";", "wait", "()", "\\", "10", ";", " ", " ", " ", " ", "Wait", " ", "for", " ", "child", " ", "process", " ", "to", " ", "terminate", ".", " ", " ", "Return", "s", " ", "return", "code", " ", "attribute", ".", "\\", "10", ";", "\\", "10", ";", "communi", "cate", "(", "input", "=", "Non", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "Interact", " ", "with", " ", "process", ":", " ", "Sen", "d", " ", "data", " ", "to", " ", "std", "in", ".", " ", " ", "Read", " ", "data", " ", "from", " ", "stdout", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "std", "err", ",", " ", "unti", "l", " ", "end", "-", "of", "-", "file", " ", "is", " ", "reache", "d", ".", " ", " ", "Wait", " ", "for", " ", "process", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "terminate", ".", " ", " ", "The", " ", "option", "al", " ", "input", " ", "argu", "ment", " ", "shou", "ld", " ", "be", " ", "a", " ", "string", " ", "to", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "sent", " ", "to", " ", "the", " ", "child", " ", "process", ",", " ", "or", " ", "Non", "e", ",", " ", "if", " ", "no", " ", "data", " ", "shou", "ld", " ", "be", " ", "sent", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "child", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "communi", "cate", "()", " ", "return", "s", " ", "a", " ", "tuple", " ", "(", "stdout", ",", " ", "std", "err", ").", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", ":", " ", "The", " ", "data", " ", "read", " ", "is", " ", "buffered", " ", "in", " ", "memory", ",", " ", "so", " ", "do", " ", "not", " ", "use", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "method", " ", "if", " ", "the", " ", "data", " ", "size", " ", "is", " ", "large", " ", "or", " ", "unlimited", ".", "\\", "10", ";", "\\", "10", ";", "The", " ", "follow", "ing", " ", "attribute", "s", " ", "are", " ", "als", "o", " ", "avail", "able", ":", "\\", "10", ";", "\\", "10", ";", "std", "in", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "std", "in", " ", "argu", "ment", " ", "is", " ", "PIPE", ",", " ", "this", " ", "attribute", " ", "is", " ", "a", " ", "file", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "provide", "s", " ", "input", " ", "to", " ", "the", " ", "child", " ", "process", ".", " ", " ", "Ot", "her", "wis", "e", ",", " ", "it", " ", "is", " ", "Non", "e", ".", "\\", "10", ";", "\\", "10", ";", "stdout", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "stdout", " ", "argu", "ment", " ", "is", " ", "PIPE", ",", " ", "this", " ", "attribute", " ", "is", " ", "a", " ", "file", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "provide", "s", " ", "output", " ", "from", " ", "the", " ", "child", " ", "process", ".", " ", " ", "Ot", "her", "wis", "e", ",", " ", "it", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "Non", "e", ".", "\\", "10", ";", "\\", "10", ";", "std", "err", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "std", "err", " ", "argu", "ment", " ", "is", " ", "PIPE", ",", " ", "this", " ", "attribute", " ", "is", " ", "file", " ", "object", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "provide", "s", " ", "error", " ", "output", " ", "from", " ", "the", " ", "child", " ", "process", ".", " ", " ", "Ot", "her", "wis", "e", ",", " ", "it", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "Non", "e", ".", "\\", "10", ";", "\\", "10", ";", "pid", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "process", " ", "ID", " ", "of", " ", "the", " ", "child", " ", "process", ".", "\\", "10", ";", "\\", "10", ";", "return", "code", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "child", " ", "return", " ", "code", ".", " ", " ", "A", " ", "Non", "e", " ", "value", " ", "indicat", "es", " ", "tha", "t", " ", "the", " ", "process", "\\", "10", ";", " ", " ", " ", " ", "hasn", "'", "t", " ", "terminate", "d", " ", "ye", "t", ".", " ", " ", "A", " ", "negati", "ve", " ", "value", " ", "-", "N", " ", "indicat", "es", " ", "tha", "t", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "child", " ", "was", " ", "terminate", "d", " ", "by", " ", "signal", " ", "N", " ", "(", "UNIX", " ", "only", ").", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "older", " ", "function", "s", " ", "with", " ", "the", " ", "subproc", "ess", " ", "module", "\\", "10", ";", "==============", "==============", "==============", "=========", "=", "\\", "10", ";", "In", " ", "this", " ", "section", ",", " ", "\"", "a", " ", "==", ">", " ", "b", "\"", " ", "means", " ", "tha", "t", " ", "b", " ", "can", " ", "be", " ", "used", " ", "as", " ", "a", " ", "replace", "ment", "\\", "10", ";", "for", " ", "a", ".", "\\", "10", ";", "\\", "10", ";", "Not", "e", ":", " ", "All", " ", "function", "s", " ", "in", " ", "this", " ", "section", " ", "fail", " ", "(", "more", " ", "or", " ", "less", ")", " ", "silently", " ", "if", "\\", "10", ";", "the", " ", "executed", " ", "program", " ", "cann", "ot", " ", "be", " ", "found", ";", " ", "this", " ", "module", " ", "raise", "s", " ", "an", " ", "OSE", "rror", "\\", "10", ";", "exception", ".", "\\", "10", ";", "\\", "10", ";", "In", " ", "the", " ", "follow", "ing", " ", "example", "s", ",", " ", "we", " ", "assume", " ", "tha", "t", " ", "the", " ", "subproc", "ess", " ", "module", " ", "is", "\\", "10", ";", "import", "ed", " ", "with", " ", "\"", "from", " ", "subproc", "ess", " ", "import", " ", "*\"", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "/", "bin", "/", "sh", " ", "shell", " ", "back", "quote", "\\", "10", ";", "--------------", "--------------", "-----", "\\", "10", ";", "output", "=", "`", "myc", "md", " ", "mya", "rg", "`", "\\", "10", ";", "==", ">", "\\", "10", ";", "output", " ", "=", " ", "Pop", "en", "([", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ",", " ", "stdout", "=", "PIPE", ").", "communi", "cate", "()[", "0", "]", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "shell", " ", "pipe", " ", "line", "\\", "10", ";", "--------------", "-----------", "\\", "10", ";", "output", "=", "`", "dme", "sg", " ", "|", " ", "grep", " ", "hda", "`", "\\", "10", ";", "==", ">", "\\", "10", ";", "p1", " ", "=", " ", "Pop", "en", "([", "\"", "dme", "sg", "\"]", ",", " ", "stdout", "=", "PIPE", ")", "\\", "10", ";", "p2", " ", "=", " ", "Pop", "en", "([", "\"", "grep", "\",", " ", "\"", "hda", "\"]", ",", " ", "std", "in", "=", "p1", ".", "stdout", ",", " ", "stdout", "=", "PIPE", ")", "\\", "10", ";", "output", " ", "=", " ", "p2", ".", "communi", "cate", "()[", "0", "]", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "os", ".", "system", "()", "\\", "10", ";", "--------------", "-------", "\\", "10", ";", "sts", " ", "=", " ", "os", ".", "system", "(\"", "myc", "md", "\"", " ", "+", " ", "\"", " ", "mya", "rg", "\")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "(\"", "myc", "md", "\"", " ", "+", " ", "\"", " ", "mya", "rg", "\",", " ", "shell", "=", "Tru", "e", ")", "\\", "10", ";", "pid", ",", " ", "sts", " ", "=", " ", "os", ".", "wait", "pid", "(", "p", ".", "pid", ",", " ", "0", ")", "\\", "10", ";", "\\", "10", ";", "Not", "e", ":", "\\", "10", ";", "\\", "10", ";", "*", " ", "Call", "ing", " ", "the", " ", "program", " ", "through", " ", "the", " ", "shell", " ", "is", " ", "usual", "ly", " ", "not", " ", "require", "d", ".", "\\", "10", ";", "\\", "10", ";", "*", " ", "It", "'", "s", " ", "easi", "er", " ", "to", " ", "look", " ", "at", " ", "the", " ", "return", "code", " ", "attribute", " ", "than", " ", "the", "\\", "10", ";", " ", " ", "exits", "tat", "us", ".", "\\", "10", ";", "\\", "10", ";", "A", " ", "more", " ", "real", "-", "world", " ", "example", " ", "wou", "ld", " ", "look", " ", "like", " ", "this", ":", "\\", "10", ";", "\\", "10", ";", "try", ":", "\\", "10", ";", " ", " ", " ", " ", "ret", "code", " ", "=", " ", "call", "(\"", "myc", "md", "\"", " ", "+", " ", "\"", " ", "mya", "rg", "\",", " ", "shell", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "ret", "code", " ", "<", " ", "0", ":", "\\", "10", ";", " ", " ", " ", " ", "print", " ", ">>", "sys", ".", "std", "err", ",", " ", "\"", "Chil", "d", " ", "was", " ", "terminate", "d", " ", "by", " ", "signal", "\",", " ", "-", "ret", "code", "\\", "10", ";", " ", " ", " ", " ", "else", ":", "\\", "10", ";", " ", " ", " ", " ", "print", " ", ">>", "sys", ".", "std", "err", ",", " ", "\"", "Chil", "d", " ", "return", "ed", "\",", " ", "ret", "code", "\\", "10", ";", "except", " ", "OSE", "rror", ",", " ", "e", ":", "\\", "10", ";", " ", " ", " ", " ", "print", " ", ">>", "sys", ".", "std", "err", ",", " ", "\"", "Execut", "ion", " ", "fail", "ed", ":\"", ",", " ", "e", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "os", ".", "spawn", "*", "\\", "10", ";", "--------------", "-----", "\\", "10", ";", "P", "\\u", "NOW", "AI", "T", " ", "example", ":", "\\", "10", ";", "\\", "10", ";", "pid", " ", "=", " ", "os", ".", "spawn", "lp", "(", "os", ".", "P", "\\u", "NOW", "AI", "T", ",", " ", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\")", "\\", "10", ";", "==", ">", "\\", "10", ";", "pid", " ", "=", " ", "Pop", "en", "([", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ").", "pid", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "P", "\\u", "WAIT", " ", "example", ":", "\\", "10", ";", "\\", "10", ";", "ret", "code", " ", "=", " ", "os", ".", "spawn", "lp", "(", "os", ".", "P", "\\u", "WAIT", ",", " ", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\")", "\\", "10", ";", "==", ">", "\\", "10", ";", "ret", "code", " ", "=", " ", "call", "([", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Vector", " ", "example", ":", "\\", "10", ";", "\\", "10", ";", "os", ".", "spawn", "vp", "(", "os", ".", "P", "\\u", "NOW", "AI", "T", ",", " ", "path", ",", " ", "args", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "Pop", "en", "([", "path", "]", " ", "+", " ", "args", "[", "1", ":]", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Environ", "ment", " ", "example", ":", "\\", "10", ";", "\\", "10", ";", "os", ".", "spawn", "lp", "e", "(", "os", ".", "P", "\\u", "NOW", "AI", "T", ",", " ", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\",", " ", "env", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "Pop", "en", "([", "\"/", "bin", "/", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ",", " ", "env", "={", "\"", "PATH", "\":", " ", "\"/", "usr", "/", "bin", "\"}", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "os", ".", "popen", "*", "\\", "10", ";", "--------------", "-----", "\\", "10", ";", "pipe", " ", "=", " ", "os", ".", "popen", "(\"", "cmd", "\",", " ", "mode", "='", "r", "',", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "pipe", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", ",", " ", "stdout", "=", "PIPE", ").", "stdout", "\\", "10", ";", "\\", "10", ";", "pipe", " ", "=", " ", "os", ".", "popen", "(\"", "cmd", "\",", " ", "mode", "='", "w", "',", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "pipe", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", ",", " ", "std", "in", "=", "PIPE", ").", "std", "in", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", ")", " ", "=", " ", "os", ".", "popen", "2", "(\"", "cmd", "\",", " ", "mode", ",", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", ",", "\\", "10", ";", " ", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ",", " ", "close", "\\u", "fds", "=", "Tru", "e", ")", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", ")", " ", "=", " ", "(", "p", ".", "std", "in", ",", " ", "p", ".", "stdout", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", "\\", "10", ";", " ", "child", "\\u", "stdout", ",", "\\", "10", ";", " ", "child", "\\u", "std", "err", ")", " ", "=", " ", "os", ".", "popen", "3", "(\"", "cmd", "\",", " ", "mode", ",", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", ",", "\\", "10", ";", " ", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ",", " ", "std", "err", "=", "PIPE", ",", " ", "close", "\\u", "fds", "=", "Tru", "e", ")", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", "\\", "10", ";", " ", "child", "\\u", "stdout", ",", "\\", "10", ";", " ", "child", "\\u", "std", "err", ")", " ", "=", " ", "(", "p", ".", "std", "in", ",", " ", "p", ".", "stdout", ",", " ", "p", ".", "std", "err", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", "\\u", "and", "\\u", "std", "err", ")", " ", "=", " ", "os", ".", "popen", "4", "(\"", "cmd", "\",", " ", "mode", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", ",", "\\", "10", ";", " ", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ",", " ", "std", "err", "=", "STD", "OUT", ",", " ", "close", "\\u", "fds", "=", "Tru", "e", ")", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", "\\u", "and", "\\u", "std", "err", ")", " ", "=", " ", "(", "p", ".", "std", "in", ",", " ", "p", ".", "stdout", ")", "\\", "10", ";", "\\", "10", ";", "On", " ", "Uni", "x", ",", " ", "os", ".", "popen", "2", ",", " ", "os", ".", "popen", "3", " ", "and", " ", "os", ".", "popen", "4", " ", "als", "o", " ", "accept", " ", "a", " ", "sequence", " ", "as", "\\", "10", ";", "the", " ", "command", " ", "to", " ", "execute", ",", " ", "in", " ", "whi", "ch", " ", "case", " ", "argu", "ment", "s", " ", "will", " ", "be", " ", "pass", "ed", "\\", "10", ";", "direct", "ly", " ", "to", " ", "the", " ", "program", " ", "with", "out", " ", "shell", " ", "interv", "enti", "on", ".", " ", " ", "Thi", "s", " ", "usage", " ", "can", " ", "be", "\\", "10", ";", "replaced", " ", "as", " ", "follow", "s", ":", "\\", "10", ";", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", ")", " ", "=", " ", "os", ".", "popen", "2", "([", "\"/", "bin", "/", "ls", "\",", " ", "\"-", "l", "\"]", ",", " ", "mode", ",", "\\", "10", ";", " ", " ", " ", " ", "buf", "size", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "([", "\"/", "bin", "/", "ls", "\",", " ", "\"-", "l", "\"]", ",", " ", "buf", "size", "=", "buf", "size", ",", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ")", "\\", "10", ";", "(", "child", "\\u", "std", "in", ",", " ", "child", "\\u", "stdout", ")", " ", "=", " ", "(", "p", ".", "std", "in", ",", " ", "p", ".", "stdout", ")", "\\", "10", ";", "\\", "10", ";", "Return", " ", "code", " ", "handling", " ", "translat", "es", " ", "as", " ", "follow", "s", ":", "\\", "10", ";", "\\", "10", ";", "pipe", " ", "=", " ", "os", ".", "popen", "(\"", "cmd", "\",", " ", "'", "w", "')", "\\", "10", ";", "...", "\\", "10", ";", "rc", " ", "=", " ", "pipe", ".", "close", "()", "\\", "10", ";", "if", " ", "rc", " ", "is", " ", "not", " ", "Non", "e", " ", "and", " ", "rc", " ", "%", " ", "256", ":", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "\"", "There", " ", "wer", "e", " ", "some", " ", "error", "s", "\"", "\\", "10", ";", "==", ">", "\\", "10", ";", "process", " ", "=", " ", "Pop", "en", "(\"", "cmd", "\",", " ", "'", "w", "',", " ", "shell", "=", "Tru", "e", ",", " ", "std", "in", "=", "PIPE", ")", "\\", "10", ";", "...", "\\", "10", ";", "process", ".", "std", "in", ".", "close", "()", "\\", "10", ";", "if", " ", "process", ".", "wait", "()", " ", "!=", " ", "0", ":", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "\"", "There", " ", "wer", "e", " ", "some", " ", "error", "s", "\"", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Repl", "acing", " ", "popen", "2", ".*", "\\", "10", ";", "--------------", "----", "\\", "10", ";", "(", "child", "\\u", "stdout", ",", " ", "child", "\\u", "std", "in", ")", " ", "=", " ", "popen", "2", ".", "popen", "2", "(\"", "some", "string", "\",", " ", "buf", "size", ",", " ", "mode", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "([", "\"", "some", "string", "\"]", ",", " ", "shell", "=", "Tru", "e", ",", " ", "buf", "size", "=", "buf", "size", "\\", "10", ";", " ", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ",", " ", "close", "\\u", "fds", "=", "Tru", "e", ")", "\\", "10", ";", "(", "child", "\\u", "stdout", ",", " ", "child", "\\u", "std", "in", ")", " ", "=", " ", "(", "p", ".", "stdout", ",", " ", "p", ".", "std", "in", ")", "\\", "10", ";", "\\", "10", ";", "On", " ", "Uni", "x", ",", " ", "popen", "2", " ", "als", "o", " ", "accepts", " ", "a", " ", "sequence", " ", "as", " ", "the", " ", "command", " ", "to", " ", "execute", ",", " ", "in", "\\", "10", ";", "whi", "ch", " ", "case", " ", "argu", "ment", "s", " ", "will", " ", "be", " ", "pass", "ed", " ", "direct", "ly", " ", "to", " ", "the", " ", "program", " ", "with", "out", "\\", "10", ";", "shell", " ", "interv", "enti", "on", ".", " ", " ", "Thi", "s", " ", "usage", " ", "can", " ", "be", " ", "replaced", " ", "as", " ", "follow", "s", ":", "\\", "10", ";", "\\", "10", ";", "(", "child", "\\u", "stdout", ",", " ", "child", "\\u", "std", "in", ")", " ", "=", " ", "popen", "2", ".", "popen", "2", "([", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ",", " ", "buf", "size", ",", "\\", "10", ";", " ", " ", " ", " ", "mode", ")", "\\", "10", ";", "==", ">", "\\", "10", ";", "p", " ", "=", " ", "Pop", "en", "([", "\"", "myc", "md", "\",", " ", "\"", "mya", "rg", "\"]", ",", " ", "buf", "size", "=", "buf", "size", ",", "\\", "10", ";", " ", " ", "std", "in", "=", "PIPE", ",", " ", "stdout", "=", "PIPE", ",", " ", "close", "\\u", "fds", "=", "Tru", "e", ")", "\\", "10", ";", "(", "child", "\\u", "stdout", ",", " ", "child", "\\u", "std", "in", ")", " ", "=", " ", "(", "p", ".", "stdout", ",", " ", "p", ".", "std", "in", ")", "\\", "10", ";", "\\", "10", ";", "The", " ", "popen", "2", ".", "Pop", "en", "3", " ", "and", " ", "popen", "2", ".", "Pop", "en", "4", " ", "basic", "ally", " ", "works", " ", "as", " ", "subproc", "ess", ".", "Pop", "en", ",", "\\", "10", ";", "except", " ", "tha", "t", ":", "\\", "10", ";", "\\", "10", ";", "*", " ", "subproc", "ess", ".", "Pop", "en", " ", "raise", "s", " ", "an", " ", "exception", " ", "if", " ", "the", " ", "executi", "on", " ", "fail", "s", "\\", "10", ";", "*", " ", "the", " ", "captures", "tde", "rr", " ", "argu", "ment", " ", "is", " ", "replaced", " ", "with", " ", "the", " ", "std", "err", " ", "argu", "ment", ".", "\\", "10", ";", "*", " ", "std", "in", "=", "PIPE", " ", "and", " ", "stdout", "=", "PIPE", " ", "must", " ", "be", " ", "specified", ".", "\\", "10", ";", "*", " ", "popen", "2", " ", "closes", " ", "all", " ", "filed", "escri", "pto", "rs", " ", "by", " ", "default", ",", " ", "but", " ", "you", " ", "have", " ", "to", " ", "speci", "fy", "\\", "10", ";", " ", " ", "close", "\\u", "fds", "=", "Tru", "e", " ", "with", " ", "subproc", "ess", ".", "Pop", "en", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ms", "windows_", "=_", "(_", "sys_", "._", "platform_", "==_", "\"", "win32", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "signal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "sets_", "import_", "Set_", "as_", "set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Except", "ion", " ", "classe", "s", " ", "used", " ", "by", " ", "this", " ", "module", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ms", "windows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "msvcrt", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "\\u", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "has", "\\u", "poll_", "=_", "hasattr_", "(_", "select_", ",_", "'", "poll", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fcntl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Whe", "n", " ", "select", " ", "or", " ", "poll", " ", "has", " ", "indicat", "ed", " ", "tha", "t", " ", "the", " ", "file", " ", "is", " ", "writ", "able", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "can", " ", "write", " ", "up", " ", "to", " ", "\\u", "PIPE", "\\u", "BUF", " ", "bytes", " ", "with", "out", " ", "risk", " ", "of", " ", "blockin", "g", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "POSI", "X", " ", "defin", "es", " ", "PIPE", "\\u", "BUF", " ", "as", " ", ">=", " ", "512", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "PIPE", "\\u", "BUF", "_", "=_", "getattr_", "(_", "select_", ",_", "'", "PIPE", "\\u", "BUF", "'_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "\"", "Pop", "en", "\"_", ",_", "\"", "PIPE", "\"_", ",_", "\"", "STD", "OUT", "\"_", ",_", "\"", "call", "\"_", ",_", "\"", "check", "\\u", "call", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "check", "\\u", "output", "\"_", ",_", "\"", "Call", "ed", "Process", "Error", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ms", "windows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "\\u", "subprocess_", "import_", "CREATE", "\\u", "NEW", "\\u", "CONSOLE", "_", ",_", "CREATE", "\\u", "NEW", "\\u", "PROCESS", "\\u", "GROUP_", ",_", "STD", "\\u", "INPUT", "\\u", "HANDLE_", ",_", "STD", "\\u", "OUTPU", "T", "\\u", "HANDLE_", ",_", "STD", "\\u", "ERROR", "\\u", "HANDLE_", ",_", "SW", "\\u", "HID", "E_", ",_", "START", "F", "\\u", "USE", "STD", "HANDLE", "S_", ",_", "START", "F", "\\u", "USE", "SHOW", "WINDOW_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "._", "extend_", "(_", "[_", "\"", "CREATE", "\\u", "NEW", "\\u", "CONSOLE", "\"_", ",_", "\"", "CREATE", "\\u", "NEW", "\\u", "PROCESS", "\\u", "GROU", "P", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "STD", "\\u", "INPUT", "\\u", "HANDLE", "\"_", ",_", "\"", "STD", "\\u", "OUTPU", "T", "\\u", "HANDLE", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "STD", "\\u", "ERROR", "\\u", "HANDLE", "\"_", ",_", "\"", "SW", "\\u", "HID", "E", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "START", "F", "\\u", "USE", "STD", "HANDLE", "S", "\"_", ",_", "\"", "START", "F", "\\u", "USE", "SHOW", "WIND", "OW", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "MAX", "FD_", "=_", "os_", "._", "sysc", "onf_", "(_", "\"", "SC", "\\u", "OPEN", "\\u", "MAX", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "MAX", "FD_", "=_", "256_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "active_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "PIPE_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "STDOUT_", "=_", "-_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ms", "windows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "demo", "\\u", "windows_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "demo", "\\u", "posix_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Popen_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "close", "\\u", "fds_", "(_", "self_", ",_", "but", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "os_", ",_", "'", "close", "range", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "close", "range_", "(_", "3_", ",_", "but", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "close", "range_", "(_", "but", "_", "+_", "1_", ",_", "MAX", "FD_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "xrange_", "(_", "3_", ",_", "MAX", "FD_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "i_", "==_", "but", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Popen_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "execute", "\\u", "child_", "(_", "self_", ",_", "args_", ",_", "executable_", ",_", "pree", "xec", "\\u", "fn_", ",_", "close", "\\u", "fds_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cwd_", ",_", "env_", ",_", "universal", "\\u", "newlines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "upi", "nfo_", ",_", "creati", "onf", "lags_", ",_", "shell_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "p2", "crea", "d_", ",_", "p2", "cw", "rite_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "c2", "prea", "d_", ",_", "c2", "pwr", "ite_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "err", "read_", ",_", "err", "write_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Execut", "e", " ", "program", " ", "(", "POSI", "X", " ", "version", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "args_", ",_", "types_", "._", "String", "Types_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "[_", "args_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "list_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "shell_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "[_", "\"/", "bin", "/", "sh", "\"_", ",_", "\"-", "c", "\"_", "]_", "+_", "args_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "executable_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "args_", "[_", "0_", "]_", "=_", "executable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "executable_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "executable_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "transfer", "ring", " ", "possib", "le", " ", "exec", " ", "fail", "ure", " ", "from", " ", "child", " ", "to", " ", "parent_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "first", " ", "char", " ", "speci", "fie", "s", " ", "the", " ", "exception", " ", "type", ":", " ", "0", " ", "means_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OSE", "rror", ",", " ", "1", " ", "means", " ", "some", " ", "other", " ", "error", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "err", "pipe", "\\u", "read_", ",_", "err", "pipe", "\\u", "write_", "=_", "self_", "._", "pipe", "\\u", "clo", "exec_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "gc", "\\u", "was", "\\u", "enabled_", "=_", "gc_", "._", "ise", "nable", "d_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Disa", "ble", " ", "gc", " ", "to", " ", "avoid", " ", "bug", " ", "where", " ", "gc", " ", "->", " ", "file", "\\u", "deal", "loc", " ", "->_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "write", " ", "to", " ", "std", "err", " ", "->", " ", "hang", ".", " ", " ", "http", "://", "bug", "s", ".", "python", ".", "org", "/", "issue", "133", "6_", "\\u\\u\\uNL\\u\\u\\u_", "gc_", "._", "disable_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "pid_", "=_", "os_", "._", "fork_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "gc", "\\u", "was", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gc_", "._", "enable_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "child", "\\u", "created_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "pid_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Child_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Clos", "e", " ", "parent", "'", "s", " ", "pipe", " ", "ends_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "p2", "cw", "rite_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "p2", "cw", "rite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "c2", "prea", "d_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "c2", "prea", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "err", "read_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "err", "read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "close_", "(_", "err", "pipe", "\\u", "read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Whe", "n", " ", "dup", "ing", " ", "fds", ",", " ", "if", " ", "there", " ", "aris", "es", " ", "a", " ", "situation", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "where", " ", "one", " ", "of", " ", "the", " ", "fds", " ", "is", " ", "eit", "her", " ", "0", ",", " ", "1", " ", "or", " ", "2", ",", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "possib", "le", " ", "tha", "t", " ", "it", " ", "is", " ", "overwrit", "ten", " ", "(", "#", "126", "0", "7", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c2", "pwr", "ite_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "c2", "pwr", "ite_", "=_", "os_", "._", "dup_", "(_", "c2", "pwr", "ite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "err", "write_", "==_", "0_", "or_", "err", "write_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "err", "write_", "=_", "os_", "._", "dup_", "(_", "err", "write_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Dup", " ", "fds", " ", "for", " ", "child_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "dup", "2_", "(_", "a_", ",_", "b_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "dup", "2", "()", " ", "remove", "s", " ", "the", " ", "CLO", "EXEC", " ", "flag", " ", "but", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "must", " ", "do", " ", "it", " ", "ours", "elv", "es", " ", "if", " ", "dup", "2", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wou", "ld", " ", "be", " ", "a", " ", "no", "-", "op", " ", "(", "issue", " ", "#", "1080", "6", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "a_", "==_", "b_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "set\\u", "clo", "exec", "\\u", "flag_", "(_", "a_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "a_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "dup", "2_", "(_", "a_", ",_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "dup", "2_", "(_", "p2", "crea", "d_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "dup", "2_", "(_", "c2", "pwr", "ite_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "dup", "2_", "(_", "err", "write_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Clos", "e", " ", "pipe", " ", "fds", ".", " ", " ", "Make", " ", "sure", " ", "we", " ", "don", "'", "t", " ", "close", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "same", " ", "fd", " ", "more", " ", "than", " ", "onc", "e", ",", " ", "or", " ", "standard", " ", "fds", "._", "\\u\\u\\uNL\\u\\u\\u_", "closed_", "=_", "set_", "(_", "[_", "None_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fd_", "in_", "[_", "p2", "crea", "d_", ",_", "c2", "pwr", "ite_", ",_", "err", "write_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "fd_", "not_", "in_", "closed_", "and_", "fd_", ">_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "closed_", "._", "add_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Clos", "e", " ", "all", " ", "other", " ", "fds", ",", " ", "if", " ", "ask", "ed", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "close", "\\u", "fds_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "close", "\\u", "fds_", "(_", "but", "_", "=_", "err", "pipe", "\\u", "write_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cwd_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "chdir_", "(_", "cwd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "pree", "xec", "\\u", "fn_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pree", "xec", "\\u", "fn_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "env_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "exec", "vp_", "(_", "executable_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "exec", "vp", "e_", "(_", "executable_", ",_", "args_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "exc", "\\u", "type_", ",_", "exc", "\\u", "value_", ",_", "tb_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Save", " ", "the", " ", "traceback", " ", "and", " ", "attach", " ", "it", " ", "to", " ", "the", " ", "exception", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "exc", "\\u", "lines_", "=_", "traceback_", "._", "format\\u", "exception_", "(_", "exc", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "exc", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exc", "\\u", "value_", "._", "child", "\\u", "traceback_", "=_", "''_", "._", "join_", "(_", "exc", "\\u", "lines_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "write_", "(_", "err", "pipe", "\\u", "write_", ",_", "pickle_", "._", "dumps_", "(_", "exc", "\\u", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "exit", "code", " ", "won", "'", "t", " ", "be", " ", "reporte", "d", " ", "to", " ", "applica", "tion", "s", ",", " ", "so", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "reall", "y", " ", "doe", "sn", "'", "t", " ", "matte", "r", " ", "what", " ", "we", " ", "return", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "\\u", "exit_", "(_", "255_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parent_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "gc", "\\u", "was", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gc_", "._", "enable_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "be", " ", "sure", " ", "the", " ", "FD", " ", "is", " ", "close", "d", " ", "no", " ", "matte", "r", " ", "what_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "close_", "(_", "err", "pipe", "\\u", "write_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p2", "crea", "d_", "is_", "not_", "None_", "and_", "p2", "cw", "rite_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "close_", "(_", "p2", "crea", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "c2", "pwr", "ite_", "is_", "not_", "None_", "and_", "c2", "prea", "d_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "close_", "(_", "c2", "pwr", "ite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "err", "write_", "is_", "not_", "None_", "and_", "err", "read_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "os_", "._", "close_", "(_", "err", "write_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wait", " ", "for", " ", "exec", " ", "to", " ", "fail", " ", "or", " ", "succe", "ed", ";", " ", "possib", "ly", " ", "rais", "ing", " ", "exception_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Except", "ion", " ", "limited", " ", "to", " ", "1", "M_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "=_", "\\u", "ein", "tr", "\\u", "retr", "y", "\\u", "call_", "(_", "os_", "._", "read_", ",_", "err", "pipe", "\\u", "read_", ",_", "104857", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "be", " ", "sure", " ", "the", " ", "FD", " ", "is", " ", "close", "d", " ", "no", " ", "matte", "r", " ", "what_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "close_", "(_", "err", "pipe", "\\u", "read_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "data_", "!=_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "\\u", "ein", "tr", "\\u", "retr", "y", "\\u", "call_", "(_", "os_", "._", "wait", "pid_", ",_", "self_", "._", "pid_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "e_", "._", "errno_", "!=_", "errno_", "._", "EC", "HI", "LD_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "child", "\\u", "exception_", "=_", "pickle_", "._", "loads_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fd_", "in_", "(_", "p2", "cw", "rite_", ",_", "c2", "prea", "d_", ",_", "err", "read_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "fd_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "close_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "child", "\\u", "exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
pybrain/pybrain/pybrain/auxiliary/__init__.py
[ { "content": "from pybrain.auxiliary.gradientdescent import GradientDescent\nfrom pybrain.auxiliary.gaussprocess import GaussianProcess\nfrom pybrain.auxiliary.importancemixing import importanceMixing", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from pybrain.auxiliary.gradientdescent import GradientDescent", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 61 }, { "span": "from pybrain.auxiliary.gaussprocess import GaussianProcess", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 58 }, { "span": "from pybrain.auxiliary.importancemixing import importanceMixing", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 63 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "pyb", "rain_", "._", "auxiliary", "_", "._", "gradi", "ent", "descent", "_", "import_", "Grad", "ient", "Descen", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyb", "rain_", "._", "auxiliary", "_", "._", "gauss", "process_", "import_", "Gaussian", "Process_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyb", "rain_", "._", "auxiliary", "_", "._", "importance", "mixing", "_", "import_", "importance", "Mix", "ing_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Unused local variable
CGATOxford/cgat/scripts/cgat_get_options.py
[ { "content": "def collectOptionsFromScript(script_name):\n '''collect options used in script *script_name*.'''\n\n # call other script\n prefix, suffix = os.path.splitext(script_name)\n\n dirname = os.path.dirname(script_name)\n basename = os.path.basename(script_name)[:-3]\n\n if os.path.exists(prefix + \".pyc\"):\n os.remove(prefix + \".pyc\")\n\n # check if script contains getopt\n with IOTools.openFile(script_name) as inf:\n if \"getopt\" in inf.read():\n E.warn(\"script %s uses getopt directly\" % script_name)\n return []\n\n try:\n module = imp.load_source(basename, script_name)\n except ImportError, msg:\n E.warn('could not import %s - skipped: %s' % (basename, msg))\n return []\n\n E.Start = LocalStart\n\n try:\n module.main(argv=[\"--help\"])\n except AttributeError:\n E.warn(\"no main method in %s\" % script_name)\n return []\n except SystemExit:\n E.warn(\"script exits - possibly does not use E.Start()\")\n return []\n except DummyError:\n pass\n\n result = []\n for option in PARSER.option_list:\n # ignore options added by optparse\n if option.dest is None:\n continue\n\n optstring = option.get_opt_string()\n if optstring.startswith(\"--\"):\n optstring = optstring[2:]\n result.append(optstring)\n\n return result", "metadata": "root.collectOptionsFromScript", "header": "['module', '___EOS___']", "index": 79 } ]
[ { "span": "dirname ", "start_line": 85, "start_column": 4, "end_line": 85, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "collect", "Optio", "ns", "Fro", "m", "Script_", "(_", "script", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "collect", " ", "options", " ", "used", " ", "in", " ", "script", " ", "*", "script", "\\u", "name", "*.", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "call", " ", "other", " ", "script_", "\\u\\u\\uNL\\u\\u\\u_", "prefix_", ",_", "suffix_", "=_", "os_", "._", "path_", "._", "splitext_", "(_", "script", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dirname_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "script", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "basename_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "script", "\\u", "name_", ")_", "[_", ":_", "-_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "prefix_", "+_", "\".", "pyc", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "prefix_", "+_", "\".", "pyc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "script", " ", "contain", "s", " ", "getopt_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "IO", "Tools_", "._", "open", "File_", "(_", "script", "\\u", "name_", ")_", "as_", "inf_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\"", "getop", "t", "\"_", "in_", "inf_", "._", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "warn_", "(_", "\"", "script", " ", "%", "s", " ", "use", "s", " ", "getop", "t", " ", "direct", "ly", "\"_", "%_", "script", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module_", "=_", "imp_", "._", "load", "\\u", "source_", "(_", "basename_", ",_", "script", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ",_", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "warn_", "(_", "'", "coul", "d", " ", "not", " ", "import", " ", "%", "s", " ", "-", " ", "skip", "ped", ":", " ", "%", "s", "'_", "%_", "(_", "basename_", ",_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "E_", "._", "Start_", "=_", "Local", "Start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module_", "._", "main_", "(_", "argv_", "=_", "[_", "\"--", "help", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Attribute", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "warn_", "(_", "\"", "no", " ", "main", " ", "method", " ", "in", " ", "%", "s", "\"_", "%_", "script", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "System", "Exit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "warn_", "(_", "\"", "script", " ", "exits", " ", "-", " ", "possib", "ly", " ", "doe", "s", " ", "not", " ", "use", " ", "E", ".", "Start", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Du", "mm", "y", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "option_", "in_", "PARSER_", "._", "option", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ignore", " ", "options", " ", "adde", "d", " ", "by", " ", "optparse_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "option_", "._", "dest_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "opts", "tring_", "=_", "option_", "._", "get", "\\u", "opt", "\\u", "string_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "opts", "tring_", "._", "startswith_", "(_", "\"--\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts", "tring_", "=_", "opts", "tring_", "[_", "2_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "._", "append_", "(_", "opts", "tring_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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ghub/frontera/frontera/utils/graphs/__init__.py
[ { "content": "import data\nfrom manager import CrawlGraphManager as Manager\nfrom models import CrawlPage as Page\nfrom models import CrawlPageRelation as Relation", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import data", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 11 }, { "span": "from manager import CrawlGraphManager as Manager", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 48 }, { "span": "from models import CrawlPage as Page", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 36 }, { "span": "from models import CrawlPageRelation as Relation", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 48 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "manager_", "import_", "Crawl", "Graph", "Manager_", "as_", "Manager_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "models_", "import_", "Crawl", "Page_", "as_", "Page_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "models_", "import_", "Crawl", "Page", "Relation_", "as_", "Relation_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1 ]
Unused import
rtucker-mozilla/mozilla_inventory/dhcp/views.py
[ { "content": "from django.core.exceptions import ValidationError\nfrom django.core.paginator import Paginator, InvalidPage, EmptyPage\n\nfrom django.db.models import Q\nfrom django.http import HttpResponse, HttpResponseRedirect\nfrom django.shortcuts import render_to_response, redirect, get_object_or_404\nfrom django.template import RequestContext\nfrom django.template.loader import render_to_string\ntry:\n import json\nexcept:\n from django.utils import simplejson as json\nimport _mysql_exceptions\n\nimport models\nimport forms\nfrom truth.models import KeyValue as TruthKeyValue, Truth\nfrom systems.models import NetworkAdapter\n#import adapters.dhcp\nfrom middleware.restrict_to_remote import allow_anyone\n\nfrom DHCP import DHCP\nfrom django.test.client import RequestFactory\nfrom django.template.defaulttags import URLNode\nfrom django.conf import settings\nfrom jinja2.filters import contextfilter\nfrom django.utils import translation\nfrom libs.jinja import jinja_render_to_response\nfrom api_v2.keyvalue_handler import KeyValueHandler\n\nfactory = RequestFactory()\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def showall(request):\n dhcp_scopes = models.DHCP.objects.all()\n h = KeyValueHandler()\n request = factory.get('/en-US/api/keyvalue/?key=is_dhcp_scope', follow=True)\n obj = h.read(request)\n dhcp_scopes = []\n for key in obj.iterkeys():\n dhcp_scopes.append(key.split(\":\")[1])\n\n return jinja_render_to_response('dhcp/index.html', {\n 'dhcp_scopes': dhcp_scopes,\n })", "metadata": "root.showall", "header": "['module', '___EOS___']", "index": 33 }, { "content": "def new(request):\n error_message = ''\n if request.method == 'POST':\n form = forms.AddDHCPScopeForm(request.POST)\n if form.is_valid():\n truth_exists = False\n try:\n tmp = Truth.objects.get(name=form.cleaned_data['scope_name'])\n truth_exists = True\n except:\n pass\n if truth_exists is False: \n t = Truth(name=form.cleaned_data['scope_name'], description=form.cleaned_data['scope_description'])\n t.save()\n k = TruthKeyValue(truth=t,key='is_dhcp_scope',value='True')\n k.save()\n return redirect('/dhcp/edit/%s' % t.name)\n else:\n error_message = 'DHCP Scope Exists'\n else:\n form = forms.AddDHCPScopeForm()\n\n return jinja_render_to_response('dhcp/new.html', {\n \"form\": form ,\n \"error_message\":error_message\n })", "metadata": "root.new", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def override_file(request, dhcp_scope):\n if request.method == 'POST':\n form = forms.DHCPScopeOverrideForm(request.POST)\n if form.is_valid():\n do = models.DHCPOverride.objects.get(dhcp_scope=dhcp_scope)\n do.override_text = form.cleaned_data['override_text']\n do.save()\n #s = form.save()\n #return redirect('/dhcp/show/')\n else:\n try:\n do = models.DHCPOverride.objects.get(dhcp_scope=dhcp_scope)\n except:\n do = models.DHCPOverride(dhcp_scope=dhcp_scope)\n do.save()\n\n form = forms.DHCPScopeOverrideForm(initial={'dhcp_scope':dhcp_scope, 'override_text':do.override_text})\n\n return jinja_render_to_response('dhcp/override.html', {\n \"form\": form,\n 'dhcp_scope':dhcp_scope\n },\n RequestContext(request))", "metadata": "root.override_file", "header": "['module', '___EOS___']", "index": 72 }, { "content": "def showfile(request, dhcp_scope):\n #scope = get_object_or_404(models.DHCP, pk=id)\n #truth = Truth.objects.get(name='phx-vlan73')\n #scope = TruthKeyValue(truth=truth)\n try:\n d = models.DHCPFile.objects.get(dhcp_scope=dhcp_scope)\n content = d.file_text\n except Exception, e:\n content = \"\"\"This file has not been stored in inventory yet. \n To get it stored. Make an innocous change to a hosts key/value entry. \n An example would be to change the nic name from nic0 to nic1 then back to nic0 again and click save. \n Once the file gets regenerated, it will be stored here\"\"\"\n output = content.replace(\"\\n\",\"<br />\")\n return render_to_response('dhcp/showfile.html', {\n\n \"output\": output \n },\n RequestContext(request))", "metadata": "root.showfile", "header": "['module', '___EOS___']", "index": 95 }, { "content": "def create(request):\n if request.method == 'POST':\n form = forms.AddDHCPScopeForm(request.POST)\n if form.is_valid():\n pass\n #s = form.save()\n #return redirect('/dhcp/show/')\n else:\n form = forms.AddDHCPScopeForm()\n\n return render_to_response('dhcp/new.html', {\n \"form\": form \n },\n RequestContext(request))", "metadata": "root.create", "header": "['module', '___EOS___']", "index": 113 }, { "content": "def edit(request, dhcp_scope):\n h = KeyValueHandler()\n trequest = factory.get('/api/keyvalue/?keystore=%s' % dhcp_scope, follow=True)\n instance = h.read(trequest)\n initial = {}\n initial['scope_name'] = dhcp_scope\n ##A bunch of try/catch blocks to create key/value pairs if one does not exist\n try:\n initial['scope_start'] = instance['dhcp.scope.start']\n except:\n trequest = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.scope.start', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['scope_start'] = ''\n try:\n initial['scope_end'] = instance['dhcp.scope.end']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.scope.end', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['scope_end'] = ''\n try:\n initial['scope_netmask'] = instance['dhcp.scope.netmask']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.scope.netmask', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['scope_netmask'] = ''\n try:\n initial['pool_start'] = instance['dhcp.pool.start']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.pool.start', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['pool_start'] = ''\n try:\n initial['pool_end'] = instance['dhcp.pool.end']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.pool.end', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['pool_end'] = ''\n try:\n initial['ntp_server1'] = instance['dhcp.option.ntp_server.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.option.ntp_server.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['ntp_server1'] = ''\n try:\n initial['ntp_server2'] = instance['dhcp.option.ntp_server.1']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.option.ntp_server.1', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['ntp_server2'] = ''\n try:\n initial['router'] = instance['dhcp.option.router.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.option.router.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['router'] = ''\n try:\n initial['domain_name'] = instance['dhcp.option.domain_name.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.option.domain_name.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['domain_name'] = ''\n try:\n initial['dns_server1'] = instance['dhcp.dns_server.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.dns_server.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['dns_server1'] = ''\n try:\n initial['dns_server2'] = instance['dhcp.dns_server.1']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.dns_server.1', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['dns_server2'] = ''\n try:\n initial['allow_booting'] = instance['dhcp.pool.allow_booting.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.pool.allow_booting.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['allow_booting'] = ''\n try:\n initial['allow_bootp'] = instance['dhcp.pool.allow_bootp.0']\n except:\n treqeust = factory.post('/en-US/api/keyvalue/%s/' % dhcp_scope, {'key':'dhcp.pool.allow_bootp.0', 'value':'', 'truth_name':dhcp_scope}, follow=True)\n h.create(trequest)\n initial['allow_bootp'] = ''\n\n if request.method == 'POST':\n form = forms.EditDHCPScopeForm(request.POST)\n if form.is_valid():\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.scope.start', 'value':form.cleaned_data['scope_start']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.scope.end', 'value':form.cleaned_data['scope_end']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.scope.netmask', 'value':form.cleaned_data['scope_netmask']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.pool.start', 'value':form.cleaned_data['pool_start']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.pool.end', 'value':form.cleaned_data['pool_end']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.option.ntp_server.0', 'value':form.cleaned_data['ntp_server1']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.option.ntp_server.1', 'value':form.cleaned_data['ntp_server2']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.dns_server.0', 'value':form.cleaned_data['dns_server1']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.dns_server.1', 'value':form.cleaned_data['dns_server2']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.option.domain_name.0', 'value':form.cleaned_data['domain_name']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.option.router.0', 'value':form.cleaned_data['router']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.pool.allow_booting.0', 'value':form.cleaned_data['allow_booting']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n trequest = factory.post('/en-US/api/v2/keyvalue/%s/' % dhcp_scope, {'truth_id': dhcp_scope, 'key':'dhcp.pool.allow_bootp.0', 'value':form.cleaned_data['allow_bootp']}, follow=True)\n h.update(trequest, dhcp_scope)\n\n else:\n form = forms.EditDHCPScopeForm(initial=initial)\n\n return jinja_render_to_response('dhcp/edit.html', {\n \"form\": form,\n 'dhcp_scope': dhcp_scope\n })", "metadata": "root.edit", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def delete(request, dhcp_scope):\n try:\n scope = Truth.objects.get(name=dhcp_scope)\n TruthKeyValue.objects.filter(truth=scope).delete()\n scope.delete()\n return redirect('/dhcp/show/')\n except: \n return redirect('/dhcp/show/')", "metadata": "root.delete", "header": "['module', '___EOS___']", "index": 263 } ]
[ { "span": "from django.core.exceptions import ValidationError", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 50 }, { "span": "from django.core.paginator import Paginator, InvalidPage, EmptyPage", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 67 }, { "span": "from django.db.models import Q", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 30 }, { "span": "from django.http import HttpResponse, HttpResponseRedirect", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 58 }, { "span": "from django.shortcuts import render_to_response, redirect, get_object_or_404", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 76 }, { "span": "from django.template.loader import render_to_string", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 51 }, { "span": "import json", "start_line": 9, "start_column": 4, "end_line": 9, "end_column": 15 }, { "span": "from django.utils import simplejson as json", "start_line": 11, "start_column": 4, "end_line": 11, "end_column": 47 }, { "span": "import _mysql_exceptions", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 24 }, { "span": "from systems.models import NetworkAdapter", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 41 }, { "span": "from middleware.restrict_to_remote import allow_anyone", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 54 }, { "span": "from DHCP import DHCP", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 21 }, { "span": "from django.template.defaulttags import URLNode", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 47 }, { "span": "from django.conf import settings", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 32 }, { "span": "from jinja2.filters import contextfilter", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 40 }, { "span": "from django.utils import translation", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 36 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "paginator_", "import_", "Paginator_", ",_", "Inva", "lid", "Page_", ",_", "Emp", "ty", "Page_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Response_", ",_", "Http", "Respons", "e", "Redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "shortcuts_", "import_", "render", "\\u", "to", "\\u", "response_", ",_", "redirect_", ",_", "get", "\\u", "object\\u", "or", "\\u", "404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "import_", "Request", "Context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "loader_", "import_", "render", "\\u", "to", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "utils_", "import_", "simplejson_", "as_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "\\u", "mysql", "\\u", "exceptions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "forms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "truth_", "._", "models_", "import_", "Key", "Value_", "as_", "Tru", "th", "Key", "Value_", ",_", "Tru", "th_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "systems_", "._", "models_", "import_", "Network", "Adapter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "import", " ", "adapter", "s", ".", "dhcp_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "middleware_", "._", "restrict", "\\u", "to", "\\u", "remote_", "import_", "allow", "\\u", "any", "one_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "DHC", "P_", "import_", "DHC", "P_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "._", "client_", "import_", "Request", "Factory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "default", "tags_", "import_", "URL", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "jinja2_", "._", "filters_", "import_", "context", "filter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "translation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "libs_", "._", "jin", "ja_", "import_", "jin", "ja", "\\u", "render", "\\u", "to", "\\u", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "api", "\\u", "v2_", "._", "keyval", "ue", "\\u", "handler_", "import_", "Key", "Value", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "factory_", "=_", "Request", "Factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "show", "all_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dhcp", "\\u", "scopes_", "=_", "models_", "._", "DHC", "P_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "=_", "Key", "Value", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "=_", "factory_", "._", "get_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/?", "key", "=", "is", "\\u", "dhcp", "\\u", "scope", "'_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "=_", "h_", "._", "read_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dhcp", "\\u", "scopes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", "in_", "obj_", "._", "iterkeys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dhcp", "\\u", "scopes_", "._", "append_", "(_", "key_", "._", "split_", "(_", "\":\"_", ")_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "jin", "ja", "\\u", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "index", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dhcp", "\\u", "scope", "s", "'_", ":_", "dhcp", "\\u", "scopes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "new_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "\\u", "message_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Add", "DHC", "PS", "cope", "Form_", "(_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "truth", "\\u", "exists_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmp_", "=_", "Tru", "th_", "._", "objects_", "._", "get_", "(_", "name_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "truth", "\\u", "exists_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "truth", "\\u", "exists_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "Tru", "th_", "(_", "name_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "name", "'_", "]_", ",_", "description_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "description", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "Tru", "th", "Key", "Value_", "(_", "truth_", "=_", "t_", ",_", "key_", "=_", "'", "is", "\\u", "dhcp", "\\u", "scope", "'_", ",_", "value_", "=_", "'", "Tru", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "redirect_", "(_", "'/", "dhcp", "/", "edit", "/", "%", "s", "'_", "%_", "t_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "\\u", "message_", "=_", "'", "DHC", "P", " ", "Sco", "pe", " ", "Exist", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Add", "DHC", "PS", "cope", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "jin", "ja", "\\u", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "new", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "error", "\\u", "message", "\"_", ":_", "error", "\\u", "message_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "override", "\\u", "file_", "(_", "request_", ",_", "dhcp", "\\u", "scope_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "DHC", "PS", "cope", "Override", "Form_", "(_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "do_", "=_", "models_", "._", "DHC", "PO", "ver", "ride", "_", "._", "objects_", "._", "get_", "(_", "dhcp", "\\u", "scope_", "=_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "do_", "._", "override", "\\u", "text_", "=_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "override", "\\u", "text", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "do_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "s", " ", "=", " ", "form", ".", "save", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "return", " ", "redirec", "t", "('", "/", "dhcp", "/", "show", "/'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "do_", "=_", "models_", "._", "DHC", "PO", "ver", "ride", "_", "._", "objects_", "._", "get_", "(_", "dhcp", "\\u", "scope_", "=_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "do_", "=_", "models_", "._", "DHC", "PO", "ver", "ride", "_", "(_", "dhcp", "\\u", "scope_", "=_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "do_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "forms_", "._", "DHC", "PS", "cope", "Override", "Form_", "(_", "initial_", "=_", "{_", "'", "dhcp", "\\u", "scope", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "override", "\\u", "text", "'_", ":_", "do_", "._", "override", "\\u", "text_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "jin", "ja", "\\u", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "override", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dhcp", "\\u", "scope", "'_", ":_", "dhcp", "\\u", "scope_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Request", "Context_", "(_", "request_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "file_", "(_", "request_", ",_", "dhcp", "\\u", "scope_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "scope", " ", "=", " ", "get", "\\u", "object\\u", "or", "\\u", "404", "(", "model", "s", ".", "DHC", "P", ",", " ", "pk", "=", "id", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "truth", " ", "=", " ", "Tru", "th", ".", "object", "s", ".", "get", "(", "name", "='", "ph", "x", "-", "vlan", "7", "3", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "scope", " ", "=", " ", "Tru", "th", "Key", "Value", "(", "truth", "=", "truth", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "models_", "._", "DHC", "PF", "ile_", "._", "objects_", "._", "get_", "(_", "dhcp", "\\u", "scope_", "=_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "d_", "._", "file", "\\u", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "\"\"\"", "Thi", "s", " ", "file", " ", "has", " ", "not", " ", "bee", "n", " ", "store", "d", " ", "in", " ", "inventor", "y", " ", "ye", "t", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "get", " ", "it", " ", "store", "d", ".", " ", "Make", " ", "an", " ", "inno", "cou", "s", " ", "change", " ", "to", " ", "a", " ", "host", "s", " ", "key", "/", "value", " ", "entry", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "example", " ", "wou", "ld", " ", "be", " ", "to", " ", "change", " ", "the", " ", "nic", " ", "name", " ", "from", " ", "nic", "0", " ", "to", " ", "nic", "1", " ", "then", " ", "back", " ", "to", " ", "nic", "0", " ", "again", " ", "and", " ", "click", " ", "save", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "On", "ce", " ", "the", " ", "file", " ", "gets", " ", "regenerate", "d", ",", " ", "it", " ", "will", " ", "be", " ", "store", "d", " ", "here", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "output_", "=_", "content_", "._", "replace_", "(_", "\"\\\\", "n", "\"_", ",_", "\"<", "br", " ", "/>\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "show", "file", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "output", "\"_", ":_", "output_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Request", "Context_", "(_", "request_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Add", "DHC", "PS", "cope", "Form_", "(_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "s", " ", "=", " ", "form", ".", "save", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "return", " ", "redirec", "t", "('", "/", "dhcp", "/", "show", "/'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Add", "DHC", "PS", "cope", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "new", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Request", "Context_", "(_", "request_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "edit_", "(_", "request_", ",_", "dhcp", "\\u", "scope_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h_", "=_", "Key", "Value", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "get_", "(_", "'/", "api", "/", "keyval", "ue", "/?", "keystore", "=", "%", "s", "'_", "%_", "dhcp", "\\u", "scope_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance_", "=_", "h_", "._", "read_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "scope", "\\u", "name", "'_", "]_", "=_", "dhcp", "\\u", "scope_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", "A", " ", "bunch", " ", "of", " ", "try", "/", "catch", " ", "blocks", " ", "to", " ", "create", " ", "key", "/", "value", " ", "pair", "s", " ", "if", " ", "one", " ", "doe", "s", " ", "not", " ", "exist_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "scope", "\\u", "start", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "scope", ".", "start", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "start", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "scope", "\\u", "start", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "scope", "\\u", "end", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "scope", ".", "end", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "end", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "scope", "\\u", "end", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "scope", "\\u", "net", "mask", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "scope", ".", "net", "mask", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "net", "mask", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "scope", "\\u", "net", "mask", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "pool", "\\u", "start", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "pool", ".", "start", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "start", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "pool", "\\u", "start", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "pool", "\\u", "end", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "pool", ".", "end", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "end", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "pool", "\\u", "end", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "ntp", "\\u", "server", "1", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "ntp", "\\u", "server", "1", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "ntp", "\\u", "server", "2", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".1", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".1", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "ntp", "\\u", "server", "2", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "router", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "option", ".", "router", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "router", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "router", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "domain", "\\u", "name", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "option", ".", "domain", "\\u", "name", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "domain", "\\u", "name", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "domain", "\\u", "name", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "dns", "\\u", "server", "1", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "dns", "\\u", "server", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "dns", "\\u", "server", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "dns", "\\u", "server", "1", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "dns", "\\u", "server", "2", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "dns", "\\u", "server", ".1", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "dns", "\\u", "server", ".1", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "dns", "\\u", "server", "2", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "allow", "\\u", "boot", "ing", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "ing", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "ing", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "allow", "\\u", "boot", "ing", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial_", "[_", "'", "allow", "\\u", "boot", "p", "'_", "]_", "=_", "instance_", "[_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "p", ".0", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "qe", "ust", "_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "p", ".0", "'_", ",_", "'", "value", "'_", ":_", "''_", ",_", "'", "truth", "\\u", "name", "'_", ":_", "dhcp", "\\u", "scope_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "create_", "(_", "tre", "quest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "initial_", "[_", "'", "allow", "\\u", "boot", "p", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Edit", "DHC", "PS", "cope", "Form_", "(_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "start", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "start", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "end", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "end", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "scope", ".", "net", "mask", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "scope", "\\u", "net", "mask", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "start", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "pool", "\\u", "start", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "end", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "pool", "\\u", "end", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "ntp", "\\u", "server", "1", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "ntp", "\\u", "server", ".1", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "ntp", "\\u", "server", "2", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "dns", "\\u", "server", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "dns", "\\u", "server", "1", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "dns", "\\u", "server", ".1", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "dns", "\\u", "server", "2", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "domain", "\\u", "name", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "domain", "\\u", "name", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "option", ".", "router", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "router", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "ing", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "allow", "\\u", "boot", "ing", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tre", "quest_", "=_", "factory_", "._", "post_", "(_", "'/", "en", "-", "US", "/", "api", "/", "v2", "/", "keyval", "ue", "/", "%", "s", "/'_", "%_", "dhcp", "\\u", "scope_", ",_", "{_", "'", "truth", "\\u", "id", "'_", ":_", "dhcp", "\\u", "scope_", ",_", "'", "key", "'_", ":_", "'", "dhcp", ".", "pool", ".", "allow", "\\u", "boot", "p", ".0", "'_", ",_", "'", "value", "'_", ":_", "form_", "._", "clean", "ed", "\\u", "data_", "[_", "'", "allow", "\\u", "boot", "p", "'_", "]_", "}_", ",_", "follow_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "._", "update_", "(_", "tre", "quest_", ",_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "forms_", "._", "Edit", "DHC", "PS", "cope", "Form_", "(_", "initial_", "=_", "initial_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "jin", "ja", "\\u", "render", "\\u", "to", "\\u", "response_", "(_", "'", "dhcp", "/", "edit", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dhcp", "\\u", "scope", "'_", ":_", "dhcp", "\\u", "scope_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "request_", ",_", "dhcp", "\\u", "scope_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "scope_", "=_", "Tru", "th_", "._", "objects_", "._", "get_", "(_", "name_", "=_", "dhcp", "\\u", "scope_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Tru", "th", "Key", "Value_", "._", "objects_", "._", "filter_", "(_", "truth_", "=_", "scope_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scope_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\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 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
First parameter of a method is not named 'self'
cornell-brg/pymtl/pclib/rtl/Decoder.py
[ { "content": " def __init__( s, sel_nbits, out_nbits ):\n\n s.in_ = InPort ( sel_nbits )\n s.out = OutPort( out_nbits )\n\n @s.combinational\n def logic():\n for i in range( out_nbits ):\n s.out[i].value = (s.in_ == i)", "metadata": "root.Decoder.__init__", "header": "['class', 'Decoder', '(', 'Model', ')', ':', '___EOS___']", "index": 11 }, { "content": " def line_trace( s ):\n return '{} () {}'.format( s.in_, s.out )", "metadata": "root.Decoder.line_trace", "header": "['class', 'Decoder', '(', 'Model', ')', ':', '___EOS___']", "index": 21 } ]
[ { "span": "def __init__( s, sel_nbits, out_nbits ):", "start_line": 11, "start_column": 2, "end_line": 11, "end_column": 42 }, { "span": "def line_trace( s ):", "start_line": 21, "start_column": 2, "end_line": 21, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Decoder_", "(_", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "s_", ",_", "sel", "\\u", "nbi", "ts_", ",_", "out", "\\u", "nbi", "ts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "in\\u_", "=_", "In", "Port_", "(_", "sel", "\\u", "nbi", "ts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "out_", "=_", "Out", "Port_", "(_", "out", "\\u", "nbi", "ts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "s_", "._", "combinat", "ional", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "logic_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "out", "\\u", "nbi", "ts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "out_", "[_", "i_", "]_", "._", "value_", "=_", "(_", "s_", "._", "in\\u_", "==_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Decoder_", "(_", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "line", "\\u", "trace_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'{}", " ", "()", " ", "{}'_", "._", "format_", "(_", "s_", "._", "in\\u_", ",_", "s_", "._", "out_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
jcberquist/sublimetext-cfml/src/testbox/test_runner.py
[ { "content": "\tdef run_tests(self, full_url, test_bundle):\n\t\tsublime.status_message(\"TestBox: running tests\")\n\t\tprint(\"TestBox: \" + full_url)\n\n\t\ttry:\n\t\t\tjson_string = urllib.request.urlopen(full_url).read().decode(\"utf-8\")\n\t\t\tresult_string = render_result(json.loads(json_string), test_bundle)\n\t\texcept:\n\t\t\tresult_string = \"\\nError when trying to fetch:\\n\" + full_url\n\t\t\tresult_string += \"\\nPlease verify the URL is valid and returns the test results in JSON.\"\n\n\t\tself.output_view.run_command(\"append\", {\"characters\": result_string, \"force\": True, \"scroll_to_end\": False})", "metadata": "root.TestboxCommand.run_tests", "header": "['class', 'TestboxCommand', '(', 'sublime_plugin', '.', 'WindowCommand', ')', ':', '___EOS___']", "index": 73 } ]
[ { "span": "except:", "start_line": 80, "start_column": 2, "end_line": 80, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Test", "box", "Command_", "(_", "sublim", "e\\u", "plugin_", "._", "Window", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "tests_", "(_", "self_", ",_", "full", "\\u", "url_", ",_", "test\\u", "bundle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "sublime_", "._", "status", "\\u", "message_", "(_", "\"", "Test", "Box", ":", " ", "runn", "ing", " ", "tests", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Test", "Box", ":", " ", "\"_", "+_", "full", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "json", "\\u", "string_", "=_", "urllib_", "._", "request_", "._", "urlopen_", "(_", "full", "\\u", "url_", ")_", "._", "read_", "(_", ")_", "._", "decode_", "(_", "\"", "utf", "-", "8", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result", "\\u", "string_", "=_", "render", "\\u", "result_", "(_", "json_", "._", "loads_", "(_", "json", "\\u", "string_", ")_", ",_", "test\\u", "bundle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "result", "\\u", "string_", "=_", "\"\\\\", "n", "Error", " ", "whe", "n", " ", "try", "ing", " ", "to", " ", "fetch", ":\\\\", "n", "\"_", "+_", "full", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result", "\\u", "string_", "+=_", "\"\\\\", "n", "Ple", "ase", " ", "verify", " ", "the", " ", "URL", " ", "is", " ", "valid", " ", "and", " ", "return", "s", " ", "the", " ", "test", " ", "results", " ", "in", " ", "JSO", "N", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "output", "\\u", "view_", "._", "run", "\\u", "command_", "(_", "\"", "append", "\"_", ",_", "{_", "\"", "character", "s", "\"_", ":_", "result", "\\u", "string_", ",_", "\"", "force", "\"_", ":_", "True_", ",_", "\"", "scroll", "\\u", "to", "\\u", "end", "\"_", ":_", "False_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
gleicon/pyriemann/examples/tcp_gevent_multiple_send.py
[ { "content": "import os, sys\nsys.path.append(\"..\")\nfrom riemann import RiemannClient\nimport time\nimport gevent\nfrom gevent import pool\nfrom gevent import monkey\ngevent.monkey.patch_all()\n\n\n\n\nif __name__ == '__main__':\n main()\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def _s(pars):\n rc = RiemannClient()\n r = rc.send(pars)\n # do something with r", "metadata": "root._s", "header": "['module', '___EOS___']", "index": 9 }, { "content": "def main():\n tb = time.time()\n p = pool.Group()\n\n for n in xrange(100):\n pars = {'host':'127.0.0.1', 'service': 'www%d' % n, 'state': 'down', 'metric_f': 10000}\n c = p.spawn(_s, pars)\n \n p.join()\n\n print time.time() - tb", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 14 } ]
[ { "span": "import os, sys", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 14 }, { "span": "from gevent import monkey", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "\"..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "rie", "man", "n_", "import_", "Ri", "eman", "n", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gevent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gevent_", "import_", "pool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gevent_", "import_", "monkey_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gevent_", "._", "monkey_", "._", "patch", "\\u", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "s_", "(_", "pars_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rc_", "=_", "Ri", "eman", "n", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "rc_", "._", "send_", "(_", "pars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "do", " ", "somet", "hing", " ", "with", " ", "r_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tb_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "pool_", "._", "Group_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "n_", "in_", "xrange_", "(_", "100_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pars_", "=_", "{_", "'", "host", "'_", ":_", "'", "127", ".0", ".0", ".1", "'_", ",_", "'", "service", "'_", ":_", "'", "www", "%", "d", "'_", "%_", "n_", ",_", "'", "state", "'_", ":_", "'", "down", "'_", ",_", "'", "metric", "\\u", "f", "'_", ":_", "10000_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "p_", "._", "spawn_", "(_", "\\u", "s_", ",_", "pars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p_", "._", "join_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "time_", "._", "time_", "(_", ")_", "-_", "tb_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
networkdynamics/zenlib/src/zen/io/gml.py
[ { "content": "\"\"\"\nThe ``zen.io.gml`` module (available as ``zen.gml``) supports the reading and \nwriting network data in the `Graph Modeling Language (GML) \n<http://en.wikipedia.org/wiki/Graph_Modelling_Language>`_. At present only \nreading GML is supported.\n\nGML is a flexible language for specifying the structure of a network (nodes \nand edges) that can be annotated with arbitrary attributes and information. \nThis module provides a full implementation of the GML file format as specified \nin the `technical report \n<http://www.fim.uni-passau.de/fileadmin/files/lehrstuhl/brandenburg/projekte/gml/gml-technical-report.pdf>`_:\n\n.. note::\n\tSource: Michael Himsolt. *GML: A portable Graph File Format*. Technical \n\tReport, Universitat Passau.\n\t\nFunctions\n---------\n\n.. autofunction:: zen.io.gml.read(fname[,weight_fxn=None])\n\"\"\"\n\nfrom zen.exceptions import *\nfrom zen.graph import Graph\nfrom zen.digraph import DiGraph\nfrom zen.bipartite import BipartiteGraph\nfrom gml_codec import BasicGMLCodec, ZenGMLCodec\nfrom gml_interpreter import GMLInterpreter\nfrom gml_tokenizer import GMLTokenizer\nfrom collections import Iterable, Hashable\nimport os\nimport cgi\nimport re\nimport codecs\nimport pdb\n\n__all__ = ['read','write']\n\nDIGITS = tuple(['%d' % x for x in range(10)]) + ('+','-')\nDIGITS_AND_QUOTES = DIGITS + ('\"',)\n\n\n\t\n\n\n\n\n\n\n\n\n\n\t\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def write(G, filename, **kwargs):\n\t\"\"\"\n\tWrites graph to file using Graph Modeling Language (gml). Node / Edge / \n\tGraph objects, if not None, are stored in the `name` attribute, and are \n\trestricted to numeric (but not complex), string, and boolean data types, \n\totherwise an exception is raised. \n\n\tNode / Edge / Graph data, if not None, are stored in a zen_data attribute \n\tand are similarly restricted. Support may be added later for serialization\n\tof arbitrary objects / data and associated to zen graphs.\n\t\n\tsee \n\thttp://www.fim.uni-passau.de/fileadmin/files/lehrstuhl/brandenburg/projekte/gml/gml-technical-report.pdf \n\tfor more info about gml.\n\n\t**Args**\n\t\t* ``G`` (:py:class:`zen.Graph`, :py:class:'zen.Digraph`, \n\t\t\t:py:class:`zen.BipartiteGraph): Graph object to be written to \n\t\t\tfile. Hypergraphs are not supported.\n\t\n\t\t* ``filename`` (str): Absolute path for the file to be written.\n\n\t**KwArgs**\n\t\t* ``write-data`` (bool | (bool, bool)): If 2-tuple of booleans \n\t\t\tsupplied, first indicates whether to write out node data second \n\t\t\twhether to write out edge data. If bool provided, it is applied \n\t\t\tfor both node and edge data.\n\n\t\t* ``use-zen-data`` (bool | (bool, bool)): Indicates whether to write \n\t\t\tout If 2-tuple of booleans supplied, first indicates whether to \n\t\t\twrite out node data second whether to write out edge data. If bool\n\t\t\tprovided, it is applied for both node and edge data. \n\n\t**Returns**:\n\t\t* None\n\t\"\"\"\n\n\t# Determine the write mode. There are various options the user can specify\n\t# which are reconsiled and validated here\n\twrite_node_data, write_edge_data, use_node_zen_data, use_edge_zen_data = resolve_write_mode(kwargs)\n\t\n\t# Get the encoder to use. This call resolves the various ways the user can\n\t# specify encoding, and does basic checks that the encoder is valid\n\tenc = resolve_codec(kwargs)\n\n\tfh = open(filename, 'w')\n\tfh.write('# This is a graph object in gml file format\\n')\n\tfh.write('# produced by the zen graph library\\n\\n')\n\n\t# Describe the encoding method used to generate the file. \n\tfh.write('ZenCodec \"%s\"\\n' % enc.__name__)\n\tfh.write('ZenStringEncoder \"%s\"\\n\\n' % enc.encode_str.__name__)\n\n\t# Start writing the graph\n\tfh.write('graph [\\n')\n\n\n\tif G.is_directed():\n\t\tfh.write('\\tdirected 1\\n')\n\n\telse:\n\t\tfh.write('\\tdirected 0\\n')\n\n\tif isinstance(G, BipartiteGraph):\n\t\tis_bipartite = True\n\t\tfh.write('\\tbipartite 1\\n')\n\n\telse:\n\t\tis_bipartite = False\n\t\tfh.write('\\tbipartite 0\\n')\t\t\n\n\t# iterate over nodes, writing them to the new gml file\n\tfor nidx, nobj, ndata in G.nodes_iter_(obj=True, data=True):\n\t\tfh.write('\\tnode [\\n')\n\t\tfh.write('\\t\\tid ' + str(nidx) + '\\n')\n\n\t\tif is_bipartite:\n\t\t\tfh.write(format_zen_data('isInU', G.is_in_U_(nidx), 2, enc))\n\n\t\tif nobj != None:\n\t\t\tfh.write(format_zen_data('name', nobj, 2, enc))\n\n\t\tif ndata != None and write_node_data:\n\t\t\tif use_node_zen_data:\n\t\t\t\tfh.write(format_zen_data('zenData', ndata, 2, enc))\n\n\t\t\telse:\t# expects zenData to be dict\n\t\t\t\tfor key, val in ndata.items():\n\t\t\t\t\tfh.write(format_zen_data(key, val, 2, enc))\n\n\t\tfh.write('\\t]\\n')\n\n\t# iterate over edges\n\tfor eidx, edata, weight in G.edges_iter_(data=True, weight=True):\n\t\tfh.write('\\tedge [\\n')\n\n\t\t# for digraphs, assumes endpoints order [source, target]\n\t\tfh.write('\\t\\tsource ' + str(G.endpoints_(eidx)[0]) + '\\n')\t\n\t\tfh.write('\\t\\ttarget ' + str(G.endpoints_(eidx)[1]) + '\\n')\n\t\tfh.write('\\t\\tweight ' + str(weight) + '\\n')\n\n\t\tif edata != None and write_edge_data:\n\t\t\tif use_edge_zen_data:\n\t\t\t\tfh.write(format_zen_data('zenData', edata, 2, enc))\n\n\t\t\telse:\t#expects zenData to be dict\n\t\t\t\tfor key, val in edata.items():\n\t\t\t\t\tfh.write(format_zen_data(key, val, 2, enc))\n\n\t\tfh.write('\\t]\\n')\n\n\tfh.write(']\\n')\n\tfh.close()", "metadata": "root.write", "header": "['module', '___EOS___']", "index": 41 }, { "content": "def format_zen_data(keyname, data, tab_depth, encoder, strict=True):\n\t\"\"\"\n\tReformats supplied data to use gml. Enforces restrictions on the types of \n\tdata that can be written to gml.\n\t\n\t**Args**\n\t\t* data (bool | int | long | float | str | dict | list): object to be \n\t\t\twritten in gml\n\t\t* key (str): key to be used in gml. Needed here because in gml lists \n\t\t\tare made by repeating the key in front of each value.\n\t\t* tab_depth (int): number of tab characters to add to the beginning \n\t\t\tof each line for nice formatting.\n\n\t**Returns**\n\t\t* formatted_data (str): gml representation of data\n\t\"\"\"\n\n\t\n\t# Validation: key names must be strictly alphanumeric\n\tif re.search('[^a-zA-Z0-9]', keyname) and strict:\n\t\traise ZenException(\n\t\t\t'gml supports only characters from [a-zA-Z0-9] in keys')\n\n\tformatted_data = ''\n\ttabs = '\\t' * tab_depth\n\n\tif not isinstance(data, (dict, list, tuple)):\n\n\t\tencoded_data = encoder.encode(data)\n\n\t\t# Validate encoder output\n\t\tif strict:\n\t\t\ttry:\n\t\t\t\tassert(isinstance(encoded_data, basestring))\n\t\t\t\tassert(encoded_data.startswith(DIGITS_AND_QUOTES))\n\t\t\t\tencoded_data.encode('ascii')\n\t\t\t\tif encoded_data.startswith(DIGITS):\n\t\t\t\t\tnum = float(encoded_data)\n\t\t\t\t\tassert(num < 2147483647 or num > -2147483648)\n\n\t\t\texcept AssertionError, UnicodeEncodeError:\n\t\t\t\traise ZenException('GML Encoder has violated gml specifications. '\\\n\t\t\t\t\t'see <http://www.fim.uni-passau.de/fileadmin/files/lehrstuhl/brandenburg/projekte/gml/gml-technical-report.pdf>. \\n Use '\\\n\t\t\t\t\t'gml.write(..., strict=False) to force writing.')\n\n\t\t# The encoded data is legal for gml. Append extras.\n\t\tformatted_data = tabs + keyname + ' ' + encoded_data + '\\n'\n\n\t# Recursive call for dicts\n\telif isinstance(data, dict):\n\t\tformatted_data += tabs + keyname + ' [\\n'\n\t\tfor key, val in data.items():\n\t\t\tformatted_data += format_zen_data(key, val, tab_depth + 1, encoder)\n\t\tformatted_data += tabs + ']\\n'\n\n\t# Recursive call for lists. GML represents lists by repeating the\n\t# key with different values\n\telse:\n\t\tassert(isinstance(data, (list, tuple)))\n\t\tfor val in data:\n\t\t\tformatted_data += format_zen_data(keyname, val, tab_depth, encoder)\n\n\n\treturn formatted_data", "metadata": "root.format_zen_data", "header": "['module', '___EOS___']", "index": 156 }, { "content": "def make_tree(fname, **kwargs):\n\t# resolve the codec. The user can specify the codec in various ways.\n\tcodec = resolve_codec(kwargs)\n\n\t# read the file \n\tfh = open(fname,'r')\n\tgml_str = fh.read()\n\tfh.close()\n\n\t# tokenize the gml string\n\ttok = GMLTokenizer()\n\ttokens = tok.tokenize(gml_str)\n\n\t# interpret the gml document into an internal datastructure\n\tinterpreter = GMLInterpreter(codec, tok)\n\tgml_tree = interpreter.interpret(tokens)\n\n\treturn gml_tree", "metadata": "root.make_tree", "header": "['module', '___EOS___']", "index": 222 }, { "content": "def read(fname,**kwargs):\n\t\"\"\"\n\tRead GML-formatted network data stored in file named ``fname``.\n\t\n\tThe node's ``id`` attribute is used to specify the node index. The node's \n\t``name`` attribute is preferably used as the node object. \n\n\tHowever, if the ``name`` attribute is missing and the ``label`` is present,\n\tthen the node's ``label`` attribute will be used as the node object. If \n\tboth are missing, then the node id will be used as the node object.\n\t\n\t.. note::\t\n\t\tCurrently graph attributes are not supported by the reader. If \n\t\tencountered, they will simply be skipped over and not added to the\n\t\tfinal graph. This is simply because graph objects don't support \n\t\tarbitrary data yet.\n\t\n\t**KwArgs**:\n\t\n\t\t* ``weight_fxn [=None]``: derive weight assignments from edge data. If\n\t\t\tspecified, this function is called with one parameter: the full \n\t\t\tset of attributes that were specified for the edge.\n\t\"\"\"\n\t\n\t# extract keyword arguments\n\tweight_fxn = kwargs.pop('weight_fxn',None)\n\n\t# parse the gml into a python dict structure\n\tgml_tree = make_tree(fname, **kwargs)\n\n\tif 'graph' in gml_tree:\n\n\t\tgraph_tree = gml_tree['graph']\n\n\t\tif(isinstance(gml_tree, list)):\n\t\t\tgraph_tree = gml_tree[0]\n\t\t\tprint 'Warning: multiple graphs stored in this file. Use '\\\n\t\t\t\t'gml.read_all(fname, [...]) to get list of all graphs'\n\t\n\t\treturn build_graph(graph_tree, weight_fxn)\n\n\telse:\n\t\treturn None", "metadata": "root.read", "header": "['module', '___EOS___']", "index": 242 }, { "content": "def read_all(fname, **kwargs):\n\n\t# extract keyword arguments\n\tweight_fxn = kwargs.pop('weight_fxn',None)\n\n\t# parse the gml into a python dict structure\n\tgml_tree = make_tree(fname, **kwargs)\n\n\tif 'graph' in gml_tree:\n\n\t\tgraph_tree = gml_tree['graph']\n\n\t\tif not isinstance(graph_tree, list):\n\t\t\tgraph_tree = [ gml_tree['graph'] ]\n\n\t\t\tgraph_tree = gml_tree[0]\n\t\t\tprint 'Warning: multiple graphs stored in this file. Use '\\\n\t\t\t\t'gml.read_all(fname, [...]) to get list of all graphs'\n\t\n\t\treturn build_graph(graph_tree, weight_fxn)\n\n\telse:\n\t\treturn None", "metadata": "root.read_all", "header": "['module', '___EOS___']", "index": 287 }, { "content": "def build_graph(graph_tree, weight_fxn):\n\n\t# What kind of graph is being built?\n\tis_bipartite = bool('bipartite' in graph_tree and graph_tree['bipartite'])\n\tis_directed = bool('directed' in graph_tree and graph_tree['directed'])\n\n\tif is_bipartite:\n\t\tG = BipartiteGraph()\n\n\telif is_directed:\n\t\tG = DiGraph()\n\n\telse:\n\t\tG = Graph()\n\n\t# Build the nodes\n\tif 'node' in graph_tree:\n\n\t\t# get the list of nodes\n\t\tnodes = graph_tree['node']\n\n\t\t# ensure the node-list is a list (needed if there's only one node)\n\t\tif not isinstance(nodes, list):\n\t\t\tnodes = [ nodes ]\n\n\t\t# Build each node and add to the graph\n\t\tfor node in nodes:\t\n\n\t\t\t# Does the node have an id?\n\t\t\thas_id = True\n\t\t\thas_valid_id = True\n\t\t\tif 'id' not in node:\n\t\t\t\thas_id = False\n\t\t\t\thas_valid_id = False\n\n\t\t\t# We can only use positive integer node ids as graph idx\n\t\t\t# If that's not the case, treat it like any other attribute\n\t\t\telif not isinstance(node['id'], int) or node['id'] < 0:\n\t\t\t\thas_valid_id = False\n\n\t\t\t# Got a valid node id\n\t\t\tnode_idx = node['id']\n\n\t\t\t# For bipartite graphs determine which node set this belongs to \n\t\t\tif is_bipartite:\n\t\t\t\tis_in_U = node['isInU']\n\n\t\t\t# collect and verify all the node properties\n\t\t\tstandard_keys = set(['id', 'name', 'zenData'])\n\t\t\tnode_data = {}\n\t\t\tnode_obj = None\n\t\t\tzen_data = None\n\n\t\t\tfor key, val in node.items():\n\n\t\t\t\tif key == 'name':\n\t\t\t\t\tnode_obj = val\n\n\t\t\t\t# give preference to 'name' as source of node_obj\n\t\t\t\telif key == 'label' and node_obj is None: \t\n\t\t\t\t\tnode_obj = val\n\n\t\t\t\telif key == 'zenData':\n\t\t\t\t\tzen_data = val\n\t\t\t\t\n\t\t\t\t# node_data is dict of all other attributes\n\t\t\t\telse:\t\n\t\t\t\t\tnode_data[key] = val \t\n\n\t\t\t# _set_ to node_data else _append_\n\t\t\tif zen_data is not None:\n\t\t\t\tif len(node_data) == 0:\n\t\t\t\t\tnode_data = zen_data\n\t\t\t\telse:\n\t\t\t\t\tnode_data['zenData'] = zen_data\n\n\t\t\telif len(node_data) == 0:\n\t\t\t\tnode_data = None\n\n\t\t\t# make sure that the node object is hashable otherwise put it\n\t\t\tif not isinstance(node_obj, basestring) and node_obj is not None:\n\n\t\t\t\tif not isinstance(node_obj, Hashable):\\\n\n\t\t\t\t\tif not isinstance(node_obj, Iterable):\n\t\t\t\t\t\tnode_obj = None\n\n\t\t\t\t\telse:\n\t\t\t\t\t\tnode_obj = tuple(node_obj)\n\n\n\t\t\t# For bipartite graph, this insertion method does not guarantee \n\t\t\t# that indices will be unchanged after a read-write cycle\n\t\t\tif is_bipartite:\n\t\t\t\tG.add_node_by_class(is_in_U, node_obj, node_data)\n\n\t\t\telif has_id and has_valid_id:\n\t\t\t\tif is_directed:\n\t\t\t\t\tG.add_node_x(node_idx, G.edge_list_capacity,\n\t\t\t\t\t\tG.edge_list_capacity, node_obj,node_data)\n\n\t\t\t\telse:\n\t\t\t\t\tG.add_node_x(node_idx, G.edge_list_capacity, node_obj, \n\t\t\t\t\t\tnode_data)\n\n\t\t\telse:\n\t\t\t\tif G.is_directed:\n\t\t\t\t\tG.add_node(nobj=node_obj, data=node_data)\n\n\t\t\t\telse:\n\t\t\t\t\tG.add_node(nobj=node_obj, data=node_data)\n\n\t# add edges\n\tif 'edge' in graph_tree:\n\n\t\t# ensure edge list is a list (needed if there is only one edge)\n\t\tedges = graph_tree['edge']\n\t\tif not isinstance(edges, list):\n\t\t\tedges = [ edges ]\n\n\t\t# iterate over the edges, add each one to the graph\n\t\tfor edge in edges:\n\n\t\t\t# make sure source and target are specified\n\t\t\tsource = None\n\t\t\ttarget = None\n\t\t\tif 'source' not in edge:\n\t\t\t\traise ZenException('Edge is missing the source attribute '\\\n\t\t\t\t\t'(edge = %s)' % str(edge))\n\n\t\t\tif 'target' not in edge:\n\t\t\t\traise ZenException('Edge is missing the target attribute '\\\n\t\t\t\t\t'(edge = %s)' % str(edge))\n\n\t\t\tweight = 1\n\t\t\tedge_idx = None\n\t\t\tzen_data = None\n\t\t\tedge_data = {}\n\n\t\t\tfor key, val in edge.items():\n\n\t\t\t\tif key == 'id':\n\t\t\t\t\tedge_idx = val\n\t\t\t\t\tif type(val) != int:\n\t\t\t\t\t\traise ZenException('Edge id attribute must be a '\\\n\t\t\t\t\t\t\t'positive integer (edge = %s)' % str(edge))\n\n\t\t\t\telif key == 'source':\n\t\t\t\t\tsource = val\n\t\t\t\t\tif type(val) != int or val < 0:\n\t\t\t\t\t\traise ZenException('Edge source attribute must be a '\\\n\t\t\t\t\t\t\t'positive integer (edge = %s)' % str(edge))\n\n\t\t\t\telif key == 'target':\n\t\t\t\t\ttarget = val\n\t\t\t\t\tif type(val) != int or val < 0:\n\t\t\t\t\t\traise ZenException('Edge target attribute must be a '\\\n\t\t\t\t\t\t\t'positive integer (edge = %s)' % str(edge))\n\n\t\t\t\telif key == 'weight':\n\t\t\t\t\tweight = float(val)\n\n\t\t\t\telif key == 'zenData':\n\t\t\t\t\tzen_data = val\n\n\t\t\t\t# edge_data is dict of all other attributes\n\t\t\t\telse: \n\t\t\t\t\tedge_data[key] = val \t\n\n\t\t\t# give precedence to a weight-getting function if provided\n\t\t\tif weight_fxn != None:\n\t\t\t\tweight = weight_fxn(edge)\n\n\t\t\t# if zenData is only other attribute aside from those handled above \n\t\t\t# _set_ to edge_data else _append_\n\t\t\tif zen_data is not None:\n\t\t\t\tif len(edge_data) == 0:\n\t\t\t\t\tedge_data = zen_data\n\t\t\t\telse:\n\t\t\t\t\tedge_data['zenData'] = zen_data\n\n\t\t\telif len(edge_data) == 0:\n\t\t\t\tedge_data = None;\n\n\t\t\tif edge_idx != None:\n\t\t\t\tG.add_edge_x(edge_idx,source,target,edge_data,weight)\n\t\t\telse:\n\t\t\t\tG.add_edge_(source,target,edge_data,weight)\n\n\treturn G", "metadata": "root.build_graph", "header": "['module', '___EOS___']", "index": 313 }, { "content": "def resolve_write_mode(kwargs):\n\n\t# Decide whether to write node and edge data\n\t# Default is to write both\n\twrite_node_data, write_edge_data = True, True\n\tif 'write_data' in kwargs:\n\n\t\t# write_data might be a tuple\n\t\tif type(kwargs['write_data']) == tuple:\n\t\t\twrite_node_data, write_edge_data = kwargs['write_data']\n\n\t\t# or just a single bool\n\t\telse:\n\t\t\twrite_node_data = write_edge_data = kwargs['write_data']\n\n\t\t#validation:\n\t\tif(not isinstance(write_node_data, bool) or not\n\t\t\tisintstance(write_edge_data, bool)):\n\t\t\traise zenException('write_data keyword argument takes bool or'\\\n\t\t\t\t' 2-tuple of bools. Found: %s (%s)' %(\n\t\t\t\t\twrite_data, type(write_data)))\n\n\t# Decide *how* to write node / edge data to file\n\t# Default is to use zen_data for both\n\tuse_node_zen_data, use_edge_zen_data = True, True\n\tif 'use_zen_data' in kwargs:\n\n\t\tif type(kwargs['use_zen_data']) == tuple:\n\t\t \tuse_node_zen_data, use_edge_zen_data = kwargs['use_zen_data']\n\n\t\telse:\n\t\t\tuse_node_zen_data = use_edge_zen_data = kwargs['use_zen_data']\n\n\t\t#validation:\n\t\tif(not isinstance(write_node_data, bool) or \n\t\t\tnot isintstance(write_edge_data, bool)):\n\t\t\traise zenException('write_data keyword argument takes bool or'\\\n\t\t\t\t' 2-tuple of bools. Found: %s (%s)' %(\n\t\t\t\t\twrite_data, type(write_data)))\n\t\n\treturn write_node_data, write_edge_data, use_node_zen_data, use_edge_zen_data", "metadata": "root.resolve_write_mode", "header": "['module', '___EOS___']", "index": 504 }, { "content": "def resolve_codec(kwargs):\n\n\t# Resolve the data encoder, check if user passed encoder *instance*\n\tif 'gml_codec' in kwargs:\n\t\tenc = kwargs['encoder']\n\t\ttry:\n\t\t\tassert(isinstance(enc.encode(''), basestring))\n\t\t\tenc.__name__.encode('ascii')\n\t\texcept (AttributeError, AssertionError) as e:\n\t\t\traise ZenException('encoder must define encode() to take type '\\\n\t\t\t\t'basestring and return type basestring containing only ascii-'\\\n\t\t\t\t'encodable characers. It must also provide an ascii-encodable '\\\n\t\t\t\t'__name__ attribute.')\n\n\t# Resolve the data encoder, check if user passed encoder by *name*\n\telif 'gml_coding' in kwargs:\n\t\tif kwargs['encoding'] == 'basic':\n\t\t\tenc = BasicGMLCodec()\n\t\telif kwargs['encoding'] == 'zen':\n\t\t\tenc = ZenGMLCodec()\n\t\telse:\n\t\t\traise ZenException('encoding must be string equal to \"basic\" or'\\\n\t\t\t\t' \"zen\"')\n\n\t# default encoder\n\telse:\n\t\tenc = BasicGMLCodec()\n\n\t# User can also just pass a string-encoder.\n\t# (The full-fledged gml encoders handle various data types)\n\tif 'string_encoder' in kwargs:\n\t\tstr_enc = kwargs['string_encoder']\n\t\ttry:\n\t\t\tassert(isinstance(str_enc(''), basestring))\n\t\texcept (TypeError, AssertionError) as e:\n\t\t\traise ZenException('string_encoder must be a function that takes '\\\n\t\t\t\t'basestring and returns basestring.')\n\n\t\tenc.encode_str = str_enc\n\n\t# User can also just pass a string-decoder.\n\t# (The full-fledged gml encoders handle various data types)\n\tif 'string_decoder' in kwargs:\n\t\tstr_dec = kwargs['string_decoder']\n\t\ttry:\n\t\t\tassert(isinstance(str_dec(''), basestring))\n\t\texcept (TypeError, AssertionError) as e:\n\t\t\traise ZenException('string_decoder must be a function that takes '\\\n\t\t\t\t'basestring and returns basestring.')\n\n\t\tenc.decode_str = str_dec\n\n\treturn enc", "metadata": "root.resolve_codec", "header": "['module', '___EOS___']", "index": 547 } ]
[ { "span": "import os", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 9 }, { "span": "import cgi", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 10 }, { "span": "import codecs", "start_line": 33, "start_column": 0, "end_line": 33, "end_column": 13 }, { "span": "import pdb", "start_line": 34, "start_column": 0, "end_line": 34, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "The", " ", "``", "zen", ".", "io", ".", "gm", "l", "``", " ", "module", " ", "(", "avail", "able", " ", "as", " ", "``", "zen", ".", "gm", "l", "``)", " ", "support", "s", " ", "the", " ", "readi", "ng", " ", "and", " ", "\\", "10", ";", "writ", "ing", " ", "network", " ", "data", " ", "in", " ", "the", " ", "`", "Graph", " ", "Model", "ing", " ", "Lang", "ua", "ge", " ", "(", "GM", "L", ")", " ", "\\", "10", ";<", "http", "://", "en", ".", "wikip", "edia", ".", "org", "/", "wiki", "/", "Graph", "\\u", "Model", "ling", "\\u", "Lang", "ua", "ge", ">`\\u", ".", " ", " ", "At", " ", "presen", "t", " ", "only", " ", "\\", "10", ";", "readi", "ng", " ", "GM", "L", " ", "is", " ", "support", "ed", ".", "\\", "10", ";", "\\", "10", ";", "GM", "L", " ", "is", " ", "a", " ", "flexib", "le", " ", "language", " ", "for", " ", "speci", "fy", "ing", " ", "the", " ", "structure", " ", "of", " ", "a", " ", "network", " ", "(", "nodes", " ", "\\", "10", ";", "and", " ", "edge", "s", ")", " ", "tha", "t", " ", "can", " ", "be", " ", "annotated", " ", "with", " ", "arbitra", "ry", " ", "attribute", "s", " ", "and", " ", "informati", "on", ".", " ", "\\", "10", ";", "Thi", "s", " ", "module", " ", "provide", "s", " ", "a", " ", "full", " ", "implementation", " ", "of", " ", "the", " ", "GM", "L", " ", "file", " ", "format", " ", "as", " ", "specified", " ", "\\", "10", ";", "in", " ", "the", " ", "`", "technical", " ", "report", " ", "\\", "10", ";<", "http", "://", "www", ".", "fim", ".", "uni", "-", "pass", "au", ".", "de", "/", "file", "admin", "/", "files", "/", "le", "hrs", "tu", "hl", "/", "brand", "enb", "urg", "/", "proje", "kte", "/", "gm", "l", "/", "gm", "l", "-", "technical", "-", "report", ".", "pdf", ">`\\u", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "note", "::", "\\", "10", ";", "\t", "Sou", "rce", ":", " ", "Mich", "ael", " ", "Hi", "mso", "lt", ".", " ", "*", "GM", "L", ":", " ", "A", " ", "portab", "le", " ", "Graph", " ", "File", " ", "Format", "*.", " ", "Techni", "cal", " ", "\\", "10", ";", "\t", "Report", ",", " ", "Univers", "ita", "t", " ", "Pass", "au", ".", "\\", "10", ";", "\t", "\\", "10", ";", "Function", "s", "\\", "10", ";", "---------", "\\", "10", ";", "\\", "10", ";", "..", " ", "autof", "uncti", "on", "::", " ", "zen", ".", "io", ".", "gm", "l", ".", "read", "(", "fname", "[", ",", "weight", "\\u", "fx", "n", "=", "Non", "e", "])", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "zen", "_", "._", "exceptions_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zen", "_", "._", "graph_", "import_", "Graph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zen", "_", "._", "digraph", "_", "import_", "Di", "Graph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "zen", "_", "._", "bip", "arti", "te_", "import_", "Bi", "partit", "e", "Graph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gm", "l\\u", "codec_", "import_", "Basic", "GM", "LC", "ode", "c_", ",_", "Ze", "n", "GM", "LC", "ode", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gm", "l\\u", "interpreter_", "import_", "GM", "LI", "nter", "prete", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gm", "l\\u", "tokenizer_", "import_", "GM", "LT", "oken", "izer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "Iterable_", ",_", "Hash", "able_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cgi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pdb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "'", "read", "'_", ",_", "'", "write", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DIGIT", "S_", "=_", "tuple_", "(_", "[_", "'%", "d", "'_", "%_", "x_", "for_", "x_", "in_", "range_", "(_", "10_", ")_", "]_", ")_", "+_", "(_", "'+'_", ",_", "'-'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DIGIT", "S", "\\u", "AND", "\\u", "QUOTE", "S_", "=_", "DIGIT", "S_", "+_", "(_", "'\"'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "write_", "(_", "G_", ",_", "filename_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "\\", "10", ";", "\t", "Write", "s", " ", "graph", " ", "to", " ", "file", " ", "usi", "ng", " ", "Graph", " ", "Model", "ing", " ", "Lang", "ua", "ge", " ", "(", "gm", "l", ").", " ", " ", "Node", " ", "/", " ", "Ed", "ge", " ", "/", " ", "\\", "10", ";", "\t", "Graph", " ", "object", "s", ",", " ", "if", " ", "not", " ", "Non", "e", ",", " ", "are", " ", "store", "d", " ", "in", " ", "the", " ", "`", "name", "`", " ", "attribute", ",", " ", "and", " ", "are", " ", "\\", "10", ";", "\t", "restrict", "ed", " ", "to", " ", "numeri", "c", " ", "(", "but", " ", "not", " ", "complex", "),", " ", "string", ",", " ", "and", " ", "boolean", " ", "data", " ", "types", ",", " ", "\\", "10", ";", "\t", "other", "wis", "e", " ", "an", " ", "exception", " ", "is", " ", "raise", "d", ".", " ", " ", "\\", "10", ";", "\\", "10", ";", "\t", "Node", " ", "/", " ", "Ed", "ge", " ", "/", " ", "Graph", " ", "data", ",", " ", "if", " ", "not", " ", "Non", "e", ",", " ", "are", " ", "store", "d", " ", "in", " ", "a", " ", "zen", "\\u", "data", " ", "attribute", " ", "\\", "10", ";", "\t", "and", " ", "are", " ", "similar", "ly", " ", "restrict", "ed", ".", " ", " ", "Supp", "ort", " ", "may", " ", "be", " ", "adde", "d", " ", "late", "r", " ", "for", " ", "serializ", "ation", "\\", "10", ";", "\t", "of", " ", "arbitra", "ry", " ", "object", "s", " ", "/", " ", "data", " ", "and", " ", "associate", "d", " ", "to", " ", "zen", " ", "graph", "s", ".", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "see", " ", "\\", "10", ";", "\t", "http", "://", "www", ".", "fim", ".", "uni", "-", "pass", "au", ".", "de", "/", "file", "admin", "/", "files", "/", "le", "hrs", "tu", "hl", "/", "brand", "enb", "urg", "/", "proje", "kte", "/", "gm", "l", "/", "gm", "l", "-", "technical", "-", "report", ".", "pdf", " ", "\\", "10", ";", "\t", "for", " ", "more", " ", "info", " ", "abo", "ut", " ", "gm", "l", ".", "\\", "10", ";", "\\", "10", ";", "\t", "**", "Arg", "s", "**", "\\", "10", ";", "\t", "\t", "*", " ", "``", "G", "``", " ", "(:", "py", ":", "class", ":`", "zen", ".", "Graph", "`", ",", " ", ":", "py", ":", "class", ":'", "zen", ".", "Dig", "raph", "`", ",", " ", "\\", "10", ";", "\t\t\t", ":", "py", ":", "class", ":`", "zen", ".", "Bi", "partit", "e", "Graph", "):", " ", "Graph", " ", "object", " ", "to", " ", "be", " ", "writt", "en", " ", "to", " ", "\\", "10", ";", "\t\t\t", "file", ".", " ", "Hyper", "graph", "s", " ", "are", " ", "not", " ", "support", "ed", ".", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "\t", "*", " ", "``", "filename", "``", " ", "(", "str", "):", " ", "Abs", "olute", " ", "path", " ", "for", " ", "the", " ", "file", " ", "to", " ", "be", " ", "writt", "en", ".", "\\", "10", ";", "\\", "10", ";", "\t", "**", "Kw", "Arg", "s", "**", "\\", "10", ";", "\t", "\t", "*", " ", "``", "write", "-", "data", "``", " ", "(", "bool", " ", "|", " ", "(", "bool", ",", " ", "bool", "))", ":", " ", "If", " ", "2", "-", "tuple", " ", "of", " ", "boolean", "s", " ", "\\", "10", ";", "\t\t\t", "supplie", "d", ",", " ", "first", " ", "indicat", "es", " ", "whe", "ther", " ", "to", " ", "write", " ", "out", " ", "node", " ", "data", " ", "second", " ", "\\", "10", ";", "\t\t\t", "whe", "ther", " ", "to", " ", "write", " ", "out", " ", "edge", " ", "data", ".", " ", " ", "If", " ", "bool", " ", "provided", ",", " ", "it", " ", "is", " ", "applied", " ", "\\", "10", ";", "\t\t\t", "for", " ", "bot", "h", " ", "node", " ", "and", " ", "edge", " ", "data", ".", "\\", "10", ";", "\\", "10", ";", "\t", "\t", "*", " ", "``", "use", "-", "zen", "-", "data", "``", " ", "(", "bool", " ", "|", " ", "(", "bool", ",", " ", "bool", "))", ":", " ", "Indicat", "es", " ", "whe", "ther", " ", "to", " ", "write", " ", "\\", "10", ";", "\t\t\t", "out", " ", "If", " ", "2", "-", "tuple", " ", "of", " ", "boolean", "s", " ", "supplie", "d", ",", " ", "first", " ", "indicat", "es", " ", "whe", "ther", " ", "to", " ", "\\", "10", ";", "\t\t\t", "write", " ", "out", " ", "node", " ", "data", " ", "second", " ", "whe", "ther", " ", "to", " ", "write", " ", "out", " ", "edge", " ", "data", ".", " ", " ", "If", " ", "bool", "\\", "10", ";", "\t\t\t", "provided", ",", " ", "it", " ", "is", " ", "applied", " ", "for", " ", "bot", "h", " ", "node", " ", "and", " ", "edge", " ", "data", ".", " ", "\\", "10", ";", "\\", "10", ";", "\t", "**", "Return", "s", "**", ":", "\\", "10", ";", "\t", "\t", "*", " ", "Non", "e", "\\", "10", ";", "\t", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Det", "erm", "ine", " ", "the", " ", "write", " ", "mode", ".", " ", " ", "There", " ", "are", " ", "vari", "ous", " ", "options", " ", "the", " ", "user", " ", "can", " ", "speci", "fy_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whi", "ch", " ", "are", " ", "recon", "sile", "d", " ", "and", " ", "validat", "ed", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "write", "\\u", "node", "\\u", "data_", ",_", "write", "\\u", "edge", "\\u", "data_", ",_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", ",_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", "=_", "resolve", "\\u", "write", "\\u", "mode_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "encode", "r", " ", "to", " ", "use", ".", " ", " ", "Thi", "s", " ", "call", " ", "resolve", "s", " ", "the", " ", "vari", "ous", " ", "way", "s", " ", "the", " ", "user", " ", "can_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "speci", "fy", " ", "encoding", ",", " ", "and", " ", "doe", "s", " ", "basic", " ", "checks", " ", "tha", "t", " ", "the", " ", "encode", "r", " ", "is", " ", "valid_", "\\u\\u\\uNL\\u\\u\\u_", "enc_", "=_", "resolve", "\\u", "codec_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fh_", "=_", "open_", "(_", "filename_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'#", " ", "Thi", "s", " ", "is", " ", "a", " ", "graph", " ", "object", " ", "in", " ", "gm", "l", " ", "file", " ", "format", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'#", " ", "produce", "d", " ", "by", " ", "the", " ", "zen", " ", "graph", " ", "librar", "y", "\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Describe", " ", "the", " ", "encoding", " ", "method", " ", "used", " ", "to", " ", "generat", "e", " ", "the", " ", "file", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "fh_", "._", "write_", "(_", "'", "Ze", "n", "Code", "c", " ", "\"%", "s", "\"\\\\", "n", "'_", "%_", "enc_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'", "Ze", "n", "String", "Encode", "r", " ", "\"%", "s", "\"\\\\", "n", "\\\\", "n", "'_", "%_", "enc_", "._", "encode", "\\u", "str_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Start", " ", "writ", "ing", " ", "the", " ", "graph_", "\\u\\u\\uNL\\u\\u\\u_", "fh_", "._", "write_", "(_", "'", "graph", " ", "[\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "G_", "._", "is", "\\u", "directed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "fh_", "._", "write_", "(_", "'\\\\", "tdir", "ect", "ed", " ", "1", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "fh_", "._", "write_", "(_", "'\\\\", "tdir", "ect", "ed", " ", "0", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "G_", ",_", "Bi", "partit", "e", "Graph_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "is", "\\u", "bip", "arti", "te_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "tb", "ipa", "rti", "te", " ", "1", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "is", "\\u", "bip", "arti", "te_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "tb", "ipa", "rti", "te", " ", "0", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "iterate", " ", "over", " ", "nodes", ",", " ", "writ", "ing", " ", "them", " ", "to", " ", "the", " ", "new", " ", "gm", "l", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "nid", "x_", ",_", "nob", "j_", ",_", "ndata", "_", "in_", "G_", "._", "nodes", "\\u", "iter", "\\u_", "(_", "obj_", "=_", "True_", ",_", "data_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "fh_", "._", "write_", "(_", "'\\\\", "tno", "de", " ", "[\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "tid", " ", "'_", "+_", "str_", "(_", "nid", "x_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "is", "\\u", "bip", "arti", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "'", "is", "In", "U", "'_", ",_", "G_", "._", "is", "\\u", "in", "\\u", "U", "\\u_", "(_", "nid", "x_", ")_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "nob", "j_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "'", "name", "'_", ",_", "nob", "j_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ndata", "_", "!=_", "None_", "and_", "write", "\\u", "node", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "'", "zen", "Data", "'_", ",_", "ndata", "_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "expect", "s", " ", "zen", "Data", " ", "to", " ", "be", " ", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "for_", "key_", ",_", "val_", "in_", "ndata", "_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "key_", ",_", "val_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "]\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "iterate", " ", "over", " ", "edges_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "eid", "x_", ",_", "edat", "a_", ",_", "weight_", "in_", "G_", "._", "edge", "s", "\\u", "iter", "\\u_", "(_", "data_", "=_", "True_", ",_", "weight_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "fh_", "._", "write_", "(_", "'\\\\", "ted", "ge", " ", "[\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "digraph", "s", ",", " ", "assume", "s", " ", "endpoint", "s", " ", "order", " ", "[", "source", ",", " ", "target", "]_", "\\u\\u\\uNL\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "ts", "ource", " ", "'_", "+_", "str_", "(_", "G_", "._", "endpoint", "s\\u_", "(_", "eid", "x_", ")_", "[_", "0_", "]_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "tta", "rget", " ", "'_", "+_", "str_", "(_", "G_", "._", "endpoint", "s\\u_", "(_", "eid", "x_", ")_", "[_", "1_", "]_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "\\\\", "twe", "ight", " ", "'_", "+_", "str_", "(_", "weight_", ")_", "+_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "edat", "a_", "!=_", "None_", "and_", "write", "\\u", "edge", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "'", "zen", "Data", "'_", ",_", "edat", "a_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", "expect", "s", " ", "zen", "Data", " ", "to", " ", "be", " ", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "for_", "key_", ",_", "val_", "in_", "edat", "a_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "fh_", "._", "write_", "(_", "format\\u", "zen", "\\u", "data_", "(_", "key_", ",_", "val_", ",_", "2_", ",_", "enc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fh_", "._", "write_", "(_", "'\\\\", "t", "]\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fh_", "._", "write_", "(_", "']", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "format\\u", "zen", "\\u", "data_", "(_", "keyname_", ",_", "data_", ",_", "tab", "\\u", "depth_", ",_", "encoder_", ",_", "strict_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "\\", "10", ";", "\t", "Ref", "ormat", "s", " ", "supplie", "d", " ", "data", " ", "to", " ", "use", " ", "gm", "l", ".", " ", " ", "Enf", "orce", "s", " ", "restriction", "s", " ", "on", " ", "the", " ", "types", " ", "of", " ", "\\", "10", ";", "\t", "data", " ", "tha", "t", " ", "can", " ", "be", " ", "writt", "en", " ", "to", " ", "gm", "l", ".", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "**", "Arg", "s", "**", "\\", "10", ";", "\t", "\t", "*", " ", "data", " ", "(", "bool", " ", "|", " ", "int", " ", "|", " ", "long", " ", "|", " ", "float", " ", "|", " ", "str", " ", "|", " ", "dict", " ", "|", " ", "list", "):", " ", "object", " ", "to", " ", "be", " ", "\\", "10", ";", "\t\t\t", "writt", "en", " ", "in", " ", "gm", "l", "\\", "10", ";", "\t", "\t", "*", " ", "key", " ", "(", "str", "):", " ", "key", " ", "to", " ", "be", " ", "used", " ", "in", " ", "gm", "l", ".", " ", " ", "Needed", " ", "here", " ", "bec", "aus", "e", " ", "in", " ", "gm", "l", " ", "lists", " ", "\\", "10", ";", "\t\t\t", "are", " ", "made", " ", "by", " ", "repeatin", "g", " ", "the", " ", "key", " ", "in", " ", "front", " ", "of", " ", "each", " ", "value", ".", "\\", "10", ";", "\t", "\t", "*", " ", "tab", "\\u", "depth", " ", "(", "int", "):", " ", "number", " ", "of", " ", "tab", " ", "character", "s", " ", "to", " ", "add", " ", "to", " ", "the", " ", "beginn", "ing", " ", "\\", "10", ";", "\t\t\t", "of", " ", "each", " ", "line", " ", "for", " ", "nice", " ", "format", "ting", ".", "\\", "10", ";", "\\", "10", ";", "\t", "**", "Return", "s", "**", "\\", "10", ";", "\t", "\t", "*", " ", "format", "ted", "\\u", "data", " ", "(", "str", "):", " ", "gm", "l", " ", "represent", "ation", " ", "of", " ", "data", "\\", "10", ";", "\t", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Validat", "ion", ":", " ", "key", " ", "names", " ", "must", " ", "be", " ", "strict", "ly", " ", "alphanumeric", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "re_", "._", "search_", "(_", "'[", "^", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "]'_", ",_", "keyname_", ")_", "and_", "strict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "raise_", "Ze", "n", "Exception_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "gm", "l", " ", "support", "s", " ", "only", " ", "character", "s", " ", "from", " ", "[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "]", " ", "in", " ", "keys", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "format", "ted", "\\u", "data_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tabs_", "=_", "'\\\\", "t", "'_", "*_", "tab", "\\u", "depth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "data_", ",_", "(_", "dict_", ",_", "list_", ",_", "tuple_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "encode", "d\\u", "data_", "=_", "encoder_", "._", "encode_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Validate", " ", "encode", "r", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "strict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "assert_", "(_", "isinstance_", "(_", "encode", "d\\u", "data_", ",_", "basestring_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "(_", "encode", "d\\u", "data_", "._", "startswith_", "(_", "DIGIT", "S", "\\u", "AND", "\\u", "QUOTE", "S_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encode", "d\\u", "data_", "._", "encode_", "(_", "'", "ascii", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "encode", "d\\u", "data_", "._", "startswith_", "(_", "DIGIT", "S_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "num_", "=_", "float_", "(_", "encode", "d\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "(_", "num_", "<_", "2147483647", "_", "or_", "num_", ">_", "-_", "2147483648", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", ",_", "Unic", "ode", "Encode", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "GM", "L", " ", "Encode", "r", " ", "has", " ", "viola", "ted", " ", "gm", "l", " ", "specifica", "tion", "s", ".", " ", "'_", "'", "see", " ", "<", "http", "://", "www", ".", "fim", ".", "uni", "-", "pass", "au", ".", "de", "/", "file", "admin", "/", "files", "/", "le", "hrs", "tu", "hl", "/", "brand", "enb", "urg", "/", "proje", "kte", "/", "gm", "l", "/", "gm", "l", "-", "technical", "-", "report", ".", "pdf", ">.", " ", "\\\\", "n", " ", "Us", "e", " ", "'_", "'", "gm", "l", ".", "write", "(.", "..", ",", " ", "strict", "=", "Fal", "se", ")", " ", "to", " ", "force", " ", "writ", "ing", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "encode", "d", " ", "data", " ", "is", " ", "lega", "l", " ", "for", " ", "gm", "l", ".", " ", "Append", " ", "extra", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "format", "ted", "\\u", "data_", "=_", "tabs_", "+_", "keyname_", "+_", "'", " ", "'_", "+_", "encode", "d\\u", "data_", "+_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Recursive", " ", "call", " ", "for", " ", "dicts_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "data_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "format", "ted", "\\u", "data_", "+=_", "tabs_", "+_", "keyname_", "+_", "'", " ", "[\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "val_", "in_", "data_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "format", "ted", "\\u", "data_", "+=_", "format\\u", "zen", "\\u", "data_", "(_", "key_", ",_", "val_", ",_", "tab", "\\u", "depth_", "+_", "1_", ",_", "encoder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "format", "ted", "\\u", "data_", "+=_", "tabs_", "+_", "']", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Recursive", " ", "call", " ", "for", " ", "lists", ".", " ", " ", "GM", "L", " ", "represent", "s", " ", "lists", " ", "by", " ", "repeatin", "g", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "key", " ", "with", " ", "different", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "assert_", "(_", "isinstance_", "(_", "data_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "val_", "in_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "format", "ted", "\\u", "data_", "+=_", "format\\u", "zen", "\\u", "data_", "(_", "keyname_", ",_", "val_", ",_", "tab", "\\u", "depth_", ",_", "encoder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "format", "ted", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "tree_", "(_", "fname_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "resolve", " ", "the", " ", "codec", ".", " ", " ", "The", " ", "user", " ", "can", " ", "speci", "fy", " ", "the", " ", "codec", " ", "in", " ", "vari", "ous", " ", "way", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "codec_", "=_", "resolve", "\\u", "codec_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "read", " ", "the", " ", "file", " _", "\\u\\u\\uNL\\u\\u\\u_", "fh_", "=_", "open_", "(_", "fname_", ",_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gm", "l\\u", "str_", "=_", "fh_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fh_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tokenize", " ", "the", " ", "gm", "l", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "tok_", "=_", "GM", "LT", "oken", "izer_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tokens_", "=_", "tok_", "._", "tokenize_", "(_", "gm", "l\\u", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "interpret", " ", "the", " ", "gm", "l", " ", "document", " ", "int", "o", " ", "an", " ", "internal", " ", "datastr", "ucture", "_", "\\u\\u\\uNL\\u\\u\\u_", "interpreter_", "=_", "GM", "LI", "nter", "prete", "r_", "(_", "codec_", ",_", "tok_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gm", "l\\u", "tree_", "=_", "interpreter_", "._", "interpret", "_", "(_", "tokens_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "gm", "l\\u", "tree_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "fname_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "\\", "10", ";", "\t", "Read", " ", "GM", "L", "-", "format", "ted", " ", "network", " ", "data", " ", "store", "d", " ", "in", " ", "file", " ", "named", " ", "``", "fname", "``.", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "The", " ", "node", "'", "s", " ", "``", "id", "``", " ", "attribute", " ", "is", " ", "used", " ", "to", " ", "speci", "fy", " ", "the", " ", "node", " ", "index", ".", " ", " ", "The", " ", "node", "'", "s", " ", "\\", "10", ";", "\t", "``", "name", "``", " ", "attribute", " ", "is", " ", "prefer", "abl", "y", " ", "used", " ", "as", " ", "the", " ", "node", " ", "object", ".", " ", " ", "\\", "10", ";", "\\", "10", ";", "\t", "Ho", "we", "ver", ",", " ", "if", " ", "the", " ", "``", "name", "``", " ", "attribute", " ", "is", " ", "missi", "ng", " ", "and", " ", "the", " ", "``", "label", "``", " ", "is", " ", "presen", "t", ",", "\\", "10", ";", "\t", "then", " ", "the", " ", "node", "'", "s", " ", "``", "label", "``", " ", "attribute", " ", "will", " ", "be", " ", "used", " ", "as", " ", "the", " ", "node", " ", "object", ".", " ", " ", "If", " ", "\\", "10", ";", "\t", "bot", "h", " ", "are", " ", "missi", "ng", ",", " ", "then", " ", "the", " ", "node", " ", "id", " ", "will", " ", "be", " ", "used", " ", "as", " ", "the", " ", "node", " ", "object", ".", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "..", " ", "note", "::", "\t", "\\", "10", ";", "\t", "\t", "Curr", "ent", "ly", " ", "graph", " ", "attribute", "s", " ", "are", " ", "not", " ", "support", "ed", " ", "by", " ", "the", " ", "reader", ".", " ", " ", "If", " ", "\\", "10", ";", "\t", "\t", "encounter", "ed", ",", " ", "the", "y", " ", "will", " ", "simp", "ly", " ", "be", " ", "skip", "ped", " ", "over", " ", "and", " ", "not", " ", "adde", "d", " ", "to", " ", "the", "\\", "10", ";", "\t", "\t", "final", " ", "graph", ".", " ", "Thi", "s", " ", "is", " ", "simp", "ly", " ", "bec", "aus", "e", " ", "graph", " ", "object", "s", " ", "don", "'", "t", " ", "support", " ", "\\", "10", ";", "\t", "\t", "arbitra", "ry", " ", "data", " ", "ye", "t", ".", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "**", "Kw", "Arg", "s", "**", ":", "\\", "10", ";", "\t", "\\", "10", ";", "\t", "\t", "*", " ", "``", "weight", "\\u", "fx", "n", " ", "[", "=", "Non", "e", "]``", ":", " ", "derive", " ", "weight", " ", "assign", "ment", "s", " ", "from", " ", "edge", " ", "data", ".", " ", " ", "If", "\\", "10", ";", "\t\t\t", "specified", ",", " ", "this", " ", "function", " ", "is", " ", "call", "ed", " ", "with", " ", "one", " ", "parameter", ":", " ", "the", " ", "full", " ", "\\", "10", ";", "\t\t\t", "set", " ", "of", " ", "attribute", "s", " ", "tha", "t", " ", "wer", "e", " ", "specified", " ", "for", " ", "the", " ", "edge", ".", "\\", "10", ";", "\t", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "extract", " ", "keyw", "ord", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "weight", "\\u", "fx", "n_", "=_", "kwargs_", "._", "pop_", "(_", "'", "weight", "\\u", "fx", "n", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "parse", " ", "the", " ", "gm", "l", " ", "int", "o", " ", "a", " ", "python", " ", "dict", " ", "structure_", "\\u\\u\\uNL\\u\\u\\u_", "gm", "l\\u", "tree_", "=_", "make", "\\u", "tree_", "(_", "fname_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "graph", "'_", "in_", "gm", "l\\u", "tree_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "graph", "\\u", "tree_", "=_", "gm", "l\\u", "tree_", "[_", "'", "graph", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "isinstance_", "(_", "gm", "l\\u", "tree_", ",_", "list_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "graph", "\\u", "tree_", "=_", "gm", "l\\u", "tree_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Warn", "ing", ":", " ", "multiple", " ", "graph", "s", " ", "store", "d", " ", "in", " ", "this", " ", "file", ".", " ", " ", "Us", "e", " ", "'_", "'", "gm", "l", ".", "read", "\\u", "all", "(", "fname", ",", " ", "[...", "])", " ", "to", " ", "get", " ", "list", " ", "of", " ", "all", " ", "graph", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "build", "\\u", "graph_", "(_", "graph", "\\u", "tree_", ",_", "weight", "\\u", "fx", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "\\u", "all_", "(_", "fname_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "extract", " ", "keyw", "ord", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "weight", "\\u", "fx", "n_", "=_", "kwargs_", "._", "pop_", "(_", "'", "weight", "\\u", "fx", "n", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "parse", " ", "the", " ", "gm", "l", " ", "int", "o", " ", "a", " ", "python", " ", "dict", " ", "structure_", "\\u\\u\\uNL\\u\\u\\u_", "gm", "l\\u", "tree_", "=_", "make", "\\u", "tree_", "(_", "fname_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "graph", "'_", "in_", "gm", "l\\u", "tree_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "graph", "\\u", "tree_", "=_", "gm", "l\\u", "tree_", "[_", "'", "graph", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "graph", "\\u", "tree_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "graph", "\\u", "tree_", "=_", "[_", "gm", "l\\u", "tree_", "[_", "'", "graph", "'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "graph", "\\u", "tree_", "=_", "gm", "l\\u", "tree_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Warn", "ing", ":", " ", "multiple", " ", "graph", "s", " ", "store", "d", " ", "in", " ", "this", " ", "file", ".", " ", " ", "Us", "e", " ", "'_", "'", "gm", "l", ".", "read", "\\u", "all", "(", "fname", ",", " ", "[...", "])", " ", "to", " ", "get", " ", "list", " ", "of", " ", "all", " ", "graph", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "build", "\\u", "graph_", "(_", "graph", "\\u", "tree_", ",_", "weight", "\\u", "fx", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "build", "\\u", "graph_", "(_", "graph", "\\u", "tree_", ",_", "weight", "\\u", "fx", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "What", " ", "kind", " ", "of", " ", "graph", " ", "is", " ", "bei", "ng", " ", "bui", "lt", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "is", "\\u", "bip", "arti", "te_", "=_", "bool_", "(_", "'", "bip", "arti", "te", "'_", "in_", "graph", "\\u", "tree_", "and_", "graph", "\\u", "tree_", "[_", "'", "bip", "arti", "te", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "directed_", "=_", "bool_", "(_", "'", "direct", "ed", "'_", "in_", "graph", "\\u", "tree_", "and_", "graph", "\\u", "tree_", "[_", "'", "direct", "ed", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "is", "\\u", "bip", "arti", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "G_", "=_", "Bi", "partit", "e", "Graph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "is", "\\u", "directed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "G_", "=_", "Di", "Graph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "G_", "=_", "Graph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "the", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "node", "'_", "in_", "graph", "\\u", "tree_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "list", " ", "of", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "nodes_", "=_", "graph", "\\u", "tree_", "[_", "'", "node", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ensure", " ", "the", " ", "node", "-", "list", " ", "is", " ", "a", " ", "list", " ", "(", "need", "ed", " ", "if", " ", "there", "'", "s", " ", "only", " ", "one", " ", "node", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "nodes_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "nodes_", "=_", "[_", "nodes_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "each", " ", "node", " ", "and", " ", "add", " ", "to", " ", "the", " ", "graph_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "node_", "in_", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Do", "es", " ", "the", " ", "node", " ", "have", " ", "an", " ", "id", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "has", "\\u", "id_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "has", "\\u", "valid", "\\u", "id_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "id", "'_", "not_", "in_", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "has", "\\u", "id_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "has", "\\u", "valid", "\\u", "id_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "can", " ", "only", " ", "use", " ", "posit", "ive", " ", "integ", "er", " ", "node", " ", "ids", " ", "as", " ", "graph", " ", "idx_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "tha", "t", "'", "s", " ", "not", " ", "the", " ", "case", ",", " ", "treat", " ", "it", " ", "like", " ", "any", " ", "other", " ", "attribute_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "isinstance_", "(_", "node_", "[_", "'", "id", "'_", "]_", ",_", "int_", ")_", "or_", "node_", "[_", "'", "id", "'_", "]_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "has", "\\u", "valid", "\\u", "id_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Got", " ", "a", " ", "valid", " ", "node", " ", "id_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node", "\\u", "idx_", "=_", "node_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "bip", "arti", "te", " ", "graph", "s", " ", "dete", "rmin", "e", " ", "whi", "ch", " ", "node", " ", "set", " ", "this", " ", "belo", "ngs", " ", "to", " _", "\\u\\u\\uNL\\u\\u\\u_", "if_", "is", "\\u", "bip", "arti", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "is", "\\u", "in", "\\u", "U_", "=_", "node_", "[_", "'", "is", "In", "U", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "collect", " ", "and", " ", "verify", " ", "all", " ", "the", " ", "node", " ", "properties_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "standard", "\\u", "keys_", "=_", "set_", "(_", "[_", "'", "id", "'_", ",_", "'", "name", "'_", ",_", "'", "zen", "Data", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "\\u", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "\\u", "obj_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zen", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "val_", "in_", "node_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "key_", "==_", "'", "name", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "node", "\\u", "obj_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "give", " ", "preference", " ", "to", " ", "'", "name", "'", " ", "as", " ", "source", " ", "of", " ", "node", "\\u", "obj_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "label", "'_", "and_", "node", "\\u", "obj_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "node", "\\u", "obj_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "zen", "Data", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "zen", "\\u", "data_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "node", "\\u", "data", " ", "is", " ", "dict", " ", "of", " ", "all", " ", "other", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "node", "\\u", "data_", "[_", "key_", "]_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\\u", "set\\u", " ", "to", " ", "node", "\\u", "data", " ", "else", " ", "\\u", "append", "\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "zen", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "len_", "(_", "node", "\\u", "data_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "node", "\\u", "data_", "=_", "zen", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "node", "\\u", "data_", "[_", "'", "zen", "Data", "'_", "]_", "=_", "zen", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "node", "\\u", "data_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "node", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "make", " ", "sure", " ", "tha", "t", " ", "the", " ", "node", " ", "object", " ", "is", " ", "hashable", " ", "other", "wis", "e", " ", "put", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "node", "\\u", "obj_", ",_", "basestring_", ")_", "and_", "node", "\\u", "obj_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "not_", "isinstance_", "(_", "node", "\\u", "obj_", ",_", "Hash", "able_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "if_", "not_", "isinstance_", "(_", "node", "\\u", "obj_", ",_", "Iterable_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "node", "\\u", "obj_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "node", "\\u", "obj_", "=_", "tuple_", "(_", "node", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "bip", "arti", "te", " ", "graph", ",", " ", "this", " ", "insertion", " ", "method", " ", "doe", "s", " ", "not", " ", "guaran", "tee", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "indice", "s", " ", "will", " ", "be", " ", "unchanged", " ", "after", " ", "a", " ", "read", "-", "write", " ", "cycle_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "\\u", "bip", "arti", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "G_", "._", "add", "\\u", "node", "\\u", "by", "\\u", "class_", "(_", "is", "\\u", "in", "\\u", "U_", ",_", "node", "\\u", "obj_", ",_", "node", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "has", "\\u", "id_", "and_", "has", "\\u", "valid", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "is", "\\u", "directed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "G_", "._", "add", "\\u", "node", "\\u", "x_", "(_", "node", "\\u", "idx_", ",_", "G_", "._", "edge", "\\u", "list", "\\u", "capacity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "G_", "._", "edge", "\\u", "list", "\\u", "capacity_", ",_", "node", "\\u", "obj_", ",_", "node", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "G_", "._", "add", "\\u", "node", "\\u", "x_", "(_", "node", "\\u", "idx_", ",_", "G_", "._", "edge", "\\u", "list", "\\u", "capacity_", ",_", "node", "\\u", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "G_", "._", "is", "\\u", "directed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "G_", "._", "add", "\\u", "node_", "(_", "nob", "j_", "=_", "node", "\\u", "obj_", ",_", "data_", "=_", "node", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "G_", "._", "add", "\\u", "node_", "(_", "nob", "j_", "=_", "node", "\\u", "obj_", ",_", "data_", "=_", "node", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "edges_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "edge", "'_", "in_", "graph", "\\u", "tree_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ensure", " ", "edge", " ", "list", " ", "is", " ", "a", " ", "list", " ", "(", "need", "ed", " ", "if", " ", "there", " ", "is", " ", "only", " ", "one", " ", "edge", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "edges_", "=_", "graph", "\\u", "tree_", "[_", "'", "edge", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "edges_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "edges_", "=_", "[_", "edges_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "iterate", " ", "over", " ", "the", " ", "edge", "s", ",", " ", "add", " ", "each", " ", "one", " ", "to", " ", "the", " ", "graph_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "edge_", "in_", "edges_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "make", " ", "sure", " ", "source", " ", "and", " ", "target", " ", "are", " ", "specified", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "source_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "source", "'_", "not_", "in_", "edge_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "Ed", "ge", " ", "is", " ", "missi", "ng", " ", "the", " ", "source", " ", "attribute", " ", "'_", "'(", "edge", " ", "=", " ", "%", "s", ")'_", "%_", "str_", "(_", "edge_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "target", "'_", "not_", "in_", "edge_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "Ed", "ge", " ", "is", " ", "missi", "ng", " ", "the", " ", "target", " ", "attribute", " ", "'_", "'(", "edge", " ", "=", " ", "%", "s", ")'_", "%_", "str_", "(_", "edge_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "weight_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "edge", "\\u", "idx_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zen", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "edge", "\\u", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", ",_", "val_", "in_", "edge_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "key_", "==_", "'", "id", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "edge", "\\u", "idx_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "val_", ")_", "!=_", "int_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "Ed", "ge", " ", "id", " ", "attribute", " ", "must", " ", "be", " ", "a", " ", "'_", "'", "posit", "ive", " ", "integ", "er", " ", "(", "edge", " ", "=", " ", "%", "s", ")'_", "%_", "str_", "(_", "edge_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "source", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "source_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "val_", ")_", "!=_", "int_", "or_", "val_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "Ed", "ge", " ", "source", " ", "attribute", " ", "must", " ", "be", " ", "a", " ", "'_", "'", "posit", "ive", " ", "integ", "er", " ", "(", "edge", " ", "=", " ", "%", "s", ")'_", "%_", "str_", "(_", "edge_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "target", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "target_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "val_", ")_", "!=_", "int_", "or_", "val_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "Ed", "ge", " ", "target", " ", "attribute", " ", "must", " ", "be", " ", "a", " ", "'_", "'", "posit", "ive", " ", "integ", "er", " ", "(", "edge", " ", "=", " ", "%", "s", ")'_", "%_", "str_", "(_", "edge_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "weight", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "weight_", "=_", "float_", "(_", "val_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "key_", "==_", "'", "zen", "Data", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "zen", "\\u", "data_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "edge", "\\u", "data", " ", "is", " ", "dict", " ", "of", " ", "all", " ", "other", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "edge", "\\u", "data_", "[_", "key_", "]_", "=_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "give", " ", "preceden", "ce", " ", "to", " ", "a", " ", "weight", "-", "getti", "ng", " ", "function", " ", "if", " ", "provided", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "weight", "\\u", "fx", "n_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "weight_", "=_", "weight", "\\u", "fx", "n_", "(_", "edge_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "zen", "Data", " ", "is", " ", "only", " ", "other", " ", "attribute", " ", "asi", "de", " ", "from", " ", "tho", "se", " ", "handle", "d", " ", "above", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\\u", "set\\u", " ", "to", " ", "edge", "\\u", "data", " ", "else", " ", "\\u", "append", "\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "zen", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "len_", "(_", "edge", "\\u", "data_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "edge", "\\u", "data_", "=_", "zen", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "edge", "\\u", "data_", "[_", "'", "zen", "Data", "'_", "]_", "=_", "zen", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "edge", "\\u", "data_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "edge", "\\u", "data_", "=_", "None_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "edge", "\\u", "idx_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "G_", "._", "add", "\\u", "edge", "\\u", "x_", "(_", "edge", "\\u", "idx_", ",_", "source_", ",_", "target_", ",_", "edge", "\\u", "data_", ",_", "weight_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "G_", "._", "add", "\\u", "edge", "\\u_", "(_", "source_", ",_", "target_", ",_", "edge", "\\u", "data_", ",_", "weight_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "G_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resolve", "\\u", "write", "\\u", "mode_", "(_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Deci", "de", " ", "whe", "ther", " ", "to", " ", "write", " ", "node", " ", "and", " ", "edge", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Default", " ", "is", " ", "to", " ", "write", " ", "both_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "write", "\\u", "node", "\\u", "data_", ",_", "write", "\\u", "edge", "\\u", "data_", "=_", "True_", ",_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "write", "\\u", "data", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "write", "\\u", "data", " ", "mig", "ht", " ", "be", " ", "a", " ", "tuple_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "type_", "(_", "kwargs_", "[_", "'", "write", "\\u", "data", "'_", "]_", ")_", "==_", "tuple_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "write", "\\u", "node", "\\u", "data_", ",_", "write", "\\u", "edge", "\\u", "data_", "=_", "kwargs_", "[_", "'", "write", "\\u", "data", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "just", " ", "a", " ", "single", " ", "bool_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "write", "\\u", "node", "\\u", "data_", "=_", "write", "\\u", "edge", "\\u", "data_", "=_", "kwargs_", "[_", "'", "write", "\\u", "data", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "validation", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "isinstance_", "(_", "write", "\\u", "node", "\\u", "data_", ",_", "bool_", ")_", "or_", "not_", "\\u\\u\\uNL\\u\\u\\u_", "isin", "tsta", "nce_", "(_", "write", "\\u", "edge", "\\u", "data_", ",_", "bool_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "zen", "Exception_", "(_", "'", "write", "\\u", "data", " ", "keyw", "ord", " ", "argu", "ment", " ", "take", "s", " ", "bool", " ", "or", "'_", "'", " ", "2", "-", "tuple", " ", "of", " ", "bool", "s", ".", " ", "Foun", "d", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "write", "\\u", "data_", ",_", "type_", "(_", "write", "\\u", "data_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Deci", "de", " ", "*", "how", "*", " ", "to", " ", "write", " ", "node", " ", "/", " ", "edge", " ", "data", " ", "to", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Default", " ", "is", " ", "to", " ", "use", " ", "zen", "\\u", "data", " ", "for", " ", "both_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", ",_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", "=_", "True_", ",_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "use", "\\u", "zen", "\\u", "data", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "type_", "(_", "kwargs_", "[_", "'", "use", "\\u", "zen", "\\u", "data", "'_", "]_", ")_", "==_", "tuple_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t", " ", "\t_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", ",_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", "=_", "kwargs_", "[_", "'", "use", "\\u", "zen", "\\u", "data", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", "=_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", "=_", "kwargs_", "[_", "'", "use", "\\u", "zen", "\\u", "data", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "validation", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "isinstance_", "(_", "write", "\\u", "node", "\\u", "data_", ",_", "bool_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "isin", "tsta", "nce_", "(_", "write", "\\u", "edge", "\\u", "data_", ",_", "bool_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "zen", "Exception_", "(_", "'", "write", "\\u", "data", " ", "keyw", "ord", " ", "argu", "ment", " ", "take", "s", " ", "bool", " ", "or", "'_", "'", " ", "2", "-", "tuple", " ", "of", " ", "bool", "s", ".", " ", "Foun", "d", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "write", "\\u", "data_", ",_", "type_", "(_", "write", "\\u", "data_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "write", "\\u", "node", "\\u", "data_", ",_", "write", "\\u", "edge", "\\u", "data_", ",_", "use", "\\u", "node", "\\u", "zen", "\\u", "data_", ",_", "use", "\\u", "edge", "\\u", "zen", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resolve", "\\u", "codec_", "(_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Resolv", "e", " ", "the", " ", "data", " ", "encode", "r", ",", " ", "check", " ", "if", " ", "user", " ", "pass", "ed", " ", "encode", "r", " ", "*", "instance", "*_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "'", "gm", "l\\u", "codec", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "enc_", "=_", "kwargs_", "[_", "'", "encode", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "assert_", "(_", "isinstance_", "(_", "enc_", "._", "encode_", "(_", "''_", ")_", ",_", "basestring_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enc_", "._", "\\u\\u", "name\\u\\u_", "._", "encode_", "(_", "'", "ascii", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Attribute", "Error_", ",_", "Assert", "ion", "Error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "encode", "r", " ", "must", " ", "defin", "e", " ", "encode", "()", " ", "to", " ", "take", " ", "type", " ", "'_", "'", "basest", "ring", " ", "and", " ", "return", " ", "type", " ", "basest", "ring", " ", "contain", "ing", " ", "only", " ", "ascii", "-'_", "'", "enco", "dable", " ", "chara", "cer", "s", ".", " ", " ", "It", " ", "must", " ", "als", "o", " ", "provide", " ", "an", " ", "ascii", "-", "enco", "dable", " ", "'_", "'\\u", "\\u", "name", "\\u\\u", " ", "attribute", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Resolv", "e", " ", "the", " ", "data", " ", "encode", "r", ",", " ", "check", " ", "if", " ", "user", " ", "pass", "ed", " ", "encode", "r", " ", "by", " ", "*", "name", "*_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "gm", "l\\u", "codi", "ng", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "kwargs_", "[_", "'", "encoding", "'_", "]_", "==_", "'", "basic", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "enc_", "=_", "Basic", "GM", "LC", "ode", "c_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "kwargs_", "[_", "'", "encoding", "'_", "]_", "==_", "'", "zen", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "enc_", "=_", "Ze", "n", "GM", "LC", "ode", "c_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "encoding", " ", "must", " ", "be", " ", "string", " ", "equal", " ", "to", " ", "\"", "basic", "\"", " ", "or", "'_", "'", " ", "\"", "zen", "\"'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "default", " ", "encoder_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "enc_", "=_", "Basic", "GM", "LC", "ode", "c_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "User", " ", "can", " ", "als", "o", " ", "just", " ", "pass", " ", "a", " ", "string", "-", "encode", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "The", " ", "full", "-", "fle", "dge", "d", " ", "gm", "l", " ", "encoders", " ", "handle", " ", "vari", "ous", " ", "data", " ", "types", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "string", "\\u", "encode", "r", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "str", "\\u", "enc_", "=_", "kwargs_", "[_", "'", "string", "\\u", "encode", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "assert_", "(_", "isinstance_", "(_", "str", "\\u", "enc_", "(_", "''_", ")_", ",_", "basestring_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Assert", "ion", "Error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "string", "\\u", "encode", "r", " ", "must", " ", "be", " ", "a", " ", "function", " ", "tha", "t", " ", "take", "s", " ", "'_", "'", "basest", "ring", " ", "and", " ", "return", "s", " ", "basest", "ring", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "enc_", "._", "encode", "\\u", "str_", "=_", "str", "\\u", "enc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "User", " ", "can", " ", "als", "o", " ", "just", " ", "pass", " ", "a", " ", "string", "-", "decode", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "The", " ", "full", "-", "fle", "dge", "d", " ", "gm", "l", " ", "encoders", " ", "handle", " ", "vari", "ous", " ", "data", " ", "types", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "string", "\\u", "decode", "r", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "str", "\\u", "dec_", "=_", "kwargs_", "[_", "'", "string", "\\u", "decode", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "assert_", "(_", "isinstance_", "(_", "str", "\\u", "dec_", "(_", "''_", ")_", ",_", "basestring_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Assert", "ion", "Error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Ze", "n", "Exception_", "(_", "'", "string", "\\u", "decode", "r", " ", "must", " ", "be", " ", "a", " ", "function", " ", "tha", "t", " ", "take", "s", " ", "'_", "'", "basest", "ring", " ", "and", " ", "return", "s", " ", "basest", "ring", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
cloudkick/libcloud/libcloud/compute/base.py
[ { "content": "# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nProvides base classes for working with drivers\n\"\"\"\nimport httplib, urllib\nimport time\nimport hashlib\nimport StringIO\nimport ssl\nimport os\nimport socket\nimport struct\n\nfrom libcloud.common.base import ConnectionKey, ConnectionUserAndKey\nfrom libcloud.compute.types import NodeState, DeploymentError\nfrom libcloud.compute.ssh import SSHClient\nfrom libcloud.httplib_ssl import LibcloudHTTPSConnection\nfrom httplib import HTTPConnection as LibcloudHTTPConnection\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Node(object):\n \"\"\"\n Provide a common interface for handling nodes of all types.\n\n The Node object provides the interface in libcloud through which\n we can manipulate nodes in different cloud providers in the same\n way. Node objects don't actually do much directly themselves,\n instead the node driver handles the connection to the node.\n\n You don't normally create a node object yourself; instead you use\n a driver and then have that create the node for you.\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> node = driver.create_node()\n >>> node.public_ip[0]\n '127.0.0.3'\n >>> node.name\n 'dummy-3'\n\n You can also get nodes from the driver's list_node function.\n\n >>> node = driver.list_nodes()[0]\n >>> node.name\n 'dummy-1'\n\n the node keeps a reference to its own driver which means that we\n can work on nodes from different providers without having to know\n which is which.\n\n >>> driver = DummyNodeDriver(72)\n >>> node2 = driver.create_node()\n >>> node.driver.creds\n 0\n >>> node2.driver.creds\n 72\n\n Althrough Node objects can be subclassed, this isn't normally\n done. Instead, any driver specific information is stored in the\n \"extra\" proproperty of the node.\n\n >>> node.extra\n {'foo': 'bar'}\n\n \"\"\"\n\n\n\n\n", "metadata": "root.Node", "header": "['module', '___EOS___']", "index": 33 }, { "content": " def __init__(self, id, name, state, public_ip, private_ip,\n driver, extra=None):\n self.id = str(id) if id else None\n self.name = name\n self.state = state\n self.public_ip = public_ip\n self.private_ip = private_ip\n self.driver = driver\n self.uuid = self.get_uuid()\n if not extra:\n self.extra = {}\n else:\n self.extra = extra", "metadata": "root.Node.__init__", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 79 }, { "content": " def get_uuid(self):\n \"\"\"Unique hash for this node\n\n @return: C{string}\n\n The hash is a function of an SHA1 hash of the node's ID and\n its driver which means that it should be unique between all\n nodes. In some subclasses (e.g. GoGrid) there is no ID\n available so the public IP address is used. This means that,\n unlike a properly done system UUID, the same UUID may mean a\n different system install at a different time\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> node = driver.create_node()\n >>> node.get_uuid()\n 'd3748461511d8b9b0e0bfa0d4d3383a619a2bb9f'\n\n Note, for example, that this example will always produce the\n same UUID!\n \"\"\"\n return hashlib.sha1(\"%s:%d\" % (self.id,self.driver.type)).hexdigest()", "metadata": "root.Node.get_uuid", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 93 }, { "content": " def reboot(self):\n \"\"\"Reboot this node\n\n @return: C{bool}\n\n This calls the node's driver and reboots the node\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> node = driver.create_node()\n >>> from libcloud.compute.types import NodeState\n >>> node.state == NodeState.RUNNING\n True\n >>> node.state == NodeState.REBOOTING\n False\n >>> node.reboot()\n True\n >>> node.state == NodeState.REBOOTING\n True\n \"\"\"\n return self.driver.reboot_node(self)", "metadata": "root.Node.reboot", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 116 }, { "content": " def destroy(self):\n \"\"\"Destroy this node\n\n @return: C{bool}\n\n This calls the node's driver and destroys the node\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> from libcloud.compute.types import NodeState\n >>> node = driver.create_node()\n >>> node.state == NodeState.RUNNING\n True\n >>> node.destroy()\n True\n >>> node.state == NodeState.RUNNING\n False\n\n \"\"\"\n return self.driver.destroy_node(self)", "metadata": "root.Node.destroy", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 138 }, { "content": " def __repr__(self):\n return (('<Node: uuid=%s, name=%s, state=%s, public_ip=%s, '\n 'provider=%s ...>')\n % (self.uuid, self.name, self.state, self.public_ip,\n self.driver.name))", "metadata": "root.Node.__repr__", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 159 }, { "content": "class NodeSize(object):\n \"\"\"\n A Base NodeSize class to derive from.\n\n NodeSizes are objects which are typically returned a driver's\n list_sizes function. They contain a number of different\n parameters which define how big an image is.\n\n The exact parameters available depends on the provider.\n\n N.B. Where a parameter is \"unlimited\" (for example bandwidth in\n Amazon) this will be given as 0.\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> size = driver.list_sizes()[0]\n >>> size.ram\n 128\n >>> size.bandwidth\n 500\n >>> size.price\n 4\n \"\"\"\n", "metadata": "root.NodeSize", "header": "['module', '___EOS___']", "index": 166 }, { "content": " def __init__(self, id, name, ram, disk, bandwidth, price, driver):\n self.id = str(id)\n self.name = name\n self.ram = ram\n self.disk = disk\n self.bandwidth = bandwidth\n self.price = price\n self.driver = driver", "metadata": "root.NodeSize.__init__", "header": "['class', 'NodeSize', '(', 'object', ')', ':', '___EOS___']", "index": 190 }, { "content": " def __repr__(self):\n return (('<NodeSize: id=%s, name=%s, ram=%s disk=%s bandwidth=%s '\n 'price=%s driver=%s ...>')\n % (self.id, self.name, self.ram, self.disk, self.bandwidth,\n self.price, self.driver.name))", "metadata": "root.NodeSize.__repr__", "header": "['class', 'NodeSize', '(', 'object', ')', ':', '___EOS___']", "index": 198 }, { "content": "class NodeImage(object):\n \"\"\"\n An operating system image.\n\n NodeImage objects are typically returned by the driver for the\n cloud provider in response to the list_images function\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> image = driver.list_images()[0]\n >>> image.name\n 'Ubuntu 9.10'\n\n Apart from name and id, there is no further standard information;\n other parameters are stored in a driver specific \"extra\" variable\n\n When creating a node, a node image should be given as an argument\n to the create_node function to decide which OS image to use.\n\n >>> node = driver.create_node(image=image)\n\n \"\"\"\n", "metadata": "root.NodeImage", "header": "['module', '___EOS___']", "index": 205 }, { "content": " def __init__(self, id, name, driver, extra=None):\n self.id = str(id)\n self.name = name\n self.driver = driver\n if not extra:\n self.extra = {}\n else:\n self.extra = extra", "metadata": "root.NodeImage.__init__", "header": "['class', 'NodeImage', '(', 'object', ')', ':', '___EOS___']", "index": 228 }, { "content": " def __repr__(self):\n return (('<NodeImage: id=%s, name=%s, driver=%s ...>')\n % (self.id, self.name, self.driver.name))", "metadata": "root.NodeImage.__repr__", "header": "['class', 'NodeImage', '(', 'object', ')', ':', '___EOS___']", "index": 236 }, { "content": "class NodeLocation(object):\n \"\"\"\n A physical location where nodes can be.\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> driver = DummyNodeDriver(0)\n >>> location = driver.list_locations()[0]\n >>> location.country\n 'US'\n \"\"\"\n", "metadata": "root.NodeLocation", "header": "['module', '___EOS___']", "index": 240 }, { "content": " def __init__(self, id, name, country, driver):\n self.id = str(id)\n self.name = name\n self.country = country\n self.driver = driver", "metadata": "root.NodeLocation.__init__", "header": "['class', 'NodeLocation', '(', 'object', ')', ':', '___EOS___']", "index": 251 }, { "content": " def __repr__(self):\n return (('<NodeLocation: id=%s, name=%s, country=%s, driver=%s>')\n % (self.id, self.name, self.country, self.driver.name))", "metadata": "root.NodeLocation.__repr__", "header": "['class', 'NodeLocation', '(', 'object', ')', ':', '___EOS___']", "index": 256 }, { "content": "class NodeAuthSSHKey(object):\n \"\"\"\n An SSH key to be installed for authentication to a node.\n\n This is the actual contents of the users ssh public key which will\n normally be installed as root's public key on the node.\n\n >>> pubkey = '...' # read from file\n >>> from libcloud.compute.base import NodeAuthSSHKey\n >>> k = NodeAuthSSHKey(pubkey)\n >>> k\n <NodeAuthSSHKey>\n\n \"\"\"", "metadata": "root.NodeAuthSSHKey", "header": "['module', '___EOS___']", "index": 260 }, { "content": " def __init__(self, pubkey):\n self.pubkey = pubkey", "metadata": "root.NodeAuthSSHKey.__init__", "header": "['class', 'NodeAuthSSHKey', '(', 'object', ')', ':', '___EOS___']", "index": 274 }, { "content": " def __repr__(self):\n return '<NodeAuthSSHKey>'", "metadata": "root.NodeAuthSSHKey.__repr__", "header": "['class', 'NodeAuthSSHKey', '(', 'object', ')', ':', '___EOS___']", "index": 276 }, { "content": "class NodeAuthPassword(object):\n \"\"\"\n A password to be used for authentication to a node.\n \"\"\"", "metadata": "root.NodeAuthPassword", "header": "['module', '___EOS___']", "index": 279 }, { "content": " def __init__(self, password):\n self.password = password", "metadata": "root.NodeAuthPassword.__init__", "header": "['class', 'NodeAuthPassword', '(', 'object', ')', ':', '___EOS___']", "index": 283 }, { "content": " def __repr__(self):\n return '<NodeAuthPassword>'", "metadata": "root.NodeAuthPassword.__repr__", "header": "['class', 'NodeAuthPassword', '(', 'object', ')', ':', '___EOS___']", "index": 285 }, { "content": "class NodeDriver(object):\n \"\"\"\n A base NodeDriver class to derive from\n\n This class is always subclassed by a specific driver. For\n examples of base behavior of most functions (except deploy node)\n see the dummy driver.\n\n \"\"\"\n\n connectionCls = ConnectionKey\n name = None\n type = None\n port = None\n features = {\"create_node\": []}\n \"\"\"\n List of available features for a driver.\n - L{create_node}\n - ssh_key: Supports L{NodeAuthSSHKey} as an authentication method\n for nodes.\n - password: Supports L{NodeAuthPassword} as an authentication\n method for nodes.\n - generates_password: Returns a password attribute on the Node\n object returned from creation.\n \"\"\"\n\n NODE_STATE_MAP = {}\n\n\n\n\n\n\n\n\n", "metadata": "root.NodeDriver", "header": "['module', '___EOS___']", "index": 288 }, { "content": " def __init__(self, key, secret=None, secure=True, host=None, port=None):\n \"\"\"\n @keyword key: API key or username to used\n @type key: str\n\n @keyword secret: Secret password to be used\n @type secret: str\n\n @keyword secure: Weither to use HTTPS or HTTP. Note: Some providers\n only support HTTPS, and it is on by default.\n @type secure: bool\n\n @keyword host: Override hostname used for connections.\n @type host: str\n\n @keyword port: Override port used for connections.\n @type port: int\n \"\"\"\n self.key = key\n self.secret = secret\n self.secure = secure\n args = [self.key]\n\n if self.secret != None:\n args.append(self.secret)\n\n args.append(secure)\n\n if host != None:\n args.append(host)\n\n if port != None:\n args.append(port)\n\n self.connection = self.connectionCls(*args)\n\n self.connection.driver = self\n self.connection.connect()", "metadata": "root.NodeDriver.__init__", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 316 }, { "content": " def create_node(self, **kwargs):\n \"\"\"Create a new node instance.\n\n @keyword name: String with a name for this new node (required)\n @type name: str\n\n @keyword size: The size of resources allocated to this node.\n (required)\n @type size: L{NodeSize}\n\n @keyword image: OS Image to boot on node. (required)\n @type image: L{NodeImage}\n\n @keyword location: Which data center to create a node in. If empty,\n undefined behavoir will be selected. (optional)\n @type location: L{NodeLocation}\n\n @keyword auth: Initial authentication information for the node\n (optional)\n @type auth: L{NodeAuthSSHKey} or L{NodeAuthPassword}\n\n @return: The newly created L{Node}.\n \"\"\"\n raise NotImplementedError, \\\n 'create_node not implemented for this driver'", "metadata": "root.NodeDriver.create_node", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 355 }, { "content": " def destroy_node(self, node):\n \"\"\"Destroy a node.\n\n Depending upon the provider, this may destroy all data associated with\n the node, including backups.\n\n @return: C{bool} True if the destroy was successful, otherwise False\n \"\"\"\n raise NotImplementedError, \\\n 'destroy_node not implemented for this driver'", "metadata": "root.NodeDriver.destroy_node", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 381 }, { "content": " def reboot_node(self, node):\n \"\"\"\n Reboot a node.\n @return: C{bool} True if the reboot was successful, otherwise False\n \"\"\"\n raise NotImplementedError, \\\n 'reboot_node not implemented for this driver'", "metadata": "root.NodeDriver.reboot_node", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 392 }, { "content": " def list_nodes(self):\n \"\"\"\n List all nodes\n @return: C{list} of L{Node} objects\n \"\"\"\n raise NotImplementedError, \\\n 'list_nodes not implemented for this driver'", "metadata": "root.NodeDriver.list_nodes", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 400 }, { "content": " def list_images(self, location=None):\n \"\"\"\n List images on a provider\n @return: C{list} of L{NodeImage} objects\n \"\"\"\n raise NotImplementedError, \\\n 'list_images not implemented for this driver'", "metadata": "root.NodeDriver.list_images", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 408 }, { "content": " def list_sizes(self, location=None):\n \"\"\"\n List sizes on a provider\n @return: C{list} of L{NodeSize} objects\n \"\"\"\n raise NotImplementedError, \\\n 'list_sizes not implemented for this driver'", "metadata": "root.NodeDriver.list_sizes", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 416 }, { "content": " def list_locations(self):\n \"\"\"\n List data centers for a provider\n @return: C{list} of L{NodeLocation} objects\n \"\"\"\n raise NotImplementedError, \\\n 'list_locations not implemented for this driver'", "metadata": "root.NodeDriver.list_locations", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 424 }, { "content": " def deploy_node(self, **kwargs):\n \"\"\"\n Create a new node, and start deployment.\n\n Depends on a Provider Driver supporting either using a specific password\n or returning a generated password.\n\n This function may raise a L{DeploymentException}, if a create_node\n call was successful, but there is a later error (like SSH failing or\n timing out). This exception includes a Node object which you may want\n to destroy if incomplete deployments are not desirable.\n\n @keyword deploy: Deployment to run once machine is online and availble to SSH.\n @type deploy: L{Deployment}\n\n @keyword ssh_username: Optional name of the account which is used when connecting to\n SSH server (default is root)\n @type ssh_username: C{str}\n\n @keyword ssh_port: Optional SSH server port (default is 22)\n @type ssh_port: C{int}\n\n See L{NodeDriver.create_node} for more keyword args.\n\n >>> from libcloud.compute.drivers.dummy import DummyNodeDriver\n >>> from libcloud.deployment import ScriptDeployment, MultiStepDeployment\n >>> from libcloud.compute.base import NodeAuthSSHKey\n >>> driver = DummyNodeDriver(0)\n >>> key = NodeAuthSSHKey('...') # read from file\n >>> script = ScriptDeployment(\"yum -y install emacs strace tcpdump\")\n >>> msd = MultiStepDeployment([key, script])\n >>> def d():\n ... try:\n ... node = driver.deploy_node(deploy=msd)\n ... except NotImplementedError:\n ... print \"not implemented for dummy driver\"\n >>> d()\n not implemented for dummy driver\n\n Deploy node is typically not overridden in subclasses. The\n existing implementation should be able to handle most such.\n \"\"\"\n # TODO: support ssh keys\n WAIT_PERIOD=3\n password = None\n\n if 'generates_password' not in self.features[\"create_node\"]:\n if 'password' not in self.features[\"create_node\"]:\n raise NotImplementedError, \\\n 'deploy_node not implemented for this driver'\n\n if not kwargs.has_key('auth'):\n kwargs['auth'] = NodeAuthPassword(os.urandom(16).encode('hex'))\n\n password = kwargs['auth'].password\n node = self.create_node(**kwargs)\n try:\n if 'generates_password' in self.features[\"create_node\"]:\n password = node.extra.get('password')\n start = time.time()\n end = start + (60 * 15)\n while time.time() < end:\n # need to wait until we get a public IP address.\n # TODO: there must be a better way of doing this\n time.sleep(WAIT_PERIOD)\n nodes = self.list_nodes()\n nodes = filter(lambda n: n.uuid == node.uuid, nodes)\n if len(nodes) == 0:\n raise DeploymentError(node, \"Booted node[%s] is missing form list_nodes.\" % node)\n if len(nodes) > 1:\n raise DeploymentError(node, \"Booted single node[%s], but multiple nodes have same UUID\"% node)\n\n node = nodes[0]\n\n if node.public_ip is not None and node.public_ip != \"\" and node.state == NodeState.RUNNING:\n break\n\n ssh_username = kwargs.get('ssh_username', 'root')\n ssh_port = kwargs.get('ssh_port', 22)\n\n client = SSHClient(hostname=node.public_ip[0],\n port=ssh_port, username=ssh_username,\n password=password)\n laste = None\n while time.time() < end:\n laste = None\n try:\n client.connect()\n break\n except (IOError, socket.gaierror, socket.error), e:\n laste = e\n time.sleep(WAIT_PERIOD)\n if laste is not None:\n raise e\n\n tries = 3\n while tries >= 0:\n try:\n n = kwargs[\"deploy\"].run(node, client)\n client.close()\n break\n except Exception, e:\n tries -= 1\n if tries == 0:\n raise\n client.connect()\n\n except DeploymentError, e:\n raise\n except Exception, e:\n raise DeploymentError(node, e)\n return n", "metadata": "root.NodeDriver.deploy_node", "header": "['class', 'NodeDriver', '(', 'object', ')', ':', '___EOS___']", "index": 432 }, { "content": "def is_private_subnet(ip):\n \"\"\"\n Utility function to check if an IP address is inside a private subnet.\n\n @type ip: C{str}\n @keyword ip: IP address to check\n\n @return: C{bool} if the specified IP address is private.\n \"\"\"\n priv_subnets = [ {'subnet': '10.0.0.0', 'mask': '255.0.0.0'},\n {'subnet': '172.16.0.0', 'mask': '255.240.0.0'},\n {'subnet': '192.168.0.0', 'mask': '255.255.0.0'} ]\n\n ip = struct.unpack('I',socket.inet_aton(ip))[0]\n\n for network in priv_subnets:\n subnet = struct.unpack('I',socket.inet_aton(network['subnet']))[0]\n mask = struct.unpack('I',socket.inet_aton(network['mask']))[0]\n\n if (ip & mask) == (subnet & mask):\n return True\n\n return False", "metadata": "root.is_private_subnet", "header": "['module', '___EOS___']", "index": 545 } ]
[ { "span": "import httplib, urllib", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 22 }, { "span": "import StringIO", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 15 }, { "span": "import ssl", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 10 }, { "span": "from libcloud.common.base import ConnectionKey, ConnectionUserAndKey", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 68 }, { "span": "from libcloud.httplib_ssl import LibcloudHTTPSConnection", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 56 }, { "span": "from httplib import HTTPConnection as LibcloudHTTPConnection", "start_line": 31, "start_column": 0, "end_line": 31, "end_column": 60 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "the", " ", "Ap", "ache", " ", "Sof", "twa", "re", " ", "Foun", "dati", "on", " ", "(", "AS", "F", ")", " ", "under", " ", "one", " ", "or", " ", "more_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contributor", " ", "license", " ", "agreement", "s", ".", " ", " ", "See", " ", "the", " ", "NOTICE", " ", "file", " ", "distributed", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "work", " ", "for", " ", "addition", "al", " ", "informati", "on", " ", "regarding", " ", "copyr", "ight", " ", "owner", "ship", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "AS", "F", " ", "license", "s", " ", "this", " ", "file", " ", "to", " ", "You", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "the", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "License", ".", " ", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Prov", "ides", " ", "base", " ", "classe", "s", " ", "for", " ", "working", " ", "with", " ", "driver", "s", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "httplib_", ",_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "ssl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "struct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "libc", "loud", "_", "._", "common_", "._", "base_", "import_", "Connect", "ion", "Key_", ",_", "Connect", "ion", "User", "And", "Key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "libc", "loud", "_", "._", "compute_", "._", "types_", "import_", "Node", "State_", ",_", "Deployment", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "libc", "loud", "_", "._", "compute_", "._", "ssh_", "import_", "SSH", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "libc", "loud", "_", "._", "http", "lib", "\\u", "ssl_", "import_", "Lib", "cloud", "HTTP", "SC", "onnect", "ion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "httplib_", "import_", "HTTP", "Connection_", "as_", "Lib", "cloud", "HTTP", "Connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "\"\\u\\u", "main", "\\u\\u\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "doctest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doctest_", "._", "testmod_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Prov", "ide", " ", "a", " ", "common", " ", "interface", " ", "for", " ", "handling", " ", "nodes", " ", "of", " ", "all", " ", "types", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "Node", " ", "object", " ", "provide", "s", " ", "the", " ", "interface", " ", "in", " ", "libc", "loud", " ", "through", " ", "whi", "ch", "\\", "10", ";", " ", " ", " ", " ", "we", " ", "can", " ", "manipulate", " ", "nodes", " ", "in", " ", "different", " ", "cloud", " ", "provide", "rs", " ", "in", " ", "the", " ", "same", "\\", "10", ";", " ", " ", " ", " ", "way", ".", " ", " ", "Node", " ", "object", "s", " ", "don", "'", "t", " ", "actual", "ly", " ", "do", " ", "muc", "h", " ", "direct", "ly", " ", "them", "sel", "ves", ",", "\\", "10", ";", " ", " ", " ", " ", "inst", "ead", " ", "the", " ", "node", " ", "driver", " ", "handle", "s", " ", "the", " ", "connecti", "on", " ", "to", " ", "the", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "don", "'", "t", " ", "normal", "ly", " ", "create", " ", "a", " ", "node", " ", "object", " ", "your", "self", ";", " ", "inst", "ead", " ", "you", " ", "use", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "driver", " ", "and", " ", "then", " ", "have", " ", "tha", "t", " ", "create", " ", "the", " ", "node", " ", "for", " ", "you", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "create", "\\u", "node", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "public", "\\u", "ip", "[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", "'", "127", ".0", ".0", ".3", "'", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "name", "\\", "10", ";", " ", " ", " ", " ", "'", "dummy", "-", "3", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "can", " ", "als", "o", " ", "get", " ", "nodes", " ", "from", " ", "the", " ", "driver", "'", "s", " ", "list", "\\u", "node", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "list", "\\u", "nodes", "()[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "name", "\\", "10", ";", " ", " ", " ", " ", "'", "dummy", "-1", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "node", " ", "keep", "s", " ", "a", " ", "reference", " ", "to", " ", "its", " ", "own", " ", "driver", " ", "whi", "ch", " ", "means", " ", "tha", "t", " ", "we", "\\", "10", ";", " ", " ", " ", " ", "can", " ", "work", " ", "on", " ", "nodes", " ", "from", " ", "different", " ", "provide", "rs", " ", "with", "out", " ", "hav", "ing", " ", "to", " ", "know", "\\", "10", ";", " ", " ", " ", " ", "whi", "ch", " ", "is", " ", "whi", "ch", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "7", "2", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", "2", " ", "=", " ", "driver", ".", "create", "\\u", "node", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "driver", ".", "creds", "\\", "10", ";", " ", " ", " ", " ", "0", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", "2", ".", "driver", ".", "creds", "\\", "10", ";", " ", " ", " ", " ", "7", "2", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Alt", "hro", "ugh", " ", "Node", " ", "object", "s", " ", "can", " ", "be", " ", "subclass", "ed", ",", " ", "this", " ", "isn", "'", "t", " ", "normal", "ly", "\\", "10", ";", " ", " ", " ", " ", "don", "e", ".", " ", " ", "Ins", "tea", "d", ",", " ", "any", " ", "driver", " ", "specific", " ", "informati", "on", " ", "is", " ", "store", "d", " ", "in", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "\"", "extra", "\"", " ", "prop", "rope", "rty", " ", "of", " ", "the", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "extra", "\\", "10", ";", " ", " ", " ", " ", "{", "'", "foo", "':", " ", "'", "bar", "'}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "state_", ",_", "public", "\\u", "ip_", ",_", "private", "\\u", "ip_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "driver_", ",_", "extra_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "id_", "=_", "str_", "(_", "id_", ")_", "if_", "id_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "state_", "=_", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "public", "\\u", "ip_", "=_", "public", "\\u", "ip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "private", "\\u", "ip_", "=_", "private", "\\u", "ip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "driver_", "=_", "driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "uuid_", "=_", "self_", "._", "get", "\\u", "uuid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "extra_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "extra_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "extra_", "=_", "extra_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "uuid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Unique", " ", "hash", " ", "for", " ", "this", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "string", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "hash", " ", "is", " ", "a", " ", "function", " ", "of", " ", "an", " ", "SHA", "1", " ", "hash", " ", "of", " ", "the", " ", "node", "'", "s", " ", "ID", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "its", " ", "driver", " ", "whi", "ch", " ", "means", " ", "tha", "t", " ", "it", " ", "shou", "ld", " ", "be", " ", "unique", " ", "bet", "ween", " ", "all", "\\", "10", ";", " ", " ", " ", " ", "nodes", ".", " ", " ", "In", " ", "some", " ", "subclasses", " ", "(", "e", ".", "g", ".", " ", "Go", "Grid", ")", " ", "there", " ", "is", " ", "no", " ", "ID", "\\", "10", ";", " ", " ", " ", " ", "avail", "able", " ", "so", " ", "the", " ", "public", " ", "IP", " ", "address", " ", "is", " ", "used", ".", " ", " ", "Thi", "s", " ", "means", " ", "tha", "t", ",", "\\", "10", ";", " ", " ", " ", " ", "unli", "ke", " ", "a", " ", "proper", "ly", " ", "don", "e", " ", "system", " ", "UU", "ID", ",", " ", "the", " ", "same", " ", "UU", "ID", " ", "may", " ", "mean", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "different", " ", "system", " ", "install", " ", "at", " ", "a", " ", "different", " ", "time", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "create", "\\u", "node", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "get", "\\u", "uuid", "()", "\\", "10", ";", " ", " ", " ", " ", "'", "d3", "748", "461", "511", "d8", "b9", "b0", "e0", "bf", "a0", "d4", "d3", "383", "a6", "1", "9", "a2", "bb", "9", "f", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", ",", " ", "for", " ", "example", ",", " ", "tha", "t", " ", "this", " ", "example", " ", "will", " ", "alw", "ay", "s", " ", "produce", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "same", " ", "UU", "ID", "!", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "hashlib_", "._", "sha1_", "(_", "\"%", "s", ":", "%", "d", "\"_", "%_", "(_", "self_", "._", "id_", ",_", "self_", "._", "driver_", "._", "type_", ")_", ")_", "._", "hexdigest_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reboot_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Reboot", " ", "this", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "bool", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "calls", " ", "the", " ", "node", "'", "s", " ", "driver", " ", "and", " ", "rebo", "ots", " ", "the", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "create", "\\u", "node", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "types", " ", "import", " ", "Node", "State", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "state", " ", "==", " ", "Node", "State", ".", "RUNN", "ING", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "state", " ", "==", " ", "Node", "State", ".", "REB", "OOT", "ING", "\\", "10", ";", " ", " ", " ", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "rebo", "ot", "()", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "state", " ", "==", " ", "Node", "State", ".", "REB", "OOT", "ING", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "driver_", "._", "rebo", "ot", "\\u", "node_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "destroy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Destr", "oy", " ", "this", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "bool", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "calls", " ", "the", " ", "node", "'", "s", " ", "driver", " ", "and", " ", "destroy", "s", " ", "the", " ", "node", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "types", " ", "import", " ", "Node", "State", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "create", "\\u", "node", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "state", " ", "==", " ", "Node", "State", ".", "RUNN", "ING", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "destroy", "()", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", ".", "state", " ", "==", " ", "Node", "State", ".", "RUNN", "ING", "\\", "10", ";", " ", " ", " ", " ", "Fal", "se", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "driver_", "._", "destroy", "\\u", "node_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "(_", "'<", "Node", ":", " ", "uuid", "=", "%", "s", ",", " ", "name", "=", "%", "s", ",", " ", "state", "=", "%", "s", ",", " ", "public", "\\u", "ip", "=", "%", "s", ",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "provide", "r", "=", "%", "s", " ", "...", ">'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "self_", "._", "uuid_", ",_", "self_", "._", "name_", ",_", "self_", "._", "state_", ",_", "self_", "._", "public", "\\u", "ip_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "driver_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Size_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "Base", " ", "Node", "Size", " ", "class", " ", "to", " ", "derive", " ", "from", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Node", "Size", "s", " ", "are", " ", "object", "s", " ", "whi", "ch", " ", "are", " ", "typical", "ly", " ", "return", "ed", " ", "a", " ", "driver", "'", "s", "\\", "10", ";", " ", " ", " ", " ", "list", "\\u", "size", "s", " ", "function", ".", " ", " ", "The", "y", " ", "contain", " ", "a", " ", "number", " ", "of", " ", "different", "\\", "10", ";", " ", " ", " ", " ", "parameter", "s", " ", "whi", "ch", " ", "defin", "e", " ", "how", " ", "big", " ", "an", " ", "image", " ", "is", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "exact", " ", "parameter", "s", " ", "avail", "able", " ", "depend", "s", " ", "on", " ", "the", " ", "provide", "r", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "N", ".", "B", ".", " ", "Whe", "re", " ", "a", " ", "parameter", " ", "is", " ", "\"", "unlimited", "\"", " ", "(", "for", " ", "example", " ", "bandwi", "dth", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "Ama", "zon", ")", " ", "this", " ", "will", " ", "be", " ", "give", "n", " ", "as", " ", "0.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "size", " ", "=", " ", "driver", ".", "list", "\\u", "size", "s", "()[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "size", ".", "ram", "\\", "10", ";", " ", " ", " ", " ", "128", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "size", ".", "bandwi", "dth", "\\", "10", ";", " ", " ", " ", " ", "500", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "size", ".", "price", "\\", "10", ";", " ", " ", " ", " ", "4", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Size_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "ram_", ",_", "disk_", ",_", "bandwidth_", ",_", "price_", ",_", "driver_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "id_", "=_", "str_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ram_", "=_", "ram_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "disk_", "=_", "disk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bandwidth_", "=_", "bandwidth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "price_", "=_", "price_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "driver_", "=_", "driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Size_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "(_", "'<", "Node", "Size", ":", " ", "id", "=", "%", "s", ",", " ", "name", "=", "%", "s", ",", " ", "ram", "=", "%", "s", " ", "disk", "=", "%", "s", " ", "bandwi", "dth", "=", "%", "s", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "price", "=", "%", "s", " ", "driver", "=", "%", "s", " ", "...", ">'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "self_", "._", "id_", ",_", "self_", "._", "name_", ",_", "self_", "._", "ram_", ",_", "self_", "._", "disk_", ",_", "self_", "._", "bandwidth_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "price_", ",_", "self_", "._", "driver_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Image_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "operati", "ng", " ", "system", " ", "image", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Node", "Image", " ", "object", "s", " ", "are", " ", "typical", "ly", " ", "return", "ed", " ", "by", " ", "the", " ", "driver", " ", "for", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "cloud", " ", "provide", "r", " ", "in", " ", "response", " ", "to", " ", "the", " ", "list", "\\u", "images", " ", "function", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "image", " ", "=", " ", "driver", ".", "list", "\\u", "images", "()[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "image", ".", "name", "\\", "10", ";", " ", " ", " ", " ", "'", "Ub", "unt", "u", " ", "9.1", "0", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ap", "art", " ", "from", " ", "name", " ", "and", " ", "id", ",", " ", "there", " ", "is", " ", "no", " ", "fur", "ther", " ", "standard", " ", "informati", "on", ";", "\\", "10", ";", " ", " ", " ", " ", "other", " ", "parameter", "s", " ", "are", " ", "store", "d", " ", "in", " ", "a", " ", "driver", " ", "specific", " ", "\"", "extra", "\"", " ", "variab", "le", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "creati", "ng", " ", "a", " ", "node", ",", " ", "a", " ", "node", " ", "image", " ", "shou", "ld", " ", "be", " ", "give", "n", " ", "as", " ", "an", " ", "argu", "ment", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "create", "\\u", "node", " ", "function", " ", "to", " ", "decide", " ", "whi", "ch", " ", "OS", " ", "image", " ", "to", " ", "use", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "node", " ", "=", " ", "driver", ".", "create", "\\u", "node", "(", "image", "=", "image", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Image_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "driver_", ",_", "extra_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "id_", "=_", "str_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "driver_", "=_", "driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "extra_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "extra_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "extra_", "=_", "extra_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Image_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "(_", "'<", "Node", "Image", ":", " ", "id", "=", "%", "s", ",", " ", "name", "=", "%", "s", ",", " ", "driver", "=", "%", "s", " ", " ", "...", ">'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "self_", "._", "id_", ",_", "self_", "._", "name_", ",_", "self_", "._", "driver_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Location_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "physical", " ", "location", " ", "where", " ", "nodes", " ", "can", " ", "be", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "location", " ", "=", " ", "driver", ".", "list", "\\u", "location", "s", "()[", "0", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "location", ".", "countr", "y", "\\", "10", ";", " ", " ", " ", " ", "'", "US", "'", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Location_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "id_", ",_", "name_", ",_", "country_", ",_", "driver_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "id_", "=_", "str_", "(_", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "country_", "=_", "country_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "driver_", "=_", "driver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Location_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "(_", "'<", "Node", "Locat", "ion", ":", " ", "id", "=", "%", "s", ",", " ", "name", "=", "%", "s", ",", " ", "countr", "y", "=", "%", "s", ",", " ", "driver", "=", "%", "s", ">'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "self_", "._", "id_", ",_", "self_", "._", "name_", ",_", "self_", "._", "country_", ",_", "self_", "._", "driver_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Auth", "SSH", "Key_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "SSH", " ", "key", " ", "to", " ", "be", " ", "install", "ed", " ", "for", " ", "authenticat", "ion", " ", "to", " ", "a", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "the", " ", "actual", " ", "content", "s", " ", "of", " ", "the", " ", "users", " ", "ssh", " ", "public", " ", "key", " ", "whi", "ch", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "normal", "ly", " ", "be", " ", "install", "ed", " ", "as", " ", "root", "'", "s", " ", "public", " ", "key", " ", "on", " ", "the", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "pubkey", " ", "=", " ", "'...", "'", " ", "#", " ", "read", " ", "from", " ", "file", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "base", " ", "import", " ", "Node", "Auth", "SSH", "Key", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "k", " ", "=", " ", "Node", "Auth", "SSH", "Key", "(", "pubkey", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "k", "\\", "10", ";", " ", " ", " ", " ", "<", "Node", "Auth", "SSH", "Key", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Auth", "SSH", "Key_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "pubkey_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pubkey_", "=_", "pubkey_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Auth", "SSH", "Key_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Node", "Auth", "SSH", "Key", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Auth", "Password_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "password", " ", "to", " ", "be", " ", "used", " ", "for", " ", "authenticat", "ion", " ", "to", " ", "a", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Auth", "Password_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "password_", "=_", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Auth", "Password_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Node", "Auth", "Passw", "ord", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "base", " ", "Node", "Drive", "r", " ", "class", " ", "to", " ", "derive", " ", "from", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "class", " ", "is", " ", "alw", "ay", "s", " ", "subclass", "ed", " ", "by", " ", "a", " ", "specific", " ", "driver", ".", " ", " ", "For", "\\", "10", ";", " ", " ", " ", " ", "example", "s", " ", "of", " ", "base", " ", "behavior", " ", "of", " ", "most", " ", "function", "s", " ", "(", "except", " ", "deploy", " ", "node", ")", "\\", "10", ";", " ", " ", " ", " ", "see", " ", "the", " ", "dummy", " ", "driver", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "connecti", "on", "Cls", "_", "=_", "Connect", "ion", "Key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "port_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "=_", "{_", "\"", "create", "\\u", "node", "\"_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "of", " ", "avail", "able", " ", "features", " ", "for", " ", "a", " ", "driver", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "L", "{", "create", "\\u", "node", "}", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "ssh", "\\u", "key", ":", " ", "Supp", "orts", " ", "L", "{", "Node", "Auth", "SSH", "Key", "}", " ", "as", " ", "an", " ", "authenticat", "ion", " ", "method", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "for", " ", "nodes", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "password", ":", " ", "Supp", "orts", " ", "L", "{", "Node", "Auth", "Passw", "ord", "}", " ", "as", " ", "an", " ", "authenticat", "ion", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "method", " ", "for", " ", "nodes", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "generat", "es", "\\u", "password", ":", " ", "Return", "s", " ", "a", " ", "password", " ", "attribute", " ", "on", " ", "the", " ", "Node", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "object", " ", "return", "ed", " ", "from", " ", "creati", "on", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "NODE", "\\u", "STATE", "\\u", "MAP_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "key_", ",_", "secret_", "=_", "None_", ",_", "secure_", "=_", "True_", ",_", "host_", "=_", "None_", ",_", "port_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "key", ":", " ", " ", " ", " ", "API", " ", "key", " ", "or", " ", "user", "name", " ", "to", " ", "used", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "key", ":", " ", " ", " ", " ", "str", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "secret", ":", " ", "Sec", "ret", " ", "password", " ", "to", " ", "be", " ", "used", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "secret", ":", " ", "str", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "secure", ":", " ", "Wei", "ther", " ", "to", " ", "use", " ", "HTTP", "S", " ", "or", " ", "HTTP", ".", " ", "Not", "e", ":", " ", "Some", " ", "provide", "rs", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "only", " ", "support", " ", "HTTP", "S", ",", " ", "and", " ", "it", " ", "is", " ", "on", " ", "by", " ", "default", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "secure", ":", " ", "bool", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "host", ":", " ", "Override", " ", "host", "name", " ", "used", " ", "for", " ", "connections", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "host", ":", " ", "str", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "port", ":", " ", "Override", " ", "port", " ", "used", " ", "for", " ", "connections", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "port", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key_", "=_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "secret_", "=_", "secret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "secure_", "=_", "secure_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "[_", "self_", "._", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "secret_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "._", "append_", "(_", "self_", "._", "secret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "._", "append_", "(_", "secure_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "host_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "._", "append_", "(_", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "port_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "._", "append_", "(_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "connection_", "=_", "self_", "._", "connecti", "on", "Cls", "_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "connection_", "._", "driver_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connection_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "node_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "new", " ", "node", " ", "instance", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "name", ":", " ", " ", " ", "String", " ", "with", " ", "a", " ", "name", " ", "for", " ", "this", " ", "new", " ", "node", " ", "(", "require", "d", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "name", ":", " ", " ", " ", "str", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "size", ":", " ", " ", " ", "The", " ", "size", " ", "of", " ", "resource", "s", " ", "allocated", " ", "to", " ", "this", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "(", "require", "d", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "size", ":", " ", " ", " ", "L", "{", "Node", "Size", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "image", ":", " ", " ", "OS", " ", "Image", " ", "to", " ", "boot", " ", "on", " ", "node", ".", " ", "(", "require", "d", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "image", ":", " ", " ", "L", "{", "Node", "Image", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "location", ":", " ", "Whi", "ch", " ", "data", " ", "center", " ", "to", " ", "create", " ", "a", " ", "node", " ", "in", ".", " ", "If", " ", "empty", ",", "\\", "10", ";", " ", " ", " ", " ", "undefined", " ", "beha", "voi", "r", " ", "will", " ", "be", " ", "selecte", "d", ".", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "location", ":", " ", "L", "{", "Node", "Locat", "ion", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "auth", ":", " ", " ", " ", "Initial", " ", "authenticat", "ion", " ", "informati", "on", " ", "for", " ", "the", " ", "node", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "auth", ":", " ", " ", " ", "L", "{", "Node", "Auth", "SSH", "Key", "}", " ", "or", " ", "L", "{", "Node", "Auth", "Passw", "ord", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "The", " ", "newl", "y", " ", "created", " ", "L", "{", "Node", "}.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "create", "\\u", "node", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "destroy", "\\u", "node_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Destr", "oy", " ", "a", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Depend", "ing", " ", "upo", "n", " ", "the", " ", "provide", "r", ",", " ", "this", " ", "may", " ", "destroy", " ", "all", " ", "data", " ", "associate", "d", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "node", ",", " ", "inclu", "ding", " ", "backup", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "bool", "}", " ", "Tru", "e", " ", "if", " ", "the", " ", "destroy", " ", "was", " ", "success", "ful", ",", " ", "other", "wis", "e", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "destroy", "\\u", "node", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rebo", "ot", "\\u", "node_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Reboot", " ", "a", " ", "node", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "bool", "}", " ", "Tru", "e", " ", "if", " ", "the", " ", "rebo", "ot", " ", "was", " ", "success", "ful", ",", " ", "other", "wis", "e", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "rebo", "ot", "\\u", "node", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "\\u", "nodes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "all", " ", "nodes", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "list", "}", " ", "of", " ", "L", "{", "Node", "}", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "list", "\\u", "nodes", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "\\u", "images_", "(_", "self_", ",_", "location_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "images", " ", "on", " ", "a", " ", "provide", "r", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "list", "}", " ", "of", " ", "L", "{", "Node", "Image", "}", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "list", "\\u", "images", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "\\u", "sizes_", "(_", "self_", ",_", "location_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "size", "s", " ", "on", " ", "a", " ", "provide", "r", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "list", "}", " ", "of", " ", "L", "{", "Node", "Size", "}", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "list", "\\u", "size", "s", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "\\u", "locations_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "data", " ", "center", "s", " ", "for", " ", "a", " ", "provide", "r", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "list", "}", " ", "of", " ", "L", "{", "Node", "Locat", "ion", "}", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "list", "\\u", "location", "s", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Node", "Driver_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "deploy", "\\u", "node_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "new", " ", "node", ",", " ", "and", " ", "start", " ", "deploy", "ment", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Depend", "s", " ", "on", " ", "a", " ", "Provider", " ", "Drive", "r", " ", "support", "ing", " ", "eit", "her", " ", "usi", "ng", " ", "a", " ", "specific", " ", "password", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "return", "ing", " ", "a", " ", "generat", "ed", " ", "password", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "may", " ", "raise", " ", "a", " ", "L", "{", "Deployment", "Except", "ion", "},", " ", "if", " ", "a", " ", "create", "\\u", "node", "\\", "10", ";", " ", " ", " ", " ", "call", " ", "was", " ", "success", "ful", ",", " ", "but", " ", "there", " ", "is", " ", "a", " ", "late", "r", " ", "error", " ", "(", "like", " ", "SSH", " ", "faili", "ng", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "tim", "ing", " ", "out", ").", " ", " ", "Thi", "s", " ", "exception", " ", "include", "s", " ", "a", " ", "Node", " ", "object", " ", "whi", "ch", " ", "you", " ", "may", " ", "want", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "destroy", " ", "if", " ", "incomplete", " ", "deployments", " ", "are", " ", "not", " ", "desi", "rab", "le", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "deploy", ":", " ", "Deployment", " ", "to", " ", "run", " ", "onc", "e", " ", "machine", " ", "is", " ", "onli", "ne", " ", "and", " ", "avail", "ble", " ", "to", " ", "SSH", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "deploy", ":", " ", "L", "{", "Deployment", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "ssh", "\\u", "user", "name", ":", " ", "Optio", "nal", " ", "name", " ", "of", " ", "the", " ", "account", " ", "whi", "ch", " ", "is", " ", "used", " ", "whe", "n", " ", "connecti", "ng", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "SSH", " ", "server", " ", "(", "default", " ", "is", " ", "root", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "ssh", "\\u", "user", "name", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", " ", " ", " ", "ssh", "\\u", "port", ":", " ", "Optio", "nal", " ", "SSH", " ", "server", " ", "port", " ", "(", "default", " ", "is", " ", "2", "2", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", " ", " ", "ssh", "\\u", "port", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "See", " ", "L", "{", "Node", "Drive", "r", ".", "create", "\\u", "node", "}", " ", "for", " ", "more", " ", "keyw", "ord", " ", "args", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "driver", "s", ".", "dummy", " ", "import", " ", "Du", "mm", "y", "Node", "Drive", "r", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "deploy", "ment", " ", "import", " ", "Script", "Deployment", ",", " ", "Multi", "Step", "Deployment", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "libc", "loud", ".", "compute", ".", "base", " ", "import", " ", "Node", "Auth", "SSH", "Key", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "driver", " ", "=", " ", "Du", "mm", "y", "Node", "Drive", "r", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "key", " ", "=", " ", "Node", "Auth", "SSH", "Key", "('.", "..", "')", " ", "#", " ", "read", " ", "from", " ", "file", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "script", " ", "=", " ", "Script", "Deployment", "(\"", "yum", " ", "-", "y", " ", "install", " ", "ema", "cs", " ", "stra", "ce", " ", "tcp", "dump", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "msd", " ", "=", " ", "Multi", "Step", "Deployment", "([", "key", ",", " ", "script", "])", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "def", " ", "d", "():", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "try", ":", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "node", " ", "=", " ", "driver", ".", "deploy", "\\u", "node", "(", "deploy", "=", "msd", ")", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "except", " ", "Not", "Impl", "ement", "ed", "Error", ":", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "print", " ", "\"", "not", " ", "implemented", " ", "for", " ", "dummy", " ", "driver", "\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "d", "()", "\\", "10", ";", " ", " ", " ", " ", "not", " ", "implemented", " ", "for", " ", "dummy", " ", "driver", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Deploy", " ", "node", " ", "is", " ", "typical", "ly", " ", "not", " ", "overrid", "den", " ", "in", " ", "subclasses", ".", " ", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "exist", "ing", " ", "implementation", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "handle", " ", "most", " ", "suc", "h", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "support", " ", "ssh", " ", "keys_", "\\u\\u\\uNL\\u\\u\\u_", "WAIT", "\\u", "PERIOD_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "generat", "es", "\\u", "password", "'_", "not_", "in_", "self_", "._", "features_", "[_", "\"", "create", "\\u", "node", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "password", "'_", "not_", "in_", "self_", "._", "features_", "[_", "\"", "create", "\\u", "node", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", ",_", "'", "deploy", "\\u", "node", " ", "not", " ", "implemented", " ", "for", " ", "this", " ", "driver", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "kwargs_", "._", "has", "\\u", "key_", "(_", "'", "auth", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "[_", "'", "auth", "'_", "]_", "=_", "Node", "Auth", "Password_", "(_", "os_", "._", "urandom_", "(_", "16_", ")_", "._", "encode_", "(_", "'", "hex", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "password_", "=_", "kwargs_", "[_", "'", "auth", "'_", "]_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node_", "=_", "self_", "._", "create", "\\u", "node_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "generat", "es", "\\u", "password", "'_", "in_", "self_", "._", "features_", "[_", "\"", "create", "\\u", "node", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "password_", "=_", "node_", "._", "extra_", "._", "get_", "(_", "'", "password", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "start_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end_", "=_", "start_", "+_", "(_", "60_", "*_", "15_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "time_", "._", "time_", "(_", ")_", "<_", "end_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "wait", " ", "unti", "l", " ", "we", " ", "get", " ", "a", " ", "public", " ", "IP", " ", "address", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "there", " ", "must", " ", "be", " ", "a", " ", "bett", "er", " ", "way", " ", "of", " ", "doi", "ng", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", "._", "sleep_", "(_", "WAIT", "\\u", "PERIOD_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodes_", "=_", "self_", "._", "list", "\\u", "nodes_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodes_", "=_", "filter_", "(_", "lambda_", "n_", ":_", "n_", "._", "uuid_", "==_", "node_", "._", "uuid_", ",_", "nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "nodes_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Deployment", "Error_", "(_", "node_", ",_", "\"", "Boot", "ed", " ", "node", "[", "%", "s", "]", " ", "is", " ", "missi", "ng", " ", "form", " ", "list", "\\u", "nodes", ".\"_", "%_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "nodes_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Deployment", "Error_", "(_", "node_", ",_", "\"", "Boot", "ed", " ", "single", " ", "node", "[", "%", "s", "],", " ", "but", " ", "multiple", " ", "nodes", " ", "have", " ", "same", " ", "UU", "ID", "\"_", "%_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node_", "=_", "nodes_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "node_", "._", "public", "\\u", "ip_", "is_", "not_", "None_", "and_", "node_", "._", "public", "\\u", "ip_", "!=_", "\"\"_", "and_", "node_", "._", "state_", "==_", "Node", "State_", "._", "RUNNING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ssh", "\\u", "username_", "=_", "kwargs_", "._", "get_", "(_", "'", "ssh", "\\u", "user", "name", "'_", ",_", "'", "root", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ssh", "\\u", "port_", "=_", "kwargs_", "._", "get_", "(_", "'", "ssh", "\\u", "port", "'_", ",_", "22_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "client_", "=_", "SSH", "Client_", "(_", "hostname_", "=_", "node_", "._", "public", "\\u", "ip_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "port_", "=_", "ssh", "\\u", "port_", ",_", "username_", "=_", "ssh", "\\u", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "e_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "time_", "._", "time_", "(_", ")_", "<_", "end_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "e_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "IO", "Error_", ",_", "socket_", "._", "gai", "error_", ",_", "socket_", "._", "error_", ")_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "e_", "=_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "WAIT", "\\u", "PERIOD_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "last", "e_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tries_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "tries_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "kwargs_", "[_", "\"", "deploy", "\"_", "]_", "._", "run_", "(_", "node_", ",_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tries_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tries_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client_", "._", "connect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Deployment", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Deployment", "Error_", "(_", "node_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "private", "\\u", "subnet_", "(_", "ip_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Utili", "ty", " ", "function", " ", "to", " ", "check", " ", "if", " ", "an", " ", "IP", " ", "address", " ", "is", " ", "insi", "de", " ", "a", " ", "private", " ", "subnet", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "ip", ":", " ", "C", "{", "str", "}", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", "ip", ":", " ", "IP", " ", "address", " ", "to", " ", "check", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "bool", "}", " ", "if", " ", "the", " ", "specified", " ", "IP", " ", "address", " ", "is", " ", "private", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priv", "\\u", "subnets_", "=_", "[_", "{_", "'", "subnet", "'_", ":_", "'", "10.", "0.", "0.", "0", "'_", ",_", "'", "mask", "'_", ":_", "'", "255.", "0.", "0.", "0", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "subnet", "'_", ":_", "'", "172", ".1", "6.0", ".0", "'_", ",_", "'", "mask", "'_", ":_", "'", "255.", "240", ".0", ".0", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "subnet", "'_", ":_", "'", "192", ".1", "68.", "0.", "0", "'_", ",_", "'", "mask", "'_", ":_", "'", "255.", "255.", "0.", "0", "'_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ip_", "=_", "struct_", "._", "unpack_", "(_", "'", "I", "'_", ",_", "socket_", "._", "inet", "\\u", "ato", "n_", "(_", "ip_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "network_", "in_", "priv", "\\u", "subnets_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subnet_", "=_", "struct_", "._", "unpack_", "(_", "'", "I", "'_", ",_", "socket_", "._", "inet", "\\u", "ato", "n_", "(_", "network_", "[_", "'", "subnet", "'_", "]_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mask_", "=_", "struct_", "._", "unpack_", "(_", "'", "I", "'_", ",_", "socket_", "._", "inet", "\\u", "ato", "n_", "(_", "network_", "[_", "'", "mask", "'_", "]_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "ip_", "&_", "mask_", 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
bfrog/whizzer/whizzer/test/test_server.py
[ { "content": " def test_tcp_server(self):\n factory = ProtocolFactory()\n factory.protocol = Protocol\n server = TcpServer(loop, factory, \"0.0.0.0\", 2000)\n server = None", "metadata": "root.TestServerCreation.test_tcp_server", "header": "['class', 'TestServerCreation', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 37 }, { "content": " def test_unix_server(self):\n factory = ProtocolFactory()\n factory.protocol = Protocol\n server = UnixServer(loop, factory, \"bogus\")\n server = None\n # path should be cleaned up as soon as garbage collected\n gc.collect()\n self.assertTrue(not os.path.exists(\"bogus\"))", "metadata": "root.TestServerCreation.test_unix_server", "header": "['class', 'TestServerCreation', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 43 } ]
[ { "span": "server ", "start_line": 41, "start_column": 8, "end_line": 41, "end_column": 14 }, { "span": "server ", "start_line": 47, "start_column": 8, "end_line": 47, "end_column": 14 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Server", "Creat", "ion_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "tcp", "\\u", "server_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "factory_", "=_", "Proto", "col", "Factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "factory_", "._", "protocol_", "=_", "Protocol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "=_", "Tc", "p", "Server_", "(_", "loop_", ",_", "factory_", ",_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "2000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Server", "Creat", "ion_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "unix", "\\u", "server_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "factory_", "=_", "Proto", "col", "Factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "factory_", "._", "protocol_", "=_", "Protocol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "=_", "Uni", "x", "Server_", "(_", "loop_", ",_", "factory_", ",_", "\"", "bog", "us", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "server_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "path", " ", "shou", "ld", " ", "be", " ", "clean", "ed", " ", "up", " ", "as", " ", "soo", "n", " ", "as", " ", "gar", "bage", " ", "collected", "_", "\\u\\u\\uNL\\u\\u\\u_", "gc_", "._", "collect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "\"", "bog", "us", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Missing call to `__init__` during object initialization
codysoyland/surlex/src/surlex/grammar.py
[ { "content": " def __init__(self, name):\n self.name = name", "metadata": "root.TagNode.__init__", "header": "['class', 'TagNode', '(', 'Node', ')', ':', '___EOS___']", "index": 48 }, { "content": "class RegexTagNode(TagNode):\n\n", "metadata": "root.RegexTagNode", "header": "['module', '___EOS___']", "index": 58 }, { "content": " def __init__(self, name, regex):\n self.name = name\n self.regex = regex", "metadata": "root.RegexTagNode.__init__", "header": "['class', 'RegexTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 59 }, { "content": "class MacroTagNode(TagNode):\n\n", "metadata": "root.MacroTagNode", "header": "['module', '___EOS___']", "index": 71 }, { "content": " def __init__(self, name, macro):\n self.name = name\n self.macro = macro", "metadata": "root.MacroTagNode.__init__", "header": "['class', 'MacroTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 72 } ]
[ { "span": "class RegexTagNode(TagNode):", "start_line": 58, "start_column": 0, "end_line": 58, "end_column": 28 }, { "span": "class MacroTagNode(TagNode):", "start_line": 71, "start_column": 0, "end_line": 71, "end_column": 28 } ]
[ { "span": "def __init__(self, name):", "start_line": 48, "start_column": 4, "end_line": 48, "end_column": 29 }, { "span": "def __init__(self, name, regex):", "start_line": 59, "start_column": 4, "end_line": 59, "end_column": 36 }, { "span": "def __init__(self, name, macro):", "start_line": 72, "start_column": 4, "end_line": 72, "end_column": 36 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Ta", "g", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "regex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "regex_", "=_", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "macro_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "macro_", "=_", "macro_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
onyxfish/clan/clan/diff.py
[ { "content": " def diff(self, report_a, report_b):\n \"\"\"\n Generate a diff for two data reports.\n \"\"\"\n arguments = GLOBAL_ARGUMENTS + ['run_date']\n\n output = OrderedDict([\n ('a', OrderedDict([(arg, report_a[arg]) for arg in arguments])),\n ('b', OrderedDict([(arg, report_b[arg]) for arg in arguments])),\n ('queries', [])\n ])\n\n output['a']\n\n for query_a in report_a['queries']:\n for query_b in report_b['queries']:\n if query_a['config'] == query_b['config']:\n diff = OrderedDict()\n\n diff['config'] = query_a['config']\n diff['data_types'] = query_a['data_types']\n diff['data'] = OrderedDict()\n\n for metric, values in query_a['data'].items():\n data_type = diff['data_types'][metric]\n diff['data'][metric] = OrderedDict()\n\n total_a = values['total']\n total_b = query_b['data'][metric]['total']\n\n for label, value in values.items():\n a = value\n \n try:\n b = query_b['data'][metric][label]\n # TODO: hack for when labels are different...\n except KeyError:\n continue\n\n change = b - a\n percent_change = float(change) / a if a > 0 else None\n \n percent_a = float(a) / total_a if total_a > 0 else None\n percent_b = float(b) / total_b if total_b > 0 else None\n\n if label == 'total' or data_type == 'TIME' or percent_a is None or percent_b is None:\n point_change = None\n else:\n point_change = percent_b - percent_a\n\n diff['data'][metric][label] = OrderedDict([\n ('change', change),\n ('percent_change', percent_change),\n ('point_change', point_change),\n ])\n\n output['queries'].append(diff)\n\n query_b = report_b['queries']\n\n return output ", "metadata": "root.DiffCommand.diff", "header": "['class', 'DiffCommand', '(', 'object', ')', ':', '___EOS___']", "index": 79 } ]
[ { "span": "query_b ", "start_line": 137, "start_column": 12, "end_line": 137, "end_column": 19 } ]
[ { "span": "query_b ", "start_line": 94, "start_column": 16, "end_line": 94, "end_column": 23 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Diff", "Command_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "diff_", "(_", "self_", ",_", "report", "\\u", "a_", ",_", "report", "\\u", "b_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Generate", " ", "a", " ", "diff", " ", "for", " ", "two", " ", "data", " ", "report", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "arguments_", "=_", "GLOB", "AL", "\\u", "ARGUMENT", "S_", "+_", "[_", "'", "run", "\\u", "date", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "output_", "=_", "Order", "ed", "Dict_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "a", "'_", ",_", "Order", "ed", "Dict_", "(_", "[_", "(_", "arg_", ",_", "report", "\\u", "a_", "[_", "arg_", "]_", ")_", "for_", "arg_", "in_", "arguments_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "b", "'_", ",_", "Order", "ed", "Dict_", "(_", "[_", "(_", "arg_", ",_", "report", "\\u", "b_", "[_", "arg_", "]_", ")_", "for_", "arg_", "in_", "arguments_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "querie", "s", "'_", ",_", "[_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "output_", "[_", "'", "a", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "query", "\\u", "a_", "in_", "report", "\\u", "a_", "[_", "'", "querie", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "query", "\\u", "b_", "in_", "report", "\\u", "b_", "[_", "'", "querie", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "query", "\\u", "a_", "[_", "'", "config", "'_", "]_", "==_", "query", "\\u", "b_", "[_", "'", "config", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "diff_", "=_", "Order", "ed", "Dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "diff_", "[_", "'", "config", "'_", "]_", "=_", "query", "\\u", "a_", "[_", "'", "config", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "[_", "'", "data\\u", "types", "'_", "]_", "=_", "query", "\\u", "a_", "[_", "'", "data\\u", "types", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "[_", "'", "data", "'_", "]_", "=_", "Order", "ed", "Dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "metric_", ",_", "values_", "in_", "query", "\\u", "a_", "[_", "'", "data", "'_", "]_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "data\\u", "type_", "=_", "diff_", "[_", "'", "data\\u", "types", "'_", "]_", "[_", "metric_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "[_", "'", "data", "'_", "]_", "[_", "metric_", "]_", "=_", "Order", "ed", "Dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "total", "\\u", "a_", "=_", "values_", "[_", "'", "total", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "b_", "=_", "query", "\\u", "b_", "[_", "'", "data", "'_", "]_", "[_", "metric_", "]_", "[_", "'", "total", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "label_", ",_", "value_", "in_", "values_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "a_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "b_", "=_", "query", "\\u", "b_", "[_", "'", "data", "'_", "]_", "[_", "metric_", "]_", "[_", "label_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "hack", " ", "for", " ", "whe", "n", " ", "labels", " ", "are", " ", "different", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "change_", "=_", "b_", "-_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "percent", "\\u", "change_", "=_", "float_", "(_", "change_", ")_", "/_", "a_", "if_", "a_", ">_", "0_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "percent", "\\u", "a_", "=_", "float_", "(_", "a_", ")_", "/_", "total", "\\u", "a_", "if_", "total", "\\u", "a_", ">_", "0_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "percent", "\\u", "b_", "=_", "float_", "(_", "b_", ")_", "/_", "total", "\\u", "b_", "if_", "total", "\\u", "b_", ">_", "0_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "label_", "==_", "'", "total", "'_", "or_", "data\\u", "type_", "==_", "'", "TIME", "'_", "or_", "percent", "\\u", "a_", "is_", "None_", "or_", "percent", "\\u", "b_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "point", "\\u", "change_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "point", "\\u", "change_", "=_", "percent", "\\u", "b_", "-_", "percent", "\\u", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "diff_", "[_", "'", "data", "'_", "]_", "[_", "metric_", "]_", "[_", "label_", "]_", "=_", "Order", "ed", "Dict_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "change", "'_", ",_", "change_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "percent", "\\u", "change", "'_", ",_", "percent", "\\u", "change_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "point", "\\u", "change", "'_", ",_", "point", "\\u", "change_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "output_", "[_", "'", "querie", "s", "'_", "]_", "._", "append_", "(_", "diff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
fp7-ofelia/ocf/optin_manager/src/python/openflow/common/permissions/views.py
[ { "content": "def request_permission(always_redirect_to,\n permission_owners_func=None,\n template=\"permissions/get_permission.html\"):\n \"\"\"\n Get a generic view to use for creating PermissionRequests.\n \n The view's template context will have:\n - C{form}: the form to show the user. By default, this is a\n L{PermissionRequestForm}\n - C{obj_perm}: the L{ObjectPermission} instance requested.\n \n The form will show all users that can delegate the requested permission by\n default. To change the shown set, specify C{permission_owners_func} which\n should return the set to show.\n \n @param always_redirect_to: path to redirect to after the permission request\n is saved.\n @keyword permission_owners_func: A callable with the following signature::\n \n permission_owners_func(request, obj_permission, user)\n \n Where C{request} is the request object passed to the view,\n C{obj_permission} is the requested L{ObjectPermission} instance, and\n C{user} is the object that the permission is being requested for. The\n function should return {django.contrib.auth.models.User} C{QuerySet}.\n @keyword template: Path of the template to use. By default, this is\n \"permissions/get_permission.html\".\n \"\"\"\n def request_permission_view(request, permission, user,\n target_obj_or_class, redirect_to=None):\n # Get the object permission\n obj_perm = register_permission_for_obj_or_class(\n target_obj_or_class, permission)[0]\n \n # Get the users who can delegate the permission\n if permission_owners_func:\n user_qs = permission_owners_func(request, obj_perm, user)\n else:\n user_qs = PermissionUser.objects.get_objects_queryset(\n User,\n dict(\n permissioninfo__obj_permission=obj_perm,\n permissioninfo__can_delegate=True),\n {})\n \n # process the request\n if request.method == \"POST\":\n perm_request = PermissionRequest(requesting_user=request.user,\n requested_permission=obj_perm)\n form = PermissionRequestForm(user_qs, request.POST,\n instance=perm_request)\n if form.is_valid():\n # Post a permission request for the permission owner\n perm_request = form.save()\n return simple.redirect_to(request, always_redirect_to,\n permanent=False)\n else:\n form = PermissionRequestForm(user_qs)\n \n return simple.direct_to_template(\n request, template=template,\n extra_context={\"form\": form, \"obj_perm\": obj_perm})\n return request_permission_view", "metadata": "root.request_permission", "header": "['module', '___EOS___']", "index": 54 } ]
[ { "span": "perm_request ", "start_line": 107, "start_column": 16, "end_line": 107, "end_column": 28 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "request", "\\u", "permission_", "(_", "alw", "ay", "s", "\\u", "redirec", "t", "\\u", "to_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permissi", "on", "\\u", "owner", "s", "\\u", "func_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "\"", "permissi", "ons", "/", "get", "\\u", "permissi", "on", ".", "html", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "a", " ", "gener", "ic", " ", "view", " ", "to", " ", "use", " ", "for", " ", "creati", "ng", " ", "Permi", "ssion", "Request", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "view", "'", "s", " ", "template", " ", "context", " ", "will", " ", "have", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "C", "{", "form", "}:", " ", "the", " ", "form", " ", "to", " ", "show", " ", "the", " ", "user", ".", " ", "By", " ", "default", ",", " ", "this", " ", "is", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "L", "{", "Permi", "ssion", "Request", "Form", "}", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "C", "{", "obj", "\\u", "perm", "}:", " ", "the", " ", "L", "{", "Object", "Permi", "ssion", "}", " ", "instance", " ", "request", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "form", " ", "will", " ", "show", " ", "all", " ", "users", " ", "tha", "t", " ", "can", " ", "delegate", " ", "the", " ", "request", "ed", " ", "permissi", "on", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "default", ".", " ", "To", " ", "change", " ", "the", " ", "shown", " ", "set", ",", " ", "speci", "fy", " ", "C", "{", "permissi", "on", "\\u", "owner", "s", "\\u", "func", "}", " ", "whi", "ch", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", " ", "return", " ", "the", " ", "set", " ", "to", " ", "show", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "alw", "ay", "s", "\\u", "redirec", "t", "\\u", "to", ":", " ", "path", " ", "to", " ", "redirec", "t", " ", "to", " ", "after", " ", "the", " ", "permissi", "on", " ", "request", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "saved", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", "permissi", "on", "\\u", "owner", "s", "\\u", "func", ":", " ", "A", " ", "calla", "ble", " ", "with", " ", "the", " ", "follow", "ing", " ", "signa", "ture", "::", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "permissi", "on", "\\u", "owner", "s", "\\u", "func", "(", "request", ",", " ", "obj", "\\u", "permissi", "on", ",", " ", "user", ")", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Whe", "re", " ", "C", "{", "request", "}", " ", "is", " ", "the", " ", "request", " ", "object", " ", "pass", "ed", " ", "to", " ", "the", " ", "view", ",", "\\", "10", ";", " ", " ", " ", " ", "C", "{", "obj", "\\u", "permissi", "on", "}", " ", "is", " ", "the", " ", "request", "ed", " ", "L", "{", "Object", "Permi", "ssion", "}", " ", "instance", ",", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "C", "{", "user", "}", " ", "is", " ", "the", " ", "object", " ", "tha", "t", " ", "the", " ", "permissi", "on", " ", "is", " ", "bei", "ng", " ", "request", "ed", " ", "for", ".", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "function", " ", "shou", "ld", " ", "return", " ", "{", "django", ".", "contrib", ".", "auth", ".", "model", "s", ".", "User", "}", " ", "C", "{", "Query", "Set", "}.", "\\", "10", ";", " ", " ", " ", " ", "@", "keyw", "ord", " ", "template", ":", " ", "Path", " ", "of", " ", "the", " ", "template", " ", "to", " ", "use", ".", " ", "By", " ", "default", ",", " ", "this", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "\"", "permissi", "ons", "/", "get", "\\u", "permissi", "on", ".", "html", "\".\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "request", "\\u", "permissi", "on", "\\u", "view_", "(_", "request_", ",_", "permission_", ",_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "obj", "\\u", "or", "\\u", "class_", ",_", "redirec", "t", "\\u", "to_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "object", " ", "permission_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "perm_", "=_", "register", "\\u", "permissi", "on", "\\u", "for", "\\u", "obj", "\\u", "or", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "obj", "\\u", "or", "\\u", "class_", ",_", "permission_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "users", " ", "who", " ", "can", " ", "delegate", " ", "the", " ", "permission_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "permissi", "on", "\\u", "owner", "s", "\\u", "func_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "qs_", "=_", "permissi", "on", "\\u", "owner", "s", "\\u", "func_", "(_", "request_", ",_", "obj", "\\u", "perm_", ",_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "qs_", "=_", "Permi", "ssion", "User_", "._", "objects_", "._", "get", "\\u", "object", "s", "\\u", "queryset_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "permissi", "oni", "nfo", "\\u\\u", "obj", "\\u", "permission_", "=_", "obj", "\\u", "perm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permissi", "oni", "nfo", "\\u\\u", "can", "\\u", "delegate_", "=_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "process", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "perm", "\\u", "request_", "=_", "Permi", "ssion", "Request_", "(_", "request", "ing", "\\u", "user_", "=_", "request_", "._", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request", "ed", "\\u", "permission_", "=_", "obj", "\\u", "perm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "Permi", "ssion", "Request", "Form_", "(_", "user", "\\u", "qs_", ",_", "request_", "._", "POST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "=_", "perm", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Post", " ", "a", " ", "permissi", "on", " ", "request", " ", "for", " ", "the", " ", "permissi", "on", " ", "owner_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "perm", "\\u", "request_", "=_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "simple_", "._", "redirec", "t", "\\u", "to_", "(_", "request_", ",_", "alw", "ay", "s", "\\u", "redirec", "t", "\\u", "to_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permanent", "_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Permi", "ssion", "Request", "Form_", "(_", "user", "\\u", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "template_", "=_", "template_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\"", "form", "\"_", ":_", "form_", ",_", "\"", "obj", "\\u", "perm", "\"_", ":_", "obj", "\\u", "perm_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "request", "\\u", "permissi", "on", "\\u", "view_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
wrr/wwwhisper/wwwhisper_auth/tests/tests_site_cache.py
[ { "content": " def test_find_returns_cached_item_if_not_modified(self):\n site = self.sites.create_item(TEST_SITE)\n site2 = self.sites.find_item(TEST_SITE)\n self.assertTrue(site is site2)", "metadata": "root.CachingSitesCollectionTest.test_find_returns_cached_item_if_not_modified", "header": "['class', 'CachingSitesCollectionTest', '(', 'TestCase', ')', ':', '___EOS___']", "index": 48 }, { "content": " def test_find_rereads_item_if_externally_modified(self):\n site = self.sites.create_item(TEST_SITE)\n orig_mod_id = site.mod_id\n # Simulate modification by an external process, not visible to\n # the current one.\n site.site_modified()\n site.mod_id = orig_mod_id\n site2 = self.sites.find_item(TEST_SITE)\n self.assertTrue(site is not site2)", "metadata": "root.CachingSitesCollectionTest.test_find_rereads_item_if_externally_modified", "header": "['class', 'CachingSitesCollectionTest', '(', 'TestCase', ')', ':', '___EOS___']", "index": 53 } ]
[ { "span": "self.assertTrue(site is site2)", "start_line": 51, "start_column": 8, "end_line": 51, "end_column": 38 }, { "span": "self.assertTrue(site is not site2)", "start_line": 61, "start_column": 8, "end_line": 61, "end_column": 42 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Caching", "Site", "s", "Collecti", "on", "Test_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "find", "\\u", "return", "s", "\\u", "cache", "d\\u", "item", "\\u", "if", "\\u", "not", "\\u", "modified_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "site_", "=_", "self_", "._", "sites_", "._", "create", "\\u", "item_", "(_", "TEST", "\\u", "SITE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "site", "2_", "=_", "self_", "._", "sites_", "._", "find", "\\u", "item_", "(_", "TEST", "\\u", "SITE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "site_", "is_", "site", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Caching", "Site", "s", "Collecti", "on", "Test_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "find", "\\u", "rer", "eads", "\\u", "item", "\\u", "if", "\\u", "external", "ly", "\\u", "modified_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "site_", "=_", "self_", "._", "sites_", "._", "create", "\\u", "item_", "(_", "TEST", "\\u", "SITE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orig", "\\u", "mod", "\\u", "id_", "=_", "site_", "._", "mod", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Simulate", " ", "modification", " ", "by", " ", "an", " ", "external", " ", "process", ",", " ", "not", " ", "visi", "ble", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "current", " ", "one", "._", "\\u\\u\\uNL\\u\\u\\u_", "site_", "._", "site", "\\u", "modified_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "site_", "._", "mod", "\\u", "id_", "=_", "orig", "\\u", "mod", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "site", "2_", "=_", "self_", "._", "sites_", "._", "find", "\\u", "item_", "(_", "TEST", "\\u", "SITE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "site_", "is_", "not_", "site", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Missing call to `__init__` during object initialization
tempodb/tempodb-python/tempodb/protocol/cursor.py
[ { "content": " def __init__(self, data, t, response):\n self.response = response\n self.type = t\n self.data = make_generator(\n [self.type(d, self.response) for d in data])", "metadata": "root.Cursor.__init__", "header": "['class', 'Cursor', '(', 'object', ')', ':', '___EOS___']", "index": 38 }, { "content": "class DataPointCursor(Cursor):\n \"\"\"An iterable cursor over a collection of DataPoint objects. The\n timezone, rollup data, and start and end times are available as the\n following attributes on the cursor directly:\n\n * tz\n * rollup\n * start\n * end\n\n The data attribute holds the actual data from the request.\n\n Additionally, the raw response object is available as the response\n attribute of the cursor.\n\n :param list data: a list of data points from the API\n :param class type: the type of object construct from the data\n :param response: the raw response object\n :type response: :class:`tempodb.response.Response`\n :param string tz: the timezone the data is returned in\"\"\"\n\n", "metadata": "root.DataPointCursor", "header": "['module', '___EOS___']", "index": 56 }, { "content": " def __init__(self, data, t, response, tz=None):\n self.response = response\n self.type = t\n self.tz = tz\n self.rollup = data.get('rollup')\n self.start = convert_iso_stamp(data.get('start'))\n self.end = convert_iso_stamp(data.get('end'))\n self.data = make_generator(\n [self.type(d, self.response, tz=tz) for d in data['data']])", "metadata": "root.DataPointCursor.__init__", "header": "['class', 'DataPointCursor', '(', 'Cursor', ')', ':', '___EOS___']", "index": 77 } ]
[ { "span": "class DataPointCursor(Cursor):", "start_line": 56, "start_column": 0, "end_line": 56, "end_column": 30 } ]
[ { "span": "def __init__(self, data, t, response):", "start_line": 38, "start_column": 4, "end_line": 38, "end_column": 42 }, { "span": "def __init__(self, data, t, response, tz=None):", "start_line": 77, "start_column": 4, "end_line": 77, "end_column": 51 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Cursor_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", ",_", "t_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "response_", "=_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "type_", "=_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data_", "=_", "make", "\\u", "generator_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "self_", "._", "type_", "(_", "d_", ",_", "self_", "._", "response_", ")_", "for_", "d_", "in_", "data_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Data", "Point", "Cursor_", "(_", "Cursor_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "An", " ", "iterable", " ", "cursor", " ", "over", " ", "a", " ", "collection", " ", "of", " ", "Data", "Point", " ", "object", "s", ".", " ", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "timezon", "e", ",", " ", "roll", "up", " ", "data", ",", " ", "and", " ", "start", " ", "and", " ", "end", " ", "times", " ", "are", " ", "avail", "able", " ", "as", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "follow", "ing", " ", "attribute", "s", " ", "on", " ", "the", " ", "cursor", " ", "direct", "ly", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "tz", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "roll", "up", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "start", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "end", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "data", " ", "attribute", " ", "hold", "s", " ", "the", " ", "actual", " ", "data", " ", "from", " ", "the", " ", "request", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Addition", "ally", ",", " ", "the", " ", "raw", " ", "response", " ", "object", " ", "is", " ", "avail", "able", " ", "as", " ", "the", " ", "response", "\\", "10", ";", " ", " ", " ", " ", "attribute", " ", "of", " ", "the", " ", "cursor", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "list", " ", "data", ":", " ", "a", " ", "list", " ", "of", " ", "data", " ", "points", " ", "from", " ", "the", " ", "API", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "class", " ", "type", ":", " ", "the", " ", "type", " ", "of", " ", "object", " ", "construct", " ", "from", " ", "the", " ", "data", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "response", ":", " ", "the", " ", "raw", " ", "response", " ", "object", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "response", ":", " ", ":", "class", ":`", "tempo", "db", ".", "response", ".", "Respons", "e", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "string", " ", "tz", ":", " ", "the", " ", "timezon", "e", " ", "the", " ", "data", " ", "is", " ", "return", "ed", " ", "in", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Data", "Point", "Cursor_", "(_", "Cursor_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", ",_", "t_", ",_", "response_", ",_", "tz_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "response_", "=_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "type_", "=_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "tz_", "=_", "tz_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "roll", "up_", "=_", "data_", "._", "get_", "(_", "'", "roll", "up", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start_", "=_", "convert", "\\u", "iso", "\\u", "stamp_", "(_", "data_", "._", "get_", "(_", "'", "start", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end_", "=_", "convert", "\\u", "iso", "\\u", "stamp_", "(_", "data_", "._", "get_", "(_", "'", "end", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data_", "=_", "make", "\\u", "generator_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "self_", "._", "type_", "(_", "d_", ",_", "self_", "._", "response_", ",_", "tz_", "=_", "tz_", ")_", "for_", "d_", "in_", "data_", "[_", "'", "data", "'_", "]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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
AppScale/appscale/AppServer/lib/django-0.96/django/db/models/__init__.py
[ { "content": "def permalink(func):\n from django.core.urlresolvers import reverse\n def inner(*args, **kwargs):\n bits = func(*args, **kwargs)\n viewname = bits[0]\n return reverse(bits[0], None, *bits[1:3])\n return inner", "metadata": "root.permalink", "header": "['module', '___EOS___']", "index": 22 } ]
[ { "span": "viewname ", "start_line": 26, "start_column": 8, "end_line": 26, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "permalink", "_", "(_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "inner_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bits_", "=_", "func_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view", "name_", "=_", "bits_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "reverse_", "(_", "bits_", "[_", "0_", "]_", ",_", "None_", ",_", "*_", "bits_", "[_", "1_", ":_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "inner_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
ppwwyyxx/tensorpack/examples/load-vgg16.py
[ { "content": "#!/usr/bin/env python2\n# -*- coding: UTF-8 -*-\n# File: load_vgg16.py\n# Author: Yuxin Wu <[email protected]>\n\nimport tensorflow as tf\nimport numpy as np\nimport os\nimport argparse\nimport cPickle as pkl\n\nfrom tensorpack.train import TrainConfig, start_train\nfrom tensorpack.predict import PredictConfig, get_predict_func\nfrom tensorpack.models import *\nfrom tensorpack.utils import *\nfrom tensorpack.tfutils import *\nfrom tensorpack.tfutils.symbolic_functions import *\nfrom tensorpack.tfutils.summary import *\nfrom tensorpack.callbacks import *\nfrom tensorpack.dataflow import *\nfrom tensorpack.dataflow.dataset import ILSVRCMeta\n\n\"\"\"\nUsage:\n python2 -m tensorpack.utils.loadcaffe PATH/TO/models/VGG/{VGG_ILSVRC_16_layers_deploy.prototxt,VGG_ILSVRC_16_layers.caffemodel} vgg16.npy\n ./load_vgg16.py --load vgg16.npy --input cat.png\n\"\"\"\n\n\n\nif __name__ == '__main__':\n parser = argparse.ArgumentParser()\n parser.add_argument('--gpu', default='0',\n help='comma separated list of GPU(s) to use.') # nargs='*' in multi mode\n parser.add_argument('--load', required=True,\n help='.npy model file generated by tensorpack.utils.loadcaffe')\n parser.add_argument('--input', help='an input image', required=True)\n args = parser.parse_args()\n if args.gpu:\n os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu\n run_test(args.load, args.input)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Model(ModelDesc):\n", "metadata": "root.Model", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def _get_input_vars(self):\n return [InputVar(tf.float32, (None, 224, 224, 3), 'input'),\n InputVar(tf.int32, (None,), 'label') ]", "metadata": "root.Model._get_input_vars", "header": "['class', 'Model', '(', 'ModelDesc', ')', ':', '___EOS___']", "index": 29 }, { "content": " def _get_cost(self, inputs, is_training):\n is_training = bool(is_training)\n keep_prob = tf.constant(0.5 if is_training else 1.0)\n\n image, label = inputs\n\n with argscope(Conv2D, kernel_shape=3):\n # 224\n l = Conv2D('conv1_1', image, 64)\n l = Conv2D('conv1_2', l, 64)\n l = MaxPooling('pool1', l, 2, stride=2, padding='VALID')\n # 112\n\n l = Conv2D('conv2_1', l, 128)\n l = Conv2D('conv2_2', l, 128)\n l = MaxPooling('pool2', l, 2, stride=2, padding='VALID')\n # 56\n\n l = Conv2D('conv3_1', l, 256)\n l = Conv2D('conv3_2', l, 256)\n l = Conv2D('conv3_3', l, 256)\n l = MaxPooling('pool3', l, 2, stride=2, padding='VALID')\n # 28\n\n l = Conv2D('conv4_1', l, 512)\n l = Conv2D('conv4_2', l, 512)\n l = Conv2D('conv4_3', l, 512)\n l = MaxPooling('pool4', l, 2, stride=2, padding='VALID')\n # 14\n\n l = Conv2D('conv5_1', l, 512)\n l = Conv2D('conv5_2', l, 512)\n l = Conv2D('conv5_3', l, 512)\n l = MaxPooling('pool5', l, 2, stride=2, padding='VALID')\n # 7\n\n l = FullyConnected('fc6', l, 4096)\n l = tf.nn.dropout(l, keep_prob)\n l = FullyConnected('fc7', l, 4096)\n l = tf.nn.dropout(l, keep_prob)\n logits = FullyConnected('fc8', l, out_dim=1000, nl=tf.identity)\n prob = tf.nn.softmax(logits, name='output')\n\n cost = tf.nn.sparse_softmax_cross_entropy_with_logits(logits, label)\n cost = tf.reduce_mean(cost, name='cost')\n return cost", "metadata": "root.Model._get_cost", "header": "['class', 'Model', '(', 'ModelDesc', ')', ':', '___EOS___']", "index": 33 }, { "content": "def run_test(path, input):\n param_dict = np.load(path).item()\n\n pred_config = PredictConfig(\n model=Model(),\n input_data_mapping=[0],\n session_init=ParamRestore(param_dict),\n output_var_names=['output:0'] # output:0 is the probability distribution\n )\n predict_func = get_predict_func(pred_config)\n\n import cv2\n im = cv2.imread(input)\n assert im is not None\n im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)\n im = cv2.resize(im, (224, 224))\n im = np.reshape(im, (1, 224, 224, 3)).astype('float32')\n im = im - 110\n outputs = predict_func([im])[0]\n prob = outputs[0]\n ret = prob.argsort()[-10:][::-1]\n print ret\n\n meta = ILSVRCMeta().get_synset_words_1000()\n print [meta[k] for k in ret]", "metadata": "root.run_test", "header": "['module', '___EOS___']", "index": 80 } ]
[ { "span": "import cPickle as pkl", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 21 }, { "span": "from tensorpack.train import TrainConfig, start_train", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 53 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python", "2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "UT", "F", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "File", ":", " ", "load", "\\u", "vgg", "16.", "py_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Author", ":", " ", "Yu", "xin", " ", "Wu", " ", "<", "pp", "ww", "yy", "xx", "@", "gma", "il", ".", "com", ">_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "tensorflow_", "as_", "tf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "c", "Pickle_", "as_", "pkl", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tensor", "pack_", "._", "train_", "import_", "Train", "Config_", ",_", "start", "\\u", "train_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "predict_", "import_", "Predic", "t", "Config_", ",_", "get", "\\u", "predi", "ct", "\\u", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "tf", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "tf", "utils_", "._", "symbolic", "\\u", "functions_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "tf", "utils_", "._", "summary_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "callbacks_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "dataflow", "_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tensor", "pack_", "._", "dataflow", "_", "._", "dataset_", "import_", "IL", "SV", "RC", "Meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Us", "age", ":", "\\", "10", ";", " ", " ", " ", " ", "python", "2", " ", "-", "m", " ", "tensor", "pack", ".", "util", "s", ".", "load", "caffe", " ", "PATH", "/", "TO", "/", "model", "s", "/", "VG", "G", "/{", "VG", "G", "\\u", "IL", "SV", "RC", "\\u", "16", "\\u", "layer", "s", "\\u", "deploy", ".", "protot", "xt", ",", "VG", "G", "\\u", "IL", "SV", "RC", "\\u", "16", "\\u", "layer", "s", ".", "caffe", "model", "}", " ", "vgg", "16.", "npy", "\\", "10", ";", " ", " ", " ", " ", "./", "load", "\\u", "vgg", "16.", "py", " ", "--", "load", " ", "vgg", "16.", "npy", " ", "--", "input", " ", "cat", ".", "png", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "gpu", "'_", ",_", "default_", "=_", "'", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "comma", " ", "separate", "d", " ", "list", " ", "of", " ", "GPU", "(", "s", ")", " ", "to", " ", "use", ".'_", ")_", "#", " ", "narg", "s", "='", "*'", " ", "in", " ", "multi", " ", "mode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "load", "'_", ",_", "required_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'.", "npy", " ", "model", " ", "file", " ", "generat", "ed", " ", "by", " ", "tensor", "pack", ".", "util", "s", ".", "load", "caffe", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "input", "'_", ",_", "help_", "=_", "'", "an", " ", "input", " ", "image", "'_", ",_", "required_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "gpu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "environ_", "[_", "'", "CU", "DA", "\\u", "VISI", "BL", "E", "\\u", "DEVICES", "'_", "]_", "=_", "args_", "._", "gpu_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "run", "\\u", "test_", "(_", "args_", "._", "load_", ",_", "args_", "._", "input_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Model_", "(_", "Model", "Desc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Model_", "(_", "Model", "Desc_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "get", "\\u", "input", "\\u", "vars_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "Inp", "ut", "Var_", "(_", "tf_", "._", "float32_", ",_", "(_", "None_", ",_", "224_", ",_", "224_", ",_", "3_", ")_", ",_", "'", "input", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Inp", "ut", "Var_", "(_", "tf_", "._", "int32_", ",_", "(_", "None_", ",_", ")_", ",_", "'", "label", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model_", "(_", "Model", "Desc_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "cost_", "(_", "self_", ",_", "inputs_", ",_", "is", "\\u", "training_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "\\u", "training_", "=_", "bool_", "(_", "is", "\\u", "training_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "keep", "\\u", "prob_", "=_", "tf_", "._", "constant_", "(_", "0.5_", "if_", "is", "\\u", "training_", "else_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image_", ",_", "label_", "=_", "inputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "args", "cope", "_", "(_", "Conv", "2", "D_", ",_", "kernel", "\\u", "shape_", "=_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "224_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "1", "\\u", "1", "'_", ",_", "image_", ",_", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "1", "\\u", "2", "'_", ",_", "l_", ",_", "64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Max", "Pooling", "_", "(_", "'", "pool", "1", "'_", ",_", "l_", ",_", "2_", ",_", "stride_", "=_", "2_", ",_", "padding_", "=_", "'", "VALID", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "112_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv2", "\\u", "1", "'_", ",_", "l_", ",_", "128_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv2", "\\u", "2", "'_", ",_", "l_", ",_", "128_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Max", "Pooling", "_", "(_", "'", "pool", "2", "'_", ",_", "l_", ",_", "2_", ",_", "stride_", "=_", "2_", ",_", "padding_", "=_", "'", "VALID", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "56_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv3", "\\u", "1", "'_", ",_", "l_", ",_", "256_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv3", "\\u", "2", "'_", ",_", "l_", ",_", "256_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv3", "\\u", "3", "'_", ",_", "l_", ",_", "256_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Max", "Pooling", "_", "(_", "'", "pool", "3", "'_", ",_", "l_", ",_", "2_", ",_", "stride_", "=_", "2_", ",_", "padding_", "=_", "'", "VALID", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "28_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "4", "\\u", "1", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "4", "\\u", "2", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "4", "\\u", "3", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Max", "Pooling", "_", "(_", "'", "pool", "4", "'_", ",_", "l_", ",_", "2_", ",_", "stride_", "=_", "2_", ",_", "padding_", "=_", "'", "VALID", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "14_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "5", "\\u", "1", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "5", "\\u", "2", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Conv", "2", "D_", "(_", "'", "conv", "5", "\\u", "3", "'_", ",_", "l_", ",_", "512_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Max", "Pooling", "_", "(_", "'", "pool", "5", "'_", ",_", "l_", ",_", "2_", ",_", "stride_", "=_", "2_", ",_", "padding_", "=_", "'", "VALID", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "7_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "=_", "Full", "y", "Connected_", "(_", "'", "fc", "6", "'_", ",_", "l_", ",_", "4096_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "tf_", "._", "nn_", "._", "dropout_", "(_", "l_", ",_", "keep", "\\u", "prob_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "Full", "y", "Connected_", "(_", "'", "fc", "7", "'_", ",_", "l_", ",_", "4096_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "=_", "tf_", "._", "nn_", "._", "dropout_", "(_", "l_", ",_", "keep", "\\u", "prob_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logits_", "=_", "Full", "y", "Connected_", "(_", "'", "fc", "8", "'_", ",_", "l_", ",_", "out", "\\u", "dim_", "=_", "1000_", ",_", "nl_", "=_", "tf_", "._", "identity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "=_", "tf_", "._", "nn_", "._", "softmax_", "(_", "logits_", ",_", "name_", "=_", "'", "output", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cost_", "=_", "tf_", "._", "nn_", "._", "spars", "e\\u", "soft", "max", "\\u", "cross", "\\u", "entr", "opy", "\\u", "with", "\\u", "logits_", "(_", "logits_", ",_", "label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cost_", "=_", "tf_", "._", "reduce", "\\u", "mean_", "(_", "cost_", ",_", "name_", "=_", "'", "cost", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cost_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "\\u", "test_", "(_", "path_", ",_", "input_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "param", "\\u", "dict_", "=_", "np_", "._", "load_", "(_", "path_", ")_", "._", "item_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pred", "\\u", "config_", "=_", "Predic", "t", "Config_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "Model_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "data\\u", "mapping_", "=_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "session", "\\u", "init_", "=_", "Param", "Restor", "e_", "(_", "param", "\\u", "dict_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "output", "\\u", "var", "\\u", "names_", "=_", "[_", "'", "output", ":", "0", "'_", "]_", "#", " ", "output", ":", "0", " ", "is", " ", "the", " ", "probabilit", "y", " ", "distribution_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "predi", "ct", "\\u", "func_", "=_", "get", "\\u", "predi", "ct", "\\u", "func_", "(_", "pred", "\\u", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "cv2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "cv2_", "._", "imread_", "(_", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "im_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "cv2_", "._", "cvt", "Color_", "(_", "im_", ",_", "cv2_", "._", "COLOR", "\\u", "BG", "R2", "RGB_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "cv2_", "._", "resize_", "(_", "im_", ",_", "(_", "224_", ",_", "224_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "np_", "._", "reshape_", "(_", "im_", ",_", "(_", "1_", ",_", "224_", ",_", "224_", ",_", "3_", ")_", ")_", "._", "astype_", "(_", "'", "float", "32", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "im_", "-_", "110_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "outputs_", "=_", "predi", "ct", "\\u", "func_", "(_", "[_", "im_", "]_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "=_", "outputs_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "prob_", "._", "argsort_", "(_", ")_", "[_", "-_", "10_", ":_", "]_", "[_", ":_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "meta_", "=_", "IL", "SV", "RC", "Meta_", "(_", ")_", "._", "get", "\\u", "synset", "\\u", "words", "\\u", "1000_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "[_", "meta_", "[_", "k_", "]_", "for_", "k_", "in_", "ret_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Testing equality to None
bitxbay/BitXBay/electru/build/lib/electrum/socks.py
[ { "content": " def connect(self, destpair):\n \"\"\"connect(self, despair)\n Connects to the specified destination through a proxy.\n destpar - A tuple of the IP/DNS address and the port number.\n (identical to socket's connect).\n To select the proxy server use setproxy().\n \"\"\"\n # Do a minimal input check first\n if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int):\n raise GeneralProxyError((5, _generalerrors[5]))\n if self.__proxy[0] == PROXY_TYPE_SOCKS5:\n if self.__proxy[2] != None:\n portnum = self.__proxy[2]\n else:\n portnum = 1080\n _orgsocket.connect(self, (self.__proxy[1], portnum))\n self.__negotiatesocks5(destpair[0], destpair[1])\n elif self.__proxy[0] == PROXY_TYPE_SOCKS4:\n if self.__proxy[2] != None:\n portnum = self.__proxy[2]\n else:\n portnum = 1080\n _orgsocket.connect(self,(self.__proxy[1], portnum))\n self.__negotiatesocks4(destpair[0], destpair[1])\n elif self.__proxy[0] == PROXY_TYPE_HTTP:\n if self.__proxy[2] != None:\n portnum = self.__proxy[2]\n else:\n portnum = 8080\n _orgsocket.connect(self,(self.__proxy[1], portnum))\n self.__negotiatehttp(destpair[0], destpair[1])\n elif self.__proxy[0] == None:\n _orgsocket.connect(self, (destpair[0], destpair[1]))\n else:\n raise GeneralProxyError((4, _generalerrors[4]))", "metadata": "root.socksocket.connect", "header": "['class', 'socksocket', '(', 'socket', '.', 'socket', ')', ':', '___EOS___']", "index": 347 } ]
[ { "span": "self.__proxy[0] == None:", "start_line": 378, "start_column": 13, "end_line": 378, "end_column": 36 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "socks", "ocket", "_", "(_", "socket_", "._", "socket_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect_", "(_", "self_", ",_", "dest", "pair_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "connect", "(", "self", ",", " ", "desp", "air", ")", "\\", "10", ";", " ", " ", " ", " ", "Connect", "s", " ", "to", " ", "the", " ", "specified", " ", "destinat", "ion", " ", "through", " ", "a", " ", "proxy", ".", "\\", "10", ";", " ", " ", " ", " ", "dest", "par", " ", "-", " ", "A", " ", "tuple", " ", "of", " ", "the", " ", "IP", "/", "DNS", " ", "address", " ", "and", " ", "the", " ", "port", " ", "number", ".", "\\", "10", ";", " ", " ", " ", " ", "(", "identi", "cal", " ", "to", " ", "socket", "'", "s", " ", "connect", ").", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "select", " ", "the", " ", "proxy", " ", "server", " ", "use", " ", "setp", "roxy", "()", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Do", " ", "a", " ", "minima", "l", " ", "input", " ", "check", " ", "first_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "not_", "type_", "(_", "dest", "pair_", ")_", "in_", "(_", "list_", ",_", "tuple_", ")_", ")_", "or_", "(_", "len_", "(_", "dest", "pair_", ")_", "<_", "2_", ")_", "or_", "(_", "type_", "(_", "dest", "pair_", "[_", "0_", "]_", ")_", "!=_", "type_", "(_", "''_", ")_", ")_", "or_", "(_", "type_", "(_", "dest", "pair_", "[_", "1_", "]_", ")_", "!=_", "int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "General", "Pro", "xy", "Error_", "(_", "(_", "5_", ",_", "\\u", "genera", "ler", "ror", "s_", "[_", "5_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u\\u", "proxy_", "[_", "0_", "]_", "==_", "PROX", "Y", "\\u", "TYPE", "\\u", "SOCK", "S", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "1080", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "orgs", "ocket", "_", "._", "connect_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "proxy_", "[_", "1_", "]_", ",_", "port", "num_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "negotiat", "eso", "cks", "5_", "(_", "dest", "pair_", "[_", "0_", "]_", ",_", "dest", "pair_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "\\u\\u", "proxy_", "[_", "0_", "]_", "==_", "PROX", "Y", "\\u", "TYPE", "\\u", "SOCK", "S4", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "1080", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "orgs", "ocket", "_", "._", "connect_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "proxy_", "[_", "1_", "]_", ",_", "port", "num_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "negotiat", "eso", "cks", "4_", "(_", "dest", "pair_", "[_", "0_", "]_", ",_", "dest", "pair_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "\\u\\u", "proxy_", "[_", "0_", "]_", "==_", "PROX", "Y", "\\u", "TYPE", "\\u", "HTTP_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "self_", "._", "\\u\\u", "proxy_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port", "num_", "=_", "8080_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "orgs", "ocket", "_", "._", "connect_", "(_", "self_", ",_", "(_", "self_", "._", "\\u\\u", "proxy_", "[_", "1_", "]_", ",_", "port", "num_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "negotiat", "eh", "ttp", "_", "(_", "dest", "pair_", "[_", "0_", "]_", ",_", "dest", "pair_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "\\u\\u", "proxy_", "[_", "0_", "]_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "orgs", "ocket", "_", "._", "connect_", "(_", "self_", ",_", "(_", "dest", "pair_", "[_", "0_", "]_", ",_", "dest", "pair_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "General", "Pro", "xy", "Error_", "(_", "(_", "4_", ",_", "\\u", "genera", "ler", "ror", "s_", "[_", "4_", "]_", ")_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
baseblack/ReproWeb/3rdParty/python/flask/helpers.py
[ { "content": "def url_for(endpoint, **values):\n \"\"\"Generates a URL to the given endpoint with the method provided.\n\n Variable arguments that are unknown to the target endpoint are appended\n to the generated URL as query arguments. If the value of a query argument\n is `None`, the whole pair is skipped. In case blueprints are active\n you can shortcut references to the same blueprint by prefixing the\n local endpoint with a dot (``.``).\n\n This will reference the index function local to the current blueprint::\n\n url_for('.index')\n\n For more information, head over to the :ref:`Quickstart <url-building>`.\n\n To integrate applications, :class:`Flask` has a hook to intercept URL build\n errors through :attr:`Flask.build_error_handler`. The `url_for` function\n results in a :exc:`~werkzeug.routing.BuildError` when the current app does\n not have a URL for the given endpoint and values. When it does, the\n :data:`~flask.current_app` calls its :attr:`~Flask.build_error_handler` if\n it is not `None`, which can return a string to use as the result of\n `url_for` (instead of `url_for`'s default to raise the\n :exc:`~werkzeug.routing.BuildError` exception) or re-raise the exception.\n An example::\n\n def external_url_handler(error, endpoint, **values):\n \"Looks up an external URL when `url_for` cannot build a URL.\"\n # This is an example of hooking the build_error_handler.\n # Here, lookup_url is some utility function you've built\n # which looks up the endpoint in some external URL registry.\n url = lookup_url(endpoint, **values)\n if url is None:\n # External lookup did not have a URL.\n # Re-raise the BuildError, in context of original traceback.\n exc_type, exc_value, tb = sys.exc_info()\n if exc_value is error:\n raise exc_type, exc_value, tb\n else:\n raise error\n # url_for will use this result, instead of raising BuildError.\n return url\n\n app.build_error_handler = external_url_handler\n\n Here, `error` is the instance of :exc:`~werkzeug.routing.BuildError`, and\n `endpoint` and `**values` are the arguments passed into `url_for`. Note\n that this is for building URLs outside the current application, and not for\n handling 404 NotFound errors.\n\n .. versionadded:: 0.9\n The `_anchor` and `_method` parameters were added.\n\n .. versionadded:: 0.9\n Calls :meth:`Flask.handle_build_error` on\n :exc:`~werkzeug.routing.BuildError`.\n\n :param endpoint: the endpoint of the URL (name of the function)\n :param values: the variable arguments of the URL rule\n :param _external: if set to `True`, an absolute URL is generated.\n :param _anchor: if provided this is added as anchor to the URL.\n :param _method: if provided this explicitly specifies an HTTP method.\n \"\"\"\n appctx = _app_ctx_stack.top\n reqctx = _request_ctx_stack.top\n if appctx is None:\n raise RuntimeError('Attempted to generate a URL with the application '\n 'context being pushed. This has to be executed ')\n\n # If request specific information is available we have some extra\n # features that support \"relative\" urls.\n if reqctx is not None:\n url_adapter = reqctx.url_adapter\n blueprint_name = request.blueprint\n if not reqctx.request._is_old_module:\n if endpoint[:1] == '.':\n if blueprint_name is not None:\n endpoint = blueprint_name + endpoint\n else:\n endpoint = endpoint[1:]\n else:\n # TODO: get rid of this deprecated functionality in 1.0\n if '.' not in endpoint:\n if blueprint_name is not None:\n endpoint = blueprint_name + '.' + endpoint\n elif endpoint.startswith('.'):\n endpoint = endpoint[1:]\n external = values.pop('_external', False)\n\n # Otherwise go with the url adapter from the appctx and make\n # the urls external by default.\n else:\n url_adapter = appctx.url_adapter\n if url_adapter is None:\n raise RuntimeError('Application was not able to create a URL '\n 'adapter for request independent URL generation. '\n 'You might be able to fix this by setting '\n 'the SERVER_NAME config variable.')\n external = values.pop('_external', True)\n\n anchor = values.pop('_anchor', None)\n method = values.pop('_method', None)\n appctx.app.inject_url_defaults(endpoint, values)\n try:\n rv = url_adapter.build(endpoint, values, method=method,\n force_external=external)\n except BuildError, error:\n # We need to inject the values again so that the app callback can\n # deal with that sort of stuff.\n values['_external'] = external\n values['_anchor'] = anchor\n values['_method'] = method\n return appctx.app.handle_url_build_error(error, endpoint, values)\n\n rv = url_adapter.build(endpoint, values, method=method,\n force_external=external)\n if anchor is not None:\n rv += '#' + url_quote(anchor)\n return rv", "metadata": "root.url_for", "header": "['module', '___EOS___']", "index": 249 } ]
[ { "span": "rv ", "start_line": 352, "start_column": 8, "end_line": 352, "end_column": 10 } ]
[ { "span": "rv ", "start_line": 362, "start_column": 4, "end_line": 362, "end_column": 6 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "url", "\\u", "for_", "(_", "endpoint_", ",_", "**_", "values_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Generate", "s", " ", "a", " ", "URL", " ", "to", " ", "the", " ", "give", "n", " ", "endpoint", " ", "with", " ", "the", " ", "method", " ", "provided", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Varia", "ble", " ", "argu", "ment", "s", " ", "tha", "t", " ", "are", " ", "unknown", " ", "to", " ", "the", " ", "target", " ", "endpoint", " ", "are", " ", "append", "ed", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "generat", "ed", " ", "URL", " ", "as", " ", "query", " ", "argu", "ment", "s", ".", " ", " ", "If", " ", "the", " ", "value", " ", "of", " ", "a", " ", "query", " ", "argu", "ment", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "`", "Non", "e", "`", ",", " ", "the", " ", "whole", " ", "pair", " ", "is", " ", "skip", "ped", ".", " ", " ", "In", " ", "case", " ", "blueprints", " ", "are", " ", "active", "\\", "10", ";", " ", " ", " ", " ", "you", " ", "can", " ", "shortcut", " ", "reference", "s", " ", "to", " ", "the", " ", "same", " ", "blue", "print", " ", "by", " ", "prefix", "ing", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "local", " ", "endpoint", " ", "with", " ", "a", " ", "dot", " ", "(", "``.", "``)", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "will", " ", "reference", " ", "the", " ", "index", " ", "function", " ", "local", " ", "to", " ", "the", " ", "current", " ", "blue", "print", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "url", "\\u", "for", "('.", "index", "')", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "more", " ", "informati", "on", ",", " ", "head", " ", "over", " ", "to", " ", "the", " ", ":", "ref", ":`", "Qui", "cks", "tart", " ", "<", "url", "-", "buildi", "ng", ">`", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "integrate", " ", "applica", "tion", "s", ",", " ", ":", "class", ":`", "Fla", "sk", "`", " ", "has", " ", "a", " ", "hook", " ", "to", " ", "intercept", " ", "URL", " ", "build", "\\", "10", ";", " ", " ", " ", " ", "error", "s", " ", "through", " ", ":", "attr", ":`", "Fla", "sk", ".", "build", "\\u", "error", "\\u", "handler", "`.", " ", " ", "The", " ", "`", "url", "\\u", "for", "`", " ", "function", "\\", "10", ";", " ", " ", " ", " ", "results", " ", "in", " ", "a", " ", ":", "exc", ":`", "~", "werk", "zeu", "g", ".", "routin", "g", ".", "Build", "Error", "`", " ", "whe", "n", " ", "the", " ", "current", " ", "app", " ", "doe", "s", "\\", "10", ";", " ", " ", " ", " ", "not", " ", "have", " ", "a", " ", "URL", " ", "for", " ", "the", " ", "give", "n", " ", "endpoint", " ", "and", " ", "values", ".", " ", " ", "Whe", "n", " ", "it", " ", "doe", "s", ",", " ", "the", "\\", "10", ";", " ", " ", " ", " ", ":", "data", ":`", "~", "fla", "sk", ".", "current", "\\u", "app", "`", " ", "calls", " ", "its", " ", ":", "attr", ":`", "~", "Fla", "sk", ".", "build", "\\u", "error", "\\u", "handler", "`", " ", "if", "\\", "10", ";", " ", " ", " ", " ", "it", " ", "is", " ", "not", " ", "`", "Non", "e", "`", ",", " ", "whi", "ch", " ", "can", " ", "return", " ", "a", " ", "string", " ", "to", " ", "use", " ", "as", " ", "the", " ", "result", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "`", "url", "\\u", "for", "`", " ", "(", "inst", "ead", " ", "of", " ", "`", "url", "\\u", "for", "`", "'", "s", " ", "default", " ", "to", " ", "raise", " ", "the", "\\", "10", ";", " ", " ", " ", " ", ":", "exc", ":`", "~", "werk", "zeu", "g", ".", "routin", "g", ".", "Build", "Error", "`", " ", "exception", ")", " ", "or", " ", "re", "-", "raise", " ", "the", " ", "exception", ".", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "example", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "external", "\\u", "url", "\\u", "handler", "(", "error", ",", " ", "endpoint", ",", " ", "**", "values", "):", "\\", "10", ";", " ", " ", " ", " ", "\"", "Look", "s", " ", "up", " ", "an", " ", "external", " ", "URL", " ", "whe", "n", " ", "`", "url", "\\u", "for", "`", " ", "cann", "ot", " ", "build", " ", "a", " ", "URL", ".\"", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Thi", "s", " ", "is", " ", "an", " ", "example", " ", "of", " ", "hook", "ing", " ", "the", " ", "build", "\\u", "error", "\\u", "handler", ".", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Her", "e", ",", " ", "look", "up", "\\u", "url", " ", "is", " ", "some", " ", "utility", " ", "function", " ", "you", "'", "ve", " ", "bui", "lt", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "whi", "ch", " ", "look", "s", " ", "up", " ", "the", " ", "endpoint", " ", "in", " ", "some", " ", "external", " ", "URL", " ", "registr", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "url", " ", "=", " ", "look", "up", "\\u", "url", "(", "endpoint", ",", " ", "**", "values", ")", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "url", " ", "is", " ", "Non", "e", ":", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Exter", "nal", " ", "look", "up", " ", "did", " ", "not", " ", "have", " ", "a", " ", "URL", ".", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Re", "-", "raise", " ", "the", " ", "Build", "Error", ",", " ", "in", " ", "context", " ", "of", " ", "original", " ", "traceback", ".", "\\", "10", ";", " ", " ", " ", " ", "exc", "\\u", "type", ",", " ", "exc", "\\u", "value", ",", " ", "tb", " ", "=", " ", "sys", ".", "exc", "\\u", "info", "()", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "exc", "\\u", "value", " ", "is", " ", "error", ":", "\\", "10", ";", " ", " ", "raise", " ", "exc", "\\u", "type", ",", " ", "exc", "\\u", "value", ",", " ", "tb", "\\", "10", ";", " ", " ", " ", " ", "else", ":", "\\", "10", ";", " ", " ", "raise", " ", "error", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "url", "\\u", "for", " ", "will", " ", "use", " ", "this", " ", "result", ",", " ", "inst", "ead", " ", "of", " ", "rais", "ing", " ", "Build", "Error", ".", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "url", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "app", ".", "build", "\\u", "error", "\\u", "handler", " ", "=", " ", "external", "\\u", "url", "\\u", "handler", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Her", "e", ",", " ", "`", "error", "`", " ", "is", " ", "the", " ", "instance", " ", "of", " ", ":", "exc", ":`", "~", "werk", "zeu", "g", ".", "routin", "g", ".", "Build", "Error", "`", ",", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "`", "endpoint", "`", " ", "and", " ", "`", "**", "values", "`", " ", "are", " ", "the", " ", "argu", "ment", "s", " ", "pass", "ed", " ", "int", "o", " ", "`", "url", "\\u", "for", "`.", " ", " ", "Not", "e", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "this", " ", "is", " ", "for", " ", "buildi", "ng", " ", "URL", "s", " ", "outsi", "de", " ", "the", " ", "current", " ", "applica", "tion", ",", " ", "and", " ", "not", " ", "for", "\\", "10", ";", " ", " ", " ", " ", "handling", " ", "404", " ", "Not", "Foun", "d", " ", "error", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "0.", "9", "\\", "10", ";", " ", " ", " ", "The", " ", "`\\u", "anchor", "`", " ", "and", " ", "`\\u", "method", "`", " ", "parameter", "s", " ", "wer", "e", " ", "adde", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "0.", "9", "\\", "10", ";", " ", " ", " ", "Calls", " ", ":", "meth", ":`", "Fla", "sk", ".", "handle", "\\u", "build", "\\u", "error", "`", " ", "on", "\\", "10", ";", " ", " ", " ", ":", "exc", ":`", "~", "werk", "zeu", "g", ".", "routin", "g", ".", "Build", "Error", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "endpoint", ":", " ", "the", " ", "endpoint", " ", "of", " ", "the", " ", "URL", " ", "(", "name", " ", "of", " ", "the", " ", "function", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "values", ":", " ", "the", " ", "variab", "le", " ", "argu", "ment", "s", " ", "of", " ", "the", " ", "URL", " ", "rule", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "\\u", "external", ":", " ", "if", " ", "set", " ", "to", " ", "`", "Tru", "e", "`", ",", " ", "an", " ", "abs", "olute", " ", "URL", " ", "is", " ", "generat", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "\\u", "anchor", ":", " ", "if", " ", "provided", " ", "this", " ", "is", " ", "adde", "d", " ", "as", " ", "anchor", " ", "to", " ", "the", " ", "URL", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "\\u", "method", ":", " ", "if", " ", "provided", " ", "this", " ", "explicit", "ly", " ", "speci", "fie", "s", " ", "an", " ", "HTTP", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appc", "tx_", "=_", "\\u", "app", "\\u", "ctx", "\\u", "stack_", "._", "top_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req", "ctx_", "=_", "\\u", "request", "\\u", "ctx", "\\u", "stack_", "._", "top_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "appc", "tx_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "'", "Atte", "mpte", "d", " ", "to", " ", "generat", "e", " ", "a", " ", "URL", " ", "with", " ", "the", " ", "applica", "tion", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "context", " ", "bei", "ng", " ", "pushed", ".", " ", " ", "Thi", "s", " ", "has", " ", "to", " ", "be", " ", "executed", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "request", " ", "specific", " ", "informati", "on", " ", "is", " ", "avail", "able", " ", "we", " ", "have", " ", "some", " ", "extra_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "features", " ", "tha", "t", " ", "support", " ", "\"", "relative", "\"", " ", "urls", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "req", "ctx_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "adapter_", "=_", "req", "ctx_", "._", "url", "\\u", "adapter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blue", "print", "\\u", "name_", "=_", "request_", "._", "blueprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "req", "ctx_", "._", "request_", "._", "\\u", "is", "\\u", "old", "\\u", "module_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "endpoint_", "[_", ":_", "1_", "]_", "==_", "'.'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "blue", "print", "\\u", "name_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "endpoint_", "=_", "blue", "print", "\\u", "name_", "+_", "endpoint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "endpoint_", "=_", "endpoint_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "get", " ", "rid", " ", "of", " ", "this", " ", "depre", "cated", " ", "functional", "it", "y", " ", "in", " ", "1.0_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'.'_", "not_", "in_", "endpoint_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "blue", "print", "\\u", "name_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "endpoint_", "=_", "blue", "print", "\\u", "name_", "+_", "'.'_", "+_", "endpoint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "endpoint_", "._", "startswith_", "(_", "'.'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "endpoint_", "=_", "endpoint_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "external_", "=_", "values_", "._", "pop_", "(_", "'\\u", "external", "'_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ot", "her", "wis", "e", " ", "go", " ", "with", " ", "the", " ", "url", " ", "adapter", " ", "from", " ", "the", " ", "appc", "tx", " ", "and", " ", "make_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "urls", " ", "external", " ", "by", " ", "default", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "adapter_", "=_", "appc", "tx_", "._", "url", "\\u", "adapter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "url", "\\u", "adapter_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "'", "Applica", "tion", " ", "was", " ", "not", " ", "able", " ", "to", " ", "create", " ", "a", " ", "URL", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adapter", " ", "for", " ", "request", " ", "independent", " ", "URL", " ", "generat", "ion", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "You", " ", "mig", "ht", " ", "be", " ", "able", " ", "to", " ", "fix", " ", "this", " ", "by", " ", "setti", "ng", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "the", " ", "SERVER", "\\u", "NAME", " ", "config", " ", "variab", "le", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "external_", "=_", "values_", "._", "pop_", "(_", "'\\u", "external", "'_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "anchor_", "=_", "values_", "._", "pop_", "(_", "'\\u", "anchor", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "values_", "._", "pop_", "(_", "'\\u", "method", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appc", "tx_", "._", "app_", "._", "inject", "\\u", "url", "\\u", "defaults_", "(_", "endpoint_", ",_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rv_", "=_", "url", "\\u", "adapter_", "._", "build_", "(_", "endpoint_", ",_", "values_", ",_", "method_", "=_", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "force", "\\u", "external_", "=_", "external_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Build", "Error_", ",_", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "need", " ", "to", " ", "inject", " ", "the", " ", "values", " ", "again", " ", "so", " ", "tha", "t", " ", "the", " ", "app", " ", "callback", " ", "can_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "deal", " ", "with", " ", "tha", "t", " ", "sort", " ", "of", " ", "stu", "ff", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "[_", "'\\u", "external", "'_", "]_", "=_", "external_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "[_", "'\\u", "anchor", "'_", "]_", "=_", "anchor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "[_", "'\\u", "method", "'_", "]_", "=_", "method_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "appc", "tx_", "._", "app_", "._", "handle", "\\u", "url", "\\u", "build", "\\u", "error_", "(_", "error_", ",_", "endpoint_", ",_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rv_", "=_", "url", "\\u", "adapter_", "._", "build_", "(_", "endpoint_", ",_", "values_", ",_", "method_", "=_", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "force", "\\u", "external_", "=_", "external_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "anchor_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rv_", "+=_", "'#'_", "+_", "url", "\\u", "quote_", "(_", "anchor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rv_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
sassoftware/conary/conary_test/cvctest/buildtest/windowsactiontest.py
[ { "content": " def testGetUpgradeCode(self):\n def mockBuildMSI(version, upCode=None):\n def do(a, macros):\n a.package = a.package % macros\n msiPath = os.path.join(self.archivePath, 'Setup2.msi')\n a.recipe._addCapsule(msiPath, 'msi', a.package % macros)\n a.recipe.winHelper = source.WindowsHelper()\n a.recipe.winHelper.productName = 'WindowsAppTest'\n a.recipe.winHelper.platform = ''\n a.recipe.winHelper.version = version\n a.recipe.winHelper.productCode = 'FIXME'\n upgradeCode = a._getUpgradeCode()\n if not upgradeCode:\n upgradeCode = 'None'\n if upCode:\n upgradeCode = upCode\n a.recipe.winHelper.upgradeCode = upgradeCode\n\n self.mock(build.BuildMSI, 'do', do)\n\n\n repos = self.openRepository()\n origDir = os.getcwd()\n\n self.resetWork()\n os.chdir(self.workDir)\n\n self.newpkg('WindowsAppTest')\n os.chdir('WindowsAppTest')\n self.writeFile('WindowsAppTest.recipe', self.test_recipe1)\n self.addfile('WindowsAppTest.recipe')\n self.commit()\n\n os.chdir(origDir)\n self.resetWork()\n os.chdir(self.workDir)\n\n mockBuildMSI('1.2.3.4', '12345')\n built = self.cookItem(repos, self.cfg, 'WindowsAppTest')\n\n self.checkout('WindowsAppTest')\n os.chdir('WindowsAppTest')\n self.writeFile('WindowsAppTest.recipe',\n self.test_recipe1.replace('1.2.3.4', '1.2.3.5'))\n self.commit()\n\n self.resetWork()\n os.chdir(origDir)\n\n mockBuildMSI('1.2.3.5')\n built = self.cookItem(repos, self.cfg, 'WindowsAppTest')[0]\n\n msis = [ x for x in built if x[0].endswith(':msi') ]\n self.assertEqual(len(msis), 1)\n\n msi = msis[0]\n\n repos = self.openRepository()\n spec = repos.findTrove(self.cfg.buildLabel, msi)\n self.assertEqual(len(spec), 1)\n\n trv = repos.getTrove(*spec[0])\n\n self.assertEqual(trv.troveInfo.capsule.msi.name(), 'WindowsAppTest')\n self.assertEqual(trv.troveInfo.capsule.msi.platform(), '')\n self.assertEqual(trv.troveInfo.capsule.msi.version(), '1.2.3.5')\n self.assertEqual(trv.troveInfo.capsule.msi.productCode(), 'FIXME')\n self.assertEqual(trv.troveInfo.capsule.msi.upgradeCode(), '12345')", "metadata": "root.WindowsActionTest.testGetUpgradeCode", "header": "['class', 'WindowsActionTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 125 }, { "content": " def testPersistingComponentInformation(self):\n def mockBuildMSI(version, components=None):\n def do(a, macros):\n a.package = a.package % macros\n msiPath = os.path.join(self.archivePath, 'Setup2.msi')\n a.recipe._addCapsule(msiPath, 'msi', a.package % macros)\n a.recipe.winHelper = source.WindowsHelper()\n a.recipe.winHelper.productName = 'WindowsAppTest'\n a.recipe.winHelper.platform = ''\n a.recipe.winHelper.version = version\n a.recipe.winHelper.productCode = 'foo'\n a.recipe.winHelper.upgradeCode = 'bar'\n if components:\n a.recipe.winHelper.components = components\n for comp in a._getComponentInfo():\n if comp not in a.recipe.winHelper.components:\n a.recipe.winHelper.components.append(comp)\n\n self.mock(build.BuildMSI, 'do', do)\n\n repos = self.openRepository()\n origDir = os.getcwd()\n\n self.resetWork()\n os.chdir(self.workDir)\n\n self.newpkg('WindowsAppTest')\n os.chdir('WindowsAppTest')\n self.writeFile('WindowsAppTest.recipe', self.test_recipe1)\n self.addfile('WindowsAppTest.recipe')\n self.commit()\n\n os.chdir(origDir)\n self.resetWork()\n os.chdir(self.workDir)\n\n mockBuildMSI('1.2.3.4',\n components=[('uuid1', 'path1'), ('uuid2', 'path2')])\n\n built = self.cookItem(repos, self.cfg, 'WindowsAppTest')\n\n spec = repos.findTrove(self.cfg.buildLabel,\n ('WindowsAppTest:msi', None, None))[0]\n trv = repos.getTrove(*spec)\n\n components = [ (x.uuid(), x.path())\n for _, x in trv.troveInfo.capsule.msi.components.iterAll() ]\n\n self.assertTrue(('uuid1', 'path1') in components)\n self.assertTrue(('uuid2', 'path2') in components)\n\n self.checkout('WindowsAppTest')\n os.chdir('WindowsAppTest')\n self.writeFile('WindowsAppTest.recipe',\n self.test_recipe1.replace('1.2.3.4', '1.2.3.5'))\n self.commit()\n\n self.resetWork()\n os.chdir(origDir)\n\n mockBuildMSI('1.2.3.5', components=[('uuid3', 'path3'), ])\n built = self.cookItem(repos, self.cfg, 'WindowsAppTest')\n\n spec = repos.findTrove(self.cfg.buildLabel,\n ('WindowsAppTest:msi', None, None))[0]\n trv = repos.getTrove(*spec)\n\n components = [ (x.uuid(), x.path())\n for _, x in trv.troveInfo.capsule.msi.components.iterAll() ]\n\n self.assertTrue(('uuid1', 'path1') in components)\n self.assertTrue(('uuid2', 'path2') in components)\n self.assertTrue(('uuid3', 'path3') in components)", "metadata": "root.WindowsActionTest.testPersistingComponentInformation", "header": "['class', 'WindowsActionTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 194 } ]
[ { "span": "built ", "start_line": 163, "start_column": 8, "end_line": 163, "end_column": 13 }, { "span": "built ", "start_line": 233, "start_column": 8, "end_line": 233, "end_column": 13 } ]
[ { "span": "built ", "start_line": 175, "start_column": 8, "end_line": 175, "end_column": 13 }, { "span": "built ", "start_line": 255, "start_column": 8, "end_line": 255, "end_column": 13 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Window", "s", "Action", "Test_", "(_", "rep", "help_", "._", "Repos", "itor", "y", "Helper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Get", "Upgrade", "Code_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "mock", "Build", "MS", "I_", "(_", "version_", ",_", "up", "Code_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "do_", "(_", "a_", ",_", "macros_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "._", "package_", "=_", "a_", "._", "package_", "%_", "macros_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msi", "Path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "archive", "Path_", ",_", "'", "Set", "up", "2", ".", "msi", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "\\u", "add", "Caps", "ule_", "(_", "msi", "Path_", ",_", "'", "msi", "'_", ",_", "a_", "._", "package_", "%_", "macros_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "=_", "source_", "._", "Window", "s", "Helper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "product", "Name_", "=_", "'", "Window", "s", "App", "Test", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "platform_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "version_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "product", "Code_", "=_", "'", "FIX", "ME", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upgrade", "Code_", "=_", "a_", "._", "\\u", "get", "Upgrade", "Code_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "upgrade", "Code_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "upgrade", "Code_", "=_", "'", "Non", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "up", "Code_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "upgrade", "Code_", "=_", "up", "Code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "upgrade", "Code_", "=_", "upgrade", "Code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "mock_", "(_", "build_", "._", "Build", "MS", "I_", ",_", "'", "do", "'_", ",_", "do_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "repos_", "=_", "self_", "._", "open", "Repository_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orig", "Dir_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "work", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "newp", "kg_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "File_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ",_", "self_", "._", "test\\u", "recip", "e1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "addfi", "le_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "chdir_", "(_", "orig", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "work", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mock", "Build", "MS", "I_", "(_", "'", "1.2", ".3", ".4", "'_", ",_", "'", "12345", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "built_", "=_", "self_", "._", "cook", "Item_", "(_", "repos_", ",_", "self_", "._", "cfg_", ",_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "checkout_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "File_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test\\u", "recip", "e1_", "._", "replace_", "(_", "'", "1.2", ".3", ".4", "'_", ",_", "'", "1.2", ".3", ".5", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "orig", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mock", "Build", "MS", "I_", "(_", "'", "1.2", ".3", ".5", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "built_", "=_", "self_", "._", "cook", "Item_", "(_", "repos_", ",_", "self_", "._", "cfg_", ",_", "'", "Window", "s", "App", "Test", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msi", "s_", "=_", "[_", "x_", "for_", "x_", "in_", "built_", "if_", "x_", "[_", "0_", "]_", "._", "endswith_", "(_", "':", "msi", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "msi", "s_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msi", "_", "=_", "msi", "s_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "repos_", "=_", "self_", "._", "open", "Repository_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "spec_", "=_", "repos_", "._", "find", "Trove", "_", "(_", "self_", "._", "cfg_", "._", "build", "Label_", ",_", "msi", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "spec_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tr", "v_", "=_", "repos_", "._", "get", "Trove", "_", "(_", "*_", "spec_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "name_", "(_", ")_", ",_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "platform_", "(_", ")_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "version_", "(_", ")_", ",_", "'", "1.2", ".3", ".5", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "product", "Code_", "(_", ")_", ",_", "'", "FIX", "ME", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "upgrade", "Code_", "(_", ")_", ",_", "'", "12345", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Window", "s", "Action", "Test_", "(_", "rep", "help_", "._", "Repos", "itor", "y", "Helper_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Persi", "stin", "g", "Compo", "nent", "Information_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "mock", "Build", "MS", "I_", "(_", "version_", ",_", "components_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "do_", "(_", "a_", ",_", "macros_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "._", "package_", "=_", "a_", "._", "package_", "%_", "macros_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msi", "Path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "archive", "Path_", ",_", "'", "Set", "up", "2", ".", "msi", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "\\u", "add", "Caps", "ule_", "(_", "msi", "Path_", ",_", "'", "msi", "'_", ",_", "a_", "._", "package_", "%_", "macros_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "=_", "source_", "._", "Window", "s", "Helper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "product", "Name_", "=_", "'", "Window", "s", "App", "Test", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "platform_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "version_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "product", "Code_", "=_", "'", "foo", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "upgrade", "Code_", "=_", "'", "bar", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "components_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "components_", "=_", "components_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "comp_", "in_", "a_", "._", "\\u", "get", "Compo", "nent", "Info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "comp_", "not_", "in_", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "components_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "a_", "._", "recipe_", "._", "win", "Helper_", "._", "components_", "._", "append_", "(_", "comp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "mock_", "(_", "build_", "._", "Build", "MS", "I_", ",_", "'", "do", "'_", ",_", "do_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "repos_", "=_", "self_", "._", "open", "Repository_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orig", "Dir_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "work", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "newp", "kg_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "File_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ",_", "self_", "._", "test\\u", "recip", "e1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "addfi", "le_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "chdir_", "(_", "orig", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "work", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mock", "Build", "MS", "I_", "(_", "'", "1.2", ".3", ".4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "components_", "=_", "[_", "(_", "'", "uuid", "1", "'_", ",_", "'", "path", "1", "'_", ")_", ",_", "(_", "'", "uuid", "2", "'_", ",_", "'", "path", "2", "'_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "built_", "=_", "self_", "._", "cook", "Item_", "(_", "repos_", ",_", "self_", "._", "cfg_", ",_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "spec_", "=_", "repos_", "._", "find", "Trove", "_", "(_", "self_", "._", "cfg_", "._", "build", "Label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Window", "s", "App", "Test", ":", "msi", "'_", ",_", "None_", ",_", "None_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr", "v_", "=_", "repos_", "._", "get", "Trove", "_", "(_", "*_", "spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "components_", "=_", "[_", "(_", "x_", "._", "uuid_", "(_", ")_", ",_", "x_", "._", "path_", "(_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u_", ",_", "x_", "in_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "components_", "._", "iter", "All_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "(_", "'", "uuid", "1", "'_", ",_", "'", "path", "1", "'_", ")_", "in_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "(_", "'", "uuid", "2", "'_", ",_", "'", "path", "2", "'_", ")_", "in_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "checkout_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "File_", "(_", "'", "Window", "s", "App", "Test", ".", "recip", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "test\\u", "recip", "e1_", "._", "replace_", "(_", "'", "1.2", ".3", ".4", "'_", ",_", "'", "1.2", ".3", ".5", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "reset", "Work", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "orig", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mock", "Build", "MS", "I_", "(_", "'", "1.2", ".3", ".5", "'_", ",_", "components_", "=_", "[_", "(_", "'", "uuid", "3", "'_", ",_", "'", "path", "3", "'_", ")_", ",_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "built_", "=_", "self_", "._", "cook", "Item_", "(_", "repos_", ",_", "self_", "._", "cfg_", ",_", "'", "Window", "s", "App", "Test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "spec_", "=_", "repos_", "._", "find", "Trove", "_", "(_", "self_", "._", "cfg_", "._", "build", "Label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "Window", "s", "App", "Test", ":", "msi", "'_", ",_", "None_", ",_", "None_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr", "v_", "=_", "repos_", "._", "get", "Trove", "_", "(_", "*_", "spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "components_", "=_", "[_", "(_", "x_", "._", "uuid_", "(_", ")_", ",_", "x_", "._", "path_", "(_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u_", ",_", "x_", "in_", "tr", "v_", "._", "trove", "Info_", "._", "capsule", "_", "._", "msi", "_", "._", "components_", "._", "iter", "All_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "(_", "'", "uuid", "1", "'_", ",_", "'", "path", "1", "'_", ")_", "in_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "(_", "'", "uuid", "2", "'_", ",_", "'", "path", "2", "'_", ")_", "in_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "(_", "'", "uuid", "3", "'_", ",_", "'", "path", "3", "'_", ")_", "in_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2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2, 2 ]
Testing equality to None
open-cloud/xos/xos/core/models/billing.py
[ { "content": " @property\n def total_invoices(self):\n # Since the amount of an invoice is the sum of it's charges, we can\n # compute the sum of the invoices by summing all charges where\n # charge.invoice != Null.\n x=self.charges.filter(invoice__isnull=False).aggregate(Sum('amount'))[\"amount__sum\"]\n if (x==None):\n return 0.0\n return x", "metadata": "root.Account.total_invoices", "header": "['class', 'Account', '(', 'PlCoreBase', ')', ':', '___EOS___']", "index": 14 }, { "content": " @property\n def total_payments(self):\n x=self.payments.all().aggregate(Sum('amount'))[\"amount__sum\"]\n if (x==None):\n return 0.0\n return x", "metadata": "root.Account.total_payments", "header": "['class', 'Account', '(', 'PlCoreBase', ')', ':', '___EOS___']", "index": 24 } ]
[ { "span": "x==None)", "start_line": 20, "start_column": 12, "end_line": 20, "end_column": 19 }, { "span": "x==None)", "start_line": 27, "start_column": 12, "end_line": 27, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Account_", "(_", "Pl", "Core", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "total", "\\u", "invoices", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sin", "ce", " ", "the", " ", "amo", "unt", " ", "of", " ", "an", " ", "invoic", "e", " ", "is", " ", "the", " ", "sum", " ", "of", " ", "it", "'", "s", " ", "charge", "s", ",", " ", "we", " ", "can_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compute", " ", "the", " ", "sum", " ", "of", " ", "the", " ", "invoices", " ", "by", " ", "summ", "ing", " ", "all", " ", "charge", "s", " ", "where_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "charge", ".", "invoic", "e", " ", "!=", " ", "Null", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "self_", "._", "charges_", "._", "filter_", "(_", "invoic", "e\\u", "\\u", "isnull_", "=_", "False_", ")_", "._", "aggregate_", "(_", "Sum_", "(_", "'", "amo", "unt", "'_", ")_", ")_", "[_", "\"", "amo", "unt", "\\u\\u", "sum", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "x_", "==_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Account_", "(_", "Pl", "Core", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "total", "\\u", "payments", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "self_", "._", "payments", "_", "._", "all_", "(_", ")_", "._", "aggregate_", "(_", "Sum_", "(_", "'", "amo", "unt", "'_", ")_", ")_", "[_", "\"", "amo", "unt", "\\u\\u", "sum", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "x_", "==_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
dwd/Suelta/suelta/mechanisms/anonymous.py
[ { "content": "from suelta.sasl import Mechanism, register_mechanism\nfrom suelta.exceptions import SASLError, SASLCancelled\n\n\n\n\nregister_mechanism('ANONYMOUS', 0, ANONYMOUS, use_hashes=False)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ANONYMOUS(Mechanism):\n\n \"\"\"\n \"\"\"\n\n\n\n\n", "metadata": "root.ANONYMOUS", "header": "['module', '___EOS___']", "index": 4 }, { "content": " def __init__(self, sasl, name):\n \"\"\"\n \"\"\"\n super(ANONYMOUS, self).__init__(sasl, name, 0)", "metadata": "root.ANONYMOUS.__init__", "header": "['class', 'ANONYMOUS', '(', 'Mechanism', ')', ':', '___EOS___']", "index": 9 }, { "content": " def get_values(self):\n \"\"\"\n \"\"\"\n return {}", "metadata": "root.ANONYMOUS.get_values", "header": "['class', 'ANONYMOUS', '(', 'Mechanism', ')', ':', '___EOS___']", "index": 14 }, { "content": " def process(self, challenge=None):\n \"\"\"\n \"\"\"\n return b'Anonymous, Suelta'", "metadata": "root.ANONYMOUS.process", "header": "['class', 'ANONYMOUS', '(', 'Mechanism', ')', ':', '___EOS___']", "index": 19 }, { "content": " def okay(self):\n \"\"\"\n \"\"\"\n return True", "metadata": "root.ANONYMOUS.okay", "header": "['class', 'ANONYMOUS', '(', 'Mechanism', ')', ':', '___EOS___']", "index": 24 }, { "content": " def get_user(self):\n \"\"\"\n \"\"\"\n return 'anonymous'", "metadata": "root.ANONYMOUS.get_user", "header": "['class', 'ANONYMOUS', '(', 'Mechanism', ')', ':', '___EOS___']", "index": 29 } ]
[ { "span": "from suelta.exceptions import SASLError, SASLCancelled", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 54 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "su", "elt", "a_", "._", "sasl", "_", "import_", "Mechani", "sm_", ",_", "register", "\\u", "mechanism", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "su", "elt", "a_", "._", "exceptions_", "import_", "SAS", "LE", "rror_", ",_", "SAS", "LC", "anc", "elle", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "register", "\\u", "mechanism", "_", "(_", "'", "ANON", "YM", "OUS", "'_", ",_", "0_", ",_", "ANON", "YM", "OUS", "_", ",_", "use", "\\u", "hashes_", "=_", "False_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "sasl", "_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "ANON", "YM", "OUS", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "sasl", "_", ",_", "name_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "values_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process_", "(_", "self_", ",_", "challenge_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "b", "'", "Ano", "nym", "ous", ",", " ", "Su", "elt", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "oka", "y_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ANON", "YM", "OUS", "_", "(_", "Mechani", "sm_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "user_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.3/pymel/util/mathutils.py
[ { "content": "\"\"\" Defines useful math functions. \"\"\"\n\nfrom __builtin__ import round as _round\nimport math\n\n# to be able to call conjugate, real and imag on all numericals\n\n\n\n\n# overload of built-in round fn to accept complex numbers\n\n# general remapping operations\n\n\n\n# TODO : modify these so that they accept iterable / element wise operations\n\n\n\n\n\n# NOTE : x first seem more natural\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def conjugate(x):\n \"\"\" the conjugate part of x \"\"\"\n if isinstance(x, complex) :\n return x.conjugate()\n else :\n return x", "metadata": "root.conjugate", "header": "['module', '___EOS___']", "index": 7 }, { "content": "def real (x):\n \"\"\" the real part of x \"\"\"\n if isinstance(x, complex) :\n return x.real\n else :\n return x", "metadata": "root.real", "header": "['module', '___EOS___']", "index": 14 }, { "content": "def imag (x):\n \"\"\" the imaginary part of x \"\"\"\n if isinstance(x, complex) :\n return x.imag\n else :\n return type(x)(0)", "metadata": "root.imag", "header": "['module', '___EOS___']", "index": 21 }, { "content": "def round(value, ndigits=0) :\n \"\"\"\n round(number[, ndigits]) -> float\n Round a number to a given precision in decimal digits (default 0 digits).\n This always returns a floating point number. Precision may be negative.\n This builtin function was overloaded in mathutils to work on complex numbers,\n in that case rel and imaginary values are rounded separately\n\n \"\"\"\n ndigits = int(ndigits)\n if isinstance(value, complex) :\n return complex(_round(value.real, ndigits), _round(value.imag, ndigits))\n else :\n return _round(value, ndigits)", "metadata": "root.round", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def gamma (c, g):\n \"\"\"\n Gamma color correction of c with a single scalar gamma value g\n\n :rtype: float\n \"\"\"\n return c**g", "metadata": "root.gamma", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def blend (a, b, weight=0.5):\n \"\"\"\n blend(a, b[, weight=0.5]) :\n Blends values a and b according to normalized weight w,\n returns a for weight == 0.0 and b for weight = 1.0, a*(1.0-weight)+b*weight in between\n\n :rtype: float\n \"\"\"\n return a*(1.0-weight)+b*weight", "metadata": "root.blend", "header": "['module', '___EOS___']", "index": 54 }, { "content": "def smoothmap(min, max, x):\n \"\"\"Returns the value of a smooth remapping function.\n\n performs a smooth Hermite interpolation between 0 and 1 in the interval min to max,\n but does not clamp the range\n\n :rtype: float\n \"\"\"\n x = float(x)\n x = float(x-min)/float(max-min)\n return x*x*(3.0-2.0*x)", "metadata": "root.smoothmap", "header": "['module', '___EOS___']", "index": 66 }, { "content": "def smoothstep(min, max, x):\n \"\"\"Returns the value of a smooth step function.\n\n Returns 0 if x < min, 1 if x > max, and performs a smooth Hermite\n interpolation between 0 and 1 in the interval min to max.\n\n :rtype: float\n \"\"\"\n if x<min:\n return 0.0\n if x>max:\n return 1.0\n return smoothmap(min, max, x)", "metadata": "root.smoothstep", "header": "['module', '___EOS___']", "index": 78 }, { "content": "def linmap(min, max, x):\n \"\"\"Returns the value of a linear remapping function.\n\n performs a linear interpolation between 0 and 1 in the interval min to max,\n but does not clamp the range\n\n :rtype: float\n \"\"\"\n return (float(x)-min)/(max-min)", "metadata": "root.linmap", "header": "['module', '___EOS___']", "index": 92 }, { "content": "def linstep(min, max, x):\n \"\"\"Returns the value of a linear step function.\n\n Returns 0 if x < min, 1 if x > max, and performs a linear\n interpolation between 0 and 1 in the interval min to max.\n\n :rtype: float\n \"\"\"\n if x<min:\n return 0.0\n if x>max:\n return 1.0\n return linmap(min, max, x)", "metadata": "root.linstep", "header": "['module', '___EOS___']", "index": 102 }, { "content": "def clamp(x=0.0, min=0.0, max=1.0) :\n \"\"\" Clamps the value x between min and max\n\n :rtype: float\n \"\"\"\n # NOTE : in 2.5 can use 'caseTrue if condition else caseFalse'\n #realmin = min if min<max else max\n #realmax = max if min<max else min\n # orig C code :\n # const double realmin=(min<max)?min:max;\n # const double realmax=(min<max)?max:min;\n # return ((x<realmin)?realmin:(x>realmax)?realmax:x);\n if min<max :\n realmin = min\n realmax = max\n else :\n realmin = max\n realmax = min\n if x<realmin :\n result = realmin\n elif x>realmax :\n result = realmax\n else :\n result = x\n return result", "metadata": "root.clamp", "header": "['module', '___EOS___']", "index": 117 }, { "content": "def setRange(x=0.0, oldmin=0.0, oldmax=1.0, newmin=0.0, newmax=1.0) :\n \"\"\" Resets x range from x linear interpolation of oldmin to oldmax to x linear interpolation from newmin to newmax\n\n :rtype: float\n \"\"\"\n if oldmin<oldmax :\n realoldmin=oldmin\n realoldmax=oldmax\n realnewmin=newmin\n realnewmax=newmax\n elif oldmin>oldmax :\n realoldmin=oldmax\n realoldmax=oldmin\n realnewmin=newmax\n realnewmax=newmin\n else :\n return x\n if x<realoldmin :\n result = realnewmin\n elif x>realoldmax :\n result = realnewmax\n else :\n result = (realnewmin+(realnewmax-realnewmin)*(x-oldmin)/(oldmax-oldmin))\n return result", "metadata": "root.setRange", "header": "['module', '___EOS___']", "index": 143 }, { "content": "def hermiteInterp(x=0.0, y0=0.0, y1=1.0, s0=0.0, s1=0.0) :\n \"\"\" Hermite interpolation of x between points y0 and y1 of tangent slope s0 and s1\n\n :rtype: float\n \"\"\"\n c = s0\n v = y0 - y1\n w = c + v\n x = w + v + s1\n b_neg = w + x\n return ((((x * x) - b_neg) * x + s0) * x + y0)", "metadata": "root.hermiteInterp", "header": "['module', '___EOS___']", "index": 168 }, { "content": "def hermite(x=0.0, v0=0.0, v1=0.0, s0=0.0, s1=0.0) :\n \"\"\"\n As the MEL command : This command returns x point along on x hermite curve from the five given control arguments.\n The first two arguments are the start and end points of the curve, respectively.\n The next two arguments are the tangents of the curve at the start point and end point of the curve, respectively.\n The fifth argument, parameter, specifies the point on the hermite curve that is returned by this function.\n This parameter is the unitized distance along the curve from the start point to the end point.\n A parameter value of 0.0 corresponds to the start point and x parameter value of 1.0 corresponds to the end point of the curve.\n\n :rtype: float\n\n \"\"\"\n\n if x<0.0 :\n res = v0\n elif x>1.0 :\n res = v1\n else :\n res = hermiteInterp(x, v0, v1, s0, s1)\n return res", "metadata": "root.hermite", "header": "['module', '___EOS___']", "index": 180 } ]
[ { "span": "import math", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", " ", "Define", "s", " ", "usef", "ul", " ", "math", " ", "function", "s", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "builtin\\u\\u_", "import_", "round_", "as_", "\\u", "round_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "be", " ", "able", " ", "to", " ", "call", " ", "conjugate", ",", " ", "real", " ", "and", " ", "imag", " ", "on", " ", "all", " ", "numerical", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "overload", " ", "of", " ", "bui", "lt", "-", "in", " ", "round", " ", "fn", " ", "to", " ", "accept", " ", "complex", " ", "numbers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "genera", "l", " ", "remap", "ping", " ", "operations_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", ":", " ", "modif", "y", " ", "these", " ", "so", " ", "tha", "t", " ", "the", "y", " ", "accept", " ", "iterable", " ", "/", " ", "element", " ", "wis", "e", " ", "operations_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", " ", ":", " ", "x", " ", "first", " ", "see", "m", " ", "more", " ", "natur", "al_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "conjugate", "_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "the", " ", "conjugate", " ", "part", " ", "of", " ", "x", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "x_", ",_", "complex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "._", "conjugate", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "real_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "the", " ", "real", " ", "part", " ", "of", " ", "x", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "x_", ",_", "complex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "._", "real_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "imag_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "the", " ", "imagin", "ary", " ", "part", " ", "of", " ", "x", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "x_", ",_", "complex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "._", "imag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "type_", "(_", "x_", ")_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "round_", "(_", "value_", ",_", "ndi", "git", "s_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "round", "(", "number", "[", ",", " ", "ndi", "git", "s", "])", " ", "->", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "Round", " ", "a", " ", "number", " ", "to", " ", "a", " ", "give", "n", " ", "preci", "sion", " ", "in", " ", "decima", "l", " ", "digit", "s", " ", "(", "default", " ", "0", " ", "digit", "s", ").", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "alw", "ay", "s", " ", "return", "s", " ", "a", " ", "float", "ing", " ", "point", " ", "number", ".", " ", " ", "Precis", "ion", " ", "may", " ", "be", " ", "negati", "ve", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "bui", "lti", "n", " ", "function", " ", "was", " ", "overload", "ed", " ", "in", " ", "math", "util", "s", " ", "to", " ", "work", " ", "on", " ", "complex", " ", "numbers", ",", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "tha", "t", " ", "case", " ", "rel", " ", "and", " ", "imagin", "ary", " ", "values", " ", "are", " ", "rounded", " ", "separately", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "git", "s_", "=_", "int_", "(_", "ndi", "git", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "complex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "complex_", "(_", "\\u", "round_", "(_", "value_", "._", "real_", ",_", "ndi", "git", "s_", ")_", ",_", "\\u", "round_", "(_", "value_", "._", "imag_", ",_", "ndi", "git", "s_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u", "round_", "(_", "value_", ",_", "ndi", "git", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gamma_", "(_", "c_", ",_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Gamma", " ", "color", " ", "correcti", "on", " ", "of", " ", "c", " ", "with", " ", "a", " ", "single", " ", "scala", "r", " ", "gamma", " ", "value", " ", "g", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "c_", "**_", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "blend", "_", "(_", "a_", ",_", "b_", ",_", "weight_", "=_", "0.5_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "blend", "(", "a", ",", " ", "b", "[", ",", " ", "weight", "=", "0.", "5", "])", " ", ":", "\\", "10", ";", " ", " ", " ", " ", "Ble", "nd", "s", " ", "values", " ", "a", " ", "and", " ", "b", " ", "according", " ", "to", " ", "normali", "zed", " ", "weight", " ", "w", ",", "\\", "10", ";", " ", " ", " ", " ", "return", "s", " ", "a", " ", "for", " ", "weight", " ", "==", " ", "0.", "0", " ", "and", " ", "b", " ", "for", " ", "weight", " ", "=", " ", "1.0", ",", " ", "a", "*(", "1.0", "-", "weight", ")+", "b", "*", "weight", " ", "in", " ", "bet", "ween", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "a_", "*_", "(_", "1.0_", "-_", "weight_", ")_", "+_", "b_", "*_", "weight_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "smooth", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "smooth", " ", "remap", "ping", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "perform", "s", " ", "a", " ", "smooth", " ", "Her", "mite", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "doe", "s", " ", "not", " ", "clamp", " ", "the", " ", "range", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "float_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "float_", "(_", "x_", "-_", "min_", ")_", "/_", "float_", "(_", "max_", "-_", "min_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "x_", "*_", "x_", "*_", "(_", "3.0_", "-_", "2.0_", "*_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "smooth", "step_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "smooth", " ", "step", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "0", " ", "if", " ", "x", " ", "<", " ", "min", ",", " ", "1", " ", "if", " ", "x", " ", ">", " ", "max", ",", " ", "and", " ", "perform", "s", " ", "a", " ", "smooth", " ", "Her", "mite", "\\", "10", ";", " ", " ", " ", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "<_", "min_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x_", ">_", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "smooth", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "lin", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "linear", " ", "remap", "ping", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "perform", "s", " ", "a", " ", "linear", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "doe", "s", " ", "not", " ", "clamp", " ", "the", " ", "range", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "float_", "(_", "x_", ")_", "-_", "min_", ")_", "/_", "(_", "max_", "-_", "min_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "lins", "tep_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "value", " ", "of", " ", "a", " ", "linear", " ", "step", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "0", " ", "if", " ", "x", " ", "<", " ", "min", ",", " ", "1", " ", "if", " ", "x", " ", ">", " ", "max", ",", " ", "and", " ", "perform", "s", " ", "a", " ", "linear", "\\", "10", ";", " ", " ", " ", " ", "interpolati", "on", " ", "bet", "ween", " ", "0", " ", "and", " ", "1", " ", "in", " ", "the", " ", "interval", " ", "min", " ", "to", " ", "max", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "<_", "min_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x_", ">_", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "lin", "map_", "(_", "min_", ",_", "max_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clamp", "_", "(_", "x_", "=_", "0.0_", ",_", "min_", "=_", "0.0_", ",_", "max_", "=_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Cla", "mps", " ", "the", " ", "value", " ", "x", " ", "bet", "ween", " ", "min", " ", "and", " ", "max", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "NOTE", " ", ":", " ", "in", " ", "2.5", " ", "can", " ", "use", " ", "'", "case", "Tru", "e", " ", "if", " ", "condition", " ", "else", " ", "case", "Fal", "se", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "real", "min", " ", "=", " ", "min", " ", "if", " ", "min", "<", "max", " ", "else", " ", "max_", "\\u\\u\\uNL\\u\\u\\u_", "#", "real", "max", " ", "=", " ", "max", " ", "if", " ", "min", "<", "max", " ", "else", " ", "min_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "orig", " ", "C", " ", "code", " ", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "const", " ", "double", " ", "real", "min", "=(", "min", "<", "max", ")?", "min", ":", "max", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "const", " ", "double", " ", "real", "max", "=(", "min", "<", "max", ")?", "max", ":", "min", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "return", " ", "((", "x", "<", "real", "min", ")?", "real", "min", ":(", "x", ">", "real", "max", ")?", "real", "max", ":", "x", ");", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "min_", "<_", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "min_", "=_", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "max_", "=_", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "min_", "=_", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "max_", "=_", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x_", "<_", "real", "min_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "real", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "x_", ">_", "real", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "real", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Range_", "(_", "x_", "=_", "0.0_", ",_", "old", "min_", "=_", "0.0_", ",_", "old", "max_", "=_", "1.0_", ",_", "newm", "in_", "=_", "0.0_", ",_", "newm", "ax_", "=_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Reset", "s", " ", "x", " ", "range", " ", "from", " ", "x", " ", "linear", " ", "interpolati", "on", " ", "of", " ", "old", "min", " ", "to", " ", "old", "max", " ", "to", " ", "x", " ", "linear", " ", "interpolati", "on", " ", "from", " ", "newm", "in", " ", "to", " ", "newm", "ax", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "min_", "<_", "old", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "old", "min_", "=_", "old", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "old", "max_", "=_", "old", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "newm", "in_", "=_", "newm", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "newm", "ax_", "=_", "newm", "ax_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "old", "min_", ">_", "old", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "old", "min_", "=_", "old", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "old", "max_", "=_", "old", "min_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "newm", "in_", "=_", "newm", "ax_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "real", "newm", "ax_", "=_", "newm", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x_", "<_", "real", "old", "min_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "real", "newm", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "x_", ">_", "real", "old", "max_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "real", "newm", "ax_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "(_", "real", "newm", "in_", "+_", "(_", "real", "newm", "ax_", "-_", "real", "newm", "in_", ")_", "*_", "(_", "x_", "-_", "old", "min_", ")_", "/_", "(_", "old", "max_", "-_", "old", "min_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "herm", "ite", "Interp", "_", "(_", "x_", "=_", "0.0_", ",_", "y0_", "=_", "0.0_", ",_", "y1_", "=_", "1.0_", ",_", "s0_", "=_", "0.0_", ",_", "s1_", "=_", "0.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Her", "mite", " ", "interpolati", "on", " ", "of", " ", "x", " ", "bet", "ween", " ", "points", " ", "y", "0", " ", "and", " ", "y1", " ", "of", " ", "tangent", " ", "slope", " ", "s0", " ", "and", " ", "s1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "s0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "y0_", "-_", "y1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", "=_", "c_", "+_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "w_", "+_", "v_", "+_", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b", "\\u", "neg_", "=_", "w_", "+_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "(_", "(_", "(_", "x_", "*_", "x_", ")_", "-_", "b", "\\u", "neg_", ")_", "*_", "x_", "+_", "s0_", ")_", "*_", "x_", "+_", "y0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "herm", "ite_", "(_", "x_", "=_", "0.0_", ",_", "v0_", "=_", "0.0_", ",_", "v1_", "=_", "0.0_", ",_", "s0_", "=_", "0.0_", ",_", "s1_", "=_", "0.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "As", " ", "the", " ", "ME", "L", " ", "command", " ", ":", " ", "Thi", "s", " ", "command", " ", "return", "s", " ", "x", " ", "point", " ", "along", " ", "on", " ", "x", " ", "herm", "ite", " ", "curve", " ", "from", " ", "the", " ", "five", " ", "give", "n", " ", "control", " ", "argu", "ment", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "first", " ", "two", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "start", " ", "and", " ", "end", " ", "points", " ", "of", " ", "the", " ", "curve", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "next", " ", "two", " ", "argu", "ment", "s", " ", "are", " ", "the", " ", "tangent", "s", " ", "of", " ", "the", " ", "curve", " ", "at", " ", "the", " ", "start", " ", "point", " ", "and", " ", "end", " ", "point", " ", "of", " ", "the", " ", "curve", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "fift", "h", " ", "argu", "ment", ",", " ", "parameter", ",", " ", "speci", "fie", "s", " ", "the", " ", "point", " ", "on", " ", "the", " ", "herm", "ite", " ", "curve", " ", "tha", "t", " ", "is", " ", "return", "ed", " ", "by", " ", "this", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "parameter", " ", "is", " ", "the", " ", "unit", "ize", "d", " ", "distance", " ", "along", " ", "the", " ", "curve", " ", "from", " ", "the", " ", "start", " ", "point", " ", "to", " ", "the", " ", "end", " ", "point", ".", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "parameter", " ", "value", " ", "of", " ", "0.", "0", " ", "correspond", "s", " ", "to", " ", "the", " ", "start", " ", "point", " ", "and", " ", "x", " ", "parameter", " ", "value", " ", "of", " ", "1.0", " ", "correspond", "s", " ", "to", " ", "the", " ", "end", " ", "point", " ", "of", " ", "the", " ", "curve", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", "float", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "x_", "<_", "0.0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "v0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "x_", ">_", "1.0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "v1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "herm", "ite", "Interp", "_", "(_", "x_", ",_", "v0_", ",_", "v1_", ",_", "s0_", ",_", "s1_", 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
adieu/django-nonrel/django/utils/autoreload.py
[ { "content": "# Autoreloading launcher.\n# Borrowed from Peter Hunt and the CherryPy project (http://www.cherrypy.org).\n# Some taken from Ian Bicking's Paste (http://pythonpaste.org/).\n#\n# Portions copyright (c) 2004, CherryPy Team ([email protected])\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without modification,\n# are permitted provided that the following conditions are met:\n#\n# * Redistributions of source code must retain the above copyright notice,\n# this list of conditions and the following disclaimer.\n# * Redistributions in binary form must reproduce the above copyright notice,\n# this list of conditions and the following disclaimer in the documentation\n# and/or other materials provided with the distribution.\n# * Neither the name of the CherryPy Team nor the names of its contributors\n# may be used to endorse or promote products derived from this software\n# without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nimport os, sys, time\n\ntry:\n import thread\nexcept ImportError:\n import dummy_thread as thread\n\n# This import does nothing, but it's necessary to avoid some race conditions\n# in the threading module. See http://code.djangoproject.com/ticket/2330 .\ntry:\n import threading\nexcept ImportError:\n pass\n\ntry:\n import termios\nexcept ImportError:\n termios = None\n\nRUN_RELOADER = True\n\n_mtimes = {}\n_win = (sys.platform == \"win32\")\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def code_changed():\n global _mtimes, _win\n for filename in filter(lambda v: v, map(lambda m: getattr(m, \"__file__\", None), sys.modules.values())):\n if filename.endswith(\".pyc\") or filename.endswith(\".pyo\"):\n filename = filename[:-1]\n if not os.path.exists(filename):\n continue # File might be in an egg, so it can't be reloaded.\n stat = os.stat(filename)\n mtime = stat.st_mtime\n if _win:\n mtime -= stat.st_ctime\n if filename not in _mtimes:\n _mtimes[filename] = mtime\n continue\n if mtime != _mtimes[filename]:\n _mtimes = {}\n return True\n return False", "metadata": "root.code_changed", "header": "['module', '___EOS___']", "index": 54 }, { "content": "def ensure_echo_on():\n if termios:\n fd = sys.stdin.fileno()\n attr_list = termios.tcgetattr(fd)\n if not attr_list[3] & termios.ECHO:\n attr_list[3] |= termios.ECHO\n termios.tcsetattr(fd, termios.TCSANOW, attr_list)", "metadata": "root.ensure_echo_on", "header": "['module', '___EOS___']", "index": 73 }, { "content": "def reloader_thread():\n ensure_echo_on()\n while RUN_RELOADER:\n if code_changed():\n sys.exit(3) # force reload\n time.sleep(1)", "metadata": "root.reloader_thread", "header": "['module', '___EOS___']", "index": 81 }, { "content": "def restart_with_reloader():\n while True:\n args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv\n if sys.platform == \"win32\":\n args = ['\"%s\"' % arg for arg in args]\n new_environ = os.environ.copy()\n new_environ[\"RUN_MAIN\"] = 'true'\n exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)\n if exit_code != 3:\n return exit_code", "metadata": "root.restart_with_reloader", "header": "['module', '___EOS___']", "index": 88 }, { "content": "def python_reloader(main_func, args, kwargs):\n if os.environ.get(\"RUN_MAIN\") == \"true\":\n thread.start_new_thread(main_func, args, kwargs)\n try:\n reloader_thread()\n except KeyboardInterrupt:\n pass\n else:\n try:\n sys.exit(restart_with_reloader())\n except KeyboardInterrupt:\n pass", "metadata": "root.python_reloader", "header": "['module', '___EOS___']", "index": 99 }, { "content": "def jython_reloader(main_func, args, kwargs):\n from _systemrestart import SystemRestart\n thread.start_new_thread(main_func, args)\n while True:\n if code_changed():\n raise SystemRestart\n time.sleep(1)", "metadata": "root.jython_reloader", "header": "['module', '___EOS___']", "index": 112 }, { "content": "def main(main_func, args=None, kwargs=None):\n if args is None:\n args = ()\n if kwargs is None:\n kwargs = {}\n if sys.platform.startswith('java'):\n reloader = jython_reloader\n else:\n reloader = python_reloader\n reloader(main_func, args, kwargs)", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 121 } ]
[ { "span": "import threading", "start_line": 40, "start_column": 4, "end_line": 40, "end_column": 20 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Auto", "relo", "ading", " ", "launcher", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bor", "row", "ed", " ", "from", " ", "Peter", " ", "Hunt", " ", "and", " ", "the", " ", "Che", "rr", "y", "Py", " ", "project", " ", "(", "http", "://", "www", ".", "cherr", "yp", "y", ".", "org", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Some", " ", "take", "n", " ", "from", " ", "Ia", "n", " ", "Bi", "ck", "ing", "'", "s", " ", "Past", "e", " ", "(", "http", "://", "python", "paste", ".", "org", "/)", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Port", "ion", "s", " ", "copyr", "ight", " ", "(", "c", ")", " ", "2004", ",", " ", "Che", "rr", "y", "Py", " ", "Tea", "m", " ", "(", "team", "@", "cherr", "yp", "y", ".", "org", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Redistributi", "on", " ", "and", " ", "use", " ", "in", " ", "source", " ", "and", " ", "binar", "y", " ", "forms", ",", " ", "with", " ", "or", " ", "with", "out", " ", "modification", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "are", " ", "permit", "ted", " ", "provided", " ", "tha", "t", " ", "the", " ", "follow", "ing", " ", "condition", "s", " ", "are", " ", "met", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "Redistributi", "ons", " ", "of", " ", "source", " ", "code", " ", "must", " ", "retain", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "this", " ", "list", " ", "of", " ", "condition", "s", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "Redistributi", "ons", " ", "in", " ", "binar", "y", " ", "form", " ", "must", " ", "reproduce", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "this", " ", "list", " ", "of", " ", "condition", "s", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", " ", "in", " ", "the", " ", "documentation", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "and", "/", "or", " ", "other", " ", "material", "s", " ", "provided", " ", "with", " ", "the", " ", "distribu", "tion", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "Nei", "ther", " ", "the", " ", "name", " ", "of", " ", "the", " ", "Che", "rr", "y", "Py", " ", "Tea", "m", " ", "nor", " ", "the", " ", "names", " ", "of", " ", "its", " ", "contributor", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "may", " ", "be", " ", "used", " ", "to", " ", "endo", "rse", " ", "or", " ", "promote", " ", "products", " ", "derive", "d", " ", "from", " ", "this", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "with", "out", " ", "specific", " ", "prior", " ", "writt", "en", " ", "permissi", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THIS", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "BY", " ", "THE", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "AND", " ", "CONTRIB", "UTO", "RS", " ", "\"", "AS", " ", "IS", "\"", " ", "AND_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ANY", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", ",", " ", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",", " ", "THE", " ", "IMPL", "IED", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", " ", "AND", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "ARE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DISC", "LAI", "MED", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", " ", "COPY", "RIG", "HT", " ", "OWNER", " ", "OR", " ", "CONTRIB", "UTO", "RS", " ", "BE", " ", "LI", "ABLE_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FOR", " ", "ANY", " ", "DIRECT", ",", " ", "INDI", "RECT", ",", " ", "INC", "IDENT", "AL", ",", " ", "SPECIAL", ",", " ", "EXE", "MPL", "ARY", ",", " ", "OR", " ", "CONS", "EQU", "ENTI", "AL_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DA", "MAGE", "S", " ", "(", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",", " ", "PROC", "URE", "MENT", " ", "OF", " ", "SUBST", "ITU", "TE", " ", "GOOD", "S", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SERVICES", ";", " ", "LOSS", " ", "OF", " ", "USE", ",", " ", "DATA", ",", " ", "OR", " ", "PROF", "IT", "S", ";", " ", "OR", " ", "BUS", "INE", "SS", " ", "INTER", "RU", "PTION", ")", " ", "HO", "WE", "VER_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CAU", "SED", " ", "AND", " ", "ON", " ", "ANY", " ", "THE", "ORY", " ", "OF", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN", " ", "CONTR", "ACT", ",", " ", "STRI", "CT", " ", "LI", "ABI", "LIT", "Y", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OR", " ", "TOR", "T", " ", "(", "INC", "LU", "DING", " ", "NEG", "LIG", "ENCE", " ", "OR", " ", "OTHER", "WI", "SE", ")", " ", "ARI", "SIN", "G", " ", "IN", " ", "ANY", " ", "WAY", " ", "OUT", " ", "OF", " ", "THE", " ", "USE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OF", " ", "THIS", " ", "SOFT", "WARE", ",", " ", "EVE", "N", " ", "IF", " ", "ADV", "ISE", "D", " ", "OF", " ", "THE", " ", "POS", "SIB", "ILI", "TY", " ", "OF", " ", "SUC", "H", " ", "DA", "MAGE", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", ",_", "sys_", ",_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "dummy", "\\u", "thread_", "as_", "thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "import", " ", "doe", "s", " ", "not", "hing", ",", " ", "but", " ", "it", "'", "s", " ", "necessar", "y", " ", "to", " ", "avoid", " ", "some", " ", "race", " ", "conditions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "the", " ", "thread", "ing", " ", "module", ".", " ", "See", " ", "http", "://", "code", ".", "django", "project", ".", "com", "/", "tick", "et", "/", "233", "0", " ", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "termios_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "termios_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "RUN", "\\u", "REL", "OAD", "ER_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "mti", "mes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "win_", "=_", "(_", "sys_", "._", "platform_", "==_", "\"", "win32", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "code", "\\u", "changed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "\\u", "mti", "mes_", ",_", "\\u", "win_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "filename_", "in_", "filter_", "(_", "lambda_", "v_", ":_", "v_", ",_", "map_", "(_", "lambda_", "m_", ":_", "getattr_", "(_", "m_", ",_", "\"\\u\\u", "file", "\\u\\u\"_", ",_", "None_", ")_", ",_", "sys_", "._", "modules_", "._", "values_", "(_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "filename_", "._", "endswith_", "(_", "\".", "pyc", "\"_", ")_", "or_", "filename_", "._", "endswith_", "(_", "\".", "pyo", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "filename_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "#", " ", "File", " ", "mig", "ht", " ", "be", " ", "in", " ", "an", " ", "egg", ",", " ", "so", " ", "it", " ", "can", "'", "t", " ", "be", " ", "reloade", "d", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stat_", "=_", "os_", "._", "stat_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mtime_", "=_", "stat_", "._", "st", "\\u", "mtime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "win_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mtime_", "-=_", "stat_", "._", "st", "\\u", "ctime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "filename_", "not_", "in_", "\\u", "mti", "mes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "mti", "mes_", "[_", "filename_", "]_", "=_", "mtime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mtime_", "!=_", "\\u", "mti", "mes_", "[_", "filename_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "mti", "mes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "ensure", "\\u", "echo", "\\u", "on_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "termios_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "sys_", "._", "stdin_", "._", "fileno_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "attr", "\\u", "list_", "=_", "termios_", "._", "tc", "getattr_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "attr", "\\u", "list_", "[_", "3_", "]_", "&_", "termios_", "._", "ECHO", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attr", "\\u", "list_", "[_", "3_", "]_", "|=_", "termios_", "._", "ECHO", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "termios_", "._", "tc", "setattr_", "(_", "fd_", ",_", "termios_", "._", "TC", "SAN", "OW", "_", ",_", "attr", "\\u", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reloade", "r", "\\u", "thread_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ensure", "\\u", "echo", "\\u", "on_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "RUN", "\\u", "REL", "OAD", "ER_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "code", "\\u", "changed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "exit_", "(_", "3_", ")_", "#", " ", "force", " ", "reload_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "restart", "\\u", "with", "\\u", "reloade", "r_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "[_", "sys_", "._", "executable_", "]_", "+_", "[_", "'-", "W", "%", "s", "'_", "%_", "o_", "for_", "o_", "in_", "sys_", "._", "warn", "options_", "]_", "+_", "sys_", "._", "argv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "platform_", "==_", "\"", "win32", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "[_", "'\"", "%", "s", "\"'_", "%_", "arg_", "for_", "arg_", "in_", "args_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "environ_", "=_", "os_", "._", "environ_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "environ_", "[_", "\"", "RUN", "\\u", "MAIN", "\"_", "]_", "=_", "'", "true", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exit", "\\u", "code_", "=_", "os_", "._", "spawn", "ve_", "(_", "os_", "._", "P", "\\u", "WAIT", "_", ",_", "sys_", "._", "executable_", ",_", "args_", ",_", "new", "\\u", "environ_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "exit", "\\u", "code_", "!=_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "exit", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "python", "\\u", "reloade", "r_", "(_", "main", "\\u", "func_", ",_", "args_", ",_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "environ_", "._", "get_", "(_", "\"", "RUN", "\\u", "MAIN", "\"_", ")_", "==_", "\"", "true", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "thread_", "._", "start", "\\u", "new", "\\u", "thread_", "(_", "main", "\\u", "func_", ",_", "args_", ",_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reloade", "r", "\\u", "thread_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "exit_", "(_", "restart", "\\u", "with", "\\u", "reloade", "r_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "jy", "tho", "n", "\\u", "reloade", "r_", "(_", "main", "\\u", "func_", ",_", "args_", ",_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "\\u", "system", "restart_", "import_", "System", "Restart", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thread_", "._", "start", "\\u", "new", "\\u", "thread_", "(_", "main", "\\u", "func_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "code", "\\u", "changed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "System", "Restart", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "main", "\\u", "func_", ",_", "args_", "=_", "None_", ",_", "kwargs_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "args_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "kwargs_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sys_", "._", "platform_", "._", "startswith_", "(_", "'", "java", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reloade", "r_", "=_", "jy", "tho", "n", "\\u", "reloade", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reloade", "r_", "=_", "python", "\\u", "reloade", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reloade", "r_", "(_", "main", "\\u", "func_", ",_", "args_", ",_", "kwargs_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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