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
Unused import
benhamner/Metrics/Python/ml_metrics/__init__.py
[ { "content": "from quadratic_weighted_kappa import *\nfrom elementwise import *\nfrom auc import auc\nfrom average_precision import apk, mapk\nfrom edit_distance import levenshtein\nfrom custom.kdd_average_precision import kdd_apk, kdd_mapk\nfrom custom.binomial_deviance import capped_log10_likelihood, capped_binomial_deviance", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from auc import auc", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 19 }, { "span": "from average_precision import apk, mapk", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 39 }, { "span": "from edit_distance import levenshtein", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 37 }, { "span": "from custom.kdd_average_precision import kdd_apk, kdd_mapk", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 58 }, { "span": "from custom.binomial_deviance import capped_log10_likelihood, capped_binomial_deviance", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 86 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "quadratic", "\\u", "weight", "ed", "\\u", "kappa_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "element", "wise_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "auc_", "import_", "auc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "averag", "e\\u", "precision_", "import_", "apk", "_", ",_", "map", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "edit", "\\u", "distance_", "import_", "leve", "nsh", "tein", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "custom_", "._", "kd", "d\\u", "averag", "e\\u", "precision_", "import_", "kd", "d\\u", "apk", "_", ",_", "kd", "d\\u", "map", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "custom_", "._", "binomial", "\\u", "devi", "ance_", "import_", "cap", "ped", "\\u", "log", "10", "\\u", "likelihood_", ",_", "cap", "ped", "\\u", "binomial", "\\u", "devi", "ance_" ]
[ 4, 4, 4, 4, 4, 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, 2, 0, 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, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
First parameter of a method is not named 'self'
francelabs/datafari/windows/python/Lib/test/pydoc_mod.py
[ { "content": " def __init__():\n \"\"\"Wow, I have no function!\"\"\"\n pass", "metadata": "root.A.__init__", "header": "['class', 'A', ':', '___EOS___']", "index": 9 } ]
[ { "span": "def __init__():", "start_line": 9, "start_column": 4, "end_line": 9, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "A_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Wo", "w", ",", " ", "I", " ", "have", " ", "no", " ", "function", "!\"", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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 ]
Unused import
couchbase/couchbase-python-client/couchbase/tests/cases/get_t.py
[ { "content": "#\n# Copyright 2013, Couchbase, Inc.\n# All Rights Reserved\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\nimport pickle\nfrom time import sleep\n\nfrom nose.plugins.attrib import attr\n\nfrom couchbase import FMT_JSON, FMT_PICKLE, FMT_UTF8, FMT_BYTES\n\nfrom couchbase.exceptions import (\n CouchbaseError, ValueFormatError, NotFoundError)\nfrom couchbase.result import MultiResult, Result\nfrom couchbase.tests.base import ConnectionTestCase, SkipTest\n\n\nif __name__ == '__main__':\n unittest.main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class GetTest(ConnectionTestCase):\n\n\n\n\n\n\n\n\n\n", "metadata": "root.GetTest", "header": "['module', '___EOS___']", "index": 29 }, { "content": " def test_trivial_get(self):\n key = self.gen_key('trivial_get')\n self.cb.upsert(key, 'value1')\n rv = self.cb.get(key)\n self.assertEqual(rv.value, 'value1')\n\n rvs = self.cb.get_multi([key])\n self.assertIsInstance(rvs, self.cls_MultiResult)\n self.assertEqual(len(rvs), 1)\n self.assertEqual(rvs[key].value, 'value1')", "metadata": "root.GetTest.test_trivial_get", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 31 }, { "content": " def test_get_missing_key(self):\n rv = self.cb.get('key_missing_1', quiet=True)\n self.assertIsNone(rv.value)\n self.assertFalse(rv.success)\n\n # Get with quiet=False\n self.assertRaises(NotFoundError, self.cb.get, 'key_missing_1',\n quiet=False)", "metadata": "root.GetTest.test_get_missing_key", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 43 }, { "content": " def test_multi_get(self):\n kv = self.gen_kv_dict(amount=3, prefix='get_multi')\n rvs = self.cb.upsert_multi(kv)\n self.assertTrue(rvs.all_ok)\n\n k_subset = list(kv.keys())[:2]\n\n rvs1 = self.cb.get_multi(k_subset)\n self.assertEqual(len(rvs1), 2)\n self.assertEqual(rvs1[k_subset[0]].value, kv[k_subset[0]])\n self.assertEqual(rvs1[k_subset[1]].value, kv[k_subset[1]])\n\n rv2 = self.cb.get_multi(kv.keys())\n self.assertEqual(rv2.keys(), kv.keys())", "metadata": "root.GetTest.test_multi_get", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 52 }, { "content": " def test_multi_mixed(self):\n kv_missing = self.gen_kv_dict(amount=3, prefix='multi_missing_mixed')\n kv_existing = self.gen_kv_dict(amount=3, prefix='multi_existing_mixed')\n\n self.cb.remove_multi(list(kv_missing.keys()) + list(kv_existing.keys()),\n quiet=True)\n\n self.cb.upsert_multi(kv_existing)\n\n rvs = self.cb.get_multi(\n list(kv_existing.keys()) + list(kv_missing.keys()),\n quiet=True)\n\n\n self.assertFalse(rvs.all_ok)\n\n for k, v in kv_missing.items():\n self.assertTrue(k in rvs)\n self.assertFalse(rvs[k].success)\n self.assertTrue(rvs[k].value is None)\n self.assertTrue(NotFoundError._can_derive(rvs[k].rc))\n\n for k, v in kv_existing.items():\n self.assertTrue(k in rvs)\n self.assertTrue(rvs[k].success)\n self.assertEqual(rvs[k].value, kv_existing[k])\n self.assertEqual(rvs[k].rc, 0)\n\n # Try this again, but without quiet\n cb_exc = None\n try:\n self.cb.get_multi(list(kv_existing.keys()) + list(kv_missing.keys()))\n except NotFoundError as e:\n cb_exc = e\n\n self.assertTrue(cb_exc)\n all_res = cb_exc.all_results\n self.assertTrue(all_res)\n self.assertFalse(all_res.all_ok)\n\n for k, v in kv_existing.items():\n self.assertTrue(k in all_res)\n self.assertTrue(all_res[k].success)\n self.assertEqual(all_res[k].value, v)\n self.assertEqual(all_res[k].rc, 0)\n\n for k, v in kv_missing.items():\n self.assertTrue(k in all_res)\n self.assertFalse(all_res[k].success)\n self.assertTrue(all_res[k].value is None)\n\n del cb_exc", "metadata": "root.GetTest.test_multi_mixed", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 68 }, { "content": " def test_extended_get(self):\n key = self.gen_key(prefix='key_extended')\n orig_cas1 = self.cb.upsert(key, 'value1').cas\n rv = self.cb.get(key)\n val1, flags1, cas1 = rv.value, rv.flags, rv.cas\n self.assertEqual(val1, 'value1')\n self.assertEqual(flags1, FMT_JSON)\n self.assertEqual(cas1, orig_cas1)\n\n # Test named tuples\n result1 = self.cb.get(key)\n self.assertEqual(result1.value, 'value1')\n self.assertEqual(result1.flags, FMT_JSON)\n self.assertEqual(result1.cas, orig_cas1)\n\n # Single get as array\n result2 = self.cb.get_multi([key])\n self.assertIsInstance(result2, self.cls_MultiResult)\n self.assertTrue(key in result2)\n self.assertEqual(result2[key].value, 'value1')\n self.assertEqual(result2[key].flags, FMT_JSON)\n self.assertEqual(result2[key].cas, orig_cas1)\n\n key2 = self.gen_key('key_extended_2')\n cas2 = self.cb.upsert(key2, 'value2').cas\n\n key3 = self.gen_key('key_extended_3')\n cas3 = self.cb.upsert(key3, 'value3').cas\n results = self.cb.get_multi([key2, key3])\n\n self.assertEqual(results[key3].value, 'value3')\n self.assertEqual(results[key3].flags, FMT_JSON)\n self.assertEqual(results[key3].cas, cas3)\n\n rv = self.cb.get('missing_key', quiet=True)\n val4, flags4, cas4 = rv.value, rv.flags, rv.cas\n self.assertEqual(val4, None)\n self.assertEqual(flags4, 0x00)\n self.assertEqual(cas4, 0)", "metadata": "root.GetTest.test_extended_get", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 122 }, { "content": " @attr('slow')\n def test_get_ttl(self):\n key = self.gen_key('get_ttl')\n self.cb.remove(key, quiet=True)\n self.cb.upsert(key, \"a_value\")\n rv = self.cb.get(key, ttl=1)\n self.assertEqual(rv.value, \"a_value\")\n sleep(2)\n rv = self.cb.get(key, quiet=True)\n self.assertFalse(rv.success)\n self.assertTrue(NotFoundError._can_derive(rv.rc))", "metadata": "root.GetTest.test_get_ttl", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 162 }, { "content": " @attr('slow')\n def test_get_multi_ttl(self):\n kvs = self.gen_kv_dict(amount=2, prefix='get_multi_ttl')\n\n self.cb.upsert_multi(kvs)\n rvs = self.cb.get_multi(list(kvs.keys()), ttl=1)\n for k, v in rvs.items():\n self.assertEqual(v.value, kvs[k])\n\n sleep(2)\n rvs = self.cb.get_multi(list(kvs.keys()), quiet=True)\n for k, v in rvs.items():\n self.assertFalse(v.success)\n self.assertTrue(k in kvs)\n self.assertTrue(NotFoundError._can_derive(v.rc))", "metadata": "root.GetTest.test_get_multi_ttl", "header": "['class', 'GetTest', '(', 'ConnectionTestCase', ')', ':', '___EOS___']", "index": 174 } ]
[ { "span": "import pickle", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 13 }, { "span": "from couchbase import FMT_JSON, FMT_PICKLE, FMT_UTF8, FMT_BYTES", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 63 }, { "span": "from couchbase.exceptions import (\n CouchbaseError, ValueFormatError, NotFoundError)", "start_line": 24, "start_column": 0, "end_line": 25, "end_column": 52 }, { "span": "from couchbase.result import MultiResult, Result", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 48 }, { "span": "from couchbase.tests.base import ConnectionTestCase, SkipTest", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 61 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2013", ",", " ", "Cou", "ch", "base", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d_", "\\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_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "sleep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "nose_", "._", "plugins_", "._", "attrib_", "import_", "attr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "couch", "base_", "import_", "FMT", "\\u", "JSON_", ",_", "FMT", "\\u", "PIC", "KL", "E_", ",_", "FMT", "\\u", "UT", "F8_", ",_", "FMT", "\\u", "BYTES_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "couch", "base_", "._", "exceptions_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Cou", "ch", "base", "Error_", ",_", "Value", "Format", "Error_", ",_", "Not", "Foun", "d", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couch", "base_", "._", "result_", "import_", "Multi", "Result_", ",_", "Result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "couch", "base_", "._", "tests_", "._", "base_", "import_", "Connect", "ion", "Test", "Case_", ",_", "Ski", "p", "Test_", "\\u\\u\\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_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\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_", "Get", "Test_", "(_", "Connect", "ion", "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\\uNL\\u\\u\\u_", "\\u\\u\\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_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "trivial", "\\u", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "self_", "._", "gen", "\\u", "key_", "(_", "'", "trivial", "\\u", "get", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb_", "._", "upsert_", "(_", "key_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rv_", "._", "value_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rvs_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "[_", "key_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "Instance_", "(_", "rvs_", ",_", "self_", "._", "cls", "\\u", "Multi", "Result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "rvs_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rvs_", "[_", "key_", "]_", "._", "value_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "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", "missi", "ng", "\\u", "key_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "'", "key", "\\u", "missi", "ng", "\\u", "1", "'_", ",_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "None_", "(_", "rv_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "rv_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "with", " ", "quie", "t", "=", "False_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Not", "Foun", "d", "Error_", ",_", "self_", "._", "cb_", "._", "get_", ",_", "'", "key", "\\u", "missi", "ng", "\\u", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "quiet_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "multi", "\\u", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kv_", "=_", "self_", "._", "gen", "\\u", "kv", "\\u", "dict_", "(_", "amount_", "=_", "3_", ",_", "prefix_", "=_", "'", "get", "\\u", "multi", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rvs_", "=_", "self_", "._", "cb_", "._", "upse", "rt", "\\u", "multi_", "(_", "kv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "rvs_", "._", "all", "\\u", "ok_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "k", "\\u", "subset_", "=_", "list_", "(_", "kv_", "._", "keys_", "(_", ")_", ")_", "[_", ":_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rv", "s1_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "k", "\\u", "subset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "rv", "s1_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rv", "s1_", "[_", "k", "\\u", "subset_", "[_", "0_", "]_", "]_", "._", "value_", ",_", "kv_", "[_", "k", "\\u", "subset_", "[_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rv", "s1_", "[_", "k", "\\u", "subset_", "[_", "1_", "]_", "]_", "._", "value_", ",_", "kv_", "[_", "k", "\\u", "subset_", "[_", "1_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rv", "2_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "kv_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rv", "2_", "._", "keys_", "(_", ")_", ",_", "kv_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "multi", "\\u", "mixed", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kv", "\\u", "missing_", "=_", "self_", "._", "gen", "\\u", "kv", "\\u", "dict_", "(_", "amount_", "=_", "3_", ",_", "prefix_", "=_", "'", "multi", "\\u", "missi", "ng", "\\u", "mixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kv", "\\u", "existing_", "=_", "self_", "._", "gen", "\\u", "kv", "\\u", "dict_", "(_", "amount_", "=_", "3_", ",_", "prefix_", "=_", "'", "multi", "\\u", "exist", "ing", "\\u", "mixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cb_", "._", "remove", "\\u", "multi_", "(_", "list_", "(_", "kv", "\\u", "missing_", "._", "keys_", "(_", ")_", ")_", "+_", "list_", "(_", "kv", "\\u", "existing_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cb_", "._", "upse", "rt", "\\u", "multi_", "(_", "kv", "\\u", "existing_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rvs_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "kv", "\\u", "existing_", "._", "keys_", "(_", ")_", ")_", "+_", "list_", "(_", "kv", "\\u", "missing_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "rvs_", "._", "all", "\\u", "ok_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "kv", "\\u", "missing_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "k_", "in_", "rvs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "rvs_", "[_", "k_", "]_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "rvs_", "[_", "k_", "]_", "._", "value_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "Not", "Foun", "d", "Error_", "._", "\\u", "can", "\\u", "derive", "_", "(_", "rvs_", "[_", "k_", "]_", "._", "rc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "kv", "\\u", "existing_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "k_", "in_", "rvs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "rvs_", "[_", "k_", "]_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rvs_", "[_", "k_", "]_", "._", "value_", ",_", "kv", "\\u", "existing_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rvs_", "[_", "k_", "]_", "._", "rc_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "this", " ", "again", ",", " ", "but", " ", "with", "out", " ", "quiet_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cb", "\\u", "exc_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "list_", "(_", "kv", "\\u", "existing_", "._", "keys_", "(_", ")_", ")_", "+_", "list_", "(_", "kv", "\\u", "missing_", "._", "keys_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Foun", "d", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cb", "\\u", "exc_", "=_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "cb", "\\u", "exc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "res_", "=_", "cb", "\\u", "exc_", "._", "all", "\\u", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "all", "\\u", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "all", "\\u", "res_", "._", "all", "\\u", "ok_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "kv", "\\u", "existing_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "k_", "in_", "all", "\\u", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "all", "\\u", "res_", "[_", "k_", "]_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "all", "\\u", "res_", "[_", "k_", "]_", "._", "value_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "all", "\\u", "res_", "[_", "k_", "]_", "._", "rc_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "kv", "\\u", "missing_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "k_", "in_", "all", "\\u", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "all", "\\u", "res_", "[_", "k_", "]_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "all", "\\u", "res_", "[_", "k_", "]_", "._", "value_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "cb", "\\u", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "extend", "ed", "\\u", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "self_", "._", "gen", "\\u", "key_", "(_", "prefix_", "=_", "'", "key", "\\u", "extend", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "orig", "\\u", "cas", "1_", "=_", "self_", "._", "cb_", "._", "upsert_", "(_", "key_", ",_", "'", "value", "1", "'_", ")_", "._", "cas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "val1_", ",_", "flags", "1_", ",_", "cas", "1_", "=_", "rv_", "._", "value_", ",_", "rv_", "._", "flags_", ",_", "rv_", "._", "cas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "val1_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "flags", "1_", ",_", "FMT", "\\u", "JSON_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "cas", "1_", ",_", "orig", "\\u", "cas", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "named", " ", "tuples_", "\\u\\u\\uNL\\u\\u\\u_", "result1_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result1_", "._", "value_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result1_", "._", "flags_", ",_", "FMT", "\\u", "JSON_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result1_", "._", "cas_", ",_", "orig", "\\u", "cas", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sing", "le", " ", "get", " ", "as", " ", "array_", "\\u\\u\\uNL\\u\\u\\u_", "result2_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "[_", "key_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Is", "Instance_", "(_", "result2_", ",_", "self_", "._", "cls", "\\u", "Multi", "Result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "key_", "in_", "result2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result2_", "[_", "key_", "]_", "._", "value_", ",_", "'", "value", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result2_", "[_", "key_", "]_", "._", "flags_", ",_", "FMT", "\\u", "JSON_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "result2_", "[_", "key_", "]_", "._", "cas_", ",_", "orig", "\\u", "cas", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "key2_", "=_", "self_", "._", "gen", "\\u", "key_", "(_", "'", "key", "\\u", "extend", "ed", "\\u", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cas", "2_", "=_", "self_", "._", "cb_", "._", "upsert_", "(_", "key2_", ",_", "'", "value", "2", "'_", ")_", "._", "cas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "key", "3_", "=_", "self_", "._", "gen", "\\u", "key_", "(_", "'", "key", "\\u", "extend", "ed", "\\u", "3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cas", "3_", "=_", "self_", "._", "cb_", "._", "upsert_", "(_", "key", "3_", ",_", "'", "value", "3", "'_", ")_", "._", "cas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "[_", "key2_", ",_", "key", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "key", "3_", "]_", "._", "value_", ",_", "'", "value", "3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "key", "3_", "]_", "._", "flags_", ",_", "FMT", "\\u", "JSON_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "results_", "[_", "key", "3_", "]_", "._", "cas_", ",_", "cas", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "'", "missi", "ng", "\\u", "key", "'_", ",_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "val", "4_", ",_", "flags", "4_", ",_", "cas", "4_", "=_", "rv_", "._", "value_", ",_", "rv_", "._", "flags_", ",_", "rv_", "._", "cas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "val", "4_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "flags", "4_", ",_", "0x00_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "cas", "4_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "attr_", "(_", "'", "slow", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "ttl_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "self_", "._", "gen", "\\u", "key_", "(_", "'", "get", "\\u", "ttl", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb_", "._", "remove_", "(_", "key_", ",_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb_", "._", "upsert_", "(_", "key_", ",_", "\"", "a", "\\u", "value", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "key_", ",_", "ttl_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "rv_", "._", "value_", ",_", "\"", "a", "\\u", "value", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rv_", "=_", "self_", "._", "cb_", "._", "get_", "(_", "key_", ",_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "rv_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "Not", "Foun", "d", "Error_", "._", "\\u", "can", "\\u", "derive", "_", "(_", "rv_", "._", "rc_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Get", "Test_", "(_", "Connect", "ion", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "attr_", "(_", "'", "slow", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "multi", "\\u", "ttl_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kvs", "_", "=_", "self_", "._", "gen", "\\u", "kv", "\\u", "dict_", "(_", "amount_", "=_", "2_", ",_", "prefix_", "=_", "'", "get", "\\u", "multi", "\\u", "ttl", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cb_", "._", "upse", "rt", "\\u", "multi_", "(_", "kvs", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rvs_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "list_", "(_", "kvs", "_", "._", "keys_", "(_", ")_", ")_", ",_", "ttl_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "rvs_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "v_", "._", "value_", ",_", "kvs", "_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sleep_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rvs_", "=_", "self_", "._", "cb_", "._", "get", "\\u", "multi_", "(_", "list_", "(_", "kvs", "_", "._", "keys_", "(_", ")_", ")_", ",_", "quiet_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "rvs_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "False_", "(_", "v_", "._", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "k_", "in_", "kvs", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "Not", "Foun", "d", "Error_", "._", "\\u", "can", "\\u", "derive", "_", "(_", "v_", "._", "rc_", ")_", ")_", "\\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,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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, 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 ]
Unused local variable
mgax/SpaghettiFS/spaghettifs/storage.py
[ { "content": " @classmethod\n def create(cls, repo_path):\n if not os.path.isdir(repo_path):\n os.mkdir(repo_path)\n\n eg = EasyGit.new_repo(repo_path, bare=True)\n\n inodes = eg.root.new_tree('inodes')\n root_ls = eg.root.new_blob('root.ls')\n root_sub = eg.root.new_tree('root.sub')\n features_blob = eg.root.new_blob('features')\n\n features_blob.data = '{}'\n features = FeatureBlob(features_blob)\n features['next_inode_number'] = 1\n features['inode_index_format'] = 'treetree'\n features['inode_format'] = 'treetree'\n\n eg.commit(cls.commit_author, 'Created empty filesystem')\n\n return cls(repo_path)", "metadata": "root.GitStorage.create", "header": "['class', 'GitStorage', '(', 'object', ')', ':', '___EOS___']", "index": 50 }, { "content": " def create_directory(self, name):\n check_filename(name)\n log.info('Creating directory %s in %s', repr(name), repr(self.path))\n\n qname = quote(name)\n with self.sub_tree as st:\n child_ls_blob = st.new_blob(qname + '.ls')\n with self.ls_blob as b:\n b.data += \"%s /\\n\" % qname\n\n self.storage._autocommit()\n\n return self[name]", "metadata": "root.StorageDir.create_directory", "header": "['class', 'StorageDir', '(', 'object', ',', 'UserDict', '.', 'DictMixin', ')', ':', '___EOS___']", "index": 208 } ]
[ { "span": "inodes ", "start_line": 57, "start_column": 8, "end_line": 57, "end_column": 14 }, { "span": "root_ls ", "start_line": 58, "start_column": 8, "end_line": 58, "end_column": 15 }, { "span": "root_sub ", "start_line": 59, "start_column": 8, "end_line": 59, "end_column": 16 }, { "span": "child_ls_blob ", "start_line": 214, "start_column": 12, "end_line": 214, "end_column": 25 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Git", "Storage_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create_", "(_", "cls_", ",_", "repo", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isdir_", "(_", "repo", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkdir_", "(_", "repo", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "eg_", "=_", "Eas", "y", "Git", "_", "._", "new", "\\u", "repo_", "(_", "repo", "\\u", "path_", ",_", "bare", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "inode", "s_", "=_", "eg_", "._", "root_", "._", "new", "\\u", "tree_", "(_", "'", "inode", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "\\u", "ls_", "=_", "eg_", "._", "root_", "._", "new", "\\u", "blob_", "(_", "'", "root", ".", "ls", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "\\u", "sub_", "=_", "eg_", "._", "root_", "._", "new", "\\u", "tree_", "(_", "'", "root", ".", "sub", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features", "\\u", "blob_", "=_", "eg_", "._", "root_", "._", "new", "\\u", "blob_", "(_", "'", "features", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "features", "\\u", "blob_", "._", "data_", "=_", "'{}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "=_", "Feature", "Blob_", "(_", "features", "\\u", "blob_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "[_", "'", "next", "\\u", "inode", "\\u", "number", "'_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "[_", "'", "inode", "\\u", "index", "\\u", "format", "'_", "]_", "=_", "'", "tree", "tree", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "[_", "'", "inode", "\\u", "format", "'_", "]_", "=_", "'", "tree", "tree", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "eg_", "._", "commit_", "(_", "cls_", "._", "commit", "\\u", "author_", ",_", "'", "Creat", "ed", " ", "empty", " ", "filesystem", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "cls_", "(_", "repo", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stor", "age", "Dir_", "(_", "object_", ",_", "User", "Dict_", "._", "Dict", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "directory_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "check", "\\u", "filename_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "info_", "(_", "'", "Creat", "ing", " ", "director", "y", " ", "%", "s", " ", "in", " ", "%", "s", "'_", ",_", "repr_", "(_", "name_", ")_", ",_", "repr_", "(_", "self_", "._", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qname_", "=_", "quote_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "sub\\u", "tree_", "as_", "st_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child", "\\u", "ls", "\\u", "blob_", "=_", "st_", "._", "new", "\\u", "blob_", "(_", "qname_", "+_", "'.", "ls", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "ls", "\\u", "blob_", "as_", "b_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "b_", "._", "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, 0, 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 ]
Unused import
jpic/playlistnow.fm/apps/playlist/management/commands/migrate_pln.py
[ { "content": "import sys\nimport datetime\nimport urllib\nimport simplejson\n\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django import db\nfrom django.contrib.auth.models import User\nfrom actstream.models import follow\nfrom django.db.models import signals\nfrom django.conf import settings\n\nfrom jpic.slughifi import slughifi\nfrom jpic.progressbar import ProgressBar\n\nfrom playlist.models import *\nfrom music.models import *\nfrom gfc.models import *\nfrom socialregistration.models import *\nimport gfc\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Command(BaseCommand):\n args = 'n/a'\n help = 'imports dataset from previous structure'\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.Command", "header": "['module', '___EOS___']", "index": 21 }, { "content": " def handle(self, *args, **options):\n backend = db.load_backend('mysql')\n conn = backend.DatabaseWrapper({'NAME': 'playlistpnow', 'USER': 'root', 'PASSWORD': 'YsD9c6WJ', 'HOST': 'localhost', 'PORT': '3306', 'OPTIONS': ''})\n old = conn.cursor()\n self.old_root_ids = (175319, 57488)\n\n signals.pre_save.disconnect(yourplaylist_bookmarked)\n signals.m2m_changed.disconnect(update_counts)\n signals.post_save.disconnect(new_follower, sender=Follow)\n signals.post_save.disconnect(new_follow, sender=Follow)\n signals.post_save.disconnect(playlist_create_activity, sender=Playlist)\n signals.m2m_changed.disconnect(last_playlist, sender=Playlist.tracks.through)\n signals.pre_save.disconnect(get_info_if_no_image)\n signals.m2m_changed.disconnect(update_fans)\n\n #self.sync_users_accounts(old)\n #self.sync_followers(old)\n #self.sync_friends(old)\n #self.sync_categories(old)\n #self.sync_tracks(old)\n self.sync_playlists(old)\n #self.sync_tiny_playlist(old)\n #self.sync_artists(old)", "metadata": "root.Command.handle", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 25 }, { "content": " def get_user(self, pk):\n if pk in self.old_root_ids:\n return User.objects.get(pk=settings.ROOT_USERID)\n else:\n try:\n return User.objects.get(pk=pk)\n except User.DoesNotExist:\n return User.objects.get(pk=settings.ROOT_USERID)", "metadata": "root.Command.get_user", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 49 }, { "content": " def count_table(self, old, table):\n old.execute('select count(*) from %s' % table)\n result = old.fetchone()\n return result[0]", "metadata": "root.Command.count_table", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 58 }, { "content": " def sync_friends(self, old):\n print \"Migrating friends ...\"\n prog = ProgressBar(0, self.count_table(old, 'users_friends_v2'), 77, mode='fixed')\n\n old.execute('select * from users_friends_v2')\n for old_friend in old.fetchall():\n if not old_friend[0]: continue\n if not old_friend[1]: continue\n\n try:\n user1 = self.get_user(old_friend[0])\n user2 = self.get_user(old_friend[1])\n follow(user1, user2, False)\n follow(user2, user1, False)\n except:\n continue\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_friends", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 63 }, { "content": " def sync_followers(self, old):\n print \"Migrating followers ...\"\n prog = ProgressBar(0, self.count_table(old, 'users_followers'), 77, mode='fixed')\n\n old.execute('select * from users_followers')\n for old_follower in old.fetchall():\n if not old_follower[0]: continue\n if not old_follower[1]: continue\n\n try:\n user = self.get_user(old_follower[0])\n follower = self.get_user(old_follower[1])\n follow(follower, user, False)\n except:\n continue\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_followers", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 84 }, { "content": " def sync_categories(self, old):\n print \"Migrating categories ...\"\n prog = ProgressBar(0, self.count_table(old, 'categories'), 77, mode='fixed')\n\n old.execute('select * from categories order by parent')\n for old_category in old.fetchall():\n category, created = PlaylistCategory.objects.get_or_create(\n pk=old_category[0])\n category.name = old_category[4]\n category.save()\n if old_category[2]:\n category.parent, pcreated = PlaylistCategory.objects.get_or_create(\n pk=old_category[2])\n category.parent.save()\n category.save()\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_categories", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 105 }, { "content": " def sync_users_accounts(self, old):\n print \"Migrating users accounts ...\"\n prog = ProgressBar(0, self.count_table(old, 'users'), 77, mode='fixed')\n\n old.execute('''\n select \n u.id, \n u.name,\n ue.email,\n ua.accountLocation,\n ua.accountAvatar,\n up.pts\n from users u \n left join users_emails ue on ue.userId = u.id\n left join users_accounts ua on ua.userId = u.id\n left join users_pts up on up.idUser = u.id\n ''')\n for old_user in old.fetchall():\n # skipping the couple of nonames\n if not old_user[1]: continue\n\n if old_user[0] in self.old_root_ids:\n user = User.objects.get(pk=settings.ROOT_USERID)\n else:\n user, created = User.objects.get_or_create(pk=old_user[0])\n count = 0\n user.username = slughifi(old_user[1])[:30] or count\n while User.objects.filter(username=user.username).exclude(pk=user.pk).count():\n user.username = '%s%s' % (slughifi(old_user[1])[:28], count)\n count += 1\n user.email = old_user[2] or '[email protected]'\n user.first_name = old_user[1]\n user.save()\n\n user.playlistprofile.points = old_user[5] or 0\n if old_user[3]:\n user.playlistprofile.user_location = old_user[3]\n if old_user[4]:\n user.playlistprofile.avatar_url = old_user[4]\n user.playlistprofile.save()\n \n old.execute('select * from users_accounts where userId = ' + str(old_user[0]))\n for old_account in old.fetchall():\n if old_account[1] == 'FACEBOOK':\n p, created=FacebookProfile.objects.get_or_create(uid=old_account[2], user=user)\n\n upstream = None\n try:\n filename, message = urllib.urlretrieve('https://graph.facebook.com/%s' % old_account[2])\n fp = open(filename)\n upstream = simplejson.load(fp)\n fp.close()\n except:\n pass\n\n if upstream:\n p.nick = upstream['name']\n if 'link' in upstream:\n p.url = upstream['link']\n else:\n p.url = 'http://www.facebook.com/profile.php?id=%s' % old_account[2]\n\n p.save()\n \n elif old_account[1] == 'TWITTER':\n p, created=TwitterProfile.objects.get_or_create(twitter_id=old_account[2],user=user)\n old.execute('select * from twitter_tokens where twitterUserId = \"%s\"' % old_account[2])\n old_profile = old.fetchone()\n if old_profile is not None:\n p.access_token = old_profile[1]\n p.token_secret = old_profile[2]\n p.nick = old_account[5].replace('http://twitter.com/', '').replace('http://www.twitter.com/', '')\n p.url = old_account[5]\n p.save()\n \n elif old_account[1] == 'GOOGLE':\n p, created=GfcProfile.objects.get_or_create(uid=old_account[2],user=user)\n p.save() \n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_users_accounts", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 125 }, { "content": " def sync_tiny_playlist(self,old):\n print \"Migrating tiny playlist ...\"\n prog = ProgressBar(0, self.count_table(old, 'users_likedSongs'), 77, mode='fixed')\n\n old.execute('select ls.userId, s.title, a.name from users_likedSongs ls left join songs s on s.id = ls.songId left join artists a on a.id = s.artistId where s.artistId = 0')\n for old_liked in old.fetchall():\n if old_liked[0] == 0:\n continue\n try:\n user = self.get_user(old_liked[0])\n except User.DoesNotExist:\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()\n continue\n\n if not old_liked[1]:\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()\n continue\n\n artist_name = old_liked[2]\n if not artist_name:\n artist_name = 'YouTube'\n\n try:\n artist = Artist.objects.get(name__iexact=artist_name)\n except Artist.DoesNotExist:\n artist = Artist(name=artist_name)\n artist.save()\n\n try:\n track = Track.objects.get(name__iexact=old_liked[1], artist=artist)\n except Track.DoesNotExist:\n track = Track(artist=artist, name=old_liked[1])\n track.save()\n \n try:\n user.playlistprofile.tiny_playlist.tracks.add(track)\n except PlaylistProfile.DoesNotExist:\n user.save()\n user.playlistprofile.tiny_playlist.tracks.add(track)\n\n # todo: user old_liked[2] timestamp to correct the action\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_tiny_playlist", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 208 }, { "content": " def sync_users_fans(self,old):\n print \"Migrating users activities ...\"\n prog = ProgressBar(0, self.count_table(old, 'users'), 77, mode='fixed')\n\n old.execute('select * from users_activities where type=9')\n for old_activity in old.fetchall():\n user = self.get_user(old_activity[1])\n\n if old_activity[5] == 9:\n artist = Artist.objects.get(pk=old_activity[6])\n artist.fans.add(user.playlistprofile)\n else:\n print 'fail'\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_users_fans", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 258 }, { "content": " def sync_artists(self, old):\n print \"Migrating artists ...\"\n prog = ProgressBar(0, self.count_table(old, 'artists_fans'), 77, mode='fixed')\n\n old.execute('select userId, artistId, name from artists_fans af left join artists a on a.id = af.artistId')\n for old_activity in old.fetchall():\n # skip empty artist names\n if not old_activity[2]: continue\n\n try:\n artist = Artist.objects.get(name__iexact=old_activity[2])\n except Artist.DoesNotExist:\n artist = Artist(name=old_activity[2])\n artist.save()\n\n if not artist.image_small:\n # set the name for lastfm to find\n artist.name = old_activity[2]\n artist.lastfm_get_info()\n # override the lastfm corrected name in favor of pln validated\n # name\n artist.name = old_activity[2]\n artist.save()\n \n try:\n user = self.get_user(old_activity[0])\n except User.DoesNotExist:\n continue\n \n artist.fans.add(user.playlistprofile)\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_artists", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 276 }, { "content": " def sync_playlists(self, old):\n print \"Migrating playlists ...\"\n prog = ProgressBar(0, self.count_table(old, 'playlists'), 77, mode='fixed')\n\n old.execute('select id, name, played, published, createdBy from playlists')\n for old_playlist in old.fetchall():\n try:\n playlist = Playlist.objects.get(id=old_playlist[0])\n except Playlist.DoesNotExist:\n playlist = Playlist(id=old_playlist[0])\n\n playlist.name = old_playlist[1]\n playlist.play_counter = old_playlist[2]\n playlist.creation_datetime = old_playlist[3] or datetime.datetime.now()\n playlist.creation_user = self.get_user(old_playlist[4])\n\n old.execute('''\nselect \n pc.categoryId\nfrom playlists_categories pc\nwhere\n pc.playlistId = %s\n''' % int(playlist.pk))\n\n for old_cat in old.fetchall():\n # skipping more dead relations weee\n if not old_cat[0]:\n continue\n playlist.category = PlaylistCategory.objects.get(pk=old_cat[0])\n\n playlist.save()\n\n old.execute('''\nselect \n userId \nfrom users_bookmarkedPlaylists\nwhere\n playlistId = %s\n''' % int(playlist.pk))\n\n for old_fan in old.fetchall():\n # skipping more dead relations weee\n if not old_fan[0]: continue\n\n fan = self.get_user(old_fan[0])\n playlist.fans.add(fan.playlistprofile)\n\n playlist.fans_count = playlist.fans.count()\n\n old.execute('''\nselect \n t.name \nfrom playlists_tags pt\nleft join tags t on t.id = pt.tagId \nwhere\npt.playlistId = %s\n''' % int(playlist.pk))\n playlist.tags = ','.join([i[0] for i in old.fetchall()])\n playlist.save()\n\n\n old.execute('select ps.songId, s.title, a.name from playlists_songs ps left join songs s on ps.songId = s.id left join artists a on a.id = s.artistId where ps.playlistId = %s and s.artistId = 0' % int(playlist.pk))\n for old_song in old.fetchall():\n # skipping more dead relations weee\n if not old_song[0]:\n continue\n \n artist_name = old_song[2]\n if not artist_name:\n artist_name = 'YouTube'\n\n try:\n artist = Artist.objects.get(name__iexact=artist_name)\n except Artist.DoesNotExist:\n artist = Artist(name=artist_name)\n artist.save()\n\n try:\n track = Track.objects.get(name__iexact=old_song[1], artist=artist)\n except Track.DoesNotExist:\n track = Track(artist=artist, name=old_song[1])\n track.save()\n\n playlist.tracks.add(track)\n\n playlist.tracks_count = playlist.tracks.count()\n playlist.save()\n \n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_playlists", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 311 }, { "content": " def sync_tracks(self, old):\n print \"Migrating tracks ...\"\n prog = ProgressBar(0, self.count_table(old, 'songs'), 77, mode='fixed')\n\n old.execute('''\nselect\n s.id,\n s.title, \n s.played, \n ys.youtubeId, \n a.id as artist_id,\n a.name,\n ys.bugs\nfrom songs s \nleft join youtubeSongs ys on ys.songId = s.id \nleft join artists a on a.id = s.artistId\nwhere s.artistId = 0\n ''')\n for old_track in old.fetchall():\n # this bugs for some reason\n # artist, created = Artist.objects.get_or_create(name__iexact=old_track[5])\n try:\n artist = Artist.objects.get(name__iexact=old_track[5])\n except Artist.DoesNotExist:\n artist = Artist(name=old_track[5])\n artist.save()\n try:\n track = Track.objects.get(name__iexact=old_track[1])\n except Track.DoesNotExist:\n track = Track(name=old_track[1], artist=artist)\n\n track.play_counter = old_track[2]\n track.youtube_id = old_track[3]\n track.youtube_bugs = old_track[6]\n\n track.save()\n\n prog.increment_amount()\n print prog, '\\r',\n sys.stdout.flush()", "metadata": "root.Command.sync_tracks", "header": "['class', 'Command', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 404 } ]
[ { "span": "from django.core.management.base import BaseCommand, CommandError", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 65 }, { "span": "import gfc", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "simplejson_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "management_", "._", "base_", "import_", "Base", "Command_", ",_", "Command", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "acts", "tream_", "._", "models_", "import_", "follow_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "signals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "jp", "ic_", "._", "slug", "hi", "fi_", "import_", "slug", "hi", "fi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "jp", "ic_", "._", "progressbar_", "import_", "Progres", "s", "Bar_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "playlist_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "music_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gf", "c_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "social", "registration_", "._", "models_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gf", "c_", "\\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_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "'", "n", "/", "a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "help_", "=_", "'", "import", "s", " ", "dataset", " ", "from", " ", "previ", "ous", " ", "structure", "'_", "\\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\\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\\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_", "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 ", " _", "backend_", "=_", "db_", "._", "load", "\\u", "backend_", "(_", "'", "mysql", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "=_", "backend_", "._", "Databa", "se", "Wrapper_", "(_", "{_", "'", "NAME", "'_", ":_", "'", "playl", "ist", "pno", "w", "'_", ",_", "'", "USER", "'_", ":_", "'", "root", "'_", ",_", "'", "PASS", "WORD", "'_", ":_", "'", "Ys", "D", "9c", "6", "WJ", "'_", ",_", "'", "HOST", "'_", ":_", "'", "local", "host", "'_", ",_", "'", "PORT", "'_", ":_", "'", "3306", "'_", ",_", "'", "OPTION", "S", "'_", ":_", "''_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old_", "=_", "conn_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "old", "\\u", "root", "\\u", "ids_", "=_", "(_", "175", "319", "_", ",_", "574", "88_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "signals_", "._", "pre", "\\u", "save_", "._", "disconnect_", "(_", "your", "playl", "ist", "\\u", "bookmark", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "m2", "m", "\\u", "changed_", "._", "disconnect_", "(_", "update", "\\u", "counts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "post", "\\u", "save_", "._", "disconnect_", "(_", "new", "\\u", "follower", "_", ",_", "sender_", "=_", "Follow", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "post", "\\u", "save_", "._", "disconnect_", "(_", "new", "\\u", "follow_", ",_", "sender_", "=_", "Follow", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "post", "\\u", "save_", "._", "disconnect_", "(_", "playl", "ist", "\\u", "create", "\\u", "activity_", ",_", "sender_", "=_", "Playlist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "m2", "m", "\\u", "changed_", "._", "disconnect_", "(_", "last", "\\u", "playlist_", ",_", "sender_", "=_", "Playlist_", "._", "tracks_", "._", "through_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "pre", "\\u", "save_", "._", "disconnect_", "(_", "get", "\\u", "info", "\\u", "if", "\\u", "no", "\\u", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "m2", "m", "\\u", "changed_", "._", "disconnect_", "(_", "update", "\\u", "fan", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "users", "\\u", "account", "s", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "followers", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "friends", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "categor", "ies", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "tracks", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "sync", "\\u", "playlists_", "(_", "old_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "tiny", "\\u", "playl", "ist", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "sync", "\\u", "artist", "s", "(", "old", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "user_", "(_", "self_", ",_", "pk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pk_", "in_", "self_", "._", "old", "\\u", "root", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "User_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "settings_", "._", "ROO", "T", "\\u", "USER", "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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "User_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "User_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "User_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "settings_", "._", "ROO", "T", "\\u", "USER", "ID_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "count", "\\u", "table_", "(_", "self_", ",_", "old_", ",_", "table_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "old_", "._", "execute_", "(_", "'", "select", " ", "count", "(*", ")", " ", "from", " ", "%", "s", "'_", "%_", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "old_", "._", "fetchone_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sync", "\\u", "friends_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "friends", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "users", "\\u", "friends", "\\u", "v2", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "users", "\\u", "friends", "\\u", "v2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "friend_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "friend_", "[_", "0_", "]_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "old", "\\u", "friend_", "[_", "1_", "]_", ":_", "continue_", "\\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 ", " _", "user1_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "friend_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user2_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "friend_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "follow_", "(_", "user1_", ",_", "user2_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "follow_", "(_", "user2_", ",_", "user1_", ",_", "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 ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "followers", "_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "followers", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "users", "\\u", "followers", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "users", "\\u", "followers", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "follower", "_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "follower", "_", "[_", "0_", "]_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "old", "\\u", "follower", "_", "[_", "1_", "]_", ":_", "continue_", "\\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 ", " _", "user_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "follower", "_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "follower", "_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "follower", "_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "follow_", "(_", "follower", "_", ",_", "user_", ",_", "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 ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "categories_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "categor", "ies", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "categor", "ies", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "categor", "ies", " ", "order", " ", "by", " ", "parent", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "category_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "category_", ",_", "created_", "=_", "Play", "list", "Category_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk_", "=_", "old", "\\u", "category_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "._", "name_", "=_", "old", "\\u", "category_", "[_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "category_", "[_", "2_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "category_", "._", "parent_", ",_", "pcr", "eat", "ed_", "=_", "Play", "list", "Category_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk_", "=_", "old", "\\u", "category_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "._", "parent_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "users", "\\u", "accounts_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "users", " ", "account", "s", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "users", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'''", "\\", "10", ";", " ", " ", " ", " ", "select", " ", "\\", "10", ";", " ", " ", " ", " ", "u", ".", "id", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "u", ".", "name", ",", "\\", "10", ";", " ", " ", " ", " ", "ue", ".", "email", ",", "\\", "10", ";", " ", " ", " ", " ", "ua", ".", "account", "Locat", "ion", ",", "\\", "10", ";", " ", " ", " ", " ", "ua", ".", "account", "Ava", "tar", ",", "\\", "10", ";", " ", " ", " ", " ", "up", ".", "pts", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "users", " ", "u", " ", "\\", "10", ";", " ", " ", " ", " ", "left", " ", "join", " ", "users", "\\u", "email", "s", " ", "ue", " ", "on", " ", "ue", ".", "user", "Id", " ", "=", " ", "u", ".", "id", "\\", "10", ";", " ", " ", " ", " ", "left", " ", "join", " ", "users", "\\u", "account", "s", " ", "ua", " ", "on", " ", "ua", ".", "user", "Id", " ", "=", " ", "u", ".", "id", "\\", "10", ";", " ", " ", " ", " ", "left", " ", "join", " ", "users", "\\u", "pts", " ", "up", " ", "on", " ", "up", ".", "id", "User", " ", "=", " ", "u", ".", "id", "\\", "10", ";", " ", " ", " ", " ", "'''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "user_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", "ping", " ", "the", " ", "couple", " ", "of", " ", "nona", "mes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "user_", "[_", "1_", "]_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "old", "\\u", "user_", "[_", "0_", "]_", "in_", "self_", "._", "old", "\\u", "root", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "settings_", "._", "ROO", "T", "\\u", "USER", "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 ", " _", "user_", ",_", "created_", "=_", "User_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "pk_", "=_", "old", "\\u", "user_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "username_", "=_", "slug", "hi", "fi_", "(_", "old", "\\u", "user_", "[_", "1_", "]_", ")_", "[_", ":_", "30_", "]_", "or_", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "User_", "._", "objects_", "._", "filter_", "(_", "username_", "=_", "user_", "._", "username_", ")_", "._", "exclude_", "(_", "pk_", "=_", "user_", "._", "pk_", ")_", "._", "count_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "._", "username_", "=_", "'%", "s", "%", "s", "'_", "%_", "(_", "slug", "hi", "fi_", "(_", "old", "\\u", "user_", "[_", "1_", "]_", ")_", "[_", ":_", "28_", "]_", ",_", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user_", "._", "email_", "=_", "old", "\\u", "user_", "[_", "2_", "]_", "or_", "'", "no", "@", "email", ".", "com", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "first", "\\u", "name_", "=_", "old", "\\u", "user_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "._", "playl", "ist", "profile_", "._", "points_", "=_", "old", "\\u", "user_", "[_", "5_", "]_", "or_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "user_", "[_", "3_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "._", "playl", "ist", "profile_", "._", "user", "\\u", "location_", "=_", "old", "\\u", "user_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "old", "\\u", "user_", "[_", "4_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "._", "playl", "ist", "profile_", "._", "avat", "ar", "\\u", "url_", "=_", "old", "\\u", "user_", "[_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user_", "._", "playl", "ist", "profile_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "users", "\\u", "account", "s", " ", "where", " ", "user", "Id", " ", "=", " ", "'_", "+_", "str_", "(_", "old", "\\u", "user_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "account_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "old", "\\u", "account_", "[_", "1_", "]_", "==_", "'", "FACE", "BOOK", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "p_", ",_", "created_", "=_", "Face", "book", "Profile_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "uid_", "=_", "old", "\\u", "account_", "[_", "2_", "]_", ",_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "upstream_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "filename_", ",_", "message_", "=_", "urllib_", "._", "urlretrieve_", "(_", "'", "https", "://", "graph", ".", "facebook", ".", "com", "/", "%", "s", "'_", "%_", "old", "\\u", "account_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "=_", "open_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upstream_", "=_", "simplejson_", "._", "load_", "(_", "fp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "upstream_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "p_", "._", "nick_", "=_", "upstream_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "link", "'_", "in_", "upstream_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "p_", "._", "url_", "=_", "upstream_", "[_", "'", "link", "'_", "]_", "\\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 ", " ", " _", "p_", "._", "url_", "=_", "'", "http", "://", "www", ".", "facebook", ".", "com", "/", "profile", ".", "php", "?", "id", "=", "%", "s", "'_", "%_", "old", "\\u", "account_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "old", "\\u", "account_", "[_", "1_", "]_", "==_", "'", "TWITTER", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "p_", ",_", "created_", "=_", "Twit", "ter", "Profile_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "twit", "ter", "\\u", "id_", "=_", "old", "\\u", "account_", "[_", "2_", "]_", ",_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "twit", "ter", "\\u", "token", "s", " ", "where", " ", "twit", "ter", "User", "Id", " ", "=", " ", "\"%", "s", "\"'_", "%_", "old", "\\u", "account_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "profile_", "=_", "old_", "._", "fetchone_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "profile_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "p_", "._", "access", "\\u", "token_", "=_", "old", "\\u", "profile_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "token", "\\u", "secret_", "=_", "old", "\\u", "profile_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p_", "._", "nick_", "=_", "old", "\\u", "account_", "[_", "5_", "]_", "._", "replace_", "(_", "'", "http", "://", "twit", "ter", ".", "com", "/'_", ",_", "''_", ")_", "._", "replace_", "(_", "'", "http", "://", "www", ".", "twit", "ter", ".", "com", "/'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "url_", "=_", "old", "\\u", "account_", "[_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "old", "\\u", "account_", "[_", "1_", "]_", "==_", "'", "GO", "OG", "LE", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "p_", ",_", "created_", "=_", "Gf", "c", "Profile_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "uid_", "=_", "old", "\\u", "account_", "[_", "2_", "]_", ",_", "user_", "=_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "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_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "tiny", "\\u", "playlist_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "tiny", " ", "playl", "ist", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "users", "\\u", "like", "d", "Son", "gs", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "ls", ".", "user", "Id", ",", " ", "s", ".", "title", ",", " ", "a", ".", "name", " ", "from", " ", "users", "\\u", "like", "d", "Son", "gs", " ", "ls", " ", "left", " ", "join", " ", "songs", " ", "s", " ", "on", " ", "s", ".", "id", " ", "=", " ", "ls", ".", "song", "Id", " ", "left", " ", "join", " ", "artist", "s", " ", "a", " ", "on", " ", "a", ".", "id", " ", "=", " ", "s", ".", "artist", "Id", " ", "where", " ", "s", ".", "artist", "Id", " ", "=", " ", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "like", "d_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "old", "\\u", "like", "d_", "[_", "0_", "]_", "==_", "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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "like", "d_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "User_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\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_", "if_", "not_", "old", "\\u", "like", "d_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\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_", "artist", "\\u", "name_", "=_", "old", "\\u", "like", "d_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "artist", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist", "\\u", "name_", "=_", "'", "You", "Tu", "be", "'_", "\\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 ", " _", "artist_", "=_", "Artist_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "artist", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Artist_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist_", "=_", "Artist_", "(_", "name_", "=_", "artist", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "save_", "(_", ")_", "\\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 ", " _", "track_", "=_", "Track_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "old", "\\u", "like", "d_", "[_", "1_", "]_", ",_", "artist_", "=_", "artist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Track_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "track_", "=_", "Track_", "(_", "artist_", "=_", "artist_", ",_", "name_", "=_", "old", "\\u", "like", "d_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "._", "save_", "(_", ")_", "\\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 ", " _", "user_", "._", "playl", "ist", "profile_", "._", "tiny", "\\u", "playlist_", "._", "tracks_", "._", "add_", "(_", "track_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Play", "list", "Profile_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "._", "playl", "ist", "profile_", "._", "tiny", "\\u", "playlist_", "._", "tracks_", "._", "add_", "(_", "track_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "todo", ":", " ", "user", " ", "old", "\\u", "like", "d", "[", "2", "]", " ", "timestamp", " ", "to", " ", "correct", " ", "the", " ", "action_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "users", "\\u", "fan", "s_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "users", " ", "activit", "ies", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "users", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "*", " ", "from", " ", "users", "\\u", "activit", "ies", " ", "where", " ", "type", "=", "9", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "activity_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "activity_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "old", "\\u", "activity_", "[_", "5_", "]_", "==_", "9_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist_", "=_", "Artist_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "old", "\\u", "activity_", "[_", "6_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "fan", "s_", "._", "add_", "(_", "user_", "._", "playl", "ist", "profile_", ")_", "\\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_", "'", "fail", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "artists_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "artist", "s", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "artist", "s", "\\u", "fan", "s", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "user", "Id", ",", " ", "artist", "Id", ",", " ", "name", " ", "from", " ", "artist", "s", "\\u", "fan", "s", " ", "af", " ", "left", " ", "join", " ", "artist", "s", " ", "a", " ", "on", " ", "a", ".", "id", " ", "=", " ", "af", ".", "artist", "Id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "activity_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", " ", "empty", " ", "artist", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "activity_", "[_", "2_", "]_", ":_", "continue_", "\\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 ", " _", "artist_", "=_", "Artist_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "old", "\\u", "activity_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Artist_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist_", "=_", "Artist_", "(_", "name_", "=_", "old", "\\u", "activity_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "artist_", "._", "image", "\\u", "small_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "the", " ", "name", " ", "for", " ", "lastf", "m", " ", "to", " ", "find_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist_", "._", "name_", "=_", "old", "\\u", "activity_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "lastf", "m", "\\u", "get", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "override", " ", "the", " ", "lastf", "m", " ", "corrected", " ", "name", " ", "in", " ", "fav", "or", " ", "of", " ", "pl", "n", " ", "validated_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "artist_", "._", "name_", "=_", "old", "\\u", "activity_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "save_", "(_", ")_", "\\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 ", " _", "user_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "activity_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "User_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "artist_", "._", "fan", "s_", "._", "add_", "(_", "user_", "._", "playl", "ist", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "playlists_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "playl", "ists", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "playl", "ists", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "id", ",", " ", "name", ",", " ", "played", ",", " ", "publi", "shed", ",", " ", "created", "By", " ", "from", " ", "playl", "ists", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "playlist_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\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 ", " _", "playlist_", "=_", "Playlist_", "._", "objects_", "._", "get_", "(_", "id_", "=_", "old", "\\u", "playlist_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Playlist_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "playlist_", "=_", "Playlist_", "(_", "id_", "=_", "old", "\\u", "playlist_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "playlist_", "._", "name_", "=_", "old", "\\u", "playlist_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "play", "\\u", "counter_", "=_", "old", "\\u", "playlist_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "creati", "on", "\\u", "datetime_", "=_", "old", "\\u", "playlist_", "[_", "3_", "]_", "or_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "creati", "on", "\\u", "user_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "playlist_", "[_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'''", "\\", "10", ";", "select", " ", "\\", "10", ";", " ", " ", " ", " ", "pc", ".", "category", "Id", "\\", "10", ";", "from", " ", "playl", "ists", "\\u", "categor", "ies", " ", "pc", "\\", "10", ";", "where", "\\", "10", ";", " ", " ", " ", " ", "pc", ".", "playl", "ist", "Id", " ", "=", " ", "%", "s", "\\", "10", ";'", "''_", "%_", "int_", "(_", "playlist_", "._", "pk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "old", "\\u", "cat_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", "ping", " ", "more", " ", "dead", " ", "relation", "s", " ", "wee", "e_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "cat_", "[_", "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_", "playlist_", "._", "category_", "=_", "Play", "list", "Category_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "old", "\\u", "cat_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "playlist_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'''", "\\", "10", ";", "select", " ", "\\", "10", ";", " ", " ", " ", " ", "user", "Id", " ", "\\", "10", ";", "from", " ", "users", "\\u", "bookmark", "ed", "Play", "lists", "\\", "10", ";", "where", "\\", "10", ";", " ", " ", " ", " ", "playl", "ist", "Id", " ", "=", " ", "%", "s", "\\", "10", ";'", "''_", "%_", "int_", "(_", "playlist_", "._", "pk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "old", "\\u", "fan", "_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", "ping", " ", "more", " ", "dead", " ", "relation", "s", " ", "wee", "e_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "fan", "_", "[_", "0_", "]_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fan", "_", "=_", "self_", "._", "get", "\\u", "user_", "(_", "old", "\\u", "fan", "_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "fan", "s_", "._", "add_", "(_", "fan", "_", "._", "playl", "ist", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "playlist_", "._", "fan", "s", "\\u", "count_", "=_", "playlist_", "._", "fan", "s_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'''", "\\", "10", ";", "select", " ", "\\", "10", ";", " ", " ", " ", " ", "t", ".", "name", " ", "\\", "10", ";", "from", " ", "playl", "ists", "\\u", "tags", " ", "pt", "\\", "10", ";", "left", " ", "join", " ", "tags", " ", "t", " ", "on", " ", "t", ".", "id", " ", "=", " ", "pt", ".", "tag", "Id", " ", "\\", "10", ";", "where", "\\", "10", ";", "pt", ".", "playl", "ist", "Id", " ", "=", " ", "%", "s", "\\", "10", ";'", "''_", "%_", "int_", "(_", "playlist_", "._", "pk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "tags_", "=_", "','_", "._", "join_", "(_", "[_", "i_", "[_", "0_", "]_", "for_", "i_", "in_", "old_", "._", "fetchall_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'", "select", " ", "ps", ".", "song", "Id", ",", " ", "s", ".", "title", ",", " ", "a", ".", "name", " ", "from", " ", "playl", "ists", "\\u", "songs", " ", "ps", " ", "left", " ", "join", " ", "songs", " ", "s", " ", "on", " ", "ps", ".", "song", "Id", " ", "=", " ", "s", ".", "id", " ", "left", " ", "join", " ", "artist", "s", " ", "a", " ", "on", " ", "a", ".", "id", " ", "=", " ", "s", ".", "artist", "Id", " ", "where", " ", "ps", ".", "playl", "ist", "Id", " ", "=", " ", "%", "s", " ", "and", " ", "s", ".", "artist", "Id", " ", "=", " ", "0", "'_", "%_", "int_", "(_", "playlist_", "._", "pk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "song_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "skip", "ping", " ", "more", " ", "dead", " ", "relation", "s", " ", "wee", "e_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "old", "\\u", "song_", "[_", "0_", "]_", ":_", "\\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_", "artist", "\\u", "name_", "=_", "old", "\\u", "song_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "artist", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "artist", "\\u", "name_", "=_", "'", "You", "Tu", "be", "'_", "\\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 ", " ", "_", "artist_", "=_", "Artist_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "artist", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Artist_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "artist_", "=_", "Artist_", "(_", "name_", "=_", "artist", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "save_", "(_", ")_", "\\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 ", " ", "_", "track_", "=_", "Track_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "old", "\\u", "song_", "[_", "1_", "]_", ",_", "artist_", "=_", "artist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Track_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "track_", "=_", "Track_", "(_", "artist_", "=_", "artist_", ",_", "name_", "=_", "old", "\\u", "song_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "playlist_", "._", "tracks_", "._", "add_", "(_", "track_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "playlist_", "._", "tracks", "\\u", "count_", "=_", "playlist_", "._", "tracks_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "playlist_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\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_", "sync", "\\u", "tracks_", "(_", "self_", ",_", "old_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Migrat", "ing", " ", "tracks", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prog_", "=_", "Progres", "s", "Bar_", "(_", "0_", ",_", "self_", "._", "count", "\\u", "table_", "(_", "old_", ",_", "'", "songs", "'_", ")_", ",_", "77_", ",_", "mode_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "old_", "._", "execute_", "(_", "'''", "\\", "10", ";", "select", "\\", "10", ";", " ", " ", " ", " ", "s", ".", "id", ",", "\\", "10", ";", " ", " ", " ", " ", "s", ".", "title", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "s", ".", "played", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "ys", ".", "youtu", "be", "Id", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "a", ".", "id", " ", "as", " ", "artist", "\\u", "id", ",", "\\", "10", ";", " ", " ", " ", " ", "a", ".", "name", ",", "\\", "10", ";", " ", " ", " ", " ", "ys", ".", "bug", "s", "\\", "10", ";", "from", " ", "songs", " ", "s", " ", "\\", "10", ";", "left", " ", "join", " ", "youtu", "be", "Son", "gs", " ", "ys", " ", "on", " ", "ys", ".", "song", "Id", " ", "=", " ", "s", ".", "id", " ", "\\", "10", ";", "left", " ", "join", " ", "artist", "s", " ", "a", " ", "on", " ", "a", ".", "id", " ", "=", " ", "s", ".", "artist", "Id", "\\", "10", ";", "where", " ", "s", ".", "artist", "Id", " ", "=", " ", "0", "\\", "10", ";", " ", " ", " ", " ", "'''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "old", "\\u", "track_", "in_", "old_", "._", "fetchall_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "bug", "s", " ", "for", " ", "some", " ", "reason_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "artist", ",", " ", "created", " ", "=", " ", "Arti", "st", ".", "object", "s", ".", "get", "\\u", "or", "\\u", "create", "(", "name", "\\u\\u", "iex", "act", "=", "old", "\\u", "track", "[", "5", "])", "_", "\\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 ", " _", "artist_", "=_", "Artist_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "old", "\\u", "track_", "[_", "5_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Artist_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "artist_", "=_", "Artist_", "(_", "name_", "=_", "old", "\\u", "track_", "[_", "5_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "artist_", "._", "save_", "(_", ")_", "\\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 ", " _", "track_", "=_", "Track_", "._", "objects_", "._", "get_", "(_", "name", "\\u\\u", "iex", "act_", "=_", "old", "\\u", "track_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Track_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "track_", "=_", "Track_", "(_", "name_", "=_", "old", "\\u", "track_", "[_", "1_", "]_", ",_", "artist_", "=_", "artist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "track_", "._", "play", "\\u", "counter_", "=_", "old", "\\u", "track_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "._", "youtu", "be", "\\u", "id_", "=_", "old", "\\u", "track_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "track_", "._", "youtu", "be", "\\u", "bugs_", "=_", "old", "\\u", "track_", "[_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "track_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prog_", "._", "increment", "\\u", "amount_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "prog_", ",_", "'\\\\", "r", "'_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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,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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 ]
Except block handles 'BaseException'
RDFLib/rdflib/rdflib/tools/rdf2dot.py
[ { "content": "def rdf2dot(g, stream, opts={}):\n \"\"\"\n Convert the RDF graph to DOT\n writes the dot output to the stream\n \"\"\"\n\n fields = collections.defaultdict(set)\n nodes = {}\n\n def node(x):\n\n if x not in nodes:\n nodes[x] = \"node%d\" % len(nodes)\n return nodes[x]\n\n def label(x, g):\n\n for labelProp in LABEL_PROPERTIES:\n l = g.value(x, labelProp)\n if l:\n return l\n\n try:\n return g.namespace_manager.compute_qname(x)[2]\n except:\n return x\n\n def formatliteral(l, g):\n v = cgi.escape(l)\n if l.datatype:\n return u'&quot;%s&quot;^^%s' % (v, qname(l.datatype, g))\n elif l.language:\n return u'&quot;%s&quot;@%s' % (v, l.language)\n return u'&quot;%s&quot;' % v\n\n def qname(x, g):\n try:\n q = g.compute_qname(x)\n return q[0] + \":\" + q[2]\n except:\n return x\n\n def color(p):\n return \"BLACK\"\n\n stream.write(u\"digraph { \\n node [ fontname=\\\"DejaVu Sans\\\" ] ; \\n\")\n\n for s, p, o in g:\n sn = node(s)\n if p == rdflib.RDFS.label:\n continue\n if isinstance(o, (rdflib.URIRef, rdflib.BNode)):\n on = node(o)\n opstr = u\"\\t%s -> %s [ color=%s, label=< <font point-size='10' \" + \\\n u\"color='#336633'>%s</font> > ] ;\\n\"\n stream.write(opstr % (sn, on, color(p), qname(p, g)))\n else:\n fields[sn].add((qname(p, g), formatliteral(o, g)))\n\n for u, n in nodes.items():\n stream.write(u\"# %s %s\\n\" % (u, n))\n f = [u\"<tr><td align='left'>%s</td><td align='left'>%s</td></tr>\" %\n x for x in sorted(fields[n])]\n opstr = u\"%s [ shape=none, color=%s label=< <table color='#666666'\" + \\\n u\" cellborder='0' cellspacing='0' border='1'><tr>\" + \\\n u\"<td colspan='2' bgcolor='grey'><B>%s</B></td></tr><tr>\" + \\\n u\"<td href='%s' bgcolor='#eeeeee' colspan='2'>\" + \\\n u\"<font point-size='10' color='#6666ff'>%s</font></td>\" + \\\n u\"</tr>%s</table> > ] \\n\"\n stream.write(opstr % (n, NODECOLOR, label(u, g), u, u, u\"\".join(f)))\n\n stream.write(\"}\\n\")", "metadata": "root.rdf2dot", "header": "['module', '___EOS___']", "index": 43 } ]
[ { "span": "except:", "start_line": 67, "start_column": 8, "end_line": 67, "end_column": 15 }, { "span": "except:", "start_line": 82, "start_column": 8, "end_line": 82, "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_", "def_", "rdf", "2d", "ot_", "(_", "g_", ",_", "stream_", ",_", "opts_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Convert", " ", "the", " ", "RDF", " ", "graph", " ", "to", " ", "DOT", "\\", "10", ";", " ", " ", " ", " ", "writes", " ", "the", " ", "dot", " ", "output", " ", "to", " ", "the", " ", "stream", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fields_", "=_", "collections_", "._", "defaultdict_", "(_", "set_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "node_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "x_", "not_", "in_", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "[_", "x_", "]_", "=_", "\"", "node", "%", "d", "\"_", "%_", "len_", "(_", "nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "nodes_", "[_", "x_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "label_", "(_", "x_", ",_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "label", "Prop_", "in_", "LAB", "EL", "\\u", "PROPERTIES_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "g_", "._", "value_", "(_", "x_", ",_", "label", "Prop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "l_", "\\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 ", " _", "return_", "g_", "._", "namespace", "\\u", "manager_", "._", "compute", "\\u", "qname_", "(_", "x_", ")_", "[_", "2_", "]_", "\\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_", "x_", "\\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_", "format", "literal_", "(_", "l_", ",_", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "cgi_", "._", "escape_", "(_", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "l_", "._", "datatype_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "u", "'&", "quot", ";", "%", "s", "&", "quot", ";", "^", "^", "%", "s", "'_", "%_", "(_", "v_", ",_", "qname_", "(_", "l_", "._", "datatype_", ",_", "g_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "l_", "._", "language_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "u", "'&", "quot", ";", "%", "s", "&", "quot", ";", "@", "%", "s", "'_", "%_", "(_", "v_", ",_", "l_", "._", "language_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "u", "'&", "quot", ";", "%", "s", "&", "quot", ";'_", "%_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "qname_", "(_", "x_", ",_", "g_", ")_", ":_", "\\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 ", " _", "q_", "=_", "g_", "._", "compute", "\\u", "qname_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "q_", "[_", "0_", "]_", "+_", "\":\"_", "+_", "q_", "[_", "2_", "]_", "\\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_", "x_", "\\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_", "color_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "BLACK", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stream_", "._", "write_", "(_", "u", "\"", "digraph", " ", "{", " ", "\\\\", "n", " ", "node", " ", "[", " ", "font", "name", "=\\\\\"", "De", "ja", "Vu", " ", "San", "s", "\\\\\"", " ", "]", " ", ";", " ", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "s_", ",_", "p_", ",_", "o_", "in_", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sn_", "=_", "node_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "p_", "==_", "rdflib_", "._", "RDF", "S_", "._", "label_", ":_", "\\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_", "if_", "isinstance_", "(_", "o_", ",_", "(_", "rdflib_", "._", "URI", "Ref_", ",_", "rdflib_", "._", "BN", "ode_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "on_", "=_", "node_", "(_", "o_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ops", "tr_", "=_", "u", "\"\\\\", "t", "%", "s", " ", "->", " ", "%", "s", " ", "[", " ", "color", "=", "%", "s", ",", " ", "label", "=", "<", " ", "<", "font", " ", "point", "-", "size", "='", "10", "'", " ", "\"_", "+_", "u", "\"", "color", "='", "#", "336", "633", "'>", "%", "s", "</", "font", ">", " ", ">", " ", "]", " ", ";\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stream_", "._", "write_", "(_", "ops", "tr_", "%_", "(_", "sn_", ",_", "on_", ",_", "color_", "(_", "p_", ")_", ",_", "qname_", "(_", "p_", ",_", "g_", ")_", ")_", ")_", "\\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 ", " _", "fields_", "[_", "sn_", "]_", "._", "add_", "(_", "(_", "qname_", "(_", "p_", ",_", "g_", ")_", ",_", "format", "literal_", "(_", "o_", ",_", "g_", ")_", ")_", ")_", "\\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_", "u_", ",_", "n_", "in_", "nodes_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stream_", "._", "write_", "(_", "u", "\"#", " ", "%", "s", " ", "%", "s", "\\\\", "n", "\"_", "%_", "(_", "u_", ",_", "n_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "[_", "u", "\"<", "tr", "><", "td", " ", "align", "='", "left", "'>", "%", "s", "</", "td", "><", "td", " ", "align", "='", "left", "'>", "%", "s", "</", "td", "><", "/", "tr", ">\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "for_", "x_", "in_", "sorted_", "(_", "fields_", "[_", "n_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ops", "tr_", "=_", "u", "\"%", "s", " ", "[", " ", "shape", "=", "none", ",", " ", "color", "=", "%", "s", " ", "label", "=", "<", " ", "<", "table", " ", "color", "='", "#", "666666", "'\"_", "+_", "u", "\"", " ", "cell", "border", "='", "0", "'", " ", "cells", "pacing", "='", "0", "'", " ", "border", "='", "1", "'><", "tr", ">\"_", "+_", "u", "\"<", "td", " ", "colsp", "an", "='", "2", "'", " ", "bg", "color", "='", "grey", "'><", "B", ">", "%", "s", "</", "B", "><", "/", "td", "><", "/", "tr", "><", "tr", ">\"_", "+_", "u", "\"<", "td", " ", "href", "='", "%", "s", "'", " ", "bg", "color", "='", "#", "eeee", "ee", "'", " ", "colsp", "an", "='", "2", "'>\"_", "+_", "u", "\"<", "font", " ", "point", "-", "size", "='", "10", "'", " ", "color", "='", "#", "6666", "ff", "'>", "%", "s", "</", "font", "><", "/", "td", ">\"_", "+_", "u", "\"<", "/", "tr", ">", "%", "s", "</", "table", ">", " ", ">", " ", "]", " ", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stream_", "._", "write_", "(_", "ops", "tr_", "%_", "(_", "n_", ",_", "NODE", "COLOR_", ",_", "label_", "(_", "u_", ",_", "g_", ")_", ",_", "u_", ",_", "u_", ",_", "u", "\"\"_", "._", "join_", "(_", "f_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stream_", "._", "write_", "(_", "\"}", "\\\\", "n", "\"_", ")_", "\\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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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 ]
Unused import
cloudmatrix/esky/esky/bootstrap.py
[ { "content": "# Copyright (c) 2009-2010, Cloud Matrix Pty. Ltd.\n# All rights reserved; available under the terms of the BSD License.\n\"\"\"\n\n esky.bootstrap: minimal bootstrapping code for esky\n\nThis module provides the minimal code necessary to bootstrap a frozen\napplication packaged using esky. It checks the base runtime directory to\nfind the most appropriate version of the app and then execvs to the frozen\nexecutable.\n\nThis module must use no modules other than builtins, since the stdlib is\nnot available in the bootstrapping environment. It must also be capable\nof bootstrapping into apps made with older versions of esky, since a partial\nupdate could result in the boostrapper from a new version being forced\nto load an old version.\n\nIf you want to compile your bootstrapping exes into standalone executables,\nthis module must also be written in the \"RPython\" dialect used by the PyPy\ntranslation toolchain.\n\nThe code from this module is always executed in the bootstrapping environment\nbefore any custom bootstrapping code. It provides the following functions for\nuse during the bootstrap process:\n\n Chainloading: execv, chainload\n Filesystem: listdir, exists, basename, dirname, pathjoin\n Version handling: split_app_version, join_app_version, parse_version,\n get_all_versions, get_best_version, is_version_dir,\n is_installed_version_dir, is_uninstalled_version_dir,\n lock_version_dir, unlock_version_dir\n\n\n\"\"\"\n\n\nimport sys\nimport errno\n\ntry:\n ESKY_CONTROL_DIR\nexcept NameError:\n ESKY_CONTROL_DIR = \"esky-files\"\n\ntry:\n ESKY_APPDATA_DIR\nexcept NameError:\n ESKY_APPDATA_DIR = \"appdata\"\n\ntry:\n __esky_name__\nexcept NameError:\n __esky_name__ = \"\"\n\ntry:\n __rpython__\nexcept NameError:\n __rpython__ = False\n\n# RPython doesn't handle SystemExit automatically, so we put the exit code\n# in this global var and catch SystemExit ourselves at the outmost scope.\n_exit_code = [0]\n\n# The os module is not builtin, so we grab what we can from the\n# platform-specific modules and fudge the rest.\nif \"posix\" in sys.builtin_module_names:\n import fcntl\n from posix import listdir, stat, unlink, rename, execv, getcwd, environ\n from posix import open as os_open\n from posix import close as os_close\n SEP = \"/\"\nelif \"nt\" in sys.builtin_module_names:\n fcntl = None\n import nt\n from nt import listdir, stat, unlink, rename, spawnv\n from nt import getcwd, P_WAIT, environ\n from nt import open as os_open\n from nt import close as os_close\n SEP = \"\\\\\"\n # The standard execv terminates the spawning process, which makes\n # it impossible to wait for it. This alternative is waitable, and\n # uses the esky.slaveproc machinery to avoid leaving zombie children.\n # A fake fcntl module which is false, but can fake out RPython\n fcntl = fcntl()\nelse:\n raise RuntimeError(\"unsupported platform: \" + sys.platform)\n\n\nif __rpython__:\n # RPython provides ll hooks for the actual os.environ object, not the\n # one we pulled out of \"nt\" or \"posix\".\n from os import environ\n\n # RPython doesn't have access to the \"sys\" module, so we fake it out.\n # The entry_point function will set these value appropriately.\n _sys = sys\n sys = sys()\n sys.modules[\"sys\"] = sys\n\n # RPython doesn't provide the sorted() builtin, and actually makes sorting\n # quite complicated in general. I can't convince the type annotator to be\n # happy about using their \"listsort\" module, so I'm doing my own using a\n # simple insertion sort. We're only sorting short lists and they always\n # contain (list(str),str), so this should do for now.\n # RPython doesn't provide the \"zfill\" or \"isalnum\" methods on strings.\n # RPython doesn't provide the \"fcntl\" module. Fake it.\n # TODO: implement it using externals\n if fcntl:\n fcntl = fcntl()\nelse:\n # We need to use a compatability wrapper for some string methods missing\n # in RPython, since we can't just add them as methods on the str type.\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_replace_p = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}.get\n\n\n\n\n\n\n_locked_version_dirs = {}\n\n\n\nif __rpython__:\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def isabs(path):\n return (path.startswith(SEP))", "metadata": "root.isabs", "header": "['module', '___EOS___']", "index": 71 }, { "content": " def abspath(path):\n path = pathjoin(getcwd(),path)\n components_in = path.split(SEP)\n components = [components_in[0]]\n for comp in components_in[1:]:\n if not comp or comp == \".\":\n pass\n elif comp == \"..\":\n components.pop()\n else:\n components.append(comp)\n return SEP.join(components)", "metadata": "root.abspath", "header": "['module', '___EOS___']", "index": 73 }, { "content": " def isabs(path):\n if path.startswith(SEP):\n return True\n if len(path) >= 2:\n if path[0].isalpha() and path[1] == \":\":\n return True\n return False", "metadata": "root.isabs", "header": "['module', '___EOS___']", "index": 93 }, { "content": " def abspath(path):\n path = pathjoin(getcwd(),path)\n components_in = path.split(SEP)\n components = [components_in[0]]\n for comp in components_in[1:]:\n if not comp or comp == \".\":\n pass\n elif comp == \"..\":\n components.pop()\n else:\n components.append(comp)\n if path.startswith(SEP + SEP):\n components.insert(0, \"\")\n return SEP.join(components)", "metadata": "root.abspath", "header": "['module', '___EOS___']", "index": 100 }, { "content": " def execv(filename,args):\n # Create an O_TEMPORARY file and pass its name to the slave process.\n # When this master process dies, the file will be deleted and the\n # slave process will know to terminate.\n try:\n tdir = environ[\"TEMP\"]\n except:\n tdir = None\n if tdir:\n try:\n nt.mkdir(pathjoin(tdir,\"esky-slave-procs\"),0600)\n except EnvironmentError:\n pass\n if exists(pathjoin(tdir,\"esky-slave-procs\")):\n flags = nt.O_CREAT|nt.O_EXCL|nt.O_TEMPORARY|nt.O_NOINHERIT\n for i in xrange(10):\n tfilenm = \"slave-%d.%d.txt\" % (nt.getpid(),i,)\n tfilenm = pathjoin(tdir,\"esky-slave-procs\",tfilenm)\n try:\n os_open(tfilenm,flags,0600)\n args.insert(1,tfilenm)\n args.insert(1,\"--esky-slave-proc\")\n break\n except EnvironmentError:\n pass\n # Ensure all arguments are quoted (to allow spaces in paths)\n for i, arg in enumerate(args):\n if arg[0] != \"\\\"\" and args[-1] != \"\\\"\":\n args[i] = \"\\\"{}\\\"\".format(arg)\n res = spawnv(P_WAIT,filename, args)\n _exit_code[0] = res\n raise SystemExit(res)", "metadata": "root.execv", "header": "['module', '___EOS___']", "index": 117 }, { "content": " class fcntl:\n LOCK_SH = 0", "metadata": "root.fcntl", "header": "['module', '___EOS___']", "index": 150 }, { "content": " def flock(self,fd,mode):\n pass", "metadata": "root.fcntl.flock", "header": "['class', 'fcntl', ':', '___EOS___']", "index": 152 }, { "content": " def __nonzero__(self):\n return False", "metadata": "root.fcntl.__nonzero__", "header": "['class', 'fcntl', ':', '___EOS___']", "index": 154 }, { "content": " class sys:\n platform = _sys.platform\n executable = _sys.executable\n argv = _sys.argv\n version_info = _sys.version_info\n modules = {}\n builtin_module_names = _sys.builtin_module_names", "metadata": "root.sys", "header": "['module', '___EOS___']", "index": 169 }, { "content": " def exit(self,code):\n _exit_code[0] = code\n raise SystemExit(code)", "metadata": "root.sys.exit", "header": "['class', 'sys', ':', '___EOS___']", "index": 176 }, { "content": " def exc_info(self):\n return None,None,None", "metadata": "root.sys.exc_info", "header": "['class', 'sys', ':', '___EOS___']", "index": 179 }, { "content": " def _list_gt(l1,l2):\n i = 0\n while i < len(l1) and i < len(l2):\n if l1[i] > l2[i]:\n return True\n if l1[i] < l2[i]:\n return False\n i += 1\n if len(l1) > len(l2):\n return True\n return False", "metadata": "root._list_gt", "header": "['module', '___EOS___']", "index": 189 }, { "content": " def sorted(lst,reverse=False):\n slst = []\n if reverse:\n for item in lst:\n for j in xrange(len(slst)):\n if not _list_gt(slst[j][0],item[0]):\n slst.insert(j,item)\n break \n else:\n slst.append(item)\n else:\n for item in lst:\n for j in xrange(len(slst)):\n if _list_gt(slst[j][0],item[0]):\n slst.insert(j,item)\n break \n else:\n slst.append(item)\n return slst", "metadata": "root.sorted", "header": "['module', '___EOS___']", "index": 200 }, { "content": " def zfill(str,n):\n while len(str) < n:\n str = \"0\" + str\n return str", "metadata": "root.zfill", "header": "['module', '___EOS___']", "index": 220 }, { "content": " def isalnum(str):\n for c in str:\n if not c.isalnum():\n return False\n return True", "metadata": "root.isalnum", "header": "['module', '___EOS___']", "index": 224 }, { "content": " class fcntl:\n LOCK_SH = fcntl.LOCK_SH", "metadata": "root.fcntl", "header": "['module', '___EOS___']", "index": 232 }, { "content": " def flock(self,fd,mode):\n pass", "metadata": "root.fcntl.flock", "header": "['class', 'fcntl', ':', '___EOS___']", "index": 234 }, { "content": " def zfill(str,n):\n return str.zfill(n)", "metadata": "root.zfill", "header": "['module', '___EOS___']", "index": 240 }, { "content": " def isalnum(str):\n return str.isalnum()", "metadata": "root.isalnum", "header": "['module', '___EOS___']", "index": 242 }, { "content": "def pathjoin(*args):\n \"\"\"Local re-implementation of os.path.join.\"\"\"\n path = args[0]\n for arg in list(args[1:]):\n if isabs(arg):\n path = arg\n else:\n while path.endswith(SEP):\n path = path[:-1]\n path = path + SEP + arg\n return path", "metadata": "root.pathjoin", "header": "['module', '___EOS___']", "index": 246 }, { "content": "def basename(p):\n \"\"\"Local re-implementation of os.path.basename.\"\"\"\n return p.split(SEP)[-1]", "metadata": "root.basename", "header": "['module', '___EOS___']", "index": 258 }, { "content": "def dirname(p):\n \"\"\"Local re-implementation of os.path.dirname.\"\"\"\n return SEP.join(p.split(SEP)[:-1])", "metadata": "root.dirname", "header": "['module', '___EOS___']", "index": 262 }, { "content": "def exists(path):\n \"\"\"Local re-implementation of os.path.exists.\"\"\"\n try:\n stat(path)\n except EnvironmentError, e:\n # TODO: how to get the errno under RPython?\n if not __rpython__:\n if e.errno not in (errno.ENOENT,errno.ENOTDIR,errno.ESRCH,):\n raise\n return False\n else:\n return True", "metadata": "root.exists", "header": "['module', '___EOS___']", "index": 266 }, { "content": "def appdir_from_executable(exepath):\n \"\"\"Find the top-level application directory, given sys.executable.\n\n Ordinarily this would simply be the directory containing the executable,\n but when running via a bundle on OSX the executable will be located at\n <appdir>/Contents/MacOS/<exe>.\n \"\"\"\n appdir = dirname(exepath)\n if sys.platform == \"darwin\" and basename(appdir) == \"MacOS\":\n # Looks like we might be in an app bundle.\n appdir = dirname(appdir)\n if basename(appdir) == \"Contents\":\n # Yep, definitely in a bundle\n appdir = dirname(appdir)\n else:\n # Nope, some other crazy scheme\n appdir = dirname(exepath)\n return appdir", "metadata": "root.appdir_from_executable", "header": "['module', '___EOS___']", "index": 279 }, { "content": "def bootstrap():\n \"\"\"Bootstrap an esky frozen app into the newest available version.\n\n This function searches the application directory to find the highest-\n numbered version of the application that is fully installed, then\n chainloads that version of the application.\n \"\"\"\n sys.executable = abspath(sys.executable)\n appdir = appdir_from_executable(sys.executable)\n vsdir = pathjoin(appdir,ESKY_APPDATA_DIR)\n # TODO: remove compatability hook for ESKY_APPDATA_DIR=\"\".\n best_version = None\n try:\n if __esky_name__:\n best_version = get_best_version(vsdir,appname=__esky_name__)\n if best_version is None:\n best_version = get_best_version(vsdir)\n if best_version is None:\n if exists(vsdir):\n raise RuntimeError(\"no usable frozen versions were found\")\n else:\n raise EnvironmentError\n except EnvironmentError:\n if exists(vsdir):\n raise\n vsdir = appdir\n if __esky_name__:\n best_version = get_best_version(vsdir,appname=__esky_name__)\n if best_version is None:\n best_version = get_best_version(vsdir)\n if best_version is None:\n raise RuntimeError(\"no usable frozen versions were found\")\n return chainload(pathjoin(vsdir,best_version))", "metadata": "root.bootstrap", "header": "['module', '___EOS___']", "index": 299 }, { "content": "def chainload(target_dir):\n \"\"\"Load and execute the selected version of an application.\n\n This function replaces the currently-running executable with the equivalent\n executable from the given target directory.\n\n On platforms that support it, this also locks the target directory so that\n it will not be removed by any simultaneously-running instances of the\n application.\n \"\"\"\n try:\n lock_version_dir(target_dir)\n except EnvironmentError:\n # If the bootstrap file is missing, the version is being uninstalled.\n # Our only option is to re-execute ourself and find the new version.\n if exists(dirname(target_dir)):\n bsfile = pathjoin(target_dir,ESKY_CONTROL_DIR)\n bsfile = pathjoin(bsfile,\"bootstrap-manifest.txt\")\n if not exists(bsfile):\n execv(sys.executable,list(sys.argv))\n return\n raise\n else:\n # If all goes well, we can actually launch the target version.\n _chainload(target_dir)", "metadata": "root.chainload", "header": "['module', '___EOS___']", "index": 334 }, { "content": "def get_exe_locations(target_dir):\n \"\"\"Generate possible locations from which to chainload in the target dir.\"\"\"\n # TODO: let this be a generator when not compiling with PyPy, so we can\n # avoid a few stat() calls in the common case.\n locs = []\n appdir = appdir_from_executable(sys.executable)\n # If we're in an appdir, first try to launch from within \"<appname>.app\"\n # directory. We must also try the default scheme for backwards compat.\n if sys.platform == \"darwin\":\n if basename(dirname(sys.executable)) == \"MacOS\":\n if __esky_name__:\n locs.append(pathjoin(target_dir,\n __esky_name__+\".app\",\n sys.executable[len(appdir)+1:]))\n else:\n for nm in listdir(target_dir):\n if nm.endswith(\".app\"):\n locs.append(pathjoin(target_dir,\n nm,\n sys.executable[len(appdir)+1:]))\n # This is the default scheme: the same path as the exe in the appdir.\n locs.append(target_dir + sys.executable[len(appdir):])\n # If sys.executable was a backup file, try using original filename.\n orig_exe = get_original_filename(sys.executable)\n if orig_exe is not None:\n locs.append(target_dir + orig_exe[len(appdir):])\n return locs", "metadata": "root.get_exe_locations", "header": "['module', '___EOS___']", "index": 361 }, { "content": "def verify(target_file):\n \"\"\"Verify the integrity of the given target file.\n\n By default this is a no-op; override it to provide e.g. signature checks.\n \"\"\"\n pass", "metadata": "root.verify", "header": "['module', '___EOS___']", "index": 390 }, { "content": "def _chainload(target_dir):\n \"\"\"Default implementation of the chainload() function.\n\n Specific freezer modules may provide a more efficient, reliable or\n otherwise better version of this function.\n \"\"\"\n exc_type,exc_value,traceback = None,None,None\n for target_exe in get_exe_locations(target_dir):\n verify(target_exe)\n try:\n execv(target_exe,[target_exe] + sys.argv[1:])\n return\n except EnvironmentError, exc_value:\n # Careful, RPython lacks a usable exc_info() function.\n exc_type,_,traceback = sys.exc_info()\n if not __rpython__:\n if exc_value.errno != errno.ENOENT:\n raise\n else:\n if exists(target_exe):\n raise\n else:\n if exc_value is not None:\n if exc_type is not None:\n raise exc_type,exc_value,traceback\n else:\n raise exc_value\n raise RuntimeError(\"couldn't chainload any executables\")", "metadata": "root._chainload", "header": "['module', '___EOS___']", "index": 398 }, { "content": "def get_best_version(appdir,include_partial_installs=False,appname=None):\n \"\"\"Get the best usable version directory from inside the given appdir.\n\n In the common case there is only a single version directory, but failed\n or partial updates can result in several being present. This function\n finds the highest-numbered version that is completely installed.\n \"\"\"\n # Find all potential version directories, sorted by version number.\n candidates = []\n for nm in listdir(appdir):\n (appnm,ver,platform) = split_app_version(nm)\n # If its name didn't parse properly, don't bother looking inside.\n if ver and platform:\n # If we're given a specific name, it must have that name\n if appname is not None and appnm != appname:\n continue\n # We have to pay another stat() call to check if it's active.\n if is_version_dir(pathjoin(appdir,nm)):\n ver = parse_version(ver)\n candidates.append((ver,nm))\n candidates = [c[1] for c in sorted(candidates,reverse=True)]\n # In the (hopefully) common case of no failed updates, we don't need\n # to poke around in the filesystem so we just return asap.\n if not candidates:\n return None\n if len(candidates) == 1:\n return candidates[0]\n if include_partial_installs:\n return candidates[0]\n # If there are several candidate versions, we need to find the best\n # one that is completely installed.\n while candidates:\n nm = candidates.pop(0)\n if is_installed_version_dir(pathjoin(appdir,nm)):\n return nm\n return None", "metadata": "root.get_best_version", "header": "['module', '___EOS___']", "index": 428 }, { "content": "def get_all_versions(appdir,include_partial_installs=False):\n \"\"\"Get a list of all usable version directories inside the given appdir.\n\n The list will be in order from most-recent to least-recent. The head\n of the list will be the same directory as returned by get_best_version.\n \"\"\"\n # Find all potential version directories, sorted by version number.\n candidates = []\n for nm in listdir(appdir):\n (_,ver,platform) = split_app_version(nm)\n if ver and platform:\n if is_version_dir(pathjoin(appdir,nm)):\n ver = parse_version(ver)\n candidates.append((ver,nm))\n candidates = [c[1] for c in sorted(candidates,reverse=True)]\n # Filter out any that are not completely installed.\n if not include_partial_installs:\n i = 0\n while i < len(candidates):\n if not is_installed_version_dir(pathjoin(appdir,candidates[i])):\n del candidates[i]\n else:\n i += 1\n return candidates", "metadata": "root.get_all_versions", "header": "['module', '___EOS___']", "index": 466 }, { "content": "def is_version_dir(vdir):\n \"\"\"Check whether the given directory contains an esky app version.\n\n Currently it only need contain the \"esky-files/bootstrap-mainfest.txt\" file.\n \"\"\"\n if exists(pathjoin(vdir,ESKY_CONTROL_DIR,\"bootstrap-manifest.txt\")):\n return True\n return False", "metadata": "root.is_version_dir", "header": "['module', '___EOS___']", "index": 492 }, { "content": "def is_installed_version_dir(vdir):\n \"\"\"Check whether the given version directory is fully installed.\n\n Currently, a completed installation is indicated by the lack of an\n \"esky-files/bootstrap\" directory.\n \"\"\"\n if not exists(pathjoin(vdir,ESKY_CONTROL_DIR,\"bootstrap\")):\n return True\n return False", "metadata": "root.is_installed_version_dir", "header": "['module', '___EOS___']", "index": 502 }, { "content": "def is_uninstalled_version_dir(vdir):\n \"\"\"Check whether the given version directory is partially uninstalled.\n\n A partially-uninstalled version dir has had the \"bootstrap-manifest.txt\"\n renamed to \"bootstrap-manifest-old.txt\".\n \"\"\"\n if exists(pathjoin(vdir,ESKY_CONTROL_DIR,\"bootstrap-manifest-old.txt\")):\n return True\n return False", "metadata": "root.is_uninstalled_version_dir", "header": "['module', '___EOS___']", "index": 513 }, { "content": "def split_app_version(s):\n \"\"\"Split an app version string to name, version and platform components.\n\n For example, app-name-0.1.2.win32 => (\"app-name\",\"0.1.2\",\"win32\")\n \"\"\"\n bits = s.split(\"-\")\n idx = 1\n while idx < len(bits):\n if bits[idx]:\n if not bits[idx][0].isalpha() or not isalnum(bits[idx]):\n break\n idx += 1\n appname = \"-\".join(bits[:idx])\n bits = \"-\".join(bits[idx:]).split(\".\")\n version = \".\".join(bits[:-1])\n platform = bits[-1]\n return (appname,version,platform)", "metadata": "root.split_app_version", "header": "['module', '___EOS___']", "index": 525 }, { "content": "def join_app_version(appname,version,platform):\n \"\"\"Join an app name, version and platform into a version directory name.\n\n For example, (\"app-name\",\"0.1.2\",\"win32\") => appname-0.1.2.win32\n \"\"\"\n return \"%s-%s.%s\" % (appname,version,platform,)", "metadata": "root.join_app_version", "header": "['module', '___EOS___']", "index": 544 }, { "content": "def parse_version(s):\n \"\"\"Parse a version string into a chronologically-sortable key\n\n This function returns a sequence of strings that compares with the results\n for other versions in a chronologically sensible way. You'd use it to\n compare two version strings like so:\n\n if parse_version(\"1.9.2\") > parse_version(\"1.10.0\"):\n raise RuntimeError(\"what rubbish, that's an older version!\")\n\n This is essentially the parse_version() function from pkg_resources,\n but re-implemented to avoid using modules that may not be available\n during bootstrapping.\n \"\"\"\n parts = []\n for part in _parse_version_parts(s.lower()):\n if part.startswith('*'):\n if part<'*final': # remove '-' before a prerelease tag\n while parts and parts[-1]=='*final-': parts.pop()\n # remove trailing zeros from each series of numeric parts\n while parts and parts[-1]=='00000000':\n parts.pop()\n parts.append(part)\n return parts", "metadata": "root.parse_version", "header": "['module', '___EOS___']", "index": 552 }, { "content": "def _parse_version_parts(s):\n parts = []\n for part in _split_version_components(s):\n part = _replace_p(part,part)\n if not part or part=='.':\n continue\n if part[:1] in '0123456789':\n parts.append(zfill(part,8)) # pad for numeric comparison\n else:\n parts.append('*'+part)\n parts.append('*final') # ensure that alpha/beta/candidate are before final\n return parts", "metadata": "root._parse_version_parts", "header": "['module', '___EOS___']", "index": 579 }, { "content": "def _split_version_components(s):\n \"\"\"Split version string into individual tokens.\n\n pkg_resources does this using a regexp: (\\d+ | [a-z]+ | \\.| -)\n Unfortunately the 're' module isn't in the bootstrap, so we have to do\n an equivalent parse by hand. Forunately, that's pretty easy.\n \"\"\"\n comps = []\n start = 0\n while start < len(s):\n end = start+1\n if s[start].isdigit():\n while end < len(s) and s[end].isdigit():\n end += 1\n elif s[start].isalpha():\n while end < len(s) and s[end].isalpha():\n end += 1\n elif s[start] in (\".\",\"-\"):\n pass\n else:\n while end < len(s) and not (s[end].isdigit() or s[end].isalpha() or s[end] in (\".\",\"-\")):\n end += 1\n comps.append(s[start:end])\n start = end\n return comps", "metadata": "root._split_version_components", "header": "['module', '___EOS___']", "index": 593 }, { "content": "def get_original_filename(backname):\n \"\"\"Given a backup filename, get the original name to which it refers.\n\n This is only really possible if the original file actually exists and\n is not guaranteed to be correct in all cases; but unless you do something\n silly it should work out OK.\n\n If no matching original file is found, None is returned.\n \"\"\"\n filtered = \".\".join([n for n in backname.split(\".\") if n != \"old\"])\n for nm in listdir(dirname(backname)):\n if nm == backname:\n continue\n if filtered == \".\".join([n for n in nm.split(\".\") if n != \"old\"]):\n return pathjoin(dirname(backname),nm)\n return None", "metadata": "root.get_original_filename", "header": "['module', '___EOS___']", "index": 620 }, { "content": "def lock_version_dir(vdir):\n \"\"\"Lock the given version dir so it cannot be uninstalled.\"\"\"\n if sys.platform == \"win32\":\n # On win32, we just hold bootstrap file open for reading.\n # This will prevent it from being renamed during uninstall.\n lockfile = pathjoin(vdir,ESKY_CONTROL_DIR,\"bootstrap-manifest.txt\")\n _locked_version_dirs.setdefault(vdir,[]).append(os_open(lockfile,0,0))\n else:\n # On posix platforms we take a shared flock on esky-files/lockfile.txt.\n # While fcntl.fcntl locks are apparently the new hotness, they have\n # unfortunate semantics that we don't want for this application:\n # * not inherited across fork()\n # * released when closing *any* fd associated with that file\n # fcntl.flock doesn't have these problems, but may fail on NFS.\n # To complicate matters, python sometimes emulates flock with fcntl!\n # We therefore use a separate lock file to avoid unpleasantness.\n lockfile = pathjoin(vdir,ESKY_CONTROL_DIR,\"lockfile.txt\")\n f = os_open(lockfile,0,0)\n _locked_version_dirs.setdefault(vdir,[]).append(f)\n fcntl.flock(f,fcntl.LOCK_SH)", "metadata": "root.lock_version_dir", "header": "['module', '___EOS___']", "index": 640 }, { "content": "def unlock_version_dir(vdir):\n \"\"\"Unlock the given version dir, allowing it to be uninstalled.\"\"\"\n os_close(_locked_version_dirs[vdir].pop())", "metadata": "root.unlock_version_dir", "header": "['module', '___EOS___']", "index": 661 }, { "content": " def main():\n bootstrap()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 666 }, { "content": " def target(driver,args):\n \"\"\"Target function for compiling a standalone bootstraper with PyPy.\"\"\"\n def entry_point(argv):\n exit_code = 0\n # TODO: resolve symlinks etc\n sys.executable = abspath(pathjoin(getcwd(),argv[0]))\n sys.argv = argv\n try:\n main()\n except SystemExit, e:\n exit_code = _exit_code[0]\n return exit_code\n return entry_point, None", "metadata": "root.target", "header": "['module', '___EOS___']", "index": 668 } ]
[ { "span": "from posix import listdir, stat, unlink, rename, execv, getcwd, environ", "start_line": 67, "start_column": 4, "end_line": 67, "end_column": 75 }, { "span": "from nt import listdir, stat, unlink, rename, spawnv", "start_line": 88, "start_column": 4, "end_line": 88, "end_column": 56 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", " ", "Copy", "right", " ", "(", "c", ")", " ", "200", "9", "-", "2010", ",", " ", "Cloud", " ", "Matrix", " ", "Pt", "y", ".", " ", "Lt", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "All", " ", "rights", " ", "reserve", "d", ";", " ", "avail", "able", " ", "under", " ", "the", " ", "term", "s", " ", "of", " ", "the", " ", "BS", "D", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "\\", "10", ";", " ", " ", "es", "ky", ".", "boots", "trap", ":", " ", " ", "minima", "l", " ", "bootstrapp", "ing", " ", "code", " ", "for", " ", "es", "ky", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "module", " ", "provide", "s", " ", "the", " ", "minima", "l", " ", "code", " ", "necessar", "y", " ", "to", " ", "boots", "trap", " ", "a", " ", "frozen", "\\", "10", ";", "applica", "tion", " ", "package", "d", " ", "usi", "ng", " ", "es", "ky", ".", " ", " ", "It", " ", "checks", " ", "the", " ", "base", " ", "runt", "ime", " ", "director", "y", " ", "to", "\\", "10", ";", "find", " ", "the", " ", "most", " ", "appropr", "iate", " ", "version", " ", "of", " ", "the", " ", "app", " ", "and", " ", "then", " ", "exec", "vs", " ", "to", " ", "the", " ", "frozen", "\\", "10", ";", "executable", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "module", " ", "must", " ", "use", " ", "no", " ", "module", "s", " ", "other", " ", "than", " ", "bui", "lti", "ns", ",", " ", "sinc", "e", " ", "the", " ", "stdlib", " ", "is", "\\", "10", ";", "not", " ", "avail", "able", " ", "in", " ", "the", " ", "bootstrapp", "ing", " ", "environ", "ment", ".", " ", " ", "It", " ", "must", " ", "als", "o", " ", "be", " ", "capable", "\\", "10", ";", "of", " ", "bootstrapp", "ing", " ", "int", "o", " ", "apps", " ", "made", " ", "with", " ", "older", " ", "version", "s", " ", "of", " ", "es", "ky", ",", " ", "sinc", "e", " ", "a", " ", "partial", "\\", "10", ";", "update", " ", "coul", "d", " ", "result", " ", "in", " ", "the", " ", "boost", "rapp", "er", " ", "from", " ", "a", " ", "new", " ", "version", " ", "bei", "ng", " ", "forced", "\\", "10", ";", "to", " ", "load", " ", "an", " ", "old", " ", "version", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "you", " ", "want", " ", "to", " ", "compile", " ", "your", " ", "bootstrapp", "ing", " ", "exe", "s", " ", "int", "o", " ", "standalone", " ", "executable", "s", ",", "\\", "10", ";", "this", " ", "module", " ", "must", " ", "als", "o", " ", "be", " ", "writt", "en", " ", "in", " ", "the", " ", "\"", "RP", "yth", "on", "\"", " ", "dialect", " ", "used", " ", "by", " ", "the", " ", "Py", "Py", "\\", "10", ";", "translatio", "n", " ", "toolchain", ".", "\\", "10", ";", "\\", "10", ";", "The", " ", "code", " ", "from", " ", "this", " ", "module", " ", "is", " ", "alw", "ay", "s", " ", "executed", " ", "in", " ", "the", " ", "bootstrapp", "ing", " ", "environ", "ment", "\\", "10", ";", "bef", "ore", " ", "any", " ", "custom", " ", "bootstrapp", "ing", " ", "code", ".", " ", " ", "It", " ", "provide", "s", " ", "the", " ", "follow", "ing", " ", "function", "s", " ", "for", "\\", "10", ";", "use", " ", "dur", "ing", " ", "the", " ", "boots", "trap", " ", "process", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", "Chain", "load", "ing", ":", " ", " ", " ", " ", " ", "exec", "v", ",", " ", "chain", "load", "\\", "10", ";", " ", " ", "Files", "yste", "m", ":", " ", " ", " ", "listd", "ir", ",", " ", "exist", "s", ",", " ", "basen", "ame", ",", " ", "dir", "name", ",", " ", "path", "join", "\\", "10", ";", " ", " ", "Version", " ", "handling", ":", " ", "split", "\\u", "app", "\\u", "version", ",", " ", "join", "\\u", "app", "\\u", "version", ",", " ", "parse", "\\u", "version", ",", "\\", "10", ";", " ", " ", "get", "\\u", "all", "\\u", "version", "s", ",", " ", "get", "\\u", "best", "\\u", "version", ",", " ", "is", "\\u", "version", "\\u", "dir", ",", "\\", "10", ";", " ", " ", "is", "\\u", "install", "ed", "\\u", "version", "\\u", "dir", ",", " ", "is", "\\u", "uninstall", "ed", "\\u", "version", "\\u", "dir", ",", "\\", "10", ";", " ", " ", "lock", "\\u", "version", "\\u", "dir", ",", " ", "unlock", "\\u", "version", "\\u", "dir", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\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 ", " _", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", "\\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 ", " _", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", "=_", "\"", "es", "ky", "-", "files", "\"_", "\\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 ", " _", "ES", "KY", "\\u", "APP", "DATA", "\\u", "DIR_", "\\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 ", " _", "ES", "KY", "\\u", "APP", "DATA", "\\u", "DIR_", "=_", "\"", "appd", "ata", "\"_", "\\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 ", " _", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", "\\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 ", " _", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", "=_", "\"\"_", "\\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 ", " _", "\\u\\u", "rpy", "tho", "n", "\\u\\u_", "\\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 ", " _", "\\u\\u", "rpy", "tho", "n", "\\u\\u_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "RP", "yth", "on", " ", "doe", "sn", "'", "t", " ", "handle", " ", "System", "Exi", "t", " ", "automati", "call", "y", ",", " ", "so", " ", "we", " ", "put", " ", "the", " ", "exit", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "in", " ", "this", " ", "global", " ", "var", " ", "and", " ", "catch", " ", "System", "Exi", "t", " ", "ours", "elv", "es", " ", "at", " ", "the", " ", "out", "most", " ", "scope", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "exit", "\\u", "code_", "=_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "The", " ", "os", " ", "module", " ", "is", " ", "not", " ", "bui", "lti", "n", ",", " ", "so", " ", "we", " ", "gra", "b", " ", "what", " ", "we", " ", "can", " ", "from", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "platform", "-", "specific", " ", "module", "s", " ", "and", " ", "fu", "dge", " ", "the", " ", "rest", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\"", "posix", "\"_", "in_", "sys_", "._", "bui", "lti", "n", "\\u", "module", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "fcntl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "posix_", "import_", "listdir_", ",_", "stat_", ",_", "unlink_", ",_", "rename_", ",_", "exec", "v_", ",_", "getcwd_", ",_", "environ_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "posix_", "import_", "open_", "as_", "os", "\\u", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "posix_", "import_", "close_", "as_", "os", "\\u", "close_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SEP", "_", "=_", "\"/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "\"", "nt", "\"_", "in_", "sys_", "._", "bui", "lti", "n", "\\u", "module", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fcntl_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "nt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nt_", "import_", "listdir_", ",_", "stat_", ",_", "unlink_", ",_", "rename_", ",_", "spawn", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nt_", "import_", "getcwd_", ",_", "P", "\\u", "WAIT", "_", ",_", "environ_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nt_", "import_", "open_", "as_", "os", "\\u", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nt_", "import_", "close_", "as_", "os", "\\u", "close_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SEP", "_", "=_", "\"\\\\\\\\\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "The", " ", "standard", " ", "exec", "v", " ", "terminate", "s", " ", "the", " ", "spawn", "ing", " ", "process", ",", " ", "whi", "ch", " ", "make", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "it", " ", "impossible", " ", "to", " ", "wait", " ", "for", " ", "it", ".", " ", " ", "Thi", "s", " ", "alternative", " ", "is", " ", "wait", "able", ",", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "use", "s", " ", "the", " ", "es", "ky", ".", "slave", "proc", " ", "machine", "ry", " ", "to", " ", "avoid", " ", "leaving", " ", "zombie", " ", "child", "ren", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "A", " ", "fake", " ", "fcn", "tl", " ", "module", " ", "whi", "ch", " ", "is", " ", "fal", "se", ",", " ", "but", " ", "can", " ", "fake", " ", "out", " ", "RP", "ython_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fcntl_", "=_", "fcntl_", "(_", ")_", "\\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_", "Run", "time", "Error_", "(_", "\"", "unsup", "porte", "d", " ", "platform", ":", " ", "\"_", "+_", "sys_", "._", "platform_", ")_", "\\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", "rpy", "tho", "n", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "RP", "yth", "on", " ", "provide", "s", " ", "ll", " ", "hook", "s", " ", "for", " ", "the", " ", "actual", " ", "os", ".", "environ", " ", "object", ",", " ", "not", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "one", " ", "we", " ", "pull", "ed", " ", "out", " ", "of", " ", "\"", "nt", "\"", " ", "or", " ", "\"", "posix", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "os_", "import_", "environ_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "RP", "yth", "on", " ", "doe", "sn", "'", "t", " ", "have", " ", "access", " ", "to", " ", "the", " ", "\"", "sys", "\"", " ", "module", ",", " ", "so", " ", "we", " ", "fake", " ", "it", " ", "out", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "entry", "\\u", "point", " ", "function", " ", "will", " ", "set", " ", "these", " ", "value", " ", "appropr", "iate", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "sys_", "=_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sys_", "=_", "sys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "modules_", "[_", "\"", "sys", "\"_", "]_", "=_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "RP", "yth", "on", " ", "doe", "sn", "'", "t", " ", "provide", " ", "the", " ", "sorte", "d", "()", " ", "bui", "lti", "n", ",", " ", "and", " ", "actual", "ly", " ", "make", "s", " ", "sorting", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "quite", " ", "compli", "cated", " ", "in", " ", "genera", "l", ".", " ", " ", "I", " ", "can", "'", "t", " ", "conv", "inc", "e", " ", "the", " ", "type", " ", "annotator", " ", "to", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "happy", " ", "abo", "ut", " ", "usi", "ng", " ", "thei", "r", " ", "\"", "lists", "ort", "\"", " ", "module", ",", " ", "so", " ", "I", "'", "m", " ", "doi", "ng", " ", "my", " ", "own", " ", "usi", "ng", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "simple", " ", "insertion", " ", "sort", ".", " ", " ", "We", "'", "re", " ", "only", " ", "sorting", " ", "short", " ", "lists", " ", "and", " ", "the", "y", " ", "alw", "ays_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "contain", " ", "(", "list", "(", "str", "),", "str", "),", " ", "so", " ", "this", " ", "shou", "ld", " ", "do", " ", "for", " ", "now", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "RP", "yth", "on", " ", "doe", "sn", "'", "t", " ", "provide", " ", "the", " ", "\"", "zfil", "l", "\"", " ", "or", " ", "\"", "isal", "num", "\"", " ", "method", "s", " ", "on", " ", "string", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "RP", "yth", "on", " ", "doe", "sn", "'", "t", " ", "provide", " ", "the", " ", "\"", "fcn", "tl", "\"", " ", "module", ".", " ", " ", "Fake", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "implement", " ", "it", " ", "usi", "ng", " ", "externals", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fcntl_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fcntl_", "=_", "fcntl_", "(_", ")_", "\\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_", "#", " ", " ", "We", " ", "need", " ", "to", " ", "use", " ", "a", " ", "compa", "tabi", "lit", "y", " ", "wrapp", "er", " ", "for", " ", "some", " ", "string", " ", "method", "s", " ", "missing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "in", " ", "RP", "yth", "on", ",", " ", "sinc", "e", " ", "we", " ", "can", "'", "t", " ", "just", " ", "add", " ", "them", " ", "as", " ", "method", "s", " ", "on", " ", "the", " ", "str", " ", "type", "._", "\\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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\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_", "\\u", "replace", "\\u", "p_", "=_", "{_", "'", "pre", "'_", ":_", "'", "c", "'_", ",_", "'", "previe", "w", "'_", ":_", "'", "c", "'_", ",_", "'-'_", ":_", "'", "final", "-'_", ",_", "'", "rc", "'_", ":_", "'", "c", "'_", ",_", "'", "dev", "'_", ":_", "'@'_", "}_", "._", "get_", "\\u\\u\\uNEWLINE\\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_", "\\u", "lock", "ed", "\\u", "version", "\\u", "dirs_", "=_", "{_", "}_", "\\u\\u\\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", "rpy", "tho", "n", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\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\\uNEWLINE\\u\\u\\u_", "def_", "isabs_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "path_", "._", "startswith_", "(_", "SEP", "_", ")_", ")_", "\\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_", "abspath_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path", "join_", "(_", "getcwd_", "(_", ")_", ",_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "component", "s", "\\u", "in_", "=_", "path_", "._", "split_", "(_", "SEP", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "components_", "=_", "[_", "component", "s", "\\u", "in_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "comp_", "in_", "component", "s", "\\u", "in_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "comp_", "or_", "comp_", "==_", "\".\"_", ":_", "\\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_", "elif_", "comp_", "==_", "\"..\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "components_", "._", "pop_", "(_", ")_", "\\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 ", " _", "components_", "._", "append_", "(_", "comp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "SEP", "_", "._", "join_", "(_", "components_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "isabs_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "path_", "._", "startswith_", "(_", "SEP", "_", ")_", ":_", "\\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_", "if_", "len_", "(_", "path_", ")_", ">=_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "path_", "[_", "0_", "]_", "._", "isalpha_", "(_", ")_", "and_", "path_", "[_", "1_", "]_", "==_", "\":\"_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\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_", "abspath_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path", "join_", "(_", "getcwd_", "(_", ")_", ",_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "component", "s", "\\u", "in_", "=_", "path_", "._", "split_", "(_", "SEP", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "components_", "=_", "[_", "component", "s", "\\u", "in_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "comp_", "in_", "component", "s", "\\u", "in_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "comp_", "or_", "comp_", "==_", "\".\"_", ":_", "\\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_", "elif_", "comp_", "==_", "\"..\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "components_", "._", "pop_", "(_", ")_", "\\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 ", " _", "components_", "._", "append_", "(_", "comp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "path_", "._", "startswith_", "(_", "SEP", "_", "+_", "SEP", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "components_", "._", "insert_", "(_", "0_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "SEP", "_", "._", "join_", "(_", "components_", ")_", "\\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_", "exec", "v_", "(_", "filename_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Creat", "e", " ", "an", " ", "O", "\\u", "TEMP", "ORA", "RY", " ", "file", " ", "and", " ", "pass", " ", "its", " ", "name", " ", "to", " ", "the", " ", "slave", " ", "process", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Whe", "n", " ", "this", " ", "master", " ", "process", " ", "die", "s", ",", " ", "the", " ", "file", " ", "will", " ", "be", " ", "delete", "d", " ", "and", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "slave", " ", "process", " ", "will", " ", "know", " ", "to", " ", "terminate", "._", "\\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 ", " _", "tdir", "_", "=_", "environ_", "[_", "\"", "TEMP", "\"_", "]_", "\\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 ", " _", "tdir", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "tdir", "_", ":_", "\\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 ", " _", "nt_", "._", "mkdir_", "(_", "path", "join_", "(_", "tdir", "_", ",_", "\"", "es", "ky", "-", "slave", "-", "proc", "s", "\"_", ")_", ",_", "0_", "600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ":_", "\\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_", "exists_", "(_", "path", "join_", "(_", "tdir", "_", ",_", "\"", "es", "ky", "-", "slave", "-", "proc", "s", "\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "flags_", "=_", "nt_", "._", "O", "\\u", "CRE", "AT_", "|_", "nt_", "._", "O", "\\u", "EXC", "L_", "|_", "nt_", "._", "O", "\\u", "TEMP", "ORA", "RY_", "|_", "nt_", "._", "O", "\\u", "NO", "INH", "ERIT", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tfi", "len", "m_", "=_", "\"", "slave", "-%", "d", ".", "%", "d", ".", "txt", "\"_", "%_", "(_", "nt_", "._", "getpid_", "(_", ")_", ",_", "i_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tfi", "len", "m_", "=_", "path", "join_", "(_", "tdir", "_", ",_", "\"", "es", "ky", "-", "slave", "-", "proc", "s", "\"_", ",_", "tfi", "len", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os", "\\u", "open_", "(_", "tfi", "len", "m_", ",_", "flags_", ",_", "0_", "600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "insert_", "(_", "1_", ",_", "tfi", "len", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "insert_", "(_", "1_", ",_", "\"--", "es", "ky", "-", "slave", "-", "proc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "all", " ", "argu", "ment", "s", " ", "are", " ", "quoted", " ", "(", "to", " ", "allow", " ", "space", "s", " ", "in", " ", "path", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "arg_", "in_", "enumerate_", "(_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "arg_", "[_", "0_", "]_", "!=_", "\"\\\\\"\"_", "and_", "args_", "[_", "-_", "1_", "]_", "!=_", "\"\\\\\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "[_", "i_", "]_", "=_", "\"\\\\\"", "{}", "\\\\\"\"_", "._", "format_", "(_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "res_", "=_", "spawn", "v_", "(_", "P", "\\u", "WAIT", "_", ",_", "filename_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "exit", "\\u", "code_", "[_", "0_", "]_", "=_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "System", "Exit_", "(_", "res_", ")_", "\\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_", "fcntl_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "LOCK", "\\u", "SH_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "fcntl_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "flock", "_", "(_", "self_", ",_", "fd_", ",_", "mode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "fcntl_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "nonzero\\u", "\\u_", "(_", "self_", ")_", ":_", "\\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\\uNEWLINE\\u\\u\\u_", "class_", "sys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "platform_", "=_", "\\u", "sys_", "._", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "executable_", "=_", "\\u", "sys_", "._", "executable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argv_", "=_", "\\u", "sys_", "._", "argv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "\\u", "info_", "=_", "\\u", "sys_", "._", "version", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modules_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bui", "lti", "n", "\\u", "module", "\\u", "names_", "=_", "\\u", "sys_", "._", "bui", "lti", "n", "\\u", "module", "\\u", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "sys_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "exit_", "(_", "self_", ",_", "code_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "exit", "\\u", "code_", "[_", "0_", "]_", "=_", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "System", "Exit_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "sys_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "exc", "\\u", "info_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", ",_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "list", "\\u", "gt_", "(_", "l1_", ",_", "l2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "i_", "<_", "len_", "(_", "l1_", ")_", "and_", "i_", "<_", "len_", "(_", "l2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "l1_", "[_", "i_", "]_", ">_", "l2_", "[_", "i_", "]_", ":_", "\\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_", "if_", "l1_", "[_", "i_", "]_", "<_", "l2_", "[_", "i_", "]_", ":_", "\\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_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "l1_", ")_", ">_", "len_", "(_", "l2_", ")_", ":_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sorted_", "(_", "lst_", ",_", "reverse_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sl", "st_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "reverse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "lst_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "xrange_", "(_", "len_", "(_", "sl", "st_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "\\u", "list", "\\u", "gt_", "(_", "sl", "st_", "[_", "j_", "]_", "[_", "0_", "]_", ",_", "item_", "[_", "0_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "sl", "st_", "._", "insert_", "(_", "j_", ",_", "item_", ")_", "\\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 ", " ", "_", "sl", "st_", "._", "append_", "(_", "item_", ")_", "\\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 ", " _", "for_", "item_", "in_", "lst_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "xrange_", "(_", "len_", "(_", "sl", "st_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "\\u", "list", "\\u", "gt_", "(_", "sl", "st_", "[_", "j_", "]_", "[_", "0_", "]_", ",_", "item_", "[_", "0_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "sl", "st_", "._", "insert_", "(_", "j_", ",_", "item_", ")_", "\\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 ", " ", "_", "sl", "st_", "._", "append_", "(_", "item_", ")_", "\\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_", "sl", "st_", "\\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_", "zfill_", "(_", "str_", ",_", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "len_", "(_", "str_", ")_", "<_", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "str_", "=_", "\"", "0", "\"_", "+_", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "str_", "\\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_", "isal", "num_", "(_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "c_", "in_", "str_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "c_", "._", "isal", "num_", "(_", ")_", ":_", "\\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_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "fcntl_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "LOCK", "\\u", "SH_", "=_", "fcntl_", "._", "LOCK", "\\u", "SH_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "fcntl_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "flock", "_", "(_", "self_", ",_", "fd_", ",_", "mode_", ")_", ":_", "\\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\\uINDENT\\u\\u\\u ", " _", "def_", "zfill_", "(_", "str_", ",_", "n_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "str_", "._", "zfill_", "(_", "n_", ")_", "\\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_", "isal", "num_", "(_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "str_", "._", "isal", "num_", "(_", ")_", "\\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_", "path", "join_", "(_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Local", " ", "re", "-", "implementation", " ", "of", " ", "os", ".", "path", ".", "join", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "arg_", "in_", "list_", "(_", "args_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isabs_", "(_", "arg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "arg_", "\\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 ", " _", "while_", "path_", "._", "endswith_", "(_", "SEP", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "path_", "+_", "SEP", "_", "+_", "arg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "path_", "\\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_", "basename_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Local", " ", "re", "-", "implementation", " ", "of", " ", "os", ".", "path", ".", "basen", "ame", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "p_", "._", "split_", "(_", "SEP", "_", ")_", "[_", "-_", "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_", "def_", "dirname_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Local", " ", "re", "-", "implementation", " ", "of", " ", "os", ".", "path", ".", "dir", "name", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "SEP", "_", "._", "join_", "(_", "p_", "._", "split_", "(_", "SEP", "_", ")_", "[_", ":_", "-_", "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_", "def_", "exists_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Local", " ", "re", "-", "implementation", " ", "of", " ", "os", ".", "path", ".", "exist", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stat_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "how", " ", "to", " ", "get", " ", "the", " ", "errno", " ", "under", " ", "RP", "yth", "on", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "\\u\\u", "rpy", "tho", "n", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "._", "errno_", "not_", "in_", "(_", "errno_", "._", "ENOENT_", ",_", "errno_", "._", "ENO", "TD", "IR_", ",_", "errno_", "._", "ESR", "CH_", ",_", ")_", ":_", "\\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_", "return_", "False_", "\\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_", "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_", "def_", "appd", "ir", "\\u", "from", "\\u", "executable_", "(_", "exe", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fin", "d", " ", "the", " ", "top", "-", "level", " ", "applica", "tion", " ", "director", "y", ",", " ", "give", "n", " ", "sys", ".", "executable", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ord", "inar", "il", "y", " ", "this", " ", "wou", "ld", " ", "simp", "ly", " ", "be", " ", "the", " ", "director", "y", " ", "contain", "ing", " ", "the", " ", "executable", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "whe", "n", " ", "runn", "ing", " ", "via", " ", "a", " ", "bundle", " ", "on", " ", "OSX", " ", "the", " ", "executable", " ", "will", " ", "be", " ", "located", " ", "at", "\\", "10", ";", " ", " ", " ", " ", "<", "appd", "ir", ">/", "Conten", "ts", "/", "Mac", "OS", "/", "<", "exe", ">.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appd", "ir_", "=_", "dirname_", "(_", "exe", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "platform_", "==_", "\"", "dar", "win", "\"_", "and_", "basename_", "(_", "appd", "ir_", ")_", "==_", "\"", "Mac", "OS", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Look", "s", " ", "like", " ", "we", " ", "mig", "ht", " ", "be", " ", "in", " ", "an", " ", "app", " ", "bundle", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "appd", "ir_", "=_", "dirname_", "(_", "appd", "ir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "basename_", "(_", "appd", "ir_", ")_", "==_", "\"", "Conten", "ts", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ye", "p", ",", " ", "definit", "el", "y", " ", "in", " ", "a", " ", "bundle_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "appd", "ir_", "=_", "dirname_", "(_", "appd", "ir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", "pe", ",", " ", "some", " ", "other", " ", "cra", "zy", " ", "scheme_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "appd", "ir_", "=_", "dirname_", "(_", "exe", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "appd", "ir_", "\\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_", "bootstrap_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Boots", "trap", " ", "an", " ", "es", "ky", " ", "frozen", " ", "app", " ", "int", "o", " ", "the", " ", "newest", " ", "avail", "able", " ", "version", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "searche", "s", " ", "the", " ", "applica", "tion", " ", "director", "y", " ", "to", " ", "find", " ", "the", " ", "high", "est", "-", "\\", "10", ";", " ", " ", " ", " ", "numbered", " ", "version", " ", "of", " ", "the", " ", "applica", "tion", " ", "tha", "t", " ", "is", " ", "full", "y", " ", "install", "ed", ",", " ", "then", "\\", "10", ";", " ", " ", " ", " ", "chain", "load", "s", " ", "tha", "t", " ", "version", " ", "of", " ", "the", " ", "applica", "tion", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "executable_", "=_", "abspath_", "(_", "sys_", "._", "executable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appd", "ir_", "=_", "appd", "ir", "\\u", "from", "\\u", "executable_", "(_", "sys_", "._", "executable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vs", "dir_", "=_", "path", "join_", "(_", "appd", "ir_", ",_", "ES", "KY", "\\u", "APP", "DATA", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "remove", " ", "compa", "tabi", "lit", "y", " ", "hook", " ", "for", " ", "ES", "KY", "\\u", "APP", "DATA", "\\u", "DIR", "=\"\"", "._", "\\u\\u\\uNL\\u\\u\\u_", "best", "\\u", "version_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "best", "\\u", "version_", "=_", "get", "\\u", "best", "\\u", "version_", "(_", "vs", "dir_", ",_", "appname_", "=_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "best", "\\u", "version_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "best", "\\u", "version_", "=_", "get", "\\u", "best", "\\u", "version_", "(_", "vs", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "best", "\\u", "version_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exists_", "(_", "vs", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "\"", "no", " ", "usable", " ", "frozen", " ", "version", "s", " ", "wer", "e", " ", "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 ", " _", "raise_", "Environ", "ment", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exists_", "(_", "vs", "dir_", ")_", ":_", "\\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_", "vs", "dir_", "=_", "appd", "ir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "best", "\\u", "version_", "=_", "get", "\\u", "best", "\\u", "version_", "(_", "vs", "dir_", ",_", "appname_", "=_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "best", "\\u", "version_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "best", "\\u", "version_", "=_", "get", "\\u", "best", "\\u", "version_", "(_", "vs", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "best", "\\u", "version_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "\"", "no", " ", "usable", " ", "frozen", " ", "version", "s", " ", "wer", "e", " ", "found", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "chain", "load_", "(_", "path", "join_", "(_", "vs", "dir_", ",_", "best", "\\u", "version_", ")_", ")_", "\\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_", "chain", "load_", "(_", "target", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Load", " ", "and", " ", "execute", " ", "the", " ", "selecte", "d", " ", "version", " ", "of", " ", "an", " ", "applica", "tion", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "replace", "s", " ", "the", " ", "currentl", "y", "-", "runn", "ing", " ", "executable", " ", "with", " ", "the", " ", "equivalent", "\\", "10", ";", " ", " ", " ", " ", "executable", " ", "from", " ", "the", " ", "give", "n", " ", "target", " ", "director", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "On", " ", "platform", "s", " ", "tha", "t", " ", "support", " ", "it", ",", " ", "this", " ", "als", "o", " ", "lock", "s", " ", "the", " ", "target", " ", "director", "y", " ", "so", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "it", " ", "will", " ", "not", " ", "be", " ", "remove", "d", " ", "by", " ", "any", " ", "simultaneous", "ly", "-", "runn", "ing", " ", "instance", "s", " ", "of", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "applica", "tion", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lock", "\\u", "version", "\\u", "dir_", "(_", "target", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "the", " ", "boots", "trap", " ", "file", " ", "is", " ", "missi", "ng", ",", " ", "the", " ", "version", " ", "is", " ", "bei", "ng", " ", "uninstall", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Ou", "r", " ", "only", " ", "option", " ", "is", " ", "to", " ", "re", "-", "execute", " ", "ours", "elf", " ", "and", " ", "find", " ", "the", " ", "new", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exists_", "(_", "dirname_", "(_", "target", "\\u", "dir_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bs", "file_", "=_", "path", "join_", "(_", "target", "\\u", "dir_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bs", "file_", "=_", "path", "join_", "(_", "bs", "file_", ",_", "\"", "boots", "trap", "-", "manifest", ".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "exists_", "(_", "bs", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec", "v_", "(_", "sys_", "._", "executable_", ",_", "list_", "(_", "sys_", "._", "argv_", ")_", ")_", "\\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_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "all", " ", "go", "es", " ", "well", ",", " ", "we", " ", "can", " ", "actual", "ly", " ", "launch", " ", "the", " ", "target", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "chain", "load_", "(_", "target", "\\u", "dir_", ")_", "\\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_", "get", "\\u", "exe", "\\u", "locations_", "(_", "target", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Generate", " ", "possib", "le", " ", "location", "s", " ", "from", " ", "whi", "ch", " ", "to", " ", "chain", "load", " ", "in", " ", "the", " ", "target", " ", "dir", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "let", " ", "this", " ", "be", " ", "a", " ", "generat", "or", " ", "whe", "n", " ", "not", " ", "compil", "ing", " ", "with", " ", "Py", "Py", ",", " ", "so", " ", "we", " ", "can_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "avoid", " ", "a", " ", "few", " ", "stat", "()", " ", "calls", " ", "in", " ", "the", " ", "common", " ", "case", "._", "\\u\\u\\uNL\\u\\u\\u_", "locs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appd", "ir_", "=_", "appd", "ir", "\\u", "from", "\\u", "executable_", "(_", "sys_", "._", "executable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "we", "'", "re", " ", "in", " ", "an", " ", "appd", "ir", ",", " ", "first", " ", "try", " ", "to", " ", "launch", " ", "from", " ", "within", " ", "\"<", "app", "name", ">.", "app", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "director", "y", ".", " ", " ", "We", " ", "must", " ", "als", "o", " ", "try", " ", "the", " ", "default", " ", "sche", "me", " ", "for", " ", "back", "ward", "s", " ", "compa", "t", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "platform_", "==_", "\"", "dar", "win", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "basename_", "(_", "dirname_", "(_", "sys_", "._", "executable_", ")_", ")_", "==_", "\"", "Mac", "OS", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "locs_", "._", "append_", "(_", "path", "join_", "(_", "target", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "es", "ky", "\\u", "name\\u\\u_", "+_", "\".", "app", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "executable_", "[_", "len_", "(_", "appd", "ir_", ")_", "+_", "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 ", " _", "for_", "nm_", "in_", "listdir_", "(_", "target", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "nm_", "._", "endswith_", "(_", "\".", "app", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "locs_", "._", "append_", "(_", "path", "join_", "(_", "target", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "executable_", "[_", "len_", "(_", "appd", "ir_", ")_", "+_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Thi", "s", " ", "is", " ", "the", " ", "default", " ", "sche", "me", ":", " ", "the", " ", "same", " ", "path", " ", "as", " ", "the", " ", "exe", " ", "in", " ", "the", " ", "appd", "ir", "._", "\\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_", "locs_", "._", "append_", "(_", "target", "\\u", "dir_", "+_", "sys_", "._", "executable_", "[_", "len_", "(_", "appd", "ir_", ")_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "sys", ".", "executable", " ", "was", " ", "a", " ", "backup", " ", "file", ",", " ", "try", " ", "usi", "ng", " ", "original", " ", "filename", "._", "\\u\\u\\uNL\\u\\u\\u_", "orig", "\\u", "exe_", "=_", "get", "\\u", "original", "\\u", "filename_", "(_", "sys_", "._", "executable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "orig", "\\u", "exe_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "locs_", "._", "append_", "(_", "target", "\\u", "dir_", "+_", "orig", "\\u", "exe_", "[_", "len_", "(_", "appd", "ir_", ")_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "locs_", "\\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_", "verify_", "(_", "target", "\\u", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Verify", " ", "the", " ", "integrity", " ", "of", " ", "the", " ", "give", "n", " ", "target", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "By", " ", "default", " ", "this", " ", "is", " ", "a", " ", "no", "-", "op", ";", " ", "override", " ", "it", " ", "to", " ", "provide", " ", "e", ".", "g", ".", " ", "signa", "ture", " ", "checks", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\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_", "\\u", "chain", "load_", "(_", "target", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Default", " ", "implementation", " ", "of", " ", "the", " ", "chain", "load", "()", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Specifi", "c", " ", "freez", "er", " ", "module", "s", " ", "may", " ", "provide", " ", "a", " ", "more", " ", "efficien", "t", ",", " ", "reliab", "le", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", " ", "bett", "er", " ", "version", " ", "of", " ", "this", " ", "function", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exc", "\\u", "type_", ",_", "exc", "\\u", "value_", ",_", "traceback_", "=_", "None_", ",_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "target", "\\u", "exe_", "in_", "get", "\\u", "exe", "\\u", "locations_", "(_", "target", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verify_", "(_", "target", "\\u", "exe_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec", "v_", "(_", "target", "\\u", "exe_", ",_", "[_", "target", "\\u", "exe_", "]_", "+_", "sys_", "._", "argv_", "[_", "1_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Environ", "ment", "Error_", ",_", "exc", "\\u", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Care", "ful", ",", " ", "RP", "yth", "on", " ", "lack", "s", " ", "a", " ", "usable", " ", "exc", "\\u", "info", "()", " ", "function", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "type_", ",_", "\\u_", ",_", "traceback_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "\\u\\u", "rpy", "tho", "n", "\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exc", "\\u", "value_", "._", "errno_", "!=_", "errno_", "._", "ENOENT_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exists_", "(_", "target", "\\u", "exe_", ")_", ":_", "\\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_", "\\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_", "exc", "\\u", "value_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "exc", "\\u", "type_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "exc", "\\u", "type_", ",_", "exc", "\\u", "value_", ",_", "traceback_", "\\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_", "exc", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Run", "time", "Error_", "(_", "\"", "coul", "dn", "'", "t", " ", "chain", "load", " ", "any", " ", "executable", "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_", "get", "\\u", "best", "\\u", "version_", "(_", "appd", "ir_", ",_", "include", "\\u", "partial", "\\u", "install", "s_", "=_", "False_", ",_", "appname_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "the", " ", "best", " ", "usable", " ", "version", " ", "director", "y", " ", "from", " ", "insi", "de", " ", "the", " ", "give", "n", " ", "appd", "ir", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "In", " ", "the", " ", "common", " ", "case", " ", "there", " ", "is", " ", "only", " ", "a", " ", "single", " ", "version", " ", "director", "y", ",", " ", "but", " ", "fail", "ed", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "partial", " ", "update", "s", " ", "can", " ", "result", " ", "in", " ", "sever", "al", " ", "bei", "ng", " ", "presen", "t", ".", " ", " ", "Thi", "s", " ", "function", "\\", "10", ";", " ", " ", " ", " ", "find", "s", " ", "the", " ", "high", "est", "-", "numbered", " ", "version", " ", "tha", "t", " ", "is", " ", "complete", "ly", " ", "install", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Fin", "d", " ", "all", " ", "potenti", "al", " ", "version", " ", "director", "ies", ",", " ", "sorte", "d", " ", "by", " ", "version", " ", "number", "._", "\\u\\u\\uNL\\u\\u\\u_", "candidates_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "nm_", "in_", "listdir_", "(_", "appd", "ir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "app", "nm_", ",_", "ver_", ",_", "platform_", ")_", "=_", "split", "\\u", "app", "\\u", "version_", "(_", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "its", " ", "name", " ", "did", "n", "'", "t", " ", "parse", " ", "proper", "ly", ",", " ", "don", "'", "t", " ", "bot", "her", " ", "look", "ing", " ", "insi", "de", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ver_", "and_", "platform_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "we", "'", "re", " ", "give", "n", " ", "a", " ", "specific", " ", "name", ",", " ", "it", " ", "must", " ", "have", " ", "tha", "t", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "appname_", "is_", "not_", "None_", "and_", "app", "nm_", "!=_", "appname_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "We", " ", "have", " ", "to", " ", "pay", " ", "anot", "her", " ", "stat", "()", " ", "call", " ", "to", " ", "check", " ", "if", " ", "it", "'", "s", " ", "active", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "\\u", "version", "\\u", "dir_", "(_", "path", "join_", "(_", "appd", "ir_", ",_", "nm_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ver_", "=_", "parse", "\\u", "version_", "(_", "ver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "candidates_", "._", "append_", "(_", "(_", "ver_", ",_", "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_", "candidates_", "=_", "[_", "c_", "[_", "1_", "]_", "for_", "c_", "in_", "sorted_", "(_", "candidates_", ",_", "reverse_", "=_", "True_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "In", " ", "the", " ", "(", "hop", "efu", "ll", "y", ")", " ", "common", " ", "case", " ", "of", " ", "no", " ", "fail", "ed", " ", "update", "s", ",", " ", "we", " ", "don", "'", "t", " ", "need", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "to", " ", "poke", " ", "aro", "und", " ", "in", " ", "the", " ", "filesystem", " ", "so", " ", "we", " ", "just", " ", "return", " ", "asa", "p", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "candidates_", ":_", "\\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_", "len_", "(_", "candidates_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "candidates_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "include", "\\u", "partial", "\\u", "install", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "candidates_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "If", " ", "there", " ", "are", " ", "sever", "al", " ", "candidate", " ", "version", "s", ",", " ", "we", " ", "need", " ", "to", " ", "find", " ", "the", " ", "best_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "one", " ", "tha", "t", " ", "is", " ", "complete", "ly", " ", "install", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "candidates_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nm_", "=_", "candidates_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "is", "\\u", "install", "ed", "\\u", "version", "\\u", "dir_", "(_", "path", "join_", "(_", "appd", "ir_", ",_", "nm_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "nm_", "\\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]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "all", "\\u", "versions_", "(_", "appd", "ir_", ",_", "include", "\\u", "partial", "\\u", "install", "s_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "a", " ", "list", " ", "of", " ", "all", " ", "usable", " ", "version", " ", "director", "ies", " ", "insi", "de", " ", "the", " ", "give", "n", " ", "appd", "ir", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "list", " ", "will", " ", "be", " ", "in", " ", "order", " ", "from", " ", "most", "-", "recent", " ", "to", " ", "leas", "t", "-", "recent", ".", " ", " ", "The", " ", "head", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "the", " ", "list", " ", "will", " ", "be", " ", "the", " ", "same", " ", "director", "y", " ", "as", " ", "return", "ed", " ", "by", " ", "get", "\\u", "best", "\\u", "version", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Fin", "d", " ", "all", " ", "potenti", "al", " ", "version", " ", "director", "ies", ",", " ", "sorte", "d", " ", "by", " ", "version", " ", "number", "._", "\\u\\u\\uNL\\u\\u\\u_", "candidates_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "nm_", "in_", "listdir_", "(_", "appd", "ir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "\\u_", ",_", "ver_", ",_", "platform_", ")_", "=_", "split", "\\u", "app", "\\u", "version_", "(_", "nm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ver_", "and_", "platform_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "is", "\\u", "version", "\\u", "dir_", "(_", "path", "join_", "(_", "appd", "ir_", ",_", "nm_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ver_", "=_", "parse", "\\u", "version_", "(_", "ver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "candidates_", "._", "append_", "(_", "(_", "ver_", ",_", "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_", "candidates_", "=_", "[_", "c_", "[_", "1_", "]_", "for_", "c_", "in_", "sorted_", "(_", "candidates_", ",_", "reverse_", "=_", "True_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "Filter", " ", "out", " ", "any", " ", "tha", "t", " ", "are", " ", "not", " ", "complete", "ly", " ", "install", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "include", "\\u", "partial", "\\u", "install", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "i_", "<_", "len_", "(_", "candidates_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "is", "\\u", "install", "ed", "\\u", "version", "\\u", "dir_", "(_", "path", "join_", "(_", "appd", "ir_", ",_", "candidates_", "[_", "i_", "]_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "candidates_", "[_", "i_", "]_", "\\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_", "+=_", "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_", "return_", "candidates_", "\\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_", "is", "\\u", "version", "\\u", "dir_", "(_", "vdi", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "whe", "ther", " ", "the", " ", "give", "n", " ", "director", "y", " ", "contain", "s", " ", "an", " ", "es", "ky", " ", "app", " ", "version", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Curr", "ent", "ly", " ", "it", " ", "only", " ", "need", " ", "contain", " ", "the", " ", "\"", "es", "ky", "-", "files", "/", "boots", "trap", "-", "main", "fes", "t", ".", "txt", "\"", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "exists_", "(_", "path", "join_", "(_", "vdi", "r_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ",_", "\"", "boots", "trap", "-", "manifest", ".", "txt", "\"_", ")_", ")_", ":_", "\\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_", "is", "\\u", "install", "ed", "\\u", "version", "\\u", "dir_", "(_", "vdi", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "whe", "ther", " ", "the", " ", "give", "n", " ", "version", " ", "director", "y", " ", "is", " ", "full", "y", " ", "install", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Curr", "ent", "ly", ",", " ", "a", " ", "complete", "d", " ", "installation", " ", "is", " ", "indicat", "ed", " ", "by", " ", "the", " ", "lack", " ", "of", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "\"", "es", "ky", "-", "files", "/", "boots", "trap", "\"", " ", "director", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "exists_", "(_", "path", "join_", "(_", "vdi", "r_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ",_", "\"", "boots", "trap", "\"_", ")_", ")_", ":_", "\\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_", "is", "\\u", "uninstall", "ed", "\\u", "version", "\\u", "dir_", "(_", "vdi", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Check", " ", "whe", "ther", " ", "the", " ", "give", "n", " ", "version", " ", "director", "y", " ", "is", " ", "partial", "ly", " ", "uninstall", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "partial", "ly", "-", "uninstall", "ed", " ", "version", " ", "dir", " ", "has", " ", "had", " ", "the", " ", "\"", "boots", "trap", "-", "manifest", ".", "txt", "\"", "\\", "10", ";", " ", " ", " ", " ", "renamed", " ", "to", " ", "\"", "boots", "trap", "-", "manifest", "-", "old", ".", "txt", "\".\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "exists_", "(_", "path", "join_", "(_", "vdi", "r_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ",_", "\"", "boots", "trap", "-", "manifest", "-", "old", ".", "txt", "\"_", ")_", ")_", ":_", "\\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_", "split", "\\u", "app", "\\u", "version_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Split", " ", "an", " ", "app", " ", "version", " ", "string", " ", "to", " ", "name", ",", " ", "version", " ", "and", " ", "platform", " ", "component", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", ",", " ", "app", "-", "name", "-0", ".1", ".2", ".", "win32", " ", "=>", " ", "(\"", "app", "-", "name", "\",\"", "0.", "1.2", "\",\"", "win32", "\")", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits_", "=_", "s_", "._", "split_", "(_", "\"-\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idx_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "idx_", "<_", "len_", "(_", "bits_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "bits_", "[_", "idx_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "bits_", "[_", "idx_", "]_", "[_", "0_", "]_", "._", "isalpha_", "(_", ")_", "or_", "not_", "isal", "num_", "(_", "bits_", "[_", "idx_", "]_", ")_", ":_", "\\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_", "idx_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "appname_", "=_", "\"-\"_", "._", "join_", "(_", "bits_", "[_", ":_", "idx_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits_", "=_", "\"-\"_", "._", "join_", "(_", "bits_", "[_", "idx_", ":_", "]_", ")_", "._", "split_", "(_", "\".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "\".\"_", "._", "join_", "(_", "bits_", "[_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "platform_", "=_", "bits_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "appname_", ",_", "version_", ",_", "platform_", ")_", "\\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_", "join", "\\u", "app", "\\u", "version_", "(_", "appname_", ",_", "version_", ",_", "platform_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Join", " ", "an", " ", "app", " ", "name", ",", " ", "version", " ", "and", " ", "platform", " ", "int", "o", " ", "a", " ", "version", " ", "director", "y", " ", "name", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", ",", " ", "(\"", "app", "-", "name", "\",\"", "0.", "1.2", "\",\"", "win32", "\")", " ", "=>", " ", "app", "name", "-0", ".1", ".2", ".", "win32", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"%", "s", "-%", "s", ".", "%", "s", "\"_", "%_", "(_", "appname_", ",_", "version_", ",_", "platform_", ",_", ")_", "\\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_", "parse", "\\u", "version_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Pars", "e", " ", "a", " ", "version", " ", "string", " ", "int", "o", " ", "a", " ", "chrono", "logical", "ly", "-", "sortable", " ", "key", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "return", "s", " ", "a", " ", "sequence", " ", "of", " ", "string", "s", " ", "tha", "t", " ", "compare", "s", " ", "with", " ", "the", " ", "results", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "other", " ", "version", "s", " ", "in", " ", "a", " ", "chrono", "logical", "ly", " ", "sensi", "ble", " ", "way", ".", " ", " ", "You", "'", "d", " ", "use", " ", "it", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "compare", " ", "two", " ", "version", " ", "string", "s", " ", "like", " ", "so", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "parse", "\\u", "version", "(\"", "1.9", ".2", "\")", " ", ">", " ", "parse", "\\u", "version", "(\"", "1.1", "0.", "0", "\"):", "\\", "10", ";", " ", " ", " ", " ", "raise", " ", "Run", "time", "Error", "(\"", "what", " ", "rub", "bis", "h", ",", " ", "tha", "t", "'", "s", " ", "an", " ", "older", " ", "version", "!\"", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "essential", "ly", " ", "the", " ", "parse", "\\u", "version", "()", " ", "function", " ", "from", " ", "pkg", "\\u", "resource", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "but", " ", "re", "-", "implemented", " ", "to", " ", "avoid", " ", "usi", "ng", " ", "module", "s", " ", "tha", "t", " ", "may", " ", "not", " ", "be", " ", "avail", "able", "\\", "10", ";", " ", " ", " ", " ", "dur", "ing", " ", "bootstrapp", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parts_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "part_", "in_", "\\u", "parse", "\\u", "version", "\\u", "parts_", "(_", "s_", "._", "lower_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "part_", "._", "startswith_", "(_", "'*'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "part_", "<_", "'*", "final", "'_", ":_", "#", " ", "remove", " ", "'-'", " ", "bef", "ore", " ", "a", " ", "prere", "lease", " ", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "parts_", "and_", "parts_", "[_", "-_", "1_", "]_", "==_", "'*", "final", "-'_", ":_", "parts_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "trail", "ing", " ", "zero", "s", " ", "from", " ", "each", " ", "series", " ", "of", " ", "numeri", "c", " ", "parts_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "parts_", "and_", "parts_", "[_", "-_", "1_", "]_", "==_", "'", "00000000", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parts_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parts_", "._", "append_", "(_", "part_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "parts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "parse", "\\u", "version", "\\u", "parts_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parts_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "part_", "in_", "\\u", "split", "\\u", "version", "\\u", "components_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "part_", "=_", "\\u", "replace", "\\u", "p_", "(_", "part_", ",_", "part_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "part_", "or_", "part_", "==_", "'.'_", ":_", "\\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_", "if_", "part_", "[_", ":_", "1_", "]_", "in_", "'", "0123456", "789", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parts_", "._", "append_", "(_", "zfill_", "(_", "part_", ",_", "8_", ")_", ")_", "#", " ", "pad", " ", "for", " ", "numeri", "c", " ", "comparison_", "\\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 ", " _", "parts_", "._", "append_", "(_", "'*'_", "+_", "part_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parts_", "._", "append_", "(_", "'*", "final", "'_", ")_", "#", " ", "ensure", " ", "tha", "t", " ", "alpha", "/", "beta", "/", "candidate", " ", "are", " ", "bef", "ore", " ", "final_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "parts_", "\\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", "split", "\\u", "version", "\\u", "components_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Split", " ", "version", " ", "string", " ", "int", "o", " ", "individual", " ", "token", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "pkg", "\\u", "resource", "s", " ", "doe", "s", " ", "this", " ", "usi", "ng", " ", "a", " ", "regexp", ":", " ", "(\\\\", "d", "+", " ", "|", " ", "[", "a", "-", "z", "]+", " ", "|", " ", "\\\\.", "|", " ", "-)", "\\", "10", ";", " ", " ", " ", " ", "Unf", "ort", "unat", "el", "y", " ", "the", " ", "'", "re", "'", " ", "module", " ", "isn", "'", "t", " ", "in", " ", "the", " ", "boots", "trap", ",", " ", "so", " ", "we", " ", "have", " ", "to", " ", "do", "\\", "10", ";", " ", " ", " ", " ", "an", " ", "equivalent", " ", "parse", " ", "by", " ", "hand", ".", " ", " ", "For", "unat", "el", "y", ",", " ", "tha", "t", "'", "s", " ", "pretty", " ", "easy", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "start_", "<_", "len_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end_", "=_", "start_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "s_", "[_", "start_", "]_", "._", "isdigit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "end_", "<_", "len_", "(_", "s_", ")_", "and_", "s_", "[_", "end_", "]_", "._", "isdigit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "s_", "[_", "start_", "]_", "._", "isalpha_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "end_", "<_", "len_", "(_", "s_", ")_", "and_", "s_", "[_", "end_", "]_", "._", "isalpha_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "s_", "[_", "start_", "]_", "in_", "(_", "\".\"_", ",_", "\"-\"_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "end_", "<_", "len_", "(_", "s_", ")_", "and_", "not_", "(_", "s_", "[_", "end_", "]_", "._", "isdigit_", "(_", ")_", "or_", "s_", "[_", "end_", "]_", "._", "isalpha_", "(_", ")_", "or_", "s_", "[_", "end_", "]_", "in_", "(_", "\".\"_", ",_", "\"-\"_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "comps_", "._", "append_", "(_", "s_", "[_", "start_", ":_", "end_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "end_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "comps_", "\\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", "\\u", "original", "\\u", "filename_", "(_", "back", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Give", "n", " ", "a", " ", "backup", " ", "filename", ",", " ", "get", " ", "the", " ", "original", " ", "name", " ", "to", " ", "whi", "ch", " ", "it", " ", "refer", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "only", " ", "reall", "y", " ", "possib", "le", " ", "if", " ", "the", " ", "original", " ", "file", " ", "actual", "ly", " ", "exist", "s", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "not", " ", "guaran", "tee", "d", " ", "to", " ", "be", " ", "correct", " ", "in", " ", "all", " ", "case", "s", ";", " ", "but", " ", "unl", "ess", " ", "you", " ", "do", " ", "somet", "hing", "\\", "10", ";", " ", " ", " ", " ", "sil", "ly", " ", "it", " ", "shou", "ld", " ", "work", " ", "out", " ", "OK", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "no", " ", "matchi", "ng", " ", "original", " ", "file", " ", "is", " ", "found", ",", " ", "Non", "e", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filtered_", "=_", "\".\"_", "._", "join_", "(_", "[_", "n_", "for_", "n_", "in_", "back", "name_", "._", "split_", "(_", "\".\"_", ")_", "if_", "n_", "!=_", "\"", "old", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "nm_", "in_", "listdir_", "(_", "dirname_", "(_", "back", "name_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "nm_", "==_", "back", "name_", ":_", "\\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_", "if_", "filtered_", "==_", "\".\"_", "._", "join_", "(_", "[_", "n_", "for_", "n_", "in_", "nm_", "._", "split_", "(_", "\".\"_", ")_", "if_", "n_", "!=_", "\"", "old", "\"_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "path", "join_", "(_", "dirname_", "(_", "back", "name_", ")_", ",_", "nm_", ")_", "\\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]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "lock", "\\u", "version", "\\u", "dir_", "(_", "vdi", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Lock", " ", "the", " ", "give", "n", " ", "version", " ", "dir", " ", "so", " ", "it", " ", "cann", "ot", " ", "be", " ", "uninstall", "ed", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "platform_", "==_", "\"", "win32", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "On", " ", "win32", ",", " ", "we", " ", "just", " ", "hold", " ", "boots", "trap", " ", "file", " ", "open", " ", "for", " ", "readi", "ng", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Thi", "s", " ", "will", " ", "prevent", " ", "it", " ", "from", " ", "bei", "ng", " ", "renamed", " ", "dur", "ing", " ", "uninstall", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lockfile", "_", "=_", "path", "join_", "(_", "vdi", "r_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ",_", "\"", "boots", "trap", "-", "manifest", ".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "lock", "ed", "\\u", "version", "\\u", "dirs_", "._", "setdefault_", "(_", "vdi", "r_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "os", "\\u", "open_", "(_", "lockfile", "_", ",_", "0_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "On", " ", "posix", " ", "platform", "s", " ", "we", " ", "take", " ", "a", " ", "shared", " ", "flock", " ", "on", " ", "es", "ky", "-", "files", "/", "lockfile", ".", "txt", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Whi", "le", " ", "fcn", "tl", ".", "fcn", "tl", " ", "lock", "s", " ", "are", " ", "appare", "ntl", "y", " ", "the", " ", "new", " ", "hot", "ness", ",", " ", "the", "y", " ", "have_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "unfo", "rtu", "nat", "e", " ", "semantics", " ", "tha", "t", " ", "we", " ", "don", "'", "t", " ", "want", " ", "for", " ", "this", " ", "applica", "tion", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "*", " ", "not", " ", "inherited", " ", "acro", "ss", " ", "fork", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "*", " ", "released", " ", "whe", "n", " ", "clos", "ing", " ", "*", "any", "*", " ", "fd", " ", "associate", "d", " ", "with", " ", "tha", "t", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "fcn", "tl", ".", "flock", " ", "doe", "sn", "'", "t", " ", "have", " ", "these", " ", "problem", "s", ",", " ", "but", " ", "may", " ", "fail", " ", "on", " ", "NF", "S", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "To", " ", "compli", "cate", " ", "matte", "rs", ",", " ", "python", " ", "somet", "imes", " ", "emulate", "s", " ", "flock", " ", "with", " ", "fcn", "tl", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "We", " ", "there", "fore", " ", "use", " ", "a", " ", "separate", " ", "lock", " ", "file", " ", "to", " ", "avoid", " ", "unpl", "eas", "ant", "ness", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lockfile", "_", "=_", "path", "join_", "(_", "vdi", "r_", ",_", "ES", "KY", "\\u", "CONTR", "OL", "\\u", "DIR_", ",_", "\"", "lockfile", ".", "txt", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "os", "\\u", "open_", "(_", "lockfile", "_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "lock", "ed", "\\u", "version", "\\u", "dirs_", "._", "setdefault_", "(_", "vdi", "r_", ",_", "[_", "]_", ")_", "._", "append_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fcntl_", "._", "flock", "_", "(_", "f_", ",_", "fcntl_", "._", "LOCK", "\\u", "SH_", ")_", "\\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_", "unlock", "\\u", "version", "\\u", "dir_", "(_", "vdi", "r_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Unlock", " ", "the", " ", "give", "n", " ", "version", " ", "dir", ",", " ", "allow", "ing", " ", "it", " ", "to", " ", "be", " ", "uninstall", "ed", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os", "\\u", "close_", "(_", "\\u", "lock", "ed", "\\u", "version", "\\u", "dirs_", "[_", "vdi", "r_", "]_", "._", "pop_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bootstrap_", "(_", ")_", "\\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_", "target_", "(_", "driver_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Target", " ", "function", " ", "for", " ", "compil", "ing", " ", "a", " ", "standalone", " ", "boots", "trap", "er", " ", "with", " ", "Py", "Py", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "entry", "\\u", "point_", "(_", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exit", "\\u", "code_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", "TOD", "O", ":", " ", "resolve", " ", "symlinks", " ", "etc", "_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "executable_", "=_", "abspath_", "(_", "path", "join_", "(_", "getcwd_", "(_", ")_", ",_", "argv_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "argv_", "=_", "argv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "System", "Exit_", ",_", "e_", ":_", "\\u\\u\\uNE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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, 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, 4, 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 ]
Unused import
openelections/openelections-core/openelex/us/nv/datasource.py
[ { "content": "\"\"\"\nNevada has CSV files containing precinct-level results for each jurisdiction and all offices\nfrom the 2004 general to the 2012 general. All of those files are pre-processed and available on Github at\nhttps://github.com/openelections/openelections-data-nv. Prior to the 2004 general and\nafter the 2012 primary, county-level XML and HTML files are available from the Secretary of State's site.\n\"\"\"\nfrom os.path import join\nimport json\nimport datetime\nimport urlparse\n\nfrom openelex import PROJECT_ROOT\nfrom openelex.base.datasource import BaseDatasource\nfrom openelex.lib import build_raw_github_url\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Datasource(BaseDatasource):\n\n # PUBLIC INTERFACE\n\n\n\n\n\n # PRIVATE METHODS\n\n\n\n\n", "metadata": "root.Datasource", "header": "['module', '___EOS___']", "index": 15 }, { "content": " def mappings(self, year=None):\n \"\"\"Return array of dicts containing source url and\n standardized filename for raw results file, along\n with other pieces of metadata\n \"\"\"\n mappings = []\n for yr, elecs in self.elections(year).items():\n mappings.extend(self._build_metadata(yr, elecs))\n return mappings", "metadata": "root.Datasource.mappings", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 18 }, { "content": " def target_urls(self, year=None):\n \"Get list of source data urls, optionally filtered by year\"\n return [item['raw_url'] for item in self.mappings(year)]", "metadata": "root.Datasource.target_urls", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 28 }, { "content": " def filename_url_pairs(self, year=None):\n return [(mapping['generated_filename'], self._url_for_fetch(mapping))\n for mapping in self.mappings(year)]", "metadata": "root.Datasource.filename_url_pairs", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 32 }, { "content": " def _url_for_fetch(self, mapping):\n try:\n return mapping['url']\n except KeyError:\n return # github url", "metadata": "root.Datasource._url_for_fetch", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 36 }, { "content": " def mappings_for_url(self, url):\n return [mapping for mapping in self.mappings() if mapping['url'] == url]", "metadata": "root.Datasource.mappings_for_url", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 42 }, { "content": " def _build_metadata(self, year, elections):\n meta = []\n year_int = int(year)\n for election in elections:\n if 'special' in election['slug']:\n results = [x for x in self._url_paths() if x['date'] == election['start_date'] and x['special'] == True]\n for result in results:\n jurisdiction = 'ocd-division/country:us/state:nv'\n generated_filename = self._generate_statewide_precinct_filename(result)\n pre_processed_url = None\n meta.append({\n \"generated_filename\": generated_filename,\n \"raw_url\": result['url'],\n \"pre_processed_url\": None,\n \"ocd_id\": jurisdiction,\n \"name\": 'Nevada',\n \"election\": election['slug']\n })\n else:\n results = [x for x in self._url_paths() if x['date'] == election['start_date'] and x['special'] == False and x['precinct'] == '']\n for result in results:\n if result['jurisdiction'] == '':\n jurisdiction = 'ocd-division/country:us/state:nv'\n generated_filename = self._generate_statewide_filename(result)\n pre_processed_url = None\n else:\n jurisdiction = [c for c in self._jurisdictions() if c['jurisdiction'] == result['jurisdiction']][0]['ocd_id']\n generated_filename = result['path']\n pre_processed_url = build_raw_github_url(self.state, str(year), result['path'])\n meta.append({\n \"generated_filename\": generated_filename,\n \"raw_url\": result['url'],\n \"pre_processed_url\": pre_processed_url,\n \"ocd_id\": jurisdiction,\n \"name\": result['jurisdiction'],\n \"election\": election['slug']\n })\n results = [x for x in self._url_paths() if x['date'] == election['start_date'] and x['special'] == False and x['precinct'] != '']\n for result in results:\n jurisdiction = 'ocd-division/country:us/state:nv'\n generated_filename = self._generate_statewide_precinct_filename(result)\n pre_processed_url = None\n meta.append({\n \"generated_filename\": generated_filename,\n \"raw_url\": result['url'],\n \"pre_processed_url\": pre_processed_url,\n \"ocd_id\": jurisdiction,\n \"name\": 'Nevada',\n \"election\": election['slug']\n })\n return meta", "metadata": "root.Datasource._build_metadata", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 47 }, { "content": " def _generate_statewide_filename(self, result):\n bits = [\n result['date'].replace('-',''),\n self.state,\n ]\n if result['party']:\n bits.append(result['party'].lower())\n bits.extend([\n result['race_type'].lower()\n ])\n filename = \"__\".join(bits) + '.xml'\n return filename", "metadata": "root.Datasource._generate_statewide_filename", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 99 }, { "content": " def _generate_statewide_precinct_filename(self, result):\n bits = [\n result['date'].replace('-',''),\n self.state,\n ]\n if result['party']:\n bits.append(result['party'].lower())\n bits.extend([\n result['race_type'].lower(),\n 'precinct'\n ])\n filename = \"__\".join(bits) + '.csv'\n return filename", "metadata": "root.Datasource._generate_statewide_precinct_filename", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 112 }, { "content": " def _jurisdictions(self):\n \"\"\"Nevada counties\"\"\"\n m = self.jurisdiction_mappings()\n mappings = [x for x in m if x['jurisdiction'] != \"\"]\n return mappings", "metadata": "root.Datasource._jurisdictions", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 126 }, { "content": " def _url_for_fetch(self, mapping):\n if mapping['pre_processed_url']:\n return mapping['pre_processed_url']\n else:\n return mapping['raw_url']", "metadata": "root.Datasource._url_for_fetch", "header": "['class', 'Datasource', '(', 'BaseDatasource', ')', ':', '___NEWLINE___', '___NL___', '# PUBLIC INTERFACE', '___NL___', '___EOS___']", "index": 132 } ]
[ { "span": "from os.path import join", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 24 }, { "span": "import json", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 11 }, { "span": "import datetime", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 15 }, { "span": "import urlparse", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 15 }, { "span": "from openelex import PROJECT_ROOT", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 33 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Ne", "vad", "a", " ", "has", " ", "CSV", " ", "files", " ", "contain", "ing", " ", "preci", "nct", "-", "level", " ", "results", " ", "for", " ", "each", " ", "jur", "isdi", "ction", " ", "and", " ", "all", " ", "office", "s", "\\", "10", ";", "from", " ", "the", " ", "2004", " ", "genera", "l", " ", "to", " ", "the", " ", "2012", " ", "genera", "l", ".", " ", "All", " ", "of", " ", "tho", "se", " ", "files", " ", "are", " ", "pre", "-", "process", "ed", " ", "and", " ", "avail", "able", " ", "on", " ", "Git", "hub", " ", "at", "\\", "10", ";", "https", "://", "git", "hub", ".", "com", "/", "opene", "lection", "s", "/", "opene", "lection", "s", "-", "data", "-", "nv", ".", " ", "Prior", " ", "to", " ", "the", " ", "2004", " ", "genera", "l", " ", "and", "\\", "10", ";", "after", " ", "the", " ", "2012", " ", "primary", ",", " ", "county", "-", "level", " ", "XML", " ", "and", " ", "HTM", "L", " ", "files", " ", "are", " ", "avail", "able", " ", "from", " ", "the", " ", "Sec", "reta", "ry", " ", "of", " ", "State", "'", "s", " ", "site", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "._", "path_", "import_", "join_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "opene", "lex_", "import_", "PROJECT", "\\u", "ROOT_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "opene", "lex_", "._", "base_", "._", "datasource_", "import_", "Base", "Datas", "ource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "opene", "lex_", "._", "lib_", "import_", "build", "\\u", "raw", "\\u", "git", "hub", "\\u", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "PRIVATE", " ", "METHODS_", "\\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_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "mappings_", "(_", "self_", ",_", "year_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "array", " ", "of", " ", "dict", "s", " ", "contain", "ing", " ", "source", " ", "url", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "standardize", "d", " ", "filename", " ", "for", " ", "raw", " ", "results", " ", "file", ",", " ", "along", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "other", " ", "piece", "s", " ", "of", " ", "metadata", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mappings_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "yr_", ",_", "elec", "s_", "in_", "self_", "._", "election", "s_", "(_", "year_", ")_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mappings_", "._", "extend_", "(_", "self_", "._", "\\u", "build", "\\u", "metadata_", "(_", "yr_", ",_", "elec", "s_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "mappings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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_", "target", "\\u", "urls_", "(_", "self_", ",_", "year_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Get", " ", "list", " ", "of", " ", "source", " ", "data", " ", "urls", ",", " ", "option", "ally", " ", "filter", "ed", " ", "by", " ", "year", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "item_", "[_", "'", "raw", "\\u", "url", "'_", "]_", "for_", "item_", "in_", "self_", "._", "mappings_", "(_", "year_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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_", "filename", "\\u", "url", "\\u", "pairs_", "(_", "self_", ",_", "year_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "(_", "mapping_", "[_", "'", "generat", "ed", "\\u", "filename", "'_", "]_", ",_", "self_", "._", "\\u", "url", "\\u", "for", "\\u", "fetch_", "(_", "mapping_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "mapping_", "in_", "self_", "._", "mappings_", "(_", "year_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "url", "\\u", "for", "\\u", "fetch_", "(_", "self_", ",_", "mapping_", ")_", ":_", "\\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_", "mapping_", "[_", "'", "url", "'_", "]_", "\\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 ", " _", "return_", "#", " ", "git", "hub", " ", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "mapping", "s", "\\u", "for", "\\u", "url_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "mapping_", "for_", "mapping_", "in_", "self_", "._", "mappings_", "(_", ")_", "if_", "mapping_", "[_", "'", "url", "'_", "]_", "==_", "url_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "build", "\\u", "metadata_", "(_", "self_", ",_", "year_", ",_", "election", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "meta_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "year", "\\u", "int_", "=_", "int_", "(_", "year_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "election_", "in_", "election", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "special", "'_", "in_", "election_", "[_", "'", "slug", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "[_", "x_", "for_", "x_", "in_", "self_", "._", "\\u", "url", "\\u", "paths_", "(_", ")_", "if_", "x_", "[_", "'", "date", "'_", "]_", "==_", "election_", "[_", "'", "start", "\\u", "date", "'_", "]_", "and_", "x_", "[_", "'", "special", "'_", "]_", "==_", "True_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "result_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "jur", "isdi", "ction_", "=_", "'", "oc", "d", "-", "divisi", "on", "/", "countr", "y", ":", "us", "/", "state", ":", "nv", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "generat", "ed", "\\u", "filename_", "=_", "self_", "._", "\\u", "generat", "e\\u", "state", "wide", "\\u", "preci", "nct", "\\u", "filename_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "process", "ed", "\\u", "url_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "generat", "ed", "\\u", "filename", "\"_", ":_", "generat", "ed", "\\u", "filename_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "raw", "\\u", "url", "\"_", ":_", "result_", "[_", "'", "url", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pre", "\\u", "process", "ed", "\\u", "url", "\"_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "oc", "d\\u", "id", "\"_", ":_", "jur", "isdi", "ction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "'", "Ne", "vad", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "election", "\"_", ":_", "election_", "[_", "'", "slug", "'_", "]_", "\\u\\u\\uNL\\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 ", " _", "results_", "=_", "[_", "x_", "for_", "x_", "in_", "self_", "._", "\\u", "url", "\\u", "paths_", "(_", ")_", "if_", "x_", "[_", "'", "date", "'_", "]_", "==_", "election_", "[_", "'", "start", "\\u", "date", "'_", "]_", "and_", "x_", "[_", "'", "special", "'_", "]_", "==_", "False_", "and_", "x_", "[_", "'", "preci", "nct", "'_", "]_", "==_", "''_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "result_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "result_", "[_", "'", "jur", "isdi", "ction", "'_", "]_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "jur", "isdi", "ction_", "=_", "'", "oc", "d", "-", "divisi", "on", "/", "countr", "y", ":", "us", "/", "state", ":", "nv", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "generat", "ed", "\\u", "filename_", "=_", "self_", "._", "\\u", "generat", "e\\u", "state", "wide", "\\u", "filename_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "process", "ed", "\\u", "url_", "=_", "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 ", " ", " _", "jur", "isdi", "ction_", "=_", "[_", "c_", "for_", "c_", "in_", "self_", "._", "\\u", "jur", "isdi", "ctions", "_", "(_", ")_", "if_", "c_", "[_", "'", "jur", "isdi", "ction", "'_", "]_", "==_", "result_", "[_", "'", "jur", "isdi", "ction", "'_", "]_", "]_", "[_", "0_", "]_", "[_", "'", "oc", "d\\u", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "generat", "ed", "\\u", "filename_", "=_", "result_", "[_", "'", "path", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "process", "ed", "\\u", "url_", "=_", "build", "\\u", "raw", "\\u", "git", "hub", "\\u", "url_", "(_", "self_", "._", "state_", ",_", "str_", "(_", "year_", ")_", ",_", "result_", "[_", "'", "path", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "meta_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "generat", "ed", "\\u", "filename", "\"_", ":_", "generat", "ed", "\\u", "filename_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "raw", "\\u", "url", "\"_", ":_", "result_", "[_", "'", "url", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pre", "\\u", "process", "ed", "\\u", "url", "\"_", ":_", "pre", "\\u", "process", "ed", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "oc", "d\\u", "id", "\"_", ":_", "jur", "isdi", "ction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "result_", "[_", "'", "jur", "isdi", "ction", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "election", "\"_", ":_", "election_", "[_", "'", "slug", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "results_", "=_", "[_", "x_", "for_", "x_", "in_", "self_", "._", "\\u", "url", "\\u", "paths_", "(_", ")_", "if_", "x_", "[_", "'", "date", "'_", "]_", "==_", "election_", "[_", "'", "start", "\\u", "date", "'_", "]_", "and_", "x_", "[_", "'", "special", "'_", "]_", "==_", "False_", "and_", "x_", "[_", "'", "preci", "nct", "'_", "]_", "!=_", "''_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "result_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "jur", "isdi", "ction_", "=_", "'", "oc", "d", "-", "divisi", "on", "/", "countr", "y", ":", "us", "/", "state", ":", "nv", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "generat", "ed", "\\u", "filename_", "=_", "self_", "._", "\\u", "generat", "e\\u", "state", "wide", "\\u", "preci", "nct", "\\u", "filename_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "process", "ed", "\\u", "url_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "generat", "ed", "\\u", "filename", "\"_", ":_", "generat", "ed", "\\u", "filename_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "raw", "\\u", "url", "\"_", ":_", "result_", "[_", "'", "url", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pre", "\\u", "process", "ed", "\\u", "url", "\"_", ":_", "pre", "\\u", "process", "ed", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "oc", "d\\u", "id", "\"_", ":_", "jur", "isdi", "ction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "'", "Ne", "vad", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "election", "\"_", ":_", "election_", "[_", "'", "slug", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\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_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "generat", "e\\u", "state", "wide", "\\u", "filename_", "(_", "self_", ",_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bits_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "date", "'_", "]_", "._", "replace_", "(_", "'-'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "state_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", "[_", "'", "part", "y", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bits_", "._", "append_", "(_", "result_", "[_", "'", "part", "y", "'_", "]_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bits_", "._", "extend_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "race", "\\u", "type", "'_", "]_", "._", "lower_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "\"\\u\\u", "\"_", "._", "join_", "(_", "bits_", ")_", "+_", "'.", "xml", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "generat", "e\\u", "state", "wide", "\\u", "preci", "nct", "\\u", "filename_", "(_", "self_", ",_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bits_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "date", "'_", "]_", "._", "replace_", "(_", "'-'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "state_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "result_", "[_", "'", "part", "y", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bits_", "._", "append_", "(_", "result_", "[_", "'", "part", "y", "'_", "]_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bits_", "._", "extend_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "race", "\\u", "type", "'_", "]_", "._", "lower_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "preci", "nct", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "\"\\u\\u", "\"_", "._", "join_", "(_", "bits_", ")_", "+_", "'.", "csv", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "jur", "isdi", "ctions", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Ne", "vad", "a", " ", "counti", "es", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "self_", "._", "jur", "isdi", "ction", "\\u", "mappings_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mappings_", "=_", "[_", "x_", "for_", "x_", "in_", "m_", "if_", "x_", "[_", "'", "jur", "isdi", "ction", "'_", "]_", "!=_", "\"\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "mappings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "ource_", "(_", "Base", "Datas", "ource_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PUBLIC", " ", "INTERFACE_", "\\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", "url", "\\u", "for", "\\u", "fetch_", "(_", "self_", ",_", "mapping_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "mapping_", "[_", "'", "pre", "\\u", "process", "ed", "\\u", "url", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "mapping_", "[_", "'", "pre", "\\u", "process", "ed", "\\u", "url", "'_", "]_", "\\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_", "mapping_", "[_", "'", "raw", "\\u", "url", "'_", "]_" ]
[ 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,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, 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, 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 ]
Unused import
dieseldev/diesel/examples/redis_lock.py
[ { "content": "import random\n\nfrom diesel import fork, quickstop, quickstart, sleep\nfrom diesel.protocols.redis import RedisClient, RedisTransactionError, RedisLock, LockNotAcquired\n\n\n\"\"\"Implement the Redis INCR command using a lock. Obviously this is inefficient, but it's a good\nexample of how to use the RedisLock class\"\"\"\n\nkey = 'test-lock-key'\nincr_key = 'test-incr-key'\ncounter = 0\n\n\n\"\"\"If sleep_factor > lock_timeout you are exercising the timeout loop, otherwise, that loop should be a noop\"\"\"\nlock_timeout = 3\nsleep_factor = 1\n\n\n\n\n\n\nquickstart(main)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def take_lock():\n global counter\n client = RedisClient('localhost', 6379)\n try:\n with RedisLock(client, key, timeout=lock_timeout) as lock:\n v = client.get(incr_key)\n sleep(random.random() * sleep_factor)\n client.set(incr_key, int(v) + 1)\n counter += 1\n except LockNotAcquired:\n pass", "metadata": "root.take_lock", "header": "['module', '___EOS___']", "index": 20 }, { "content": "def main():\n client = RedisClient('localhost', 6379)\n client.delete(key)\n client.set(incr_key, 0)\n\n for _ in xrange(500):\n fork(take_lock)\n if random.random() > 0.1:\n sleep(random.random() / 10)\n sleep(2)\n assert counter == int(client.get(incr_key)), 'Incr failed!'\n quickstop()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 32 } ]
[ { "span": "from diesel.protocols.redis import RedisClient, RedisTransactionError, RedisLock, LockNotAcquired", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 97 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "diese", "l_", "import_", "fork_", ",_", "quicks", "top_", ",_", "quicks", "tart_", ",_", "sleep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "diese", "l_", "._", "protocols_", "._", "redis_", "import_", "Red", "is", "Client_", ",_", "Red", "is", "Transa", "ction", "Error_", ",_", "Red", "is", "Lock_", ",_", "Lock", "Not", "Acquire", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Impl", "ement", " ", "the", " ", "Red", "is", " ", "INC", "R", " ", "command", " ", "usi", "ng", " ", "a", " ", "lock", ".", " ", "Ob", "vio", "usl", "y", " ", "this", " ", "is", " ", "ine", "ffic", "ient", ",", " ", "but", " ", "it", "'", "s", " ", "a", " ", "good", "\\", "10", ";", "example", " ", "of", " ", "how", " ", "to", " ", "use", " ", "the", " ", "Red", "is", "Lock", " ", "class", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "key_", "=_", "'", "test", "-", "lock", "-", "key", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "incr", "\\u", "key_", "=_", "'", "test", "-", "incr", "-", "key", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "counter_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "If", " ", "sleep", "\\u", "factor", " ", ">", " ", "lock", "\\u", "timeo", "ut", " ", "you", " ", "are", " ", "exe", "rci", "sing", " ", "the", " ", "timeo", "ut", " ", "loop", ",", " ", "other", "wis", "e", ",", " ", "tha", "t", " ", "loop", " ", "shou", "ld", " ", "be", " ", "a", " ", "noop", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lock", "\\u", "timeout_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep", "\\u", "factor_", "=_", "1_", "\\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_", "quicks", "tart_", "(_", "main_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "take", "\\u", "lock_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "counter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "Red", "is", "Client_", "(_", "'", "local", "host", "'_", ",_", "6379", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "Red", "is", "Lock_", "(_", "client_", ",_", "key_", ",_", "timeout_", "=_", "lock", "\\u", "timeout_", ")_", "as_", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "client_", "._", "get_", "(_", "incr", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "(_", "random_", "._", "random_", "(_", ")_", "*_", "sleep", "\\u", "factor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "set_", "(_", "incr", "\\u", "key_", ",_", "int_", "(_", "v_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "counter_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Lock", "Not", "Acquire", "d_", ":_", "\\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_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "Red", "is", "Client_", "(_", "'", "local", "host", "'_", ",_", "6379", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "delete_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "set_", "(_", "incr", "\\u", "key_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "\\u_", "in_", "xrange_", "(_", "500_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fork_", "(_", "take", "\\u", "lock_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "random_", "._", "random_", "(_", ")_", ">_", "0.1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sleep_", "(_", "random_", "._", "random_", "(_", ")_", "/_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sleep_", "(_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "counter_", "==_", "int_", "(_", "client_", "._", "get_", "(_", "incr", "\\u", "key_", ")_", ")_", ",_", "'", "Inc", "r", " ", "fail", "ed", "!'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "quicks", "top_", "(_", ")_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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 ]
Unused import
binder-project/binder/web/builder.py
[ { "content": "from threading import Thread\nimport sys\nimport os\nimport Queue\n\nfrom multiprocess import pool, Process\nimport multiprocessing\n\nfrom binder.app import App\nfrom binder.utils import make_dir\n\nNUM_WORKERS = 5\nGET_TIMEOUT = 2\nLOG_DIR = \"/home/andrew/logs/binder\"\n\n# Copied+pasted from http://stackoverflow.com/questions/6974695/python-process-pool-non-daemonic\n# TODO use message queuing system instead of 2 process pools\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class NoDaemonProcess(Process):\n # make 'daemon' attribute always return False\n daemon = property(_get_daemon, _set_daemon)", "metadata": "root.NoDaemonProcess", "header": "['module', '___EOS___']", "index": 17 }, { "content": " def _get_daemon(self):\n return False", "metadata": "root.NoDaemonProcess._get_daemon", "header": "['class', 'NoDaemonProcess', '(', 'Process', ')', ':', '___NEWLINE___', \"# make 'daemon' attribute always return False\", '___NL___', '___EOS___']", "index": 19 }, { "content": " def _set_daemon(self, value):\n pass", "metadata": "root.NoDaemonProcess._set_daemon", "header": "['class', 'NoDaemonProcess', '(', 'Process', ')', ':', '___NEWLINE___', \"# make 'daemon' attribute always return False\", '___NL___', '___EOS___']", "index": 21 }, { "content": "class NoDaemonPool(pool.Pool):\n Process = NoDaemonProcess", "metadata": "root.NoDaemonPool", "header": "['module', '___EOS___']", "index": 25 }, { "content": "def build_app(spec, log_dir, preload=False):\n name = spec[\"name\"]\n app = App.get_app(name)\n if app and app.build_state == App.BuildState.BUILDING:\n print(\"App {} already building. Wait for build to complete before resubmitting.\".format(name))\n return\n new_app = App.create(spec)\n try:\n new_app.build(preload=preload)\n except Exception as e:\n # the \"catch-all\" clause\n print(\"Could not build app {}: {}\".format(new_app.name, e))\n App.index.update_build_state(App.BuildState.FAILED)", "metadata": "root.build_app", "header": "['module', '___EOS___']", "index": 28 }, { "content": "class Builder(Thread):\n\n\n\n", "metadata": "root.Builder", "header": "['module', '___EOS___']", "index": 42 }, { "content": " def __init__(self, queue, preload):\n super(Builder, self).__init__()\n self._build_queue = queue\n\n self._pool = NoDaemonPool(processes=NUM_WORKERS) \n multiprocessing.freeze_support()\n\n self._stopped = False\n self._preload = preload\n\n make_dir(LOG_DIR)", "metadata": "root.Builder.__init__", "header": "['class', 'Builder', '(', 'Thread', ')', ':', '___EOS___']", "index": 44 }, { "content": " def stop(self):\n self._stopped = True\n self._pool.terminate()", "metadata": "root.Builder.stop", "header": "['class', 'Builder', '(', 'Thread', ')', ':', '___EOS___']", "index": 56 }, { "content": " def _build(self, spec):\n try:\n pool = self._pool\n pool.apply_async(build_app, (spec, LOG_DIR, self._preload))\n except Exception as e:\n print(\"Exception in _build: {}\".format(e))", "metadata": "root.Builder._build", "header": "['class', 'Builder', '(', 'Thread', ')', ':', '___EOS___']", "index": 60 }, { "content": " def run(self):\n while not self._stopped:\n try:\n next_job = self._build_queue.get(timeout=GET_TIMEOUT)\n print(\"Got job: {}\".format(next_job))\n self._build(next_job)\n except Queue.Empty:\n pass", "metadata": "root.Builder.run", "header": "['class', 'Builder', '(', 'Thread', ')', ':', '___EOS___']", "index": 67 } ]
[ { "span": "import sys", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 10 }, { "span": "import os", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "threading_", "import_", "Thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "multipro", "cess", "_", "import_", "pool_", ",_", "Process_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "multiprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "binde", "r_", "._", "app_", "import_", "App_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "binde", "r_", "._", "utils_", "import_", "make", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "NUM", "\\u", "WORKER", "S_", "=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "GET", "\\u", "TIMEOUT_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOG", "\\u", "DIR_", "=_", "\"/", "home", "/", "andr", "ew", "/", "logs", "/", "binde", "r", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copie", "d", "+", "paste", "d", " ", "from", " ", "http", "://", "stack", "overflow", ".", "com", "/", "question", "s", "/", "697", "469", "5", "/", "python", "-", "process", "-", "pool", "-", "non", "-", "daemon", "ic_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", "use", " ", "message", " ", "que", "uin", "g", " ", "system", " ", "inst", "ead", " ", "of", " ", "2", " ", "process", " ", "pools_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "No", "Da", "emo", "n", "Process_", "(_", "Process_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "make", " ", "'", "daemon", "'", " ", "attribute", " ", "alw", "ay", "s", " ", "return", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "daemon_", "=_", "property_", "(_", "\\u", "get", "\\u", "daemon_", ",_", "\\u", "set\\u", "daemon_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "No", "Da", "emo", "n", "Process_", "(_", "Process_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "make", " ", "'", "daemon", "'", " ", "attribute", " ", "alw", "ay", "s", " ", "return", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "get", "\\u", "daemon_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "No", "Da", "emo", "n", "Process_", "(_", "Process_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "make", " ", "'", "daemon", "'", " ", "attribute", " ", "alw", "ay", "s", " ", "return", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "daemon_", "(_", "self_", ",_", "value_", ")_", ":_", "\\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_", "No", "Da", "emo", "n", "Pool_", "(_", "pool_", "._", "Pool_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Process_", "=_", "No", "Da", "emo", "n", "Process_", "\\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_", "build", "\\u", "app_", "(_", "spec_", ",_", "log", "\\u", "dir_", ",_", "prelo", "ad_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "spec_", "[_", "\"", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "App_", "._", "get", "\\u", "app_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "app_", "and_", "app_", "._", "build", "\\u", "state_", "==_", "App_", "._", "Build", "State_", "._", "BUILD", "ING_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "App", " ", "{}", " ", "alr", "ead", "y", " ", "buildi", "ng", ".", " ", "Wait", " ", "for", " ", "build", " ", "to", " ", "complete", " ", "bef", "ore", " ", "resu", "bmi", "tting", ".\"_", "._", "format_", "(_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "app_", "=_", "App_", "._", "create_", "(_", "spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "app_", "._", "build_", "(_", "prelo", "ad_", "=_", "prelo", "ad_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "\"", "catch", "-", "all", "\"", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Cou", "ld", " ", "not", " ", "build", " ", "app", " ", "{}:", " ", "{}\"_", "._", "format_", "(_", "new", "\\u", "app_", "._", "name_", ",_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "App_", "._", "index_", "._", "update", "\\u", "build", "\\u", "state_", "(_", "App_", "._", "Build", "State_", "._", "FAILED_", ")_", "\\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_", "Builder_", "(_", "Thread_", ")_", ":_", "\\u\\u\\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_", "Builder_", "(_", "Thread_", ")_", ":_", "\\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_", ",_", "queue_", ",_", "prelo", "ad_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Builder_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "build", "\\u", "queue_", "=_", "queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "pool_", "=_", "No", "Da", "emo", "n", "Pool_", "(_", "processes_", "=_", "NUM", "\\u", "WORKER", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "multiprocessing_", "._", "freez", "e\\u", "support_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "stopped_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "prelo", "ad_", "=_", "prelo", "ad_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "dir_", "(_", "LOG", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Builder_", "(_", "Thread_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "stop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "stopped_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pool_", "._", "terminate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Builder_", "(_", "Thread_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "build_", "(_", "self_", ",_", "spec_", ")_", ":_", "\\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 ", " _", "pool_", "=_", "self_", "._", "\\u", "pool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool_", "._", "appl", "y", "\\u", "async_", "(_", "build", "\\u", "app_", ",_", "(_", "spec_", ",_", "LOG", "\\u", "DIR_", ",_", "self_", "._", "\\u", "prelo", "ad_", ")_", ")_", "\\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 ", " _", "print_", "(_", "\"", "Except", "ion", " ", "in", " ", "\\u", "build", ":", " ", "{}\"_", "._", "format_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Builder_", "(_", "Thread_", ")_", ":_", "\\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_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "not_", "self_", "._", "\\u", "stopped_", ":_", "\\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 ", " _", "next", "\\u", "job_", "=_", "self_", "._", "\\u", "build", "\\u", "queue_", "._", "get_", "(_", "timeout_", "=_", "GET", "\\u", "TIMEOUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Got", " ", "job", ":", " ", "{}\"_", "._", "format_", "(_", "next", "\\u", "job_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "build_", "(_", "next", "\\u", "job_", ")_", "\\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 ", " _", "pass_" ]
[ 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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, 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 ]
Unused local variable
tvidas/a5/scripts/bin/control.py
[ { "content": "def runInVM(m,job,VMs,adbport,vmlock,adbl,results, fcnt):\n\tname = multiprocessing.current_process().name\n\n \tformatter = logging.Formatter(fmt=LOGFORMAT,datefmt=LOGDATEFORMAT)\n \tpathForFile = MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \"-run.log\"\n\tprint \"HH%sHH\" % pathForFile\n \thandler = logging.FileHandler(pathForFile, mode='w')\n \thandler.setFormatter(formatter)\n\n \tvlogger = logger.getChild(\"worker\" + name + \".vm\")\n \tvlogger.setLevel(logging.DEBUG)\n \tvlogger.addHandler(handler)\n\n\tvlogger.info(\"logging started at \" + pathForFile)\n\n\n\trval = True\n\tif VMs[m].state in [\"Reserved\"] :\n\t\twith vmlock:\n\t\t\tVMlocal = VMs[m];\n\t\t\tVMlocal.state = \"Starting\"\n\t\t\tVMs[m] = VMlocal;\n\t\t#emulator doens't observe system hosts: (must start emulator with -partition-size 128 (for example) to give room to write)\n\t\t#adb pull /etc/hosts\n\t\t#edit to 10.0.2.2 (your local machine)\n\t\t#adb remount\n\t\t#adb push hosts /etc/hosts\n\t\tt1 = time.time()\n\t\t\n\n\t\t#emulator -avd NAME -partition-size 128 -ports 5,2322 -no-window -tcpdump FILE -dns-server SERVER -http-proxy PROXY\n\t\t#TODO instead of wipe-data, would be best to re-create the VM\n\t\tEMUSTART = \"%s/emulator -avd %s -partition-size %s -port %s -no-window -tcpdump %s -wipe-data\"\n\t\t#./adb logcat\n\t\t#./adb install /storage/malware/RU.apk\n\t\t#./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED\n\n\t\t#start (with specified ports)\n\t\t#emulator -ports X,Y @avd_X\n\n\t\t#wait for emulator to be fully started\n\t\t#./adb -s emulator-5584 wait-for-device\n\t\tEMUWAIT = \"%s/adb -s %s wait-for-device\"\n\n\t\tEMULOGCAT = \"%s/adb -s %s logcat\"\n\n\t\t#command\n\t\t#adb -s emualtor-X shell cmd\n\n\t\tEMUINSTALL = \"%s/adb -s %s install %s\"\n\n\t\t#<INTENT> specifications include these flags:\n\t\t# [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n\t\t# [-c <CATEGORY> [-c <CATEGORY>] ...]\n\t\t# [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]\n\t\t# [--esn <EXTRA_KEY> ...]\n\t\t# [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]\n\t\t# [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]\n\t\t#adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n net.fstab.checkit_android/.StartupReceiver\n\t\t#am broadcast -a android.intent.action.BOOT_COMPLETED\n\t\tEMUINTENT = \"%s/adb -s %s shell am broadcast -a %s\"\n\t\n\t\t#adb shell am start -n com.package.name/com.package.name.ActivityName\n\t\t#am start -a android.intent.action.MAIN -n com.iftitah.android.contact/com.iftitah.android.contact.Contact\n\t\t#am start -a <ACTION> -n <PACKAGE>/<PACKAGE><ACTIVITYCLASS>\n\t\tEMULAUNCH = \"%s/adb -s %s shell am start -a %s -n %s/%s\"\n\n\t\t#kill\n\t\t#could do adb shell stop\n\t\t#but why really? just going to reset for next run anyway\n\t\t# (though a stop would preserve state)\n\t\t#adb -s emulator-X emu kill\n\t\tEMUKILL = \"%s/adb -s %s emu kill\"\n\n\t\t#monkey\n\t\t#$ adb shell monkey -v -p your.package.name 100 --ignore-security-exceptions -s SEED\n\t\tEMUMONKEY = \"%s/adb -s %s shell monkey -v -p %s 100 --ignore-security-exceptions -s %s --throttle 250\"\n\n\t\t#update database with start values\n\t\tpermissions_filename = job['sha256'] + \".xml\"\n\t\timage_used = VMs[m].name\n\t\tstart_time = time.strftime(\"%Y-%m-%d-%H:%M:%S\", time.gmtime())\n\t\tmsdb.updateStartRun(job['jobuuid'],image_used,start_time,permissions_filename,MSVERSION)\n\n\t\tvlogger.info( name + \":\" + \"...starting VM \" + VMs[m].name)\n\t\t#start it\n\t\tcmd = EMUSTART % ( SDKPATH, VMs[m].name, PSIZE, str(adbport), MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256']+ \"-orig.pcap\")\n\t\tvlogger.info( name + \":\" + cmd)\n\t\tpEmu = None\n\t\ttry:\n\t\t\targs = shlex.split(cmd)\n\t\t\tpEmu = subprocess.Popen(args)\n\t\texcept:\n\t\t\tvlogger.info( name + \":\" + \"emulator start error\", sys.exc_info()[0])\n\t\t\tsys.exit(1)\n\t\t#check for start error conditions:\n\t\t#emulator: WARNING: ignoring locked SD Card image at /path/to/avd/ms-sdk003-003/sdcard.img\n\t\t#it seems too many emulator instances are running on this machine. Aborting\n\n\n\t\t#wait for it to start\n\t\tcmd = EMUWAIT % ( ADBPATH, \"emulator-\" + str(adbport))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\ttry:\n\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\t\tvlogger.info( name + \":\" + \"emulator wait returned: %d\" % ret )\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"emulator wait error: %s\" % cmd )\n\t\t\tsys.exit(1)\n\t\tvlogger.info( name + \":\" + \"emulator-\" + str(adbport) + \" started\")\n\t\ttime.sleep(VM_POLL_REST * 3)\n\t\twith vmlock:\n\t\t\tVMlocal = VMs[m];\n\t\t\tVMlocal.state = \"Running\"\n\t\t\tVMs[m] = VMlocal;\n\n\t\t#start logcat\n\t\t#start it\n\t\tcmd = EMULOGCAT % ( SDKPATH, \"emulator-\" + str(adbport))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\tpLogCat = None\n\t\tfLogCat = None\n\t\ttry:\n\t\t\targs = shlex.split(cmd)\n\t\t\tvlogger.info( args)\n\t\t\tfLogCat = open(MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \".logcat\",\"w\")\n\t\t\tfNull = open(\"/dev/null\")\n#TODO\t\t\tpLogCat = subprocess.Popen(args, stdin=fNull, stderr=fNull, stdout=fLogCat)\n\t\texcept:\n\t\t\tvlogger.error( name + \": \" + cmd )\n\t\t\tvlogger.error( formatExceptionInfo())\n\t\t\tvlogger.error( name + \":\" + \"emulator logcat error\", sys.exc_info()[0])\n\t\t\tsys.exit(1)\n\n\t\t#install malicious app\n\t\tcmd = EMUINSTALL % ( ADBPATH, \"emulator-\" + str(adbport), \"'\" + job['fullpath'] + \"'\")\n\t\tvlogger.info( name + \":\" + cmd)\n\t\n\t\ttry:\n\t\t\tret = subprocess.check_output([cmd], shell=True)\n\t\t\tvlogger.info( name + \":\" + \"emulator install returned: %s\" % ret )\n\t\t\tinstall_attempts = ADBTRIES\n\t\t\twhile \"Success\" not in ret and install_attempts > 0:\n\t\t\t\tkick_adb_maybe(adbl, fcnt)\n\t\t\t\tvlogger.info( name + \":\" + \"install failed emulator install returned: %s\" % ret )\n\t\t\t\ttime.sleep(VM_POLL_REST)\n\n\t\t\t\t#TODO FIXME, track down why this sometimes stalls forever, seem on SDKs 11 and 14...\n\t\t\t\tret = subprocess.check_output([cmd], shell=True)\n\t\t\t\tinstall_attempts -= 1\n\t\t\t\tif install_attempts <= 0:\n\t\t\t\t\tsyslog.syslog(VMs[m].name + \":\" + \"install failed emulator install returned: %s\" % ret )\n\t\t\t\t\tvlogger.error(VMs[m].name + \":\" + \"install failed emulator install returned: %s\" % ret )\n\t\t\t\t\n\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"emulator install fatal error: %s\" % cmd )\n\t\t\tvlogger.error( formatExceptionInfo())\n\t\t\tsys.exit(1)\n\n\t\t#possible errors:\n\t\t#Error: Could not access the Package Manager. Is the system running?\n\n\t\ttime.sleep(VM_POLL_REST * 3)\n\n\t\t#stimulate\n\t\tdoc = etree.parse( MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \".xml\")\n\t\tpackage = doc.find('package')\n\n\t\t\n\t\tli = libIntent.libIntent(\"localhost\",adbport)\n\t\n\t\t#for each rint\n\t\tfor rint in doc.findall('rint'):\n\t\t\tvlogger.info( name + \" handling \" + str(rint.text))\n\t\t\tli.handleRIntent(str(rint.text))\n\n\t\t#for each permission (actions and rints _should_ catch all these....)\n\t\tfor perm in doc.findall('permission'):\n\t\t\tvlogger.info( name + \" handling \" + str(perm.text))\n\t\t\tli.handlePermission(str(perm.text))\n\n\t\t#for each action\n\t\tfor action in doc.findall('action'):\n\t\t\tvlogger.info( name + \" handling \" + str(action.text))\n\t\t\tli.handleAction(str(action.text))\n\t\t\t#BROADCASTS are done this way\n\t\t\t#cmd = EMUINTENT % ( ADBPATH, \"emulator-\" + str(adbport), \"android.intent.action.BOOT_COMPLETED\")\n\t\t\tcmd = EMUINTENT % ( ADBPATH, \"emulator-\" + str(adbport), str(action.text))\n\t\t\tvlogger.info( name + \":\" + cmd)\n\t\t\ttry:\n\t\t\t\t#TODO check for \"Broadcast completed\" in output, repeat if necessary\n\t\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\t\texcept:\n\t\t\t\tsyslog.syslog(\"app %s error sending intent %s\" % (job['sha256'],str(action.text)))\n\t\t\t\tvlogger.error( name + \":\" + \"emulator intent error: %s\" % cmd )\n\t\t\t\tvlogger.error( name + \":\" + \"emulator intent error: %d\" % ret )\n\t\t\t\t#TODO exit is a little too harsh here, but should probably requeue somehow\n\t\t\t\t#sys.exit(1)\n\t\t\t\t#sys.exit(1)\n\n\t\t#somethings just don't have nice rint or actions\n\t\tli.sendCall()\n\t\ttime.sleep(VM_POLL_REST)\n\t\tli.endAllCalls()\n\n\t\t#open app\n\n\n\t\t# TODO this should not be a for/for loop, the actions shoudl be paired with activities\n\t\tfor activity in doc.findall('activity'):\n\t\t\tfor action in doc.findall('action'):\n\t\t\t\tvlogger.info( name + \": \" + \"################## launching activity \" + str(activity.text))\n\t\t\t\tcmd = EMULAUNCH % ( ADBPATH, \"emulator-\" + str(adbport), str(action.text), str(package.text), str(activity.text))\n\t\t\t\tvlogger.info( name + \":\" + cmd)\n\t\t\t\ttry:\n\t\t\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\t\t\texcept:\n\t\t\t\t\tvlogger.error( name + \":\" + \"emulator launch error: %s\" % cmd )\n\t\t\t\t\tvlogger.error( name + \":\" + \"emulator launch error: %d\" % ret )\n\t\t\t\t\t#TODO exit is a little too harsh here, but should probably requeue somehow\n\t\t\t\t\t#sys.exit(1)\n\n\t\ttime.sleep(VM_POLL_REST * 5)\n\n\t\t#monkey around\n\t\tcmd = EMUMONKEY % ( ADBPATH, \"emulator-\" + str(adbport), str(package.text), random.randint(1,100))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\n\t\ttry:\n\t\t\tret = subprocess.check_output([cmd], shell=True)\n\t\t\tvlogger.info( name + \":\" + \"emulator monkey returned: %s\" % ret )\n#\t\t\tmonkey_attempts = ADBTRIES\n#\t\t\twhile \"Success\" not in ret and monkey_attempts > 0:\n#\t\t\t\tkick_adb_maybe(adbl, fcnt)\n#\t\t\t\tvlogger.info( name + \":\" + \"monkey failed emulator monkey returned: %s\" % ret )\n#\t\t\t\ttime.sleep(VM_POLL_REST)\n#\n#\t\t\t\tret = subprocess.check_output([cmd], shell=True)\n#\t\t\t\tmonkey_attempts -= 1\n#\t\t\t\tif monkey_attempts <= 0:\n#\t\t\t\t\tsyslog.syslog(VMs[m].name + \":\" + \"monkey failed emulator monkey returned: %s\" % ret )\n\t\t\t\t\n\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"emulator monkey fatal error: %s\" % cmd )\n\t\t\tsyslog.syslog(VMs[m].name + \":\" + \"monkey failed emulator monkey error: %s\" % cmd )\n\t\t\tvlogger.error( formatExceptionInfo())\n\t\t\tsys.exit(1)\n\n\t\t#kill\n\t\tcmd = EMUKILL % ( ADBPATH, \"emulator-\" + str(adbport))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\ttry:\n\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"emulator kill error\")\n\t\t\tsys.exit(1)\n\n\t\t#cleanup\n\t\tif pEmu.poll() is not None:\n\t\t\tvlogger.info( name + \": \" + \"poll is \" + str(pEmu.poll()))\n\t\t\ttry:\t\n\t\t\t\tpEmu.terminate()\n\t\t\texcept:\n\t\t\t\tvlogger.error( name + \": \" + \"pEmu term failed\")\n#TODO\t\tif pLogCat.poll() is not None:\n#TODO\t\t\tpLogCat.terminate()\n\t\tfLogCat.flush()\n\t\tfLogCat.close()\n\t\tfNull.close()\n\t\t\n\t\ttime.sleep(VM_POLL_REST)\n\t\tvlogger.info( name + \":\" + \"...stopping VM \" + VMs[m].name)\n\t\twith vmlock:\t\n\t\t\tVMlocal = VMs[m];\n\t\t\tVMlocal.state = \"Off\"\n\t\t\tVMs[m] = VMlocal;\n\t\n\t\tt2 = time.time()\t\n\n\t\tcomplete_time = time.strftime(\"%Y-%m-%d-%H:%M:%S\", time.gmtime())\n\t\tresults_file = job['sha256'] + \".pcap\"\n\t\tmsdb.updateFinishRun(job['jobuuid'],complete_time,results_file)\n\n\t\t#post process pcap, pretty crude for now, adb uses it's port and port+1; so two prunes\n\t\t#...and it seems that adb uses 5555 regardless of which even port is specified\n\t\toriginalpcap = MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \"-orig.pcap\"\n\t\ttmppcap = MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \"-temp.pcap\"\n\t\tfinalpcap = MALWAREJOBSBASE + \"/\" + job['jobuuid'] + \"/\" + job['sha256'] + \".pcap\"\n\n\t\t#cmd = \"prune_pcap.sh %s %s %s\" % (os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \"-orig.pcap\",os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \".pcap\", str(adbport))\n\t\tcmd = \"prune_pcap.sh %s %s %s\" % (originalpcap,tmppcap, str(adbport))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\ttry:\n\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"pcap prune error\")\n\t\t\tsys.exit(1)\n\n\t\t#cmd = \"prune_pcap.sh %s %s %s\" % (os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \"-orig.pcap\",os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \".pcap\", str(int(adbport)+1))\n\t\tcmd = \"prune_pcap.sh %s %s %s\" % (tmppcap,finalpcap, str(int(adbport)+1))\n\t\tvlogger.info( name + \":\" + cmd)\n\t\ttry:\n\t\t\tret = subprocess.check_call([cmd], shell=True)\n\t\texcept:\n\t\t\tvlogger.error( name + \":\" + \"pcap prune error\")\n\t\t\tsys.exit(1)\n\n\t\t#cmd = \"prune_pcap.sh %s %s %s\" % (os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \"-orig.pcap\",os.path.dirname(job['fullpath']) + \"/\" + job['sha256']+ \".pcap\", str(5555))\n#\t\tcmd = \"prune_pcap.sh %s %s %s\" % (originalpcap,finalpcap, str(adbport))\n#\t\tvlogger.info( name + \":\" + cmd)\n#\t\ttry:\n#\t\t\tret = subprocess.check_call([cmd], shell=True)\n#\t\texcept:\n#\t\t\tvlogger.error( name + \":\" + \"pcap prune error\")\n#\t\t\tsys.exit(1)\n\n\t\t#TODO unique ip addresses\n\t\t#tshark -r <input.pcap> -T fields -e ip.dst ip.src | sort | uniq\n\n\n\t\tvlogger.info( name + \":\" + \"sample took %s seconds process\" % str(t2 - t1))\n\t\tresults.put(t2-t1)\n\n\telif VMs[m].state in [\"Off\"]:\n\t\tvlogger.info( name + \":\" + VMs[m].name + \"run error: found in state OFF!\")\n\t\trval = False\n\telif VMs[m].state in [\"Ready\"]:\n\t\tvlogger.info( name + \":\" + VMs[m].name + \"run error: is running and not available for new malware\")\n\t\trval = False\n\t\t#if m.name in assignments:\n\t\t#\tif assignments[m.name]['timeout'] <= time.time():\n\t\t#\t\t#do anything you want to wrap up\n\t\t#\t\tjob_post_process(m)\n\t\t#\t\tjob_cleanup(m)\n\t\t#\t\tvm_poweroff(m)\n\t\t#else: # if the machine is running but there is no job assigned to it then kill it\n\t\t#\tpcap_terminate(m)\n\t\t#\tvm_poweroff(m)\n#\telse: #not sure this is relevant...may need to remove it\n#\t\tvm_poweroff(m) #I need to get a list of states that I want to poweroff by default\n\treturn rval", "metadata": "root.runInVM", "header": "['module', '___EOS___']", "index": 221 }, { "content": "def findCompatibleVM(job,VMs,vml):\n\trval = None\t\n\twith vml:\n\t\t#logger.info( \" ...uuid is \" + job['jobuuid'])\n\t\t#logger.info( \" ...app target is \" + str(job['target']))\n\t\tfor m in VMs.keys():\n\t\t\t#logger.info( \" seeing if \" + VMs[m].name + \" is compat...\")\n\t\t\t#logger.info( \" ...version is \" + str(int(VMs[m].version)) + \" ...\")\n\t#\t\t#Don't process machines without the ms naming convention\n\t#\t\tif not re.match('ms-vm\\d{3}',VMs[m].name):\n\t#\t\t\tcontinue\n\n\n\t\t\t#if the AndroidManifest doesn't havd a minsdk, maxsdk or targetsdk, then we don't know anything\n\t\t\t#about what version the app was created for, so we randomly pick something\n\t\t\t#if we pick \"wrong\" for our VM set, the job will just get delayed and we'll pick something else later\n\n\t\t\ttargetsdk = int(job['target'])\n\t\t\tif targetsdk == 0:\n\t\t\t\ttargetsdk = random.randint(MINSDKVER,MAXSDKVER)\n\t\t\t\tsyslog.syslog(\"app %s didn't specify any sdk information selecting %s\" % (job['sha256'],targetsdk))\n\t\t\t\t\n\n\t# states are Off=not powered on, Ready=powered on and ready for malware, Running=currently running (some other) malware, reserved=found, but not on yet\n\t\t\tif VMs[m].state in [\"Off\"] and int(VMs[m].version) == targetsdk:\n\t\t\t\tif not flagTerminate: #Dont assign more jobs if we are terminating\n\t\t\t\t\tlogger.info( VMs[m].name + \" (\" + str(m) + \") is available\")\n\t\t\t\t\tVMlocal = VMs[m];\n\t\t\t\t\tVMlocal.setState(\"Reserved\")\n\t\t\t\t\tVMs[m] = VMlocal;\n\t\t\t\t\t\n\t\t\t\t\trval = m\n\t\t\t\t\tbreak\n\t\t\t\t\t#job_assign(m) #vm is started at end of job assignment\n\t\t\t\t\t#Uncomment the next time to debug one job at a time\n\t\t\t\t\t#flagTerminate = True\n\t\t\telif VMs[m].state in [\"Running\"]:\n\t\t\t\tv = 1\n\t\t\t\t#logger.info( VMs[m].name + \" is running and not available for new malware\")\n\t\t\t\t#if m.name in assignments:\n\t\t\t\t#\tif assignments[m.name]['timeout'] <= time.time():\n\t\t\t\t#\t\t#do anything you want to wrap up\n\t\t\t\t#\t\tjob_post_process(m)\n\t\t\t\t#\t\tjob_cleanup(m)\n\t\t\t\t#\t\tvm_poweroff(m)\n\t\t\t\t#else: # if the machine is running but there is no job assigned to it then kill it\n\t\t\t\t#\tpcap_terminate(m)\n\t\t\t\t#\tvm_poweroff(m)\n\t#\t\telse: #not sure this is relevant...may need to remove it\n\t#\t\t\tvm_poweroff(m) #I need to get a list of states that I want to poweroff by default\n\treturn rval", "metadata": "root.findCompatibleVM", "header": "['module', '___EOS___']", "index": 565 }, { "content": "def worker(s, pool, q, str1, VMs, vml, adbport, count, adbl, results, fcnt):\n #global assignments\n global beanstalk\n\n name = multiprocessing.current_process().name\n\n formatter = logging.Formatter(fmt=LOGFORMAT,datefmt=LOGDATEFORMAT)\n handler = logging.FileHandler(\"worker.log\")\n handler.setFormatter(formatter)\n\n wlogger = logger.getChild(\"worker\" + name)\n wlogger.setLevel(logging.DEBUG)\n wlogger.addHandler(handler)\n\n with s:\n pool.makeActive(name)\n\twhile True:\n\t\t#funky kill pill\n\t\tcontent = q.get()\n\t\tq.put(content)\n \tif content == \"die\":\n\t\t\twlogger.info( name + \":\" + \" is committing suicide\")\n\t\t\tpool.makeInactive(name)\n\t\t\tsys.exit(0)\n\t\telse:\n\t\t\t#logger.info( 'Now running: %s %s %s (%s)' % (str(pool), str1, content,adbport))\n\t\t\twlogger.info( name + \":\" + \" is working...\")\n\n\t\t\t#check for a job in the beanstalk Q\n\t\t\t#if not beanstalk:\n\t\t\t#\terror_log('Re-establishing connection to beanstalkd')\n\t\t\t#\tbeanstalk = beanstalkc.Connection(host=BSHOST, port=BSPORT)\n\t\t\t#\tbeanstalk.watch(BSMSBOXQ)\n\t\t\t#\tbeanstalk.use(BSMSBOXQ)\n\t\t\t#\tbeanstalk.ignore('default')\n\t\t\trebeanstalk()\n\n\t\t\t#all this checking is just \"best effort\" another thread may still reserve first\n\t\t\tif BSMSBOXQ not in beanstalk.tubes():\n\t\t\t\t\twlogger.info( name + \":\" + \"there are no samples in the beanstalk\")\n\t\t\telse:\n\t\t\t\tarejobs = beanstalk.peek_ready()\n\t\t\t\tif arejobs is None:\n\t\t\t\t\twlogger.info( name + \":\" + \"there are no samples ready in the beanstalk\")\n\t\t\t\t\ttime.sleep(VM_POLL_REST)\n\t\t\t\telse:\n\n\t\t\t\t\t#we want to reserve, not peak_ready because if we can't process, we want to release with a delay later\n\t\t\t\t\tbeansalkjob = None\n\t\t\t\t\ttry:\n\t\t\t\t\t\tbeanstalkjob = beanstalk.reserve()\n\t\t\t\t\texcept:\n\t\t\t\t\t\twlogger.info( name + \": \" + \"beanstalk reserve error, probably out of jobs\")\n\n\t\t\t\t\t#if there was a job and we got it then queue up analysis\n\t\t\t\t\tjob = None\n\t\t\t\t\tif beanstalkjob:\n\t\t\t\t\t\ttry:\n\t\t\t\t\t\t\tjob = eval(beanstalkjob.body)\n\t\t\t\t\t\texcept:\n\t\t\t\t\t\t\terror_log('ERROR: could not eval job - invalid job')\n\t\t\t\t\t\t\tbeanstalkjob.delete()\n\t\t\t\t\t\t\twlogger.info( name + \":\" + \"BAD JOB, deleting\")\n\t\t\t\t\t\t\t#return False\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tif job:\n\t\t\t\t\t\t\t#is there a VM compatible with this sample that is ready to be used?\n\t\t\t\t\t\t\tm = findCompatibleVM(job,VMs,vml)\n\t\t\t\t\t\t\tif m is not None:\n\t\t\t\t\t\t\t\t#wlogger.info( name + \":\" + \"using VM \" + str(m))\n\t\t\t\t\t\t\t\twlogger.info( name + \":\" + \"using VM \" + str(m) + \" for \" + job['basename'] + \"(\" + job['target'] + \")\")\n\t\t\t\t\t\t\t\t#process sample\n\n\t\t\t\t\t\t\t\t#TODO this delete should really only happen if runInVM succeeds\n\t\t\t\t\t\t\t\tbeanstalkjob.delete()\n\t\t\t\t\t\t\t\tif runInVM(m,job,VMs,adbport,vml,adbl,results, fcnt):\n\t\t\t\t\t\t\t\t\t#runInVM might take a while\n\t\t\t\t\t\t\t\t\trebeanstalk()\n\t\t\t\t\t\t\t\t\t#delete from BSqueue if successfull\n\t\t\t\t\t\t\t\t\t#beanstalkjob.delete()\n\t\t\t\t\t\t\t\t\tcount.value += 1\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t#should never hit this due to live/die toggle\t\t\n\t\t\t\t\t\t\t\tif flagTerminate:\n\t\t\t\t\t\t\t\t\twlogger.info( name + \":\" + \"terminating?!\")\n\t\t\t\t\t\t\t\t\tsys.exit(0)\n\t\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\t\tcontinue\n\n\t\t\t\t\t\t\t\t#put back into VMready Q\n\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\t#no VM found, put it back in the queue (nobody will process for 60 seconds\n\t\t\t\t\t\t\t\tbeanstalkjob.release(delay=BSDELAY)\n\t\t\t\t\t\t\t\twlogger.info( name + \":\" + \"requeuing job requiring a target version \" + job['target'])\n\t\t\t#time.sleep(VM_POLL_REST)", "metadata": "root.worker", "header": "['module', '___EOS___']", "index": 627 }, { "content": "def main():\n\tglobal flagTerminate\n global beanstalk\n\tglobal logger\n\n\tlogger = setupLogger()\n\n \t# define a Handler which writes INFO messages or higher to the sys.stderr\n\tconsole = logging.StreamHandler()\n\tconsole.setLevel(logging.INFO)\n\t# set a format which is simpler for console use\n\tformatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')\n\t# tell the handler to use this format\n\tconsole.setFormatter(formatter)\n\t# add the handler to the root logger\n\tlogging.getLogger().addHandler(console)\n\n\trandom.seed()\n\n\tpool = ActivePool()\n\tassignments = pool.mgr.dict()\n\tcount = pool.mgr.Value('i', 0)\n\tADBFAILCOUNT = pool.mgr.Value('i', 0)\n\n\tVMs = pool.mgr.dict()\n\n\ts = multiprocessing.Semaphore(NUMACTIVEWORKERS)\n\tq = multiprocessing.Queue()\n\tr = multiprocessing.Queue()\n\tresults = []\n\tal = multiprocessing.RLock()\n\tvml = multiprocessing.RLock()\n\tcl = multiprocessing.RLock()\n\n\tget_VMs(VMs)\n\tlist_VMs(VMs)\n\t#make sure any pcaps are killed and we are starting with a clean filesystem\n\n\tfor i in range(30):\n\t\t#q.put(\"item \" + str(i) + \" content\")\n\t\tq.put(\"live\" + str(i))\n\t\t\n\n\t#adb ports are 5554 - 5584, only even\t\n\tport = ADBPORT\n\tjobs = [\n\t\tmultiprocessing.Process(target=worker, name=str(i), args=(s, pool, q, \"hi\", VMs, vml, str(port+(i*2)), count, al, r, ADBFAILCOUNT))\n\t\tfor i in range(NUMWORKERS)\n\t\t]\n\n\tfor j in jobs:\n\t\tlogger.info( \"starting worker %s\" % j.name)\n\t\tj.start()\n\n#\tfor j in jobs:\n#\t\tj.join()\n#\t\tlogger.info( 'Now running: %s' % str(pool))\n\n\t#make the connection after the child spawning, each child makes thier own connections\n\trebeanstalk()\n\n\twhile True:\n\n\t\tlogger.info( \"==============================\")\n\t\tlogger.info( \"processed %d samples so far\" % count.value)\n\t\ttry:\n\t\t\t#not great, but the parent is the only consumer of r items\n\t\t\tthing = r.get(block=False)\n\t\t\tresults.append(thing)\n\t\texcept:\n\t\t\tlogger.warning( \"results queue exception\")\n\t\t\n\t\tif len(results) > 0:\n\t\t\tlogger.info( \"average sample time: %s\" % str(sum(results) / float(len(results))))\n\t\ttry:\n\t\t\tif BSMSBOXQ not in beanstalk.tubes():\n\t\t\t\t\tlogger.info( \"there are no samples in the beanstalk\")\n\t\t\telse:\n\t\t\t\tif beanstalk.peek_ready() is not None:\n\t\t\t\t\tlogger.info( str(beanstalk.stats_tube(BSMSBOXQ)['current-jobs-ready']) + \" samples ready to process\")\n\t\t\t\telse:\n\t\t\t\t\tlogger.info( \"0 samples ready to process\")\n\t\t\t\tif beanstalk.peek_reserved() is not None:\n\t\t\t\t\tlogger.info( str(beanstalk.stats_tube(BSMSBOXQ)['current-jobs-reserved']) + \" samples are processing\")\n\t\t\t\telse:\n\t\t\t\t\tlogger.info( \"0 samples are processing\")\n\t\t\t\tif beanstalk.peek_delayed() is not None:\n\t\t\t\t\tlogger.info( str(beanstalk.stats_tube(BSMSBOXQ)['current-jobs-delayed']) + \" samples are delayed\")\n\t\t\t\telse:\n\t\t\t\t\tlogger.info( \"0 samples are delayed\")\n\t\texcept KeyError:\n\t\t\tlogger.warning( \"beanstalk keyerror\")\n\t\texcept:\n\t\t\tlogger.warning( \"beanstalk general error\")\n\t\tlogger.info( \"about \" + str(q.qsize()) + \" current q items\")\n\t\tlogger.info( \"adb has failed \" + str(ADBFAILCOUNT.value) + \" times since last kick\")\n\t\tlogger.debug( \"should be \" + str(NUMWORKERS) + \" processes:\")\n\t\twalive = 0\n\t\twdead = 0\n\t\tfor j in jobs:\n\t\t\tif j.is_alive():\n\t\t\t\tlogger.debug( \" \" + str(j.pid))\n\t\t\t\twalive += 1\n\t\t\telse: \n\t\t\t\tlogger.debug( \" dead\")\n\t\t\t\twdead += 1\n\t\t\t\t#this will kill the controller, leaving the children pipes wanting more (you will get sigpipe errors)\n\t\t\t\t#this is pretty harsh and shouldn't probably be done in production\n\t\t\t\t#TODO\n\t\t\t\t#sys.exit(1)\n\t\tlogger.info( \"%s alive; %s dead\" % (walive, wdead))\n\t\tupdateStatus(NUMWORKERS,walive,wdead)\n\n\t\tlist_VMs(VMs)\n\t\ttime.sleep(VM_POLL_REST + 10)\n\n\t\t#blocks until all items in q are processed\n\t\t#safe to exit\n\t\t#should check for sigint\n\t\t#if q.qsize() == 0:\n\t\t#\tfor i in jobs:\n\t\t#\t\tq.put(\"die\")\n\t\t#\tq.close()\n\n\tsys.exit(0)\n\n\n\tsignal.signal(signal.SIGINT, sigint_handler)\n\tsyslog.syslog('Startup - Entering main polling loop...')\n\twhile True:\n\n\t\tget_VMs(VMs)\n\t\tlist_VMs(VMs)\n\t\t#make sure any pcaps are killed and we are starting with a clean filesystem\n\t\t#pcap_terminate(m)\n\t\t#job_cleanup(m)\n\n\t\t#check for a job in the beanstalk Q\n\t\tif not beanstalk:\n\t\t\terror_log('Re-establishing connection to beanstalkd')\n\t\t\tbeanstalk = beanstalkc.Connection(host=BSHOST, port=BSPORT)\n\t\t\tbeanstalk.watch(BSMSBOXQ)\n\t\t\tbeanstalk.use(BSMSBOXQ)\n\t\t\tbeanstalk.ignore('default')\n\n\t\t#we want to reserve, not peak_ready because if we can't process, we want to release with a delay later\n\t\tbeanstalkjob = beanstalk.reserve()\n\n\t\t#if there was a job and we got it then queue up analysis\n\t\tif beanstalkjob:\n\t\t\ttry:\n\t\t\t\tjob = eval(beanstalkjob.body)\n\t\t\texcept:\n\t\t\t\terror_log('ERROR: could not eval job - invalid job')\n\t\t\t\tbeanstalkjob.delete()\n\t\t\t\treturn False\n\n\t\t\t#is there a VM compatible with this sample that is ready to be used?\n\t\t\tm = findCompatibleVM(job,VMs,vml)\n\t\t\tif m is not None:\n\t\t\t\tlogger.info( \"yay using VM \" + str(m))\n\t\t\t\t#process sample\n\n\t\t\t\tsys.exit(0)\n\n\t\t\t\t#delete from queue if successfull\n\t\t\t\t#beanstalkjob.delete()\n\t\t\telse:\n\t\t\t\t#no VM found, put it back in the queue (nobody will process for 60 seconds\n\t\t\t\tbeanstalkjob.release(delay=60)\n\t\t\t\tlogger.info( \"requeuing job requiring a target version \" + job['target'])\n\n\n#\t\t\n#\t\t#break ot of the loop and exit if the assignments are clear and the terminate flag is set\n\t\tif flagTerminate and len(assignments)==0:\n\t\t\tsyslog.syslog('All assigned jobs are completed (EXITING)...')\n\t\t\tbreak\n\t\t#put a pause in the polling cycle...set to 0 for no pause\n\t\ttime.sleep(VM_POLL_REST)\n\t\tsys.exit(0)\n\tsyslog.syslog('Shutdown - Leaving main polling loop...')\n\treturn 0", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 733 } ]
[ { "span": "pLogCat ", "start_line": 341, "start_column": 2, "end_line": 341, "end_column": 9 }, { "span": "ret ", "start_line": 525, "start_column": 3, "end_line": 525, "end_column": 6 }, { "span": "v ", "start_line": 602, "start_column": 4, "end_line": 602, "end_column": 5 }, { "span": "beansalkjob ", "start_line": 675, "start_column": 5, "end_line": 675, "end_column": 16 }, { "span": "assignments ", "start_line": 753, "start_column": 1, "end_line": 753, "end_column": 12 }, { "span": "cl ", "start_line": 765, "start_column": 1, "end_line": 765, "end_column": 3 } ]
[]
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_", "run", "In", "VM_", "(_", "m_", ",_", "job_", ",_", "VM", "s_", ",_", "adb", "port_", ",_", "vm", "lock_", ",_", "adb", "l_", ",_", "results_", ",_", "fcn", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "name_", "=_", "multiprocessing_", "._", "current", "\\u", "process_", "(_", ")_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "formatter_", "=_", "logging_", "._", "Formatter_", "(_", "fmt_", "=_", "LOG", "FORMAT_", ",_", "datefmt_", "=_", "LOG", "DAT", "EF", "ORM", "AT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path", "For", "File_", "=_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\"-", "run", ".", "log", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "HH", "%", "s", "HH", "\"_", "%_", "path", "For", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "=_", "logging_", "._", "File", "Handler_", "(_", "path", "For", "File_", ",_", "mode_", "=_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "set", "Formatter_", "(_", "formatter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vlo", "gger_", "=_", "logger_", "._", "get", "Child_", "(_", "\"", "worker", "\"_", "+_", "name_", "+_", "\".", "vm", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "set", "Level_", "(_", "logging_", "._", "DEBUG_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "add", "Handler_", "(_", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "\"", "logg", "ing", " ", "start", "ed", " ", "at", " ", "\"_", "+_", "path", "For", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "VM", "s_", "[_", "m_", "]_", "._", "state_", "in_", "[_", "\"", "Reserve", "d", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "vm", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "VM", "local_", "=_", "VM", "s_", "[_", "m_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "local_", "._", "state_", "=_", "\"", "Start", "ing", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "s_", "[_", "m_", "]_", "=_", "VM", "local_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "emulator", " ", "doe", "ns", "'", "t", " ", "observe", " ", "system", " ", "host", "s", ":", " ", " ", "(", "must", " ", "start", " ", "emulator", " ", "with", " ", "-", "partit", "ion", "-", "size", " ", "128", " ", "(", "for", " ", "example", ")", " ", "to", " ", "give", " ", "room", " ", "to", " ", "write", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "pull", " ", "/", "etc", "/", "hosts_", "\\u\\u\\uNL\\u\\u\\u_", "#", "edit", " ", "to", " ", "10.", "0.", "2.2", " ", "(", "your", " ", "local", " ", "machine", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "remo", "unt_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "push", " ", "host", "s", " ", "/", "etc", "/", "hosts_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "emulator", " ", "-", "av", "d", " ", "NAME", " ", "-", "partit", "ion", "-", "size", " ", "128", " ", "-", "port", "s", " ", "5", ",", "232", "2", " ", "-", "no", "-", "window", " ", "-", "tcp", "dump", " ", "FILE", " ", "-", "dns", "-", "server", " ", "SERVER", " ", "-", "http", "-", "proxy", " ", "PROX", "Y_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", " ", "inst", "ead", " ", "of", " ", "wipe", "-", "data", ",", " ", "wou", "ld", " ", "be", " ", "best", " ", "to", " ", "re", "-", "create", " ", "the", " ", "VM_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UST", "ART", "_", "=_", "\"%", "s", "/", "emulator", " ", "-", "av", "d", " ", "%", "s", " ", "-", "partit", "ion", "-", "size", " ", "%", "s", " ", "-", "port", " ", "%", "s", " ", "-", "no", "-", "window", " ", "-", "tcp", "dump", " ", "%", "s", " ", "-", "wipe", "-", "data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#.", "/", "adb", " ", "logc", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#.", "/", "adb", " ", "install", " ", "/", "storage", "/", "mal", "ware", "/", "RU", ".", "apk", "_", "\\u\\u\\uNL\\u\\u\\u_", "#.", "/", "adb", " ", "shell", " ", "am", " ", "broadcast", " ", "-", "a", " ", "android", ".", "intent", ".", "action", ".", "BOOT", "\\u", "COMPLETED", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "start", " ", "(", "with", " ", "specified", " ", "port", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "emulator", " ", "-", "port", "s", " ", "X", ",", "Y", " ", "@", "av", "d\\u", "X_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "wait", " ", "for", " ", "emulator", " ", "to", " ", "be", " ", "full", "y", " ", "started_", "\\u\\u\\uNL\\u\\u\\u_", "#.", "/", "adb", " ", "-", "s", " ", "emulator", "-", "558", "4", " ", "wait", "-", "for", "-", "device_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UW", "AI", "T_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "wait", "-", "for", "-", "device", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UL", "OG", "CAT", "_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "logc", "at", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "command_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "-", "s", " ", "emu", "alt", "or", "-", "X", " ", "shell", " ", "cmd_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UI", "NS", "TAL", "L_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "install", " ", "%", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "<", "INTEN", "T", ">", " ", "specifica", "tion", "s", " ", "include", " ", "these", " ", "flags", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "a", " ", "<", "ACTI", "ON", ">]", " ", "[-", "d", " ", "<", "DATA", "\\u", "URI", ">]", " ", "[-", "t", " ", "<", "MIME", "\\u", "TYPE", ">]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "c", " ", "<", "CATEGORY", ">", " ", "[-", "c", " ", "<", "CATEGORY", ">]", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "e", "|--", "es", " ", "<", "EXTRA", "\\u", "KEY", ">", " ", "<", "EXTRA", "\\u", "STRING", "\\u", "VALU", "E", ">", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "-", "esn", " ", "<", "EXTRA", "\\u", "KEY", ">", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "-", "ez", " ", "<", "EXTRA", "\\u", "KEY", ">", " ", "<", "EXTRA", "\\u", "BOOLEAN", "\\u", "VALU", "E", ">", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "[-", "e", "|--", "ei", " ", "<", "EXTRA", "\\u", "KEY", ">", " ", "<", "EXTRA", "\\u", "INT", "\\u", "VALU", "E", ">", " ", "...]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "shell", " ", "am", " ", "broadcast", " ", "-", "a", " ", "android", ".", "intent", ".", "action", ".", "BOOT", "\\u", "COMPLETED", " ", "-", "c", " ", "android", ".", "intent", ".", "category", ".", "HOM", "E", " ", "-", "n", " ", "net", ".", "fsta", "b", ".", "check", "it", "\\u", "android", "/.", "Start", "up", "Receiver_", "\\u\\u\\uNL\\u\\u\\u_", "#", "am", " ", "broadcast", " ", "-", "a", " ", "android", ".", "intent", ".", "action", ".", "BOOT", "\\u", "COMPLETED", "_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UINT", "ENT_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "shell", " ", "am", " ", "broadcast", " ", "-", "a", " ", "%", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "shell", " ", "am", " ", "start", " ", "-", "n", " ", "com", ".", "package", ".", "name", "/", "com", ".", "package", ".", "name", ".", "Activ", "it", "y", "Name_", "\\u\\u\\uNL\\u\\u\\u_", "#", "am", " ", "start", " ", "-", "a", " ", "android", ".", "intent", ".", "action", ".", "MAIN", " ", "-", "n", " ", "com", ".", "ift", "ita", "h", ".", "android", ".", "contact", "/", "com", ".", "ift", "ita", "h", ".", "android", ".", "contact", ".", "Contact_", "\\u\\u\\uNL\\u\\u\\u_", "#", "am", " ", "start", " ", "-", "a", " ", "<", "ACTI", "ON", ">", " ", "-", "n", " ", "<", "PACKAG", "E", ">/", "<", "PACKAG", "E", "><", "ACTIVITY", "CLASS", ">_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "ULA", "UNC", "H_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "shell", " ", "am", " ", "start", " ", "-", "a", " ", "%", "s", " ", "-", "n", " ", "%", "s", "/", "%", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "kill_", "\\u\\u\\uNL\\u\\u\\u_", "#", "coul", "d", " ", "do", " ", "adb", " ", "shell", " ", "stop_", "\\u\\u\\uNL\\u\\u\\u_", "#", "but", " ", "wh", "y", " ", "reall", "y", "?", " ", " ", "just", " ", "goi", "ng", " ", "to", " ", "reset", " ", "for", " ", "next", " ", "run", " ", "anyway", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "tho", "ugh", " ", "a", " ", "stop", " ", "wou", "ld", " ", "preserve", " ", "state", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "-", "s", " ", "emulator", "-", "X", " ", "emu", " ", "kill_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UK", "ILL", "_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "emu", " ", "kill", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "monkey_", "\\u\\u\\uNL\\u\\u\\u_", "#$", " ", "adb", " ", "shell", " ", "monkey", " ", "-", "v", " ", "-", "p", " ", "your", ".", "package", ".", "name", " ", "100", " ", "--", "ignore", "-", "security", "-", "exception", "s", " ", "-", "s", " ", "SEED", "_", "\\u\\u\\uNL\\u\\u\\u_", "EM", "UM", "ON", "KEY_", "=_", "\"%", "s", "/", "adb", " ", "-", "s", " ", "%", "s", " ", "shell", " ", "monkey", " ", "-", "v", " ", "-", "p", " ", "%", "s", " ", "100", " ", "--", "ignore", "-", "security", "-", "exception", "s", " ", "-", "s", " ", "%", "s", " ", "--", "throttle", " ", "250", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "update", " ", "databa", "se", " ", "with", " ", "start", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "permissi", "ons", "\\u", "filename_", "=_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\".", "xml", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "used_", "=_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "time_", "=_", "time_", "._", "strftime_", "(_", "\"%", "Y", "-%", "m", "-%", "d", "-%", "H", ":", "%", "M", ":", "%", "S", "\"_", ",_", "time_", "._", "gmtime_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msd", "b_", "._", "update", "Start", "Run_", "(_", "job_", "[_", "'", "job", "uuid", "'_", "]_", ",_", "image", "\\u", "used_", ",_", "start", "\\u", "time_", ",_", "permissi", "ons", "\\u", "filename_", ",_", "MS", "VERSION_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"...", "startin", "g", " ", "VM", " ", "\"_", "+_", "VM", "s_", "[_", "m_", "]_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "start", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "EM", "UST", "ART", "_", "%_", "(_", "SD", "KP", "ATH", "_", ",_", "VM", "s_", "[_", "m_", "]_", "._", "name_", ",_", "PS", "IZE_", ",_", "str_", "(_", "adb", "port_", ")_", ",_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\"-", "orig", ".", "pcap", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "Em", "u_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "args_", "=_", "shlex_", "._", "split_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "Em", "u_", "=_", "subprocess_", "._", "Popen_", "(_", "args_", ")_", "\\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_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "start", " ", "error", "\"_", ",_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "check", " ", "for", " ", "start", " ", "error", " ", "condition", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "emulator", ":", " ", "WARN", "ING", ":", " ", "ign", "orin", "g", " ", "lock", "ed", " ", "SD", " ", "Card", " ", "image", " ", "at", " ", "/", "path", "/", "to", "/", "av", "d", "/", "ms", "-", "sd", "k", "003", "-0", "03", "/", "sdc", "ard", ".", "img_", "\\u\\u\\uNL\\u\\u\\u_", "#", "it", " ", "see", "ms", " ", "too", " ", "many", " ", "emulator", " ", "instance", "s", " ", "are", " ", "runn", "ing", " ", "on", " ", "this", " ", "machine", ".", " ", "Abo", "rti", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "wait", " ", "for", " ", "it", " ", "to", " ", "start_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "EM", "UW", "AI", "T_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "wait", " ", "return", "ed", ":", " ", "%", "d", "\"_", "%_", "ret_", ")_", "\\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_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "wait", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", "+_", "\"", " ", "start", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", "*_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "vm", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "VM", "local_", "=_", "VM", "s_", "[_", "m_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "local_", "._", "state_", "=_", "\"", "Run", "ning", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "s_", "[_", "m_", "]_", "=_", "VM", "local_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "start", " ", "logc", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", "start", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "EM", "UL", "OG", "CAT", "_", "%_", "(_", "SD", "KP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p", "Log", "Cat_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "Log", "Cat_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "args_", "=_", "shlex_", "._", "split_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "Log", "Cat_", "=_", "open_", "(_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\".", "logc", "at", "\"_", ",_", "\"", "w", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "Null_", "=_", "open_", "(_", "\"/", "dev", "/", "null", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "TOD", "O", "\t\t\t", "p", "Log", "Cat", " ", "=", " ", "subproc", "ess", ".", "Pop", "en", "(", "args", ",", " ", "std", "in", "=", "f", "Null", ",", " ", "std", "err", "=", "f", "Null", ",", " ", "stdout", "=", "f", "Log", "Cat", ")_", "\\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\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":", " ", "\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "format", "Except", "ion", "Info_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "logc", "at", " ", "error", "\"_", ",_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "install", " ", "mali", "cio", "us", " ", "app_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "EM", "UI", "NS", "TAL", "L_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ",_", "\"'\"_", "+_", "job_", "[_", "'", "full", "path", "'_", "]_", "+_", "\"'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\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_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "output_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "install", " ", "return", "ed", ":", " ", "%", "s", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "install", "\\u", "attempts_", "=_", "AD", "BT", "RIE", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "\"", "Success", "\"_", "not_", "in_", "ret_", "and_", "install", "\\u", "attempts_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "kick", "\\u", "adb", "\\u", "may", "be_", "(_", "adb", "l_", ",_", "fcn", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "install", " ", "fail", "ed", " ", "emulator", " ", "install", " ", "return", "ed", ":", " ", "%", "s", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", " ", "FIX", "ME", ",", " ", "track", " ", "down", " ", "wh", "y", " ", "this", " ", "somet", "imes", " ", "stall", "s", " ", "forever", ",", " ", "see", "m", " ", "on", " ", "SD", "Ks", " ", "11", " ", "and", " ", "14.", "..", "_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "output_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "install", "\\u", "attempts_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "install", "\\u", "attempts_", "<=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "syslog_", "._", "syslog_", "(_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\":\"_", "+_", "\"", "install", " ", "fail", "ed", " ", "emulator", " ", "install", " ", "return", "ed", ":", " ", "%", "s", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\":\"_", "+_", "\"", "install", " ", "fail", "ed", " ", "emulator", " ", "install", " ", "return", "ed", ":", " ", "%", "s", "\"_", "%_", "ret_", ")_", "\\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_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "install", " ", "fat", "al", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "format", "Except", "ion", "Info_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "possib", "le", " ", "error", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Error", ":", " ", "Cou", "ld", " ", "not", " ", "access", " ", "the", " ", "Packa", "ge", " ", "Manager", ".", " ", " ", "Is", " ", "the", " ", "system", " ", "runn", "ing", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", "*_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "stimul", "ate_", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "=_", "etree_", "._", "parse_", "(_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\".", "xml", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "package_", "=_", "doc_", "._", "find_", "(_", "'", "package", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "li_", "=_", "lib", "Inten", "t_", "._", "lib", "Inten", "t_", "(_", "\"", "local", "host", "\"_", ",_", "adb", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "each", " ", "rint_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "rint_", "in_", "doc_", "._", "findall_", "(_", "'", "rint", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\"", " ", "handling", " ", "\"_", "+_", "str_", "(_", "rint_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "li_", "._", "handle", "RI", "ntent", "_", "(_", "str_", "(_", "rint_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "each", " ", "permissi", "on", " ", "(", "action", "s", " ", "and", " ", "rint", "s", " ", "\\u", "shou", "ld", "\\u", " ", "catch", " ", "all", " ", "these", "....", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "perm_", "in_", "doc_", "._", "findall_", "(_", "'", "permissi", "on", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\"", " ", "handling", " ", "\"_", "+_", "str_", "(_", "perm_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "li_", "._", "handle", "Permission_", "(_", "str_", "(_", "perm_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "each", " ", "action_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "action_", "in_", "doc_", "._", "findall_", "(_", "'", "action", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\"", " ", "handling", " ", "\"_", "+_", "str_", "(_", "action_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "li_", "._", "handle", "Action_", "(_", "str_", "(_", "action_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "BROADCAST", "S", " ", "are", " ", "don", "e", " ", "this", " ", "way_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "EM", "UINT", "ENT", " ", "%", " ", "(", " ", "AD", "BP", "ATH", ",", " ", "\"", "emulator", "-\"", " ", "+", " ", "str", "(", "adb", "port", "),", " ", "\"", "android", ".", "intent", ".", "action", ".", "BOOT", "\\u", "COMPLETED", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "EM", "UINT", "ENT_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ",_", "str_", "(_", "action_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "TOD", "O", " ", "check", " ", "for", " ", "\"", "Broad", "cast", " ", "complete", "d", "\"", " ", "in", " ", "output", ",", " ", "repeat", " ", "if", " ", "necessar", "y_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "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\t", "\t\t\t_", "syslog_", "._", "syslog_", "(_", "\"", "app", " ", "%", "s", " ", "error", " ", "sendin", "g", " ", "intent", " ", "%", "s", "\"_", "%_", "(_", "job_", "[_", "'", "sha2", "56", "'_", "]_", ",_", "str_", "(_", "action_", "._", "text_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "intent", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "intent", " ", "error", ":", " ", "%", "d", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "TOD", "O", " ", "exit", " ", "is", " ", "a", " ", "litt", "le", " ", "too", " ", "har", "sh", " ", "here", ",", " ", "but", " ", "shou", "ld", " ", "probab", "ly", " ", "reque", "ue", " ", "some", "how_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "exit", "(", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "exit", "(", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "somet", "hing", "s", " ", "just", " ", "don", "'", "t", " ", "have", " ", "nice", " ", "rint", " ", "or", " ", "actions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "li_", "._", "send", "Call_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "li_", "._", "end", "All", "Calls", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "open", " ", "app_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", " ", "this", " ", "shou", "ld", " ", "not", " ", "be", " ", "a", " ", "for", "/", "for", " ", "loop", ",", " ", "the", " ", "action", "s", " ", "shou", "dl", " ", "be", " ", "paired", " ", "with", " ", "activities_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "activity_", "in_", "doc_", "._", "findall_", "(_", "'", "activit", "y", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "for_", "action_", "in_", "doc_", "._", "findall_", "(_", "'", "action", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":", " ", "\"_", "+_", "\"############", "######", " ", "launch", "ing", " ", "activit", "y", " ", "\"_", "+_", "str_", "(_", "activity_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "EM", "ULA", "UNC", "H_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ",_", "str_", "(_", "action_", "._", "text_", ")_", ",_", "str_", "(_", "package_", "._", "text_", ")_", ",_", "str_", "(_", "activity_", "._", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "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\t", "\t\t\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "launch", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "launch", " ", "error", ":", " ", "%", "d", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "TOD", "O", " ", "exit", " ", "is", " ", "a", " ", "litt", "le", " ", "too", " ", "har", "sh", " ", "here", ",", " ", "but", " ", "shou", "ld", " ", "probab", "ly", " ", "reque", "ue", " ", "some", "how_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "exit", "(", "1", ")_", "\\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_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", "*_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "monkey", " ", "around_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "EM", "UM", "ON", "KEY_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ",_", "str_", "(_", "package_", "._", "text_", ")_", ",_", "random_", "._", "randint_", "(_", "1_", ",_", "100_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\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_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "output_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "monkey", " ", "return", "ed", ":", " ", "%", "s", "\"_", "%_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "\t\t\t", "monkey", "\\u", "atte", "mpt", "s", " ", "=", " ", "AD", "BT", "RIE", "S_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "whi", "le", " ", "\"", "Success", "\"", " ", "not", " ", "in", " ", "ret", " ", "and", " ", "monkey", "\\u", "atte", "mpt", "s", " ", ">", " ", "0", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "kick", "\\u", "adb", "\\u", "may", "be", "(", "adb", "l", ",", " ", "fcn", "t", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "vlo", "gger", ".", "info", "(", " ", "name", " ", "+", " ", "\":\"", " ", "+", " ", "\"", "monkey", " ", "fail", "ed", " ", "emulator", " ", "monkey", " ", "return", "ed", ":", " ", "%", "s", "\"", " ", "%", " ", "ret", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "time", ".", "sleep", "(", "VM", "\\u", "POLL", "\\u", "REST", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "ret", " ", "=", " ", "subproc", "ess", ".", "check", "\\u", "output", "([", "cmd", "],", " ", "shell", "=", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "monkey", "\\u", "atte", "mpt", "s", " ", "-=", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "if", " ", "monkey", "\\u", "atte", "mpt", "s", " ", "<=", " ", "0", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "\t", "\t", "syslo", "g", ".", "syslo", "g", "(", "VM", "s", "[", "m", "].", "name", " ", "+", " ", "\":\"", " ", "+", " ", "\"", "monkey", " ", "fail", "ed", " ", "emulator", " ", "monkey", " ", "return", "ed", ":", " ", "%", "s", "\"", " ", "%", " ", "ret", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "monkey", " ", "fat", "al", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "syslog_", "._", "syslog_", "(_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\":\"_", "+_", "\"", "monkey", " ", "fail", "ed", " ", "emulator", " ", "monkey", " ", "error", ":", " ", "%", "s", "\"_", "%_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "error_", "(_", "format", "Except", "ion", "Info_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "kill_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "EM", "UK", "ILL", "_", "%_", "(_", "AD", "BP", "ATH", "_", ",_", "\"", "emulator", "-\"_", "+_", "str_", "(_", "adb", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "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\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "emulator", " ", "kill", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cleanup_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p", "Em", "u_", "._", "poll_", "(_", ")_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":", " ", "\"_", "+_", "\"", "poll", " ", "is", " ", "\"_", "+_", "str_", "(_", "p", "Em", "u_", "._", "poll_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "p", "Em", "u_", "._", "terminate_", "(_", ")_", "\\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\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":", " ", "\"_", "+_", "\"", "p", "Em", "u", " ", "term", " ", "fail", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "TOD", "O", "\t", "\t", "if", " ", "p", "Log", "Cat", ".", "poll", "()", " ", "is", " ", "not", " ", "Non", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", "\t\t\t", "p", "Log", "Cat", ".", "terminate", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f", "Log", "Cat_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "Log", "Cat_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f", "Null_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"...", "stopping", " ", "VM", " ", "\"_", "+_", "VM", "s_", "[_", "m_", "]_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "vm", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "VM", "local_", "=_", "VM", "s_", "[_", "m_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "local_", "._", "state_", "=_", "\"", "Off", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "s_", "[_", "m_", "]_", "=_", "VM", "local_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t2_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "time_", "=_", "time_", "._", "strftime_", "(_", "\"%", "Y", "-%", "m", "-%", "d", "-%", "H", ":", "%", "M", ":", "%", "S", "\"_", ",_", "time_", "._", "gmtime_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results", "\\u", "file_", "=_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\".", "pcap", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msd", "b_", "._", "update", "Finish", "Run_", "(_", "job_", "[_", "'", "job", "uuid", "'_", "]_", ",_", "complete", "\\u", "time_", ",_", "results", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "post", " ", "process", " ", "pcap", ",", " ", "pretty", " ", "crud", "e", " ", "for", " ", "now", ",", " ", "adb", " ", "use", "s", " ", "it", "'", "s", " ", "port", " ", "and", " ", "port", "+", "1", ";", " ", "so", " ", "two", " ", "prune", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#..", ".", "and", " ", "it", " ", "see", "ms", " ", "tha", "t", " ", "adb", " ", "use", "s", " ", "5555", " ", "rega", "rd", "less", " ", "of", " ", "whi", "ch", " ", "even", " ", "port", " ", "is", " ", "specified", "_", "\\u\\u\\uNL\\u\\u\\u_", "original", "pcap", "_", "=_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\"-", "orig", ".", "pcap", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "pcap", "_", "=_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\"-", "temp", ".", "pcap", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "final", "pcap", "_", "=_", "MAL", "WARE", "JOB", "SB", "AS", "E_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "job", "uuid", "'_", "]_", "+_", "\"/\"_", "+_", "job_", "[_", "'", "sha2", "56", "'_", "]_", "+_", "\".", "pcap", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"", " ", "%", " ", "(", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\"-", "orig", ".", "pcap", "\",", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\".", "pcap", "\",", " ", "str", "(", "adb", "port", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"_", "%_", "(_", "original", "pcap", "_", ",_", "tmp", "pcap", "_", ",_", "str_", "(_", "adb", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "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\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "pcap", " ", "prune", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"", " ", "%", " ", "(", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\"-", "orig", ".", "pcap", "\",", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\".", "pcap", "\",", " ", "str", "(", "int", "(", "adb", "port", ")+", "1", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmd_", "=_", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"_", "%_", "(_", "tmp", "pcap", "_", ",_", "final", "pcap", "_", ",_", "str_", "(_", "int_", "(_", "adb", "port_", ")_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "ret_", "=_", "subprocess_", "._", "check", "\\u", "call_", "(_", "[_", "cmd_", "]_", ",_", "shell_", "=_", "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\t", "\t\t_", "vlo", "gger_", "._", "error_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "pcap", " ", "prune", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cmd", " ", "=", " ", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"", " ", "%", " ", "(", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\"-", "orig", ".", "pcap", "\",", "os", ".", "path", ".", "dir", "name", "(", "job", "['", "full", "path", "'])", " ", "+", " ", "\"/", "\"", " ", "+", " ", "job", "['", "sha2", "56", "']", "+", " ", "\".", "pcap", "\",", " ", "str", "(", "5555", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "cmd", " ", "=", " ", "\"", "prune", "\\u", "pcap", ".", "sh", " ", "%", "s", " ", "%", "s", " ", "%", "s", "\"", " ", "%", " ", "(", "original", "pcap", ",", "final", "pcap", ",", " ", "str", "(", "adb", "port", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "vlo", "gger", ".", "info", "(", " ", "name", " ", "+", " ", "\":\"", " ", "+", " ", "cmd", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "ret", " ", "=", " ", "subproc", "ess", ".", "check", "\\u", "call", "([", "cmd", "],", " ", "shell", "=", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "except", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "vlo", "gger", ".", "error", "(", " ", "name", " ", "+", " ", "\":\"", " ", "+", " ", "\"", "pcap", " ", "prune", " ", "error", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "sys", ".", "exit", "(", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", " ", "unique", " ", "ip", " ", "addresses_", "\\u\\u\\uNL\\u\\u\\u_", "#", "tsh", "ark", " ", "-", "r", " ", "<", "input", ".", "pcap", ">", " ", "-", "T", " ", "fields", " ", "-", "e", " ", "ip", ".", "dst", " ", "ip", ".", "src", " ", "|", " ", "sort", " ", "|", " ", "uniq", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "sample", " ", "too", "k", " ", "%", "s", " ", "second", "s", " ", "process", "\"_", "%_", "str_", "(_", "t2_", "-_", "t1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "._", "put_", "(_", "t2_", "-_", "t1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "VM", "s_", "[_", "m_", "]_", "._", "state_", "in_", "[_", "\"", "Off", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\"", "run", " ", "error", ":", " ", "found", " ", "in", " ", "state", " ", "OFF", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "VM", "s_", "[_", "m_", "]_", "._", "state_", "in_", "[_", "\"", "Read", "y", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "vlo", "gger_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\"", "run", " ", "error", ":", " ", "is", " ", "runn", "ing", " ", "and", " ", "not", " ", "avail", "able", " ", "for", " ", "new", " ", "mal", "ware", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "m", ".", "name", " ", "in", " ", "assign", "ment", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "if", " ", "assign", "ment", "s", "[", "m", ".", "name", "]['", "timeo", "ut", "']", " ", "<=", " ", "time", ".", "time", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "#", "do", " ", "anyt", "hing", " ", "you", " ", "want", " ", "to", " ", "wrap", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "job", "\\u", "post", "\\u", "process", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "job", "\\u", "clean", "up", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "vm", "\\u", "power", "off", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "else", ":", " ", "#", " ", "if", " ", "the", " ", "machine", " ", "is", " ", "runn", "ing", " ", "but", " ", "there", " ", "is", " ", "no", " ", "job", " ", "assign", "ed", " ", "to", " ", "it", " ", "then", " ", "kill", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "pcap", "\\u", "terminate", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "vm", "\\u", "power", "off", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "else", ":", " ", "#", "not", " ", "sure", " ", "this", " ", "is", " ", "rele", "van", "t", "...", "may", " ", "need", " ", "to", " ", "remove", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "vm", "\\u", "power", "off", "(", "m", ")", " ", "#", "I", " ", "need", " ", "to", " ", "get", " ", "a", " ", "list", " ", "of", " ", "state", "s", " ", "tha", "t", " ", "I", " ", "want", " ", "to", " ", "power", "off", " ", "by", " ", "default_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rval_", "\\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_", "find", "Compatible", "VM_", "(_", "job_", ",_", "VM", "s_", ",_", "vm", "l_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "rval_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "vm", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "\"", " ", " ", " ", "...", "uuid", " ", "is", " ", "\"", " ", "+", " ", "job", "['", "job", "uuid", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "\"", " ", " ", " ", "...", "app", " ", "target", " ", "is", " ", "\"", " ", "+", " ", "str", "(", "job", "['", "target", "'])", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "for_", "m_", "in_", "VM", "s_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "\"", " ", " ", " ", "see", "ing", " ", "if", " ", "\"", " ", "+", " ", "VM", "s", "[", "m", "].", "name", " ", "+", " ", "\"", " ", "is", " ", "compa", "t", "...\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "\"", " ", " ", " ", "...", "version", " ", "is", " ", "\"", " ", "+", " ", "str", "(", "int", "(", "VM", "s", "[", "m", "].", "version", "))", " ", "+", " ", "\"", " ", "...\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "#", "Don", "'", "t", " ", "process", " ", "machine", "s", " ", "with", "out", " ", "the", " ", "ms", " ", "nami", "ng", " ", "convention", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "if", " ", "not", " ", "re", ".", "match", "('", "ms", "-", "vm", "\\\\", "d", "{", "3", "}'", ",", "VM", "s", "[", "m", "].", "name", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "continue_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "the", " ", "And", "roid", "Manifest", " ", "doe", "sn", "'", "t", " ", "hav", "d", " ", "a", " ", "mins", "dk", ",", " ", "maxs", "dk", " ", "or", " ", "target", "sd", "k", ",", " ", "then", " ", "we", " ", "don", "'", "t", " ", "know", " ", "anyt", "hing_", "\\u\\u\\uNL\\u\\u\\u_", "#", "abo", "ut", " ", "what", " ", "version", " ", "the", " ", "app", " ", "was", " ", "created", " ", "for", ",", " ", "so", " ", "we", " ", "random", "ly", " ", "pick", " ", "something_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "we", " ", "pick", " ", "\"", "wrong", "\"", " ", "for", " ", "our", " ", "VM", " ", "set", ",", " ", "the", " ", "job", " ", "will", " ", "just", " ", "get", " ", "delayed", " ", "and", " ", "we", "'", "ll", " ", "pick", " ", "somet", "hing", " ", "else", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "target", "sdk_", "=_", "int_", "(_", "job_", "[_", "'", "target", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "target", "sdk_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "target", "sdk_", "=_", "random_", "._", "randint_", "(_", "MIN", "SD", "KV", "ER_", ",_", "MAX", "SD", "KV", "ER_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "syslog_", "._", "syslog_", "(_", "\"", "app", " ", "%", "s", " ", "did", "n", "'", "t", " ", "speci", "fy", " ", "any", " ", "sd", "k", " ", "informati", "on", " ", "selecti", "ng", " ", "%", "s", "\"_", "%_", "(_", "job_", "[_", "'", "sha2", "56", "'_", "]_", ",_", "target", "sdk_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "state", "s", " ", "are", " ", "Off", "=", "not", " ", "powered", " ", "on", ",", " ", "Read", "y", "=", "powered", " ", "on", " ", "and", " ", "read", "y", " ", "for", " ", "mal", "ware", ",", " ", "Run", "ning", "=", "currentl", "y", " ", "runn", "ing", " ", "(", "some", " ", "other", ")", " ", "mal", "ware", ",", " ", "reserve", "d", "=", "found", ",", " ", "but", " ", "not", " ", "on", " ", "ye", "t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "VM", "s_", "[_", "m_", "]_", "._", "state_", "in_", "[_", "\"", "Off", "\"_", "]_", "and_", "int_", "(_", "VM", "s_", "[_", "m_", "]_", "._", "version_", ")_", "==_", "target", "sdk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "not_", "flag", "Terminate", "_", ":_", "#", "Don", "t", " ", "assign", " ", "more", " ", "jobs", " ", "if", " ", "we", " ", "are", " ", "termina", "ting_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "logger_", "._", "info_", "(_", "VM", "s_", "[_", "m_", "]_", "._", "name_", "+_", "\"", " ", "(\"_", "+_", "str_", "(_", "m_", ")_", "+_", "\")", " ", "is", " ", "avail", "able", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "local_", "=_", "VM", "s_", "[_", "m_", "]_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "local_", "._", "set", "State_", "(_", "\"", "Reserve", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VM", "s_", "[_", "m_", "]_", "=_", "VM", "local_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval_", "=_", "m_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "job", "\\u", "assign", "(", "m", ")", " ", "#", "vm", " ", "is", " ", "start", "ed", " ", "at", " ", "end", " ", "of", " ", "job", " ", "assignment_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Unco", "mmen", "t", " ", "the", " ", "next", " ", "time", " ", "to", " ", "debug", " ", "one", " ", "job", " ", "at", " ", "a", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "#", "flag", "Terminate", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "VM", "s_", "[_", "m_", "]_", "._", "state_", "in_", "[_", "\"", "Run", "ning", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "v_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "VM", "s", "[", "m", "].", "name", " ", "+", " ", "\"", " ", "is", " ", "runn", "ing", " ", "and", " ", "not", " ", "avail", "able", " ", "for", " ", "new", " ", "mal", "ware", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "m", ".", "name", " ", "in", " ", "assign", "ment", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "if", " ", "assign", "ment", "s", "[", "m", ".", "name", "]['", "timeo", "ut", "']", " ", "<=", " ", "time", ".", "time", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "#", "do", " ", "anyt", "hing", " ", "you", " ", "want", " ", "to", " ", "wrap", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "job", "\\u", "post", "\\u", "process", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "job", "\\u", "clean", "up", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "vm", "\\u", "power", "off", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "else", ":", " ", "#", " ", "if", " ", "the", " ", "machine", " ", "is", " ", "runn", "ing", " ", "but", " ", "there", " ", "is", " ", "no", " ", "job", " ", "assign", "ed", " ", "to", " ", "it", " ", "then", " ", "kill", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "pcap", "\\u", "terminate", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "vm", "\\u", "power", "off", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "else", ":", " ", "#", "not", " ", "sure", " ", "this", " ", "is", " ", "rele", "van", "t", "...", "may", " ", "need", " ", "to", " ", "remove", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t\t", "vm", "\\u", "power", "off", "(", "m", ")", " ", "#", "I", " ", "need", " ", "to", " ", "get", " ", "a", " ", "list", " ", "of", " ", "state", "s", " ", "tha", "t", " ", "I", " ", "want", " ", "to", " ", "power", "off", " ", "by", " ", "default_", "\\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_", "rval_", "\\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_", "worker_", "(_", "s_", ",_", "pool_", ",_", "q_", ",_", "str1_", ",_", "VM", "s_", ",_", "vm", "l_", ",_", "adb", "port_", ",_", "count_", ",_", "adb", "l_", ",_", "results_", ",_", "fcn", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "global", " ", "assignments_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "beans", "talk", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "multiprocessing_", "._", "current", "\\u", "process_", "(_", ")_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "formatter_", "=_", "logging_", "._", "Formatter_", "(_", "fmt_", "=_", "LOG", "FORMAT_", ",_", "datefmt_", "=_", "LOG", "DAT", "EF", "ORM", "AT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "=_", "logging_", "._", "File", "Handler_", "(_", "\"", "worker", ".", "log", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "set", "Formatter_", "(_", "formatter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "wl", "ogg", "er_", "=_", "logger_", "._", "get", "Child_", "(_", "\"", "worker", "\"_", "+_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "ogg", "er_", "._", "set", "Level_", "(_", "logging_", "._", "DEBUG_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "ogg", "er_", "._", "add", "Handler_", "(_", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pool_", "._", "make", "Active_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "fun", "ky", " ", "kill", " ", "pill", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "content_", "=_", "q_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "._", "put_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "content_", "==_", "\"", "die", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", " ", "is", " ", "committ", "ing", " ", "sui", "cide", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool_", "._", "make", "Ina", "ctive", "_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logg", "er", ".", "info", "(", " ", "'", "No", "w", " ", "runn", "ing", ":", " ", "%", "s", " ", "%", "s", " ", "%", "s", " ", "(%", "s", ")'", " ", "%", " ", "(", "str", "(", "pool", "),", " ", "str", "1", ",", " ", "content", ",", "adb", "port", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", " ", "is", " ", "working", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "check", " ", "for", " ", "a", " ", "job", " ", "in", " ", "the", " ", "beans", "talk", " ", "Q_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "not", " ", "beans", "talk", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "error", "\\u", "log", "('", "Re", "-", "establish", "ing", " ", "connecti", "on", " ", "to", " ", "beans", "talk", "d", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "beans", "talk", " ", "=", " ", "beans", "talk", "c", ".", "Connect", "ion", "(", "host", "=", "BS", "HOST", ",", " ", "port", "=", "BS", "PORT", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "beans", "talk", ".", "watch", "(", "BS", "MS", "BO", "XQ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "beans", "talk", ".", "use", "(", "BS", "MS", "BO", "XQ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "beans", "talk", ".", "ignore", "('", "default", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "reb", "ean", "stal", "k_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "all", " ", "this", " ", "checking", " ", "is", " ", "just", " ", "\"", "best", " ", "effort", "\"", " ", "anot", "her", " ", "thread", " ", "may", " ", "still", " ", "reserve", " ", "first_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "BS", "MS", "BO", "XQ", "_", "not_", "in_", "beans", "talk", "_", "._", "tube", "s_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "there", " ", "are", " ", "no", " ", "samples", " ", "in", " ", "the", " ", "beans", "talk", "\"_", ")_", "\\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_", "are", "jobs_", "=_", "beans", "talk", "_", "._", "peek", "\\u", "ready_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "are", "jobs_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "there", " ", "are", " ", "no", " ", "samples", " ", "read", "y", " ", "in", " ", "the", " ", "beans", "talk", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", ")_", "\\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_", "#", "we", " ", "want", " ", "to", " ", "reserve", ",", " ", "not", " ", "peak", "\\u", "read", "y", " ", "bec", "aus", "e", " ", "if", " ", "we", " ", "can", "'", "t", " ", "process", ",", " ", "we", " ", "want", " ", "to", " ", "release", " ", "with", " ", "a", " ", "dela", "y", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "beans", "alk", "job_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "beans", "talk", "job_", "=_", "beans", "talk", "_", "._", "reserve", "_", "(_", ")_", "\\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\t\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":", " ", "\"_", "+_", "\"", "beans", "talk", " ", "reserve", " ", "error", ",", " ", "probab", "ly", " ", "out", " ", "of", " ", "jobs", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "there", " ", "was", " ", "a", " ", "job", " ", "and", " ", "we", " ", "got", " ", "it", " ", "then", " ", "queue", " ", "up", " ", "analysis_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "job_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "beans", "talk", "job_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t_", "job_", "=_", "eval_", "(_", "beans", "talk", "job_", "._", "body_", ")_", "\\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\t\t\t\t_", "error", "\\u", "log_", "(_", "'", "ERROR", ":", " ", "coul", "d", " ", "not", " ", "eval", " ", "job", " ", "-", " ", "invalid", " ", "job", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "job_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "BAD", " ", "JOB", ",", " ", "delet", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "return", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "job_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "is", " ", "there", " ", "a", " ", "VM", " ", "compatible", " ", "with", " ", "this", " ", "sample", " ", "tha", "t", " ", "is", " ", "read", "y", " ", "to", " ", "be", " ", "used", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t_", "m_", "=_", "find", "Compatible", "VM_", "(_", "job_", ",_", "VM", "s_", ",_", "vm", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "wl", "ogg", "er", ".", "info", "(", " ", "name", " ", "+", " ", "\":\"", " ", "+", " ", "\"", "usi", "ng", " ", "VM", " ", "\"", " ", "+", " ", "str", "(", "m", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "usi", "ng", " ", "VM", " ", "\"_", "+_", "str_", "(_", "m_", ")_", "+_", "\"", " ", "for", " ", "\"_", "+_", "job_", "[_", "'", "basen", "ame", "'_", "]_", "+_", "\"(\"_", "+_", "job_", "[_", "'", "target", "'_", "]_", "+_", "\")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "process", " ", "sample_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", " ", "this", " ", "delete", " ", "shou", "ld", " ", "reall", "y", " ", "only", " ", "happ", "en", " ", "if", " ", "run", "In", "VM", " ", "succeeds", "_", "\\u\\u\\uNL\\u\\u\\u_", "beans", "talk", "job_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "run", "In", "VM_", "(_", "m_", ",_", "job_", ",_", "VM", "s_", ",_", "adb", "port_", ",_", "vm", "l_", ",_", "adb", "l_", ",_", "results_", ",_", "fcn", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "run", "In", "VM", " ", "mig", "ht", " ", "take", " ", "a", " ", "while_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t\t\t_", "reb", "ean", "stal", "k_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "delete", " ", "from", " ", "BS", "queue", " ", "if", " ", "success", "full_", "\\u\\u\\uNL\\u\\u\\u_", "#", "beans", "talk", "job", ".", "delete", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "count_", "._", "value_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "shou", "ld", " ", "neve", "r", " ", "hit", " ", "this", " ", "due", " ", "to", " ", "live", "/", "die", " ", "toggle", "\t\t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "flag", "Terminate", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t\t\t_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "termina", "ting", "?!", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "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\t", "\t\t\t\t\t\t\t\t_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "put", " ", "back", " ", "int", "o", " ", "VM", "read", "y", " ", "Q_", "\\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_", "#", "no", " ", "VM", " ", "found", ",", " ", "put", " ", "it", " ", "back", " ", "in", " ", "the", " ", "queue", " ", "(", "nob", "ody", " ", "will", " ", "process", " ", "for", " ", "60", " ", "seconds_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t\t_", "beans", "talk", "job_", "._", "release_", "(_", "delay_", "=_", "BS", "DELAY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "ogg", "er_", "._", "info_", "(_", "name_", "+_", "\":\"_", "+_", "\"", "reque", "uin", "g", " ", "job", " ", "requi", "ring", " ", "a", " ", "target", " ", "version", " ", "\"_", "+_", "job_", "[_", "'", "target", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "time", ".", "sleep", "(", "VM", "\\u", "POLL", "\\u", "REST", ")_", "\\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\t", "_", "global_", "flag", "Terminate", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "beans", "talk", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "setup", "Logger_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defin", "e", " ", "a", " ", "Handle", "r", " ", "whi", "ch", " ", "writes", " ", "INFO", " ", "message", "s", " ", "or", " ", "higher", " ", "to", " ", "the", " ", "sys", ".", "stderr_", "\\u\\u\\uNL\\u\\u\\u_", "console_", "=_", "logging_", "._", "Stream", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "console_", "._", "set", "Level_", "(_", "logging_", "._", "INFO_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "a", " ", "format", " ", "whi", "ch", " ", "is", " ", "simple", "r", " ", "for", " ", "console", " ", "use_", "\\u\\u\\uNL\\u\\u\\u_", "formatter_", "=_", "logging_", "._", "Formatter_", "(_", "'%", "(", "name", ")-", "1", "2s", ":", " ", "%", "(", "level", "name", ")-", "8s", " ", "%", "(", "message", ")", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "tell", " ", "the", " ", "handler", " ", "to", " ", "use", " ", "this", " ", "format_", "\\u\\u\\uNL\\u\\u\\u_", "console_", "._", "set", "Formatter_", "(_", "formatter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "add", " ", "the", " ", "handler", " ", "to", " ", "the", " ", "root", " ", "logger_", "\\u\\u\\uNL\\u\\u\\u_", "logging_", "._", "get", "Logger_", "(_", ")_", "._", "add", "Handler_", "(_", "console_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "random_", "._", "seed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pool_", "=_", "Activ", "e", "Pool_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assignments_", "=_", "pool_", "._", "mgr_", "._", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "pool_", "._", "mgr_", "._", "Value_", "(_", "'", "i", "'_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "AD", "BF", "AI", "LC", "OUN", "T_", "=_", "pool_", "._", "mgr_", "._", "Value_", "(_", "'", "i", "'_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "VM", "s_", "=_", "pool_", "._", "mgr_", "._", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "multiprocessing_", "._", "Semaphore", "_", "(_", "NUM", "ACTI", "VE", "WORKER", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "multiprocessing_", "._", "Queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "multiprocessing_", "._", "Queue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "al_", "=_", "multiprocessing_", "._", "RL", "ock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vm", "l_", "=_", "multiprocessing_", "._", "RL", "ock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cl_", "=_", "multiprocessing_", "._", "RL", "ock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "get", "\\u", "VM", "s_", "(_", "VM", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list", "\\u", "VM", "s_", "(_", "VM", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "make", " ", "sure", " ", "any", " ", "pcap", "s", " ", "are", " ", "kille", "d", " ", "and", " ", "we", " ", "are", " ", "startin", "g", " ", "with", " ", "a", " ", "clean", " ", "filesystem_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "30_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "q", ".", "put", "(\"", "item", " ", "\"", " ", "+", " ", "str", "(", "i", ")", " ", "+", " ", "\"", " ", "content", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "q_", "._", "put_", "(_", "\"", "live", "\"_", "+_", "str_", "(_", "i_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "adb", " ", "port", "s", " ", "are", " ", "555", "4", " ", "-", " ", "558", "4", ",", " ", "only", " ", "even", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "port_", "=_", "AD", "BP", "ORT", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "multiprocessing_", "._", "Process_", "(_", "target_", "=_", "worker_", ",_", "name_", "=_", "str_", "(_", "i_", ")_", ",_", "args_", "=_", "(_", "s_", ",_", "pool_", ",_", "q_", ",_", "\"", "hi", "\"_", ",_", "VM", "s_", ",_", "vm", "l_", ",_", "str_", "(_", "port_", "+_", "(_", "i_", "*_", "2_", ")_", ")_", ",_", "count_", ",_", "al_", ",_", "r_", ",_", "AD", "BF", "AI", "LC", "OUN", "T_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "NUM", "WORKER", "S_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "j_", "in_", "jobs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "logger_", "._", "info_", "(_", "\"", "startin", "g", " ", "worker", " ", "%", "s", "\"_", "%_", "j_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "j_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "for", " ", "j", " ", "in", " ", "jobs", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "j", ".", "join", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "logg", "er", ".", "info", "(", " ", "'", "No", "w", " ", "runn", "ing", ":", " ", "%", "s", "'", " ", "%", " ", "str", "(", "pool", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "make", " ", "the", " ", "connecti", "on", " ", "after", " ", "the", " ", "child", " ", "spawn", "ing", ",", " ", "each", " ", "child", " ", "make", "s", " ", "thi", "er", " ", "own", " ", "connections_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reb", "ean", "stal", "k_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "logger_", "._", "info_", "(_", "\"====", "==============", "============", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "process", "ed", " ", "%", "d", " ", "samples", " ", "so", " ", "far", "\"_", "%_", "count_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "not", " ", "great", ",", " ", "but", " ", "the", " ", "parent", " ", "is", " ", "the", " ", "only", " ", "consume", "r", " ", "of", " ", "r", " ", "items_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "thing_", "=_", "r_", "._", "get_", "(_", "block_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "._", "append_", "(_", "thing_", ")_", "\\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_", "logger_", "._", "warning_", "(_", "\"", "results", " ", "queue", " ", "exception", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "results_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "logger_", "._", "info_", "(_", "\"", "averag", "e", " ", "sample", " ", "time", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "sum_", "(_", "results_", ")_", "/_", "float_", "(_", "len_", "(_", "results_", ")_", ")_", ")_", ")_", "\\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\t", "\t\t_", "if_", "BS", "MS", "BO", "XQ", "_", "not_", "in_", "beans", "talk", "_", "._", "tube", "s_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "logger_", "._", "info_", "(_", "\"", "there", " ", "are", " ", "no", " ", "samples", " ", "in", " ", "the", " ", "beans", "talk", "\"_", ")_", "\\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_", "if_", "beans", "talk", "_", "._", "peek", "\\u", "ready_", "(_", ")_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "logger_", "._", "info_", "(_", "str_", "(_", "beans", "talk", "_", "._", "stats", "\\u", "tube", "_", "(_", "BS", "MS", "BO", "XQ", "_", ")_", "[_", "'", "current", "-", "jobs", "-", "read", "y", "'_", "]_", ")_", "+_", "\"", " ", "samples", " ", "read", "y", " ", "to", " ", "process", "\"_", ")_", "\\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_", "logger_", "._", "info_", "(_", "\"", "0", " ", "samples", " ", "read", "y", " ", "to", " ", "process", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "beans", "talk", "_", "._", "peek", "\\u", "reserved_", "(_", ")_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "logger_", "._", "info_", "(_", "str_", "(_", "beans", "talk", "_", "._", "stats", "\\u", "tube", "_", "(_", "BS", "MS", "BO", "XQ", "_", ")_", "[_", "'", "current", "-", "jobs", "-", "reserve", "d", "'_", "]_", ")_", "+_", "\"", " ", "samples", " ", "are", " ", "process", "ing", "\"_", ")_", "\\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_", "logger_", "._", "info_", "(_", "\"", "0", " ", "samples", " ", "are", " ", "process", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "beans", "talk", "_", "._", "peek", "\\u", "delayed_", "(_", ")_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "logger_", "._", "info_", "(_", "str_", "(_", "beans", "talk", "_", "._", "stats", "\\u", "tube", "_", "(_", "BS", "MS", "BO", "XQ", "_", ")_", "[_", "'", "current", "-", "jobs", "-", "delayed", "'_", "]_", ")_", "+_", "\"", " ", "samples", " ", "are", " ", "delayed", "\"_", ")_", "\\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_", "logger_", "._", "info_", "(_", "\"", "0", " ", "samples", " ", "are", " ", "delayed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "logger_", "._", "warning_", "(_", "\"", "beans", "talk", " ", "key", "error", "\"_", ")_", "\\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_", "logger_", "._", "warning_", "(_", "\"", "beans", "talk", " ", "genera", "l", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "abo", "ut", " ", "\"_", "+_", "str_", "(_", "q_", "._", "qsize_", "(_", ")_", ")_", "+_", "\"", " ", "current", " ", "q", " ", "items", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "adb", " ", "has", " ", "fail", "ed", " ", "\"_", "+_", "str_", "(_", "AD", "BF", "AI", "LC", "OUN", "T_", "._", "value_", ")_", "+_", "\"", " ", "times", " ", "sinc", "e", " ", "last", " ", "kick", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "\"", "shou", "ld", " ", "be", " ", "\"_", "+_", "str_", "(_", "NUM", "WORKER", "S_", ")_", "+_", "\"", " ", "process", "es", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wal", "ive_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wd", "ead_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "jobs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "j_", "._", "is", "\\u", "alive_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "logger_", "._", "debug_", "(_", "\"", " ", " ", " ", "\"_", "+_", "str_", "(_", "j_", "._", "pid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wal", "ive_", "+=_", "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\t", "\t\t\t_", "logger_", "._", "debug_", "(_", "\"", " ", " ", " ", "dead", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wd", "ead_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "this", " ", "will", " ", "kill", " ", "the", " ", "controlle", "r", ",", " ", "leaving", " ", "the", " ", "child", "ren", " ", "pipe", "s", " ", "want", "ing", " ", "more", " ", "(", "you", " ", "will", " ", "get", " ", "sig", "pipe", " ", "error", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "this", " ", "is", " ", "pretty", " ", "har", "sh", " ", "and", " ", "shou", "ld", "n", "'", "t", " ", "probab", "ly", " ", "be", " ", "don", "e", " ", "in", " ", "production_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "exit", "(", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"%", "s", " ", "alive", ";", " ", "%", "s", " ", "dead", "\"_", "%_", "(_", "wal", "ive_", ",_", "wd", "ead_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "Status_", "(_", "NUM", "WORKER", "S_", ",_", "wal", "ive_", ",_", "wd", "ead_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "list", "\\u", "VM", "s_", "(_", "VM", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", "+_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "blocks", " ", "unti", "l", " ", "all", " ", "items", " ", "in", " ", "q", " ", "are", " ", "processed_", "\\u\\u\\uNL\\u\\u\\u_", "#", "safe", " ", "to", " ", "exit_", "\\u\\u\\uNL\\u\\u\\u_", "#", "shou", "ld", " ", "check", " ", "for", " ", "sig", "int_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "q", ".", "qs", "ize", "()", " ", "==", " ", "0", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "for", " ", "i", " ", "in", " ", "jobs", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "q", ".", "put", "(\"", "die", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "q", ".", "close", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "signal_", "._", "signal_", "(_", "signal_", "._", "SIGINT_", ",_", "sig", "int\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "syslog_", "._", "syslog_", "(_", "'", "Start", "up", " ", "-", " ", "Enter", "ing", " ", "main", " ", "polling", " ", "loop", "...'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "get", "\\u", "VM", "s_", "(_", "VM", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list", "\\u", "VM", "s_", "(_", "VM", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "make", " ", "sure", " ", "any", " ", "pcap", "s", " ", "are", " ", "kille", "d", " ", "and", " ", "we", " ", "are", " ", "startin", "g", " ", "with", " ", "a", " ", "clean", " ", "filesystem_", "\\u\\u\\uNL\\u\\u\\u_", "#", "pcap", "\\u", "terminate", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "job", "\\u", "clean", "up", "(", "m", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "check", " ", "for", " ", "a", " ", "job", " ", "in", " ", "the", " ", "beans", "talk", " ", "Q_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "beans", "talk", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "error", "\\u", "log_", "(_", "'", "Re", "-", "establish", "ing", " ", "connecti", "on", " ", "to", " ", "beans", "talk", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "_", "=_", "beans", "talk", "c_", "._", "Connection_", "(_", "host_", "=_", "BS", "HOST_", ",_", "port_", "=_", "BS", "PORT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "_", "._", "watch_", "(_", "BS", "MS", "BO", "XQ", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "_", "._", "use_", "(_", "BS", "MS", "BO", "XQ", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "_", "._", "ignore_", "(_", "'", "default", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "we", " ", "want", " ", "to", " ", "reserve", ",", " ", "not", " ", "peak", "\\u", "read", "y", " ", "bec", "aus", "e", " ", "if", " ", "we", " ", "can", "'", "t", " ", "process", ",", " ", "we", " ", "want", " ", "to", " ", "release", " ", "with", " ", "a", " ", "dela", "y", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "beans", "talk", "job_", "=_", "beans", "talk", "_", "._", "reserve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "there", " ", "was", " ", "a", " ", "job", " ", "and", " ", "we", " ", "got", " ", "it", " ", "then", " ", "queue", " ", "up", " ", "analysis_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "beans", "talk", "job_", ":_", "\\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_", "job_", "=_", "eval_", "(_", "beans", "talk", "job_", "._", "body_", ")_", "\\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\t_", "error", "\\u", "log_", "(_", "'", "ERROR", ":", " ", "coul", "d", " ", "not", " ", "eval", " ", "job", " ", "-", " ", "invalid", " ", "job", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beans", "talk", "job_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "is", " ", "there", " ", "a", " ", "VM", " ", "compatible", " ", "with", " ", "this", " ", "sample", " ", "tha", "t", " ", "is", " ", "read", "y", " ", "to", " ", "be", " ", "used", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "m_", "=_", "find", "Compatible", "VM_", "(_", "job_", ",_", "VM", "s_", ",_", "vm", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "logger_", "._", "info_", "(_", "\"", "ya", "y", " ", "usi", "ng", " ", "VM", " ", "\"_", "+_", "str_", "(_", "m_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "process", " ", "sample_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "delete", " ", "from", " ", "queue", " ", "if", " ", "success", "full_", "\\u\\u\\uNL\\u\\u\\u_", "#", "beans", "talk", "job", ".", "delete", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "no", " ", "VM", " ", "found", ",", " ", "put", " ", "it", " ", "back", " ", "in", " ", "the", " ", "queue", " ", "(", "nob", "ody", " ", "will", " ", "process", " ", "for", " ", "60", " ", "seconds_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "beans", "talk", "job_", "._", "release_", "(_", "delay_", "=_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "info_", "(_", "\"", "reque", "uin", "g", " ", "job", " ", "requi", "ring", " ", "a", " ", "target", " ", "version", " ", "\"_", "+_", "job_", "[_", "'", "target", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t\t_", "\\u\\u\\uNL\\u\\u\\u_", "#", "\t", "\t", "#", "break", " ", "ot", " ", "of", " ", "the", " ", "loop", " ", "and", " ", "exit", " ", "if", " ", "the", " ", "assign", "ment", "s", " ", "are", " ", "clear", " ", "and", " ", "the", " ", "terminate", " ", "flag", " ", "is", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "flag", "Terminate", "_", "and_", "len_", "(_", "assignments_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "syslog_", "._", "syslog_", "(_", "'", "All", " ", "assign", "ed", " ", "jobs", " ", "are", " ", "complete", "d", " ", "(", "EXIT", "ING", ").", "..'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "put", " ", "a", " ", "paus", "e", " ", "in", " ", "the", " ", "polling", " ", "cycle", "...", "set", " ", "to", " ", "0", " ", "for", " ", "no", " ", "pause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "VM", "\\u", "POLL", "\\u", "REST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "syslog_", "._", "syslog_", "(_", "'", "Shut", "down", " ", "-", " ", "Leav", "ing", " ", "main", " ", "polling", " ", "loop", "...'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "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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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 ]
First parameter of a method is not named 'self'
cornell-brg/pymtl/pclib/test/TestMemory_test.py
[ { "content": " def __init__( s, nports, src_msgs, sink_msgs, stall_prob, latency,\n src_delay, sink_delay ):\n\n # Messge type\n\n mem_msgs = MemMsg4B()\n\n # Instantiate models\n\n s.srcs = []\n for i in range(nports):\n s.srcs.append( TestSource( mem_msgs.req, src_msgs[i], src_delay ) )\n\n s.mem = TestMemory( mem_msgs, nports, stall_prob, latency )\n\n s.sinks = []\n for i in range(nports):\n s.sinks.append( TestSink( mem_msgs.resp, sink_msgs[i], sink_delay ) )\n\n # Connect\n\n for i in range( nports ):\n s.connect( s.srcs[i].out, s.mem.reqs[i] )\n s.connect( s.sinks[i].in_, s.mem.resps[i] )", "metadata": "root.TestHarness.__init__", "header": "['class', 'TestHarness', '(', 'Model', ')', ':', '___EOS___']", "index": 23 }, { "content": " def done( s ):\n\n done_flag = 1\n for src,sink in zip( s.srcs, s.sinks ):\n done_flag &= src.done and sink.done\n return done_flag", "metadata": "root.TestHarness.done", "header": "['class', 'TestHarness', '(', 'Model', ')', ':', '___EOS___']", "index": 48 }, { "content": " def line_trace(s ):\n return s.srcs[0].line_trace() + \" \" + s.mem.line_trace() + \" \" + s.sinks[0].line_trace()", "metadata": "root.TestHarness.line_trace", "header": "['class', 'TestHarness', '(', 'Model', ')', ':', '___EOS___']", "index": 55 } ]
[ { "span": "def __init__( s, nports, src_msgs, sink_msgs, stall_prob, latency,\n src_delay, sink_delay ):", "start_line": 23, "start_column": 2, "end_line": 24, "end_column": 40 }, { "span": "def done( s ):", "start_line": 48, "start_column": 2, "end_line": 48, "end_column": 16 }, { "span": "def line_trace(s ):", "start_line": 55, "start_column": 2, "end_line": 55, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Test", "Har", "ness_", "(_", "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_", ",_", "npo", "rts_", ",_", "src", "\\u", "msgs_", ",_", "sink", "\\u", "msgs_", ",_", "stall", "\\u", "prob_", ",_", "latency_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "src", "\\u", "delay_", ",_", "sink", "\\u", "delay_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mess", "ge", " ", "type_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mem", "\\u", "msgs_", "=_", "Mem", "Msg", "4", "B_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Instantiate", " ", "models_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "._", "srcs", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "npo", "rts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "srcs", "_", "._", "append_", "(_", "Test", "Source_", "(_", "mem", "\\u", "msgs_", "._", "req_", ",_", "src", "\\u", "msgs_", "[_", "i_", "]_", ",_", "src", "\\u", "delay_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "s_", "._", "mem_", "=_", "Test", "Memory_", "(_", "mem", "\\u", "msgs_", ",_", "npo", "rts_", ",_", "stall", "\\u", "prob_", ",_", "latency_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "._", "sink", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "npo", "rts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "sink", "s_", "._", "append_", "(_", "Test", "Sink_", "(_", "mem", "\\u", "msgs_", "._", "resp_", ",_", "sink", "\\u", "msgs_", "[_", "i_", "]_", ",_", "sink", "\\u", "delay_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Connect_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "npo", "rts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "connect_", "(_", "s_", "._", "srcs", "_", "[_", "i_", "]_", "._", "out_", ",_", "s_", "._", "mem_", "._", "reqs_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "connect_", "(_", "s_", "._", "sink", "s_", "[_", "i_", "]_", "._", "in\\u_", ",_", "s_", "._", "mem_", "._", "resp", "s_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Har", "ness_", "(_", "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_", "done_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "don", "e\\u", "flag_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "src_", ",_", "sink_", "in_", "zip_", "(_", "s_", "._", "srcs", "_", ",_", "s_", "._", "sink", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "don", "e\\u", "flag_", "&=_", "src_", "._", "done_", "and_", "sink_", "._", "done_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "don", "e\\u", "flag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Har", "ness_", "(_", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\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_", "s_", "._", "srcs", "_", "[_", "0_", "]_", "._", "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, 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, 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, 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 ]
Unused import
apache/climate/ocw-ui/backend/local_file_metadata_extractors.py
[ { "content": "#\n# 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\n''' Helpers for local model/observation file metadata extraction. '''\n\nimport sys\nimport netCDF4\nimport json\n\nfrom bottle import Bottle, request, route, response\n\nimport ocw.utils\n\nlfme_app = Bottle()\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@lfme_app.route('/list_latlon/<file_path:path>')\ndef list_latlon(file_path):\n ''' Retrieve lat/lon information from given file.\n \n :param file_path: Path to the NetCDF file from which lat/lon information\n should be extracted\n :type file_path: string:\n\n :returns: Dictionary containing lat/lon information if successful, otherwise\n failure information is returned.\n\n **Example successful JSON return**\n\n .. sourcecode:: javascript\n\n {\n 'success': true,\n 'lat_name': The guessed latitude variable name,\n 'lon_name': the guessed longitude variable name,\n 'lat_min': The minimum latitude value,\n 'lat_max': The maximum latitude value,\n 'lon_min': The minimum longitude value,\n 'lon_max': The maximum longitude value\n }\n\n **Example failure JSON return**\n\n .. sourcecode:: javascript\n\n {\n 'success': false,\n 'variables': List of all variables present in the NetCDF file\n }\n '''\n in_file = netCDF4.Dataset(file_path, mode='r')\n\n var_names = set([key.encode().lower() for key in in_file.variables.keys()])\n var_names_list = list(var_names)\n\n lat_name_guesses = set(['latitude','lat','lats','latitudes'])\n lon_name_guesses = set(['longitude','lon','lons','longitudes'])\n\n # Attempt to determine the lat name\n found_lat_name = False\n\n # Find the intersection (if there is one) of the var names with the lat guesses\n lat_guesses = list(var_names & lat_name_guesses)\n\n if len(lat_guesses) >= 1:\n found_lat_name = True\n lat_name = var_names_list[var_names_list.index(lat_guesses[0])]\n\n lats = in_file.variables[lat_name][:]\n\n # Change 0 - 360 degree values to be -180 to 180\n lats[lats > 180] = lats[lats > 180] - 360\n\n lat_min = float(lats.min())\n lat_max = float(lats.max())\n\n # Attempt to determine the lon name\n found_lon_name = False\n\n # Find the intersection (if there is one) of the var names with the lon guesses\n lon_guesses = list(var_names & lon_name_guesses)\n\n if len(lon_guesses) >= 1:\n found_lon_name = True\n lon_name = var_names_list[var_names_list.index(lon_guesses[0])]\n\n lons = in_file.variables[lon_name][:]\n\n # Change 0 - 360 degree values to be -180 to 180\n lons[lons > 180] = lons[lons > 180] - 360\n\n lon_min = float(lons.min())\n lon_max = float(lons.max())\n\n in_file.close()\n\n success = found_lat_name and found_lon_name\n if success:\n values = [success, lat_name, lon_name, lat_min, lat_max, lon_min, lon_max]\n value_names = ['success', 'lat_name', 'lon_name', 'lat_min', 'lat_max', 'lon_min', 'lon_max']\n output = dict(zip(value_names, values))\n else:\n output = {'success': success, 'variables': var_names_list}\n\n if request.query.callback:\n return '%s(%s)' % (request.query.callback, json.dumps(output))\n return output", "metadata": "root.list_latlon", "header": "['module', '___EOS___']", "index": 29 }, { "content": "@lfme_app.route('/list_time/<file_path:path>')\ndef list_time(file_path):\n ''' Retrieve time information from provided file.\n\n :param file_path: Path to the NetCDF file from which time information\n should be extracted\n :type file_path: String:\n\n :returns: Dictionary containing time information if successful, otherwise\n failure information is returned.\n\n **Example successful JSON return**\n\n .. sourcecode:: javascript\n\n {\n \"success\": true,\n \"time_name\": The guessed time variable name,\n \"start_time\": \"1988-06-10 00:00:00\",\n \"end_time\": \"2008-01-27 00:00:00\"\n }\n\n **Example failure JSON return**\n\n .. sourcecode:: javascript\n\n {\n \"success\": false\n \"variables\": List of all variable names in the file\n } \n '''\n in_file = netCDF4.Dataset(file_path, mode='r')\n\n var_names = set([key.encode().lower() for key in in_file.variables.keys()])\n var_names_list = list(var_names)\n\n time_name_guesses = set(['time', 'times', 't', 'date', 'dates', 'julian'])\n\n # Find the intersection (if there is one) of the var names with the lat guesses\n time_guesses = list(var_names & time_name_guesses)\n\n if len(time_guesses) >= 1:\n # Convert time data to datetime objects\n time_var_name = time_guesses[0]\n times = ocw.utils.decode_time_values(in_file, time_var_name)\n\n start_time = str(min(times))\n end_time = str(max(times))\n\n output = {\n 'success': True,\n 'time_name': time_var_name,\n 'start_time': start_time,\n 'end_time': end_time\n }\n else:\n output = {'success': False, 'variables': var_names_list}\n\n if request.query.callback:\n return '%s(%s)' % (request.query.callback, json.dumps(output))\n return output", "metadata": "root.list_time", "header": "['module', '___EOS___']", "index": 121 }, { "content": "@lfme_app.route('/list_vars/<file_path:path>')\ndef list_vars(file_path):\n ''' Retrieve variable names from file.\n\n :param file_path: Path to the NetCDF file from which variable information\n should be extracted\n :type file_path: String:\n\n :returns: Dictionary containing variable information if succesful, otherwise\n failure information is returned.\n\n **Example successful JSON return**\n\n .. sourcecode:: javascript\n\n {\n \"success\": true,\n \"variables\": List of variable names in the file\n }\n\n **Example failure JSON return**\n\n .. sourcecode:: javascript\n\n {\n \"success\": false\n }\n '''\n try:\n in_file = netCDF4.Dataset(file_path, mode='r')\n except RuntimeError:\n output = {'success': False}\n else:\n output = {'success': True, 'variables': in_file.variables.keys()}\n in_file.close()\n finally:\n if request.query.callback:\n return \"%s(%s)\" % (request.query.callback, json.dumps(output))\n return output", "metadata": "root.list_vars", "header": "['module', '___EOS___']", "index": 183 }, { "content": "@lfme_app.hook('after_request')\ndef enable_cors():\n ''' Allow Cross-Origin Resource Sharing for all URLs. '''\n response.headers['Access-Control-Allow-Origin'] = '*'", "metadata": "root.enable_cors", "header": "['module', '___EOS___']", "index": 223 } ]
[ { "span": "import sys", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 10 }, { "span": "from bottle import Bottle, request, route, response", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 51 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\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_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Help", "ers", " ", "for", " ", "local", " ", "model", "/", "observa", "tion", " ", "file", " ", "metadata", " ", "extracti", "on", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "net", "CD", "F4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "bottle_", "import_", "Bott", "le_", ",_", "request_", ",_", "route_", ",_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "oc", "w_", "._", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lf", "me", "\\u", "app_", "=_", "Bott", "le_", "(_", ")_", "\\u\\u\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "lf", "me", "\\u", "app_", "._", "route_", "(_", "'/", "list", "\\u", "latlon", "/", "<", "file", "\\u", "path", ":", "path", ">'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "list", "\\u", "latlon", "_", "(_", "file", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Retrieve", " ", "lat", "/", "lon", " ", "informati", "on", " ", "from", " ", "give", "n", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "file", "\\u", "path", ":", " ", "Path", " ", "to", " ", "the", " ", "Net", "CD", "F", " ", "file", " ", "from", " ", "whi", "ch", " ", "lat", "/", "lon", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", " ", "be", " ", "extracted", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "file", "\\u", "path", ":", " ", "string", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "lat", "/", "lon", " ", "informati", "on", " ", "if", " ", "success", "ful", ",", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "fail", "ure", " ", "informati", "on", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "success", "ful", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "'", "success", "':", " ", "true", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lat", "\\u", "name", "':", " ", "The", " ", "guessed", " ", "latitude", " ", "variab", "le", " ", "name", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lon", "\\u", "name", "':", " ", "the", " ", "guessed", " ", "longitude", " ", "variab", "le", " ", "name", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lat", "\\u", "min", "':", " ", "The", " ", "minim", "um", " ", "latitude", " ", "value", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lat", "\\u", "max", "':", " ", "The", " ", "maxim", "um", " ", "latitude", " ", "value", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lon", "\\u", "min", "':", " ", "The", " ", "minim", "um", " ", "longitude", " ", "value", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "lon", "\\u", "max", "':", " ", "The", " ", "maxim", "um", " ", "longitude", " ", "value", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "fail", "ure", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "'", "success", "':", " ", "fal", "se", ",", "\\", "10", ";", " ", " ", " ", " ", "'", "variab", "les", "':", " ", "List", " ", "of", " ", "all", " ", "variab", "les", " ", "presen", "t", " ", "in", " ", "the", " ", "Net", "CD", "F", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "file_", "=_", "net", "CD", "F4_", "._", "Dataset_", "(_", "file", "\\u", "path_", ",_", "mode_", "=_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "names_", "=_", "set_", "(_", "[_", "key_", "._", "encode_", "(_", ")_", "._", "lower_", "(_", ")_", "for_", "key_", "in_", "in", "\\u", "file_", "._", "variables_", "._", "keys_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "var", "\\u", "names", "\\u", "list_", "=_", "list_", "(_", "var", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lat", "\\u", "name", "\\u", "guesses", "_", "=_", "set_", "(_", "[_", "'", "latitude", "'_", ",_", "'", "lat", "'_", ",_", "'", "lat", "s", "'_", ",_", "'", "latitude", "s", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lon", "\\u", "name", "\\u", "guesses", "_", "=_", "set_", "(_", "[_", "'", "longitude", "'_", ",_", "'", "lon", "'_", ",_", "'", "lon", "s", "'_", ",_", "'", "longitude", "s", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Atte", "mpt", " ", "to", " ", "dete", "rmin", "e", " ", "the", " ", "lat", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "found", "\\u", "lat", "\\u", "name_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "intersect", "ion", " ", "(", "if", " ", "there", " ", "is", " ", "one", ")", " ", "of", " ", "the", " ", "var", " ", "names", " ", "with", " ", "the", " ", "lat", " ", "guesses", "_", "\\u\\u\\uNL\\u\\u\\u_", "lat", "\\u", "guesses", "_", "=_", "list_", "(_", "var", "\\u", "names_", "&_", "lat", "\\u", "name", "\\u", "guesses", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "lat", "\\u", "guesses", "_", ")_", ">=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found", "\\u", "lat", "\\u", "name_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lat", "\\u", "name_", "=_", "var", "\\u", "names", "\\u", "list_", "[_", "var", "\\u", "names", "\\u", "list_", "._", "index_", "(_", "lat", "\\u", "guesses", "_", "[_", "0_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lats_", "=_", "in", "\\u", "file_", "._", "variables_", "[_", "lat", "\\u", "name_", "]_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Change", " ", "0", " ", "-", " ", "360", " ", "degr", "ee", " ", "values", " ", "to", " ", "be", " ", "-1", "80", " ", "to", " ", "180_", "\\u\\u\\uNL\\u\\u\\u_", "lats_", "[_", "lats_", ">_", "180_", "]_", "=_", "lats_", "[_", "lats_", ">_", "180_", "]_", "-_", "360_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lat", "\\u", "min_", "=_", "float_", "(_", "lats_", "._", "min_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lat", "\\u", "max_", "=_", "float_", "(_", "lats_", "._", "max_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Atte", "mpt", " ", "to", " ", "dete", "rmin", "e", " ", "the", " ", "lon", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "found", "\\u", "lon", "\\u", "name_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "intersect", "ion", " ", "(", "if", " ", "there", " ", "is", " ", "one", ")", " ", "of", " ", "the", " ", "var", " ", "names", " ", "with", " ", "the", " ", "lon", " ", "guesses", "_", "\\u\\u\\uNL\\u\\u\\u_", "lon", "\\u", "guesses", "_", "=_", "list_", "(_", "var", "\\u", "names_", "&_", "lon", "\\u", "name", "\\u", "guesses", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "lon", "\\u", "guesses", "_", ")_", ">=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found", "\\u", "lon", "\\u", "name_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lon", "\\u", "name_", "=_", "var", "\\u", "names", "\\u", "list_", "[_", "var", "\\u", "names", "\\u", "list_", "._", "index_", "(_", "lon", "\\u", "guesses", "_", "[_", "0_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lons_", "=_", "in", "\\u", "file_", "._", "variables_", "[_", "lon", "\\u", "name_", "]_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Change", " ", "0", " ", "-", " ", "360", " ", "degr", "ee", " ", "values", " ", "to", " ", "be", " ", "-1", "80", " ", "to", " ", "180_", "\\u\\u\\uNL\\u\\u\\u_", "lons_", "[_", "lons_", ">_", "180_", "]_", "=_", "lons_", "[_", "lons_", ">_", "180_", "]_", "-_", "360_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lon", "\\u", "min_", "=_", "float_", "(_", "lons_", "._", "min_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lon", "\\u", "max_", "=_", "float_", "(_", "lons_", "._", "max_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "in", "\\u", "file_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "success_", "=_", "found", "\\u", "lat", "\\u", "name_", "and_", "found", "\\u", "lon", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "[_", "success_", ",_", "lat", "\\u", "name_", ",_", "lon", "\\u", "name_", ",_", "lat", "\\u", "min_", ",_", "lat", "\\u", "max_", ",_", "lon", "\\u", "min_", ",_", "lon", "\\u", "max_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value", "\\u", "names_", "=_", "[_", "'", "success", "'_", ",_", "'", "lat", "\\u", "name", "'_", ",_", "'", "lon", "\\u", "name", "'_", ",_", "'", "lat", "\\u", "min", "'_", ",_", "'", "lat", "\\u", "max", "'_", ",_", "'", "lon", "\\u", "min", "'_", ",_", "'", "lon", "\\u", "max", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "dict_", "(_", "zip_", "(_", "value", "\\u", "names_", ",_", "values_", ")_", ")_", "\\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_", "=_", "{_", "'", "success", "'_", ":_", "success_", ",_", "'", "variab", "les", "'_", ":_", "var", "\\u", "names", "\\u", "list_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "query_", "._", "callback_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "request_", "._", "query_", "._", "callback_", ",_", "json_", "._", "dumps_", "(_", "output_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_", "\\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_", "@_", "lf", "me", "\\u", "app_", "._", "route_", "(_", "'/", "list", "\\u", "time", "/", "<", "file", "\\u", "path", ":", "path", ">'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "list", "\\u", "time_", "(_", "file", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Retrieve", " ", "time", " ", "informati", "on", " ", "from", " ", "provided", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "file", "\\u", "path", ":", " ", "Path", " ", "to", " ", "the", " ", "Net", "CD", "F", " ", "file", " ", "from", " ", "whi", "ch", " ", "time", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", " ", "be", " ", "extracted", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "file", "\\u", "path", ":", " ", "String", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "time", " ", "informati", "on", " ", "if", " ", "success", "ful", ",", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "fail", "ure", " ", "informati", "on", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "success", "ful", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "success", "\":", " ", "true", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "time", "\\u", "name", "\":", " ", "The", " ", "guessed", " ", "time", " ", "variab", "le", " ", "name", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "start", "\\u", "time", "\":", " ", "\"", "1988", "-0", "6", "-1", "0", " ", "00", ":", "00", ":", "00", "\",", "\\", "10", ";", " ", " ", " ", " ", "\"", "end", "\\u", "time", "\":", " ", "\"", "2008", "-0", "1", "-", "2", "7", " ", "00", ":", "00", ":", "00", "\"", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "fail", "ure", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "success", "\":", " ", "fal", "se", "\\", "10", ";", " ", " ", " ", " ", "\"", "variab", "les", "\":", " ", "List", " ", "of", " ", "all", " ", "variab", "le", " ", "names", " ", "in", " ", "the", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "}", " ", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "file_", "=_", "net", "CD", "F4_", "._", "Dataset_", "(_", "file", "\\u", "path_", ",_", "mode_", "=_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "var", "\\u", "names_", "=_", "set_", "(_", "[_", "key_", "._", "encode_", "(_", ")_", "._", "lower_", "(_", ")_", "for_", "key_", "in_", "in", "\\u", "file_", "._", "variables_", "._", "keys_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "var", "\\u", "names", "\\u", "list_", "=_", "list_", "(_", "var", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u", "name", "\\u", "guesses", "_", "=_", "set_", "(_", "[_", "'", "time", "'_", ",_", "'", "times", "'_", ",_", "'", "t", "'_", ",_", "'", "date", "'_", ",_", "'", "dates", "'_", ",_", "'", "julia", "n", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "intersect", "ion", " ", "(", "if", " ", "there", " ", "is", " ", "one", ")", " ", "of", " ", "the", " ", "var", " ", "names", " ", "with", " ", "the", " ", "lat", " ", "guesses", "_", "\\u\\u\\uNL\\u\\u\\u_", "time", "\\u", "guesses", "_", "=_", "list_", "(_", "var", "\\u", "names_", "&_", "time", "\\u", "name", "\\u", "guesses", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "time", "\\u", "guesses", "_", ")_", ">=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "time", " ", "data", " ", "to", " ", "datetime", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time", "\\u", "var", "\\u", "name_", "=_", "time", "\\u", "guesses", "_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "times_", "=_", "oc", "w_", "._", "utils_", "._", "decode", "\\u", "time", "\\u", "values_", "(_", "in", "\\u", "file_", ",_", "time", "\\u", "var", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "time_", "=_", "str_", "(_", "min_", "(_", "times_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "time_", "=_", "str_", "(_", "max_", "(_", "times_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "output_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "\\u", "name", "'_", ":_", "time", "\\u", "var", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "start", "\\u", "time", "'_", ":_", "start", "\\u", "time_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "end", "\\u", "time", "'_", ":_", "end", "\\u", "time_", "\\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 ", " _", "output_", "=_", "{_", "'", "success", "'_", ":_", "False_", ",_", "'", "variab", "les", "'_", ":_", "var", "\\u", "names", "\\u", "list_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "query_", "._", "callback_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'%", "s", "(%", "s", ")'_", "%_", "(_", "request_", "._", "query_", "._", "callback_", ",_", "json_", "._", "dumps_", "(_", "output_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_", "\\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_", "@_", "lf", "me", "\\u", "app_", "._", "route_", "(_", "'/", "list", "\\u", "vars", "/", "<", "file", "\\u", "path", ":", "path", ">'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "list", "\\u", "vars_", "(_", "file", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Retrieve", " ", "variab", "le", " ", "names", " ", "from", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "file", "\\u", "path", ":", " ", "Path", " ", "to", " ", "the", " ", "Net", "CD", "F", " ", "file", " ", "from", " ", "whi", "ch", " ", "variab", "le", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", " ", "be", " ", "extracted", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "file", "\\u", "path", ":", " ", "String", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "variab", "le", " ", "informati", "on", " ", "if", " ", "succe", "sfu", "l", ",", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "fail", "ure", " ", "informati", "on", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "success", "ful", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "success", "\":", " ", "true", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "variab", "les", "\":", " ", "List", " ", "of", " ", "variab", "le", " ", "names", " ", "in", " ", "the", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "fail", "ure", " ", "JSO", "N", " ", "return", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "javascript", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "success", "\":", " ", "fal", "se", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "in", "\\u", "file_", "=_", "net", "CD", "F4_", "._", "Dataset_", "(_", "file", "\\u", "path_", ",_", "mode_", "=_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Run", "time", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\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_", "=_", "{_", "'", "success", "'_", ":_", "True_", ",_", "'", "variab", "les", "'_", ":_", "in", "\\u", "file_", "._", "variables_", "._", "keys_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "file_", "._", "close_", "(_", ")_", "\\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_", "request_", "._", "query_", "._", "callback_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", "(%", "s", ")\"_", "%_", "(_", "request_", "._", "query_", "._", "callback_", ",_", "json_", "._", "dumps_", "(_", "output_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_", "\\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_", "@_", "lf", "me", "\\u", "app_", "._", "hook_", "(_", "'", "after", "\\u", "request", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "enable", "\\u", "cors", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "All", "ow", " ", "Cross", "-", "Orig", "in", " ", "Reso", "urc", "e", " ", "Shar", "ing", " ", "for", " ", "all", " ", "URL", "s", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "headers_", "[_", "'", "Access", "-", "Control", "-", "All", "ow", "-", "Orig", "in", "'_", "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era, Inc. under one\n# or more contributor license agreements. See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership. Cloudera, Inc. licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with 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\nimport django_openid_auth\nimport desktop.conf\nimport libopenid.conf\nimport logging\n\nfrom desktop.lib import security_util\n\n\n\n__all__ = ['OPENID_CONFIG', 'OPENID_CREATE_USERS', 'OPENID_SSO_SERVER_URL', 'OPENID_USE_EMAIL_FOR_USERNAME', 'OPENID_IDENTITY_URL_PREFIX']\n\n\n\n\nOPENID_CONFIG = {\n \n # set to 1 to output debugging information\n 'debug': 1,\n\n}\n\n# openid sso endpoint url\nOPENID_SSO_SERVER_URL = libopenid.conf.SERVER_ENDPOINT_URL.get();\n\nOPENID_CREATE_USERS = libopenid.conf.CREATE_USERS_ON_LOGIN.get();\n\nOPENID_USE_EMAIL_FOR_USERNAME = libopenid.conf.USE_EMAIL_FOR_USERNAME.get();\n\nOPENID_IDENTITY_URL_PREFIX = libopenid.conf.IDENTITY_URL_PREFIX.get();\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import django_openid_auth", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 25 }, { "span": "import desktop.conf", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 19 }, { "span": "import logging", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 14 }, { "span": "from desktop.lib import security_util", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "Cloud", "era", ",", " ", "Inc", ".", " ", "under", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "more", " ", "contributor", " ", "license", " ", "agreement", "s", ".", " ", " ", "See", " ", "the", " ", "NOTICE", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "with", " ", "this", " ", "work", " ", "for", " ", "addition", "al", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "regarding", " ", "copyr", "ight", " ", "owner", "ship", ".", " ", " ", "Cloud", "era", ",", " ", "Inc", ".", " ", "license", "s", " ", "this", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "you", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "ance_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "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_", "import_", "django", "\\u", "openid", "\\u", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "desktop_", "._", "conf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "lib", "openid", "_", "._", "conf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "desktop_", "._", "lib_", "import_", "security", "\\u", "util_", "\\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", "all\\u\\u_", "=_", "[_", "'", "OPEN", "ID", "\\u", "CONFIG", "'_", ",_", "'", "OPEN", "ID", "\\u", "CREATE", "\\u", "USERS", "'_", ",_", "'", "OPEN", "ID", "\\u", "SSO", "\\u", "SERVER", "\\u", "URL", "'_", ",_", "'", "OPEN", "ID", "\\u", "USE", "\\u", "EMA", "IL", "\\u", "FOR", "\\u", "USER", "NAME", "'_", ",_", "'", "OPEN", "ID", "\\u", "IDENTITY", "\\u", "URL", "\\u", "PREF", "IX", "'_", "]_", "\\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_", "OPEN", "ID", "\\u", "CONFIG_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "to", " ", "1", " ", "to", " ", "output", " ", "debugg", "ing", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "'", "debug", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "openid", " ", "sso", " ", "endpoint", " ", "url_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "ID", "\\u", "SSO", "\\u", "SERVER", "\\u", "URL_", "=_", "lib", "openid", "_", "._", "conf_", "._", "SERVER", "\\u", "ENDPOINT", "\\u", "URL_", "._", "get_", "(_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "ID", "\\u", "CREATE", "\\u", "USERS", "_", "=_", "lib", "openid", "_", "._", "conf_", "._", "CREATE", "\\u", "USERS", "\\u", "ON", "\\u", "LOGIN", "_", "._", "get_", "(_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "ID", "\\u", "USE", "\\u", "EMA", "IL", "\\u", "FOR", "\\u", "USERNAME_", "=_", "lib", "openid", "_", "._", "conf_", "._", "USE", "\\u", "EMA", "IL", "\\u", "FOR", "\\u", "USERNAME_", "._", "get_", "(_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "ID", "\\u", "IDENTITY", "\\u", "URL", "\\u", "PREFIX_", "=_", "lib", "openid", "_", "._", "conf_", "._", "IDENTITY", "\\u", "URL", "\\u", "PREFIX_", "._", "get_", "(_", ")_", ";_" ]
[ 4, 4, 4, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
CollabQ/CollabQ/components/dummy_sms_service/__init__.py
[ { "content": "\"\"\"an sms service that doesn't do anything\"\"\"\nimport logging\n\nfrom common.protocol import sms\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def send_message(to_list, message):\n logging.info(\"SMS_SERVICE: send_message(%s, %s)\", to_list, message)", "metadata": "root.send_message", "header": "['module', '___EOS___']", "index": 5 }, { "content": "def from_request(cls, request):\n params = {'sender': request.REQUEST.get('sender'),\n 'target': request.REQUEST.get('target'),\n 'message': request.REQUEST.get('message'),\n }\n return cls(**params)", "metadata": "root.from_request", "header": "['module', '___EOS___']", "index": 9 } ]
[ { "span": "from common.protocol import sms", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 31 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "an", " ", "sms", " ", "service", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "do", " ", "anyt", "hing", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "common_", "._", "protocol_", "import_", "sms_", "\\u\\u\\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_", "send", "\\u", "message_", "(_", "to", "\\u", "list_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "\"", "SMS", "\\u", "SERV", "ICE", ":", " ", "send", "\\u", "message", "(%", "s", ",", " ", "%", "s", ")\"_", ",_", "to", "\\u", "list_", ",_", "message_", ")_", "\\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_", "from", "\\u", "request_", "(_", "cls_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "{_", "'", "sender", "'_", ":_", "request_", "._", "REQUEST_", "._", "get_", "(_", "'", "sender", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "target", "'_", ":_", "request_", "._", "REQUEST_", "._", "get_", "(_", "'", "target", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "request_", "._", "REQUEST_", "._", "get_", "(_", "'", "message", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "(_", "**_", "params_", ")_" ]
[ 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, 0, 1, 1, 1, 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, 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 ]
Unused import
istresearch/scrapy-cluster/kafka-monitor/tests/tests_offline.py
[ { "content": "'''\nOffline tests\n'''\n\nimport unittest\nfrom unittest import TestCase\nfrom mock import MagicMock\n\nimport sys\nfrom os import path\nsys.path.append(path.dirname(path.dirname(path.abspath(__file__))))\n\nfrom kafka_monitor import KafkaMonitor\nfrom plugins.scraper_handler import ScraperHandler\nfrom plugins.base_handler import BaseHandler\nfrom plugins.action_handler import ActionHandler\nfrom plugins.stats_handler import StatsHandler\nimport copy\n\nfrom kafka.common import OffsetOutOfRangeError\nfrom jsonschema import Draft4Validator\nimport tldextract\n\n\n\n\n\n\n\nif __name__ == '__main__':\n unittest.main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ExampleHandler(BaseHandler):\n schema = \"crazy_schema.json\"\n", "metadata": "root.ExampleHandler", "header": "['module', '___EOS___']", "index": 24 }, { "content": " def setup(self, settings):\n pass", "metadata": "root.ExampleHandler.setup", "header": "['class', 'ExampleHandler', '(', 'BaseHandler', ')', ':', '___EOS___']", "index": 27 }, { "content": "class TestKafkaMonitor(TestCase):\n\n\n\n\n", "metadata": "root.TestKafkaMonitor", "header": "['module', '___EOS___']", "index": 31 }, { "content": " def setUp(self):\n self.kafka_monitor = KafkaMonitor(\"settings.py\", True)\n self.kafka_monitor.settings = self.kafka_monitor.wrapper.load(\"settings.py\")\n self.kafka_monitor.logger = MagicMock()", "metadata": "root.TestKafkaMonitor.setUp", "header": "['class', 'TestKafkaMonitor', '(', 'TestCase', ')', ':', '___EOS___']", "index": 33 }, { "content": " def test_load_plugins(self):\n # test loading default plugins\n assert_keys = [100, 200, 300]\n self.kafka_monitor._load_plugins()\n self.assertEqual(self.kafka_monitor.plugins_dict.keys(), assert_keys)\n\n # test removing a plugin from settings\n assert_keys = [200,300]\n self.kafka_monitor.settings['PLUGINS'] \\\n ['plugins.scraper_handler.ScraperHandler'] = None\n self.kafka_monitor._load_plugins()\n self.assertEqual(self.kafka_monitor.plugins_dict.keys(), assert_keys)\n self.kafka_monitor.settings['PLUGINS'] \\\n ['plugins.scraper_handler.ScraperHandler'] = 100\n\n # fail if the class is not found\n self.kafka_monitor.settings['PLUGINS'] \\\n ['plugins.crazy_class.CrazyHandler'] = 300\n self.assertRaises(ImportError, self.kafka_monitor._load_plugins)\n del self.kafka_monitor.settings['PLUGINS'] \\\n ['plugins.crazy_class.CrazyHandler']\n\n # Throw error if schema could not be found\n self.kafka_monitor.settings['PLUGINS'] \\\n ['tests.tests_offline.ExampleHandler'] = 300,\n self.assertRaises(IOError, self.kafka_monitor._load_plugins)\n del self.kafka_monitor.settings['PLUGINS'] \\\n ['tests.tests_offline.ExampleHandler']", "metadata": "root.TestKafkaMonitor.test_load_plugins", "header": "['class', 'TestKafkaMonitor', '(', 'TestCase', ')', ':', '___EOS___']", "index": 38 }, { "content": " def test_load_stats_total(self):\n # test no rolling stats, only total\n self.kafka_monitor.stats_dict = {}\n self.kafka_monitor.settings['STATS_TIMES'] = []\n self.kafka_monitor._setup_stats_total(MagicMock())\n\n self.assertEquals(self.kafka_monitor.stats_dict['total'].keys(), ['lifetime'])\n self.assertEquals(self.kafka_monitor.stats_dict['fail'].keys(), ['lifetime'])\n\n # test good/bad rolling stats\n self.kafka_monitor.stats_dict = {}\n self.kafka_monitor.settings['STATS_TIMES'] = [\n 'SECONDS_15_MINUTE',\n 'SECONDS_1_HOUR',\n 'SECONDS_DUMB',\n ]\n good = [\n 'lifetime', # for totals, not DUMB\n 900,\n 3600,\n ]\n\n self.kafka_monitor._setup_stats_total(MagicMock())\n self.assertEquals(\n sorted(self.kafka_monitor.stats_dict['total'].keys()),\n sorted(good))\n self.assertEquals(\n sorted(self.kafka_monitor.stats_dict['fail'].keys()),\n sorted(good))\n\n k1 = 'stats:kafka-monitor:total'\n k2 = 'stats:kafka-monitor:fail'\n\n for time_key in self.kafka_monitor.stats_dict['total']:\n if time_key == 0:\n self.assertEquals(\n self.kafka_monitor.stats_dict['total'][0].key,\n '{k}:lifetime'.format(k=k1)\n )\n else:\n self.assertEquals(\n self.kafka_monitor.stats_dict['total'][time_key].key,\n '{k}:{t}'.format(k=k1, t=time_key)\n )\n\n for time_key in self.kafka_monitor.stats_dict['fail']:\n if time_key == 0:\n self.assertEquals(\n self.kafka_monitor.stats_dict['fail'][0].key,\n '{k}:lifetime'.format(k=k2)\n )\n else:\n self.assertEquals(\n self.kafka_monitor.stats_dict['fail'][time_key].key,\n '{k}:{t}'.format(k=k2, t=time_key)\n )", "metadata": "root.TestKafkaMonitor.test_load_stats_total", "header": "['class', 'TestKafkaMonitor', '(', 'TestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def test_load_stats_plugins(self):\n # lets assume we are loading the default plugins\n self.kafka_monitor._load_plugins()\n\n # test no rolling stats\n self.kafka_monitor.stats_dict = {}\n self.kafka_monitor.settings['STATS_TIMES'] = []\n self.kafka_monitor._setup_stats_plugins(MagicMock())\n defaults = [\n 'ScraperHandler',\n 'ActionHandler',\n 'StatsHandler'\n ]\n\n self.assertEquals(\n sorted(self.kafka_monitor.stats_dict['plugins'].keys()),\n sorted(defaults))\n\n for key in self.kafka_monitor.plugins_dict:\n plugin_name = self.kafka_monitor.plugins_dict[key]['instance'].__class__.__name__\n self.assertEquals(\n self.kafka_monitor.stats_dict['plugins'][plugin_name].keys(),\n ['lifetime'])\n\n # test good/bad rolling stats\n self.kafka_monitor.stats_dict = {}\n self.kafka_monitor.settings['STATS_TIMES'] = [\n 'SECONDS_15_MINUTE',\n 'SECONDS_1_HOUR',\n 'SECONDS_DUMB',\n ]\n good = [\n 'lifetime', # for totals, not DUMB\n 900,\n 3600,\n ]\n\n self.kafka_monitor._setup_stats_plugins(MagicMock())\n\n self.assertEquals(\n sorted(self.kafka_monitor.stats_dict['plugins'].keys()),\n sorted(defaults))\n\n for key in self.kafka_monitor.plugins_dict:\n plugin_name = self.kafka_monitor.plugins_dict[key]['instance'].__class__.__name__\n self.assertEquals(\n sorted(self.kafka_monitor.stats_dict['plugins'][plugin_name].keys()),\n sorted(good))\n\n for plugin_key in self.kafka_monitor.stats_dict['plugins']:\n k1 = 'stats:kafka-monitor:{p}'.format(p=plugin_key)\n for time_key in self.kafka_monitor.stats_dict['plugins'][plugin_key]:\n if time_key == 0:\n self.assertEquals(\n self.kafka_monitor.stats_dict['plugins'][plugin_key][0].key,\n '{k}:lifetime'.format(k=k1)\n )\n else:\n self.assertEquals(\n self.kafka_monitor.stats_dict['plugins'][plugin_key][time_key].key,\n '{k}:{t}'.format(k=k1, t=time_key)\n )", "metadata": "root.TestKafkaMonitor.test_load_stats_plugins", "header": "['class', 'TestKafkaMonitor', '(', 'TestCase', ')', ':', '___EOS___']", "index": 124 }, { "content": " def test_process_messages(self):\n self.kafka_monitor.consumer = MagicMock()\n self.kafka_monitor.stats_dict = {}\n\n # handle kafka offset errors\n self.kafka_monitor.consumer.get_messages = MagicMock(\n side_effect=OffsetOutOfRangeError(\"1\"))\n try:\n self.kafka_monitor._process_messages()\n except OffsetOutOfRangeError:\n self.fail(\"_process_messages did not handle Kafka Offset Error\")\n\n # handle bad json errors\n message_string = \"{\\\"sdasdf sd}\"\n\n # fake class so we can use dot notation\n class a:\n pass\n m = a()\n m.message = a()\n m.message.value = message_string\n messages = [m]\n self.kafka_monitor.consumer.get_messages = MagicMock(\n return_value=messages)\n try:\n self.kafka_monitor._process_messages()\n except OffsetOutOfRangeError:\n self.fail(\"_process_messages did not handle bad json\")\n\n # set up to process messages\n self.kafka_monitor.consumer.get_messages = MagicMock(\n return_value=messages)\n self.kafka_monitor._load_plugins()\n self.kafka_monitor.validator = self.kafka_monitor.extend_with_default(Draft4Validator)\n self.kafka_monitor.plugins_dict.items()[0][1]['instance'].handle = MagicMock(side_effect=AssertionError(\"scrape\"))\n self.kafka_monitor.plugins_dict.items()[1][1]['instance'].handle = MagicMock(side_effect=AssertionError(\"action\"))\n\n\n # test that handler function is called for the scraper\n message_string = \"{\\\"url\\\":\\\"www.stuff.com\\\",\\\"crawlid\\\":\\\"1234\\\",\" \\\n \"\\\"appid\\\":\\\"testapp\\\"}\"\n m.message.value = message_string\n messages = [m]\n try:\n self.kafka_monitor._process_messages()\n self.fail(\"Scrape not called\")\n except AssertionError as e:\n self.assertEquals(\"scrape\", e.message)\n\n # test that handler function is called for the actions\n message_string = \"{\\\"uuid\\\":\\\"blah\\\",\\\"crawlid\\\":\\\"1234\\\",\" \\\n \"\\\"appid\\\":\\\"testapp\\\",\\\"action\\\":\\\"info\\\",\\\"spiderid\\\":\\\"link\\\"}\"\n m.message.value = message_string\n messages = [m]\n try:\n self.kafka_monitor._process_messages()\n self.fail(\"Action not called\")\n except AssertionError as e:\n self.assertEquals(\"action\", e.message)", "metadata": "root.TestKafkaMonitor.test_process_messages", "header": "['class', 'TestKafkaMonitor', '(', 'TestCase', ')', ':', '___EOS___']", "index": 187 }, { "content": "class TestPlugins(TestCase):\n\n\n\n\n", "metadata": "root.TestPlugins", "header": "['module', '___EOS___']", "index": 248 }, { "content": " def test_default_handler(self):\n handler = BaseHandler()\n try:\n handler.setup(\"s\")\n self.fail(\"base setup should be abstract\")\n except NotImplementedError:\n pass\n\n try:\n handler.handle({})\n self.fail(\"base handler should be abstract\")\n except NotImplementedError:\n pass", "metadata": "root.TestPlugins.test_default_handler", "header": "['class', 'TestPlugins', '(', 'TestCase', ')', ':', '___EOS___']", "index": 250 }, { "content": " def test_scrape_handler(self):\n valid = {\n \"url\": \"www.stuff.com\",\n \"crawlid\": \"abc124\",\n \"appid\": \"testapp\",\n \"spiderid\": \"link\",\n \"priority\": 5,\n }\n handler = ScraperHandler()\n handler.extract = tldextract.TLDExtract()\n handler.redis_conn = MagicMock()\n\n # check it is added to redis\n handler.redis_conn.zadd = MagicMock(side_effect=AssertionError(\"added\"))\n try:\n handler.handle(valid)\n self.fail(\"Action not called\")\n except AssertionError as e:\n self.assertEquals(\"added\", e.message)\n\n # check timeout is added\n handler.redis_conn.zadd = MagicMock()\n handler.redis_conn.set = MagicMock(side_effect=AssertionError(\"expires\"))\n valid['expires'] = 124242\n try:\n handler.handle(valid)\n self.fail(\"Expires not called\")\n except AssertionError as e:\n self.assertEquals(\"expires\", e.message)", "metadata": "root.TestPlugins.test_scrape_handler", "header": "['class', 'TestPlugins', '(', 'TestCase', ')', ':', '___EOS___']", "index": 264 }, { "content": " def test_action_handler(self):\n handler = ActionHandler()\n handler.redis_conn = MagicMock()\n handler.redis_conn.set = MagicMock(side_effect=AssertionError(\"added\"))\n\n valid = {\n \"uuid\": \"abaksdjb\",\n \"crawlid\": \"abc124\",\n \"appid\": \"testapp\",\n \"spiderid\": \"link\",\n \"action\": \"info\",\n }\n\n try:\n handler.handle(valid)\n self.fail(\"Added not called\")\n except AssertionError as e:\n self.assertEquals(\"added\", e.message)", "metadata": "root.TestPlugins.test_action_handler", "header": "['class', 'TestPlugins', '(', 'TestCase', ')', ':', '___EOS___']", "index": 294 }, { "content": " def test_stats_handler(self):\n handler = StatsHandler()\n handler.redis_conn = MagicMock()\n handler.redis_conn.set = MagicMock(side_effect=AssertionError(\"added\"))\n\n valid = {\n \"uuid\":\"abaksdjb\",\n \"appid\":\"testapp\",\n \"stats\":\"all\",\n }\n\n try:\n handler.handle(valid)\n self.fail(\"Added not called\")\n except AssertionError as e:\n self.assertEquals(\"added\", e.message)", "metadata": "root.TestPlugins.test_stats_handler", "header": "['class', 'TestPlugins', '(', 'TestCase', ')', ':', '___EOS___']", "index": 313 }, { "content": " def test_bad_plugins(self):\n class ForgotSchema(BaseHandler):\n def handle(self, d):\n pass\n\n class ForgotHandle(BaseHandler):\n schema = \"mySchema\"\n\n handler = ForgotSchema()\n try:\n handler.setup(\"s\")\n self.fail(\"did not raise error\")\n except NotImplementedError as e:\n pass\n handler.handle({})\n\n handler = ForgotHandle()\n handler.setup(\"s\")\n try:\n handler.handle({})\n self.fail(\"did not raise error\")\n except NotImplementedError:\n pass", "metadata": "root.TestPlugins.test_bad_plugins", "header": "['class', 'TestPlugins', '(', 'TestCase', ')', ':', '___EOS___']", "index": 330 } ]
[ { "span": "import copy", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "Off", "line", " ", "tests", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "unittest_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mock_", "import_", "Mag", "ic", "Mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "import_", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "path_", "._", "dirname_", "(_", "path_", "._", "dirname_", "(_", "path_", "._", "abspath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kaf", "ka", "\\u", "monitor_", "import_", "Ka", "fk", "a", "Monitor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plugins_", "._", "scraper", "\\u", "handler_", "import_", "Scrape", "r", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plugins_", "._", "base", "\\u", "handler_", "import_", "Base", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plugins_", "._", "action", "\\u", "handler_", "import_", "Action", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plugins_", "._", "stats", "\\u", "handler_", "import_", "Stat", "s", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kaf", "ka_", "._", "common_", "import_", "Off", "set", "Out", "Of", "Range", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "jsonschema", "_", "import_", "Dra", "ft", "4", "Validator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tld", "extract_", "\\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_", "\\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 ", " _", "unittest_", "._", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Exam", "ple", "Handler_", "(_", "Base", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "schema_", "=_", "\"", "cra", "zy", "\\u", "schema", ".", "json", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Exam", "ple", "Handler_", "(_", "Base", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "setup_", "(_", "self_", ",_", "settings_", ")_", ":_", "\\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_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "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 ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "=_", "Ka", "fk", "a", "Monitor_", "(_", "\"", "settings", ".", "py", "\"_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "=_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "wrapper_", "._", "load_", "(_", "\"", "settings", ".", "py", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "logger_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "plugins_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "load", "ing", " ", "default", " ", "plugins_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert", "\\u", "keys_", "=_", "[_", "100_", ",_", "200_", ",_", "300_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "._", "keys_", "(_", ")_", ",_", "assert", "\\u", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "remo", "ving", " ", "a", " ", "plugin", " ", "from", " ", "settings_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "keys_", "=_", "[_", "200_", ",_", "300_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "plugin", "s", ".", "scraper", "\\u", "handler", ".", "Scrape", "r", "Handle", "r", "'_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "._", "keys_", "(_", ")_", ",_", "assert", "\\u", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "plugin", "s", ".", "scraper", "\\u", "handler", ".", "Scrape", "r", "Handle", "r", "'_", "]_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fail", " ", "if", " ", "the", " ", "class", " ", "is", " ", "not", " ", "found_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "plugin", "s", ".", "cra", "zy", "\\u", "class", ".", "Cra", "zy", "Handle", "r", "'_", "]_", "=_", "300_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Import", "Error_", ",_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "plugin", "s", ".", "cra", "zy", "\\u", "class", ".", "Cra", "zy", "Handle", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Throw", " ", "error", " ", "if", " ", "schema", " ", "coul", "d", " ", "not", " ", "be", " ", "found_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "tests", ".", "tests", "\\u", "offline", ".", "Exam", "ple", "Handle", "r", "'_", "]_", "=_", "300_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "IO", "Error_", ",_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "PLUGINS", "'_", "]_", "[_", "'", "tests", ".", "tests", "\\u", "offline", ".", "Exam", "ple", "Handle", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "stats", "\\u", "total_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "no", " ", "rolling", " ", "stats", ",", " ", "only", " ", "total_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "STATS", "\\u", "TIMES", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "setup", "\\u", "stats", "\\u", "total_", "(_", "Mag", "ic", "Mock_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "total", "'_", "]_", "._", "keys_", "(_", ")_", ",_", "[_", "'", "life", "time", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "fail", "'_", "]_", "._", "keys_", "(_", ")_", ",_", "[_", "'", "life", "time", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "good", "/", "bad", " ", "rolling", " ", "stats_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "STATS", "\\u", "TIMES", "'_", "]_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "15", "\\u", "MINUTE", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "1", "\\u", "HOUR", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "DU", "MB", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "good_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "life", "time", "'_", ",_", "#", " ", "for", " ", "totals", ",", " ", "not", " ", "DU", "MB_", "\\u\\u\\uNL\\u\\u\\u_", "900_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "3600_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "setup", "\\u", "stats", "\\u", "total_", "(_", "Mag", "ic", "Mock_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "total", "'_", "]_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "good_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "fail", "'_", "]_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "good_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "k1_", "=_", "'", "stats", ":", "kaf", "ka", "-", "monit", "or", ":", "total", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k2_", "=_", "'", "stats", ":", "kaf", "ka", "-", "monit", "or", ":", "fail", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "time", "\\u", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "total", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "time", "\\u", "key_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "total", "'_", "]_", "[_", "0_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "life", "time", "'_", "._", "format_", "(_", "k_", "=_", "k1_", ")_", "\\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_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "total", "'_", "]_", "[_", "time", "\\u", "key_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "{", "t", "}'_", "._", "format_", "(_", "k_", "=_", "k1_", ",_", "t_", "=_", "time", "\\u", "key_", ")_", "\\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_", "for_", "time", "\\u", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "fail", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "time", "\\u", "key_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "fail", "'_", "]_", "[_", "0_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "life", "time", "'_", "._", "format_", "(_", "k_", "=_", "k2_", ")_", "\\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_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "fail", "'_", "]_", "[_", "time", "\\u", "key_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "{", "t", "}'_", "._", "format_", "(_", "k_", "=_", "k2_", ",_", "t_", "=_", "time", "\\u", "key_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "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_", "def_", "test\\u", "load", "\\u", "stats", "\\u", "plugins_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "lets", " ", "assume", " ", "we", " ", "are", " ", "load", "ing", " ", "the", " ", "default", " ", "plugins_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "no", " ", "rolling", " ", "stats_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "STATS", "\\u", "TIMES", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "setup", "\\u", "stats", "\\u", "plugins_", "(_", "Mag", "ic", "Mock_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "defaults_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Scrape", "r", "Handle", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Action", "Handle", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Stat", "s", "Handle", "r", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "defaults_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plugin", "\\u", "name_", "=_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "[_", "key_", "]_", "[_", "'", "instance", "'_", "]_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "[_", "plugin", "\\u", "name_", "]_", "._", "keys_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "life", "time", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "good", "/", "bad", " ", "rolling", " ", "stats_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "settings_", "[_", "'", "STATS", "\\u", "TIMES", "'_", "]_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "15", "\\u", "MINUTE", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "1", "\\u", "HOUR", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SECOND", "S", "\\u", "DU", "MB", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "good_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "life", "time", "'_", ",_", "#", " ", "for", " ", "totals", ",", " ", "not", " ", "DU", "MB_", "\\u\\u\\uNL\\u\\u\\u_", "900_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "3600_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "setup", "\\u", "stats", "\\u", "plugins_", "(_", "Mag", "ic", "Mock_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "defaults_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plugin", "\\u", "name_", "=_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "[_", "key_", "]_", "[_", "'", "instance", "'_", "]_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "[_", "plugin", "\\u", "name_", "]_", "._", "keys_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sorted_", "(_", "good_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "plugin", "\\u", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k1_", "=_", "'", "stats", ":", "kaf", "ka", "-", "monit", "or", ":", "{", "p", "}'_", "._", "format_", "(_", "p_", "=_", "plugin", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "time", "\\u", "key_", "in_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "[_", "plugin", "\\u", "key_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "time", "\\u", "key_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "[_", "plugin", "\\u", "key_", "]_", "[_", "0_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "life", "time", "'_", "._", "format_", "(_", "k_", "=_", "k1_", ")_", "\\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_", "._", "assert", "Equals_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "[_", "'", "plugin", "s", "'_", "]_", "[_", "plugin", "\\u", "key_", "]_", "[_", "time", "\\u", "key_", "]_", "._", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{", "k", "}:", "{", "t", "}'_", "._", "format_", "(_", "k_", "=_", "k1_", ",_", "t_", "=_", "time", "\\u", "key_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Ka", "fk", "a", "Monitor_", "(_", "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_", "def_", "test\\u", "process", "\\u", "messages_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "consumer_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "stats", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "handle", " ", "kaf", "ka", " ", "offset", " ", "errors_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "consumer_", "._", "get", "\\u", "messages_", "=_", "Mag", "ic", "Mock_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "side", "\\u", "effect_", "=_", "Off", "set", "Out", "Of", "Range", "Error_", "(_", "\"", "1", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "process", "\\u", "messages_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Off", "set", "Out", "Of", "Range", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"\\u", "process", "\\u", "message", "s", " ", "did", " ", "not", " ", "handle", " ", "Ka", "fk", "a", " ", "Off", "set", " ", "Error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "handle", " ", "bad", " ", "json", " ", "errors_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message", "\\u", "string_", "=_", "\"{\\\\", "\"", "sda", "sdf", " ", " ", " ", "sd", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fake", " ", "class", " ", "so", " ", "we", " ", "can", " ", "use", " ", "dot", " ", "notation", "_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "a_", ":_", "\\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_", "m_", "=_", "a_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "message_", "=_", "a_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "message_", "._", "value_", "=_", "message", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "=_", "[_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "consumer_", "._", "get", "\\u", "messages_", "=_", "Mag", "ic", "Mock_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "return", "\\u", "value_", "=_", "messages_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "process", "\\u", "messages_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Off", "set", "Out", "Of", "Range", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"\\u", "process", "\\u", "message", "s", " ", "did", " ", "not", " ", "handle", " ", "bad", " ", "json", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "up", " ", "to", " ", "process", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "consumer_", "._", "get", "\\u", "messages_", "=_", "Mag", "ic", "Mock_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "return", "\\u", "value_", "=_", "messages_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "load", "\\u", "plugins_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "validator_", "=_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "extend", "\\u", "with", "\\u", "default_", "(_", "Dra", "ft", "4", "Validator_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "._", "items_", "(_", ")_", "[_", "0_", "]_", "[_", "1_", "]_", "[_", "'", "instance", "'_", "]_", "._", "handle_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "scrape", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "plugin", "s", "\\u", "dict_", "._", "items_", "(_", ")_", "[_", "1_", "]_", "[_", "1_", "]_", "[_", "'", "instance", "'_", "]_", "._", "handle_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "action", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "test", " ", "tha", "t", " ", "handler", " ", "function", " ", "is", " ", "call", "ed", " ", "for", " ", "the", " ", "scraper_", "\\u\\u\\uNL\\u\\u\\u_", "message", "\\u", "string_", "=_", "\"{\\\\", "\"", "url", "\\\\\":", "\\\\\"", "www", ".", "stu", "ff", ".", "com", "\\\\\",", "\\\\\"", "crawl", "id", "\\\\\":", "\\\\\"", "1234", "\\\\\",", "\"_", "\"\\\\\"", "appid", "\\\\\":", "\\\\\"", "testa", "pp", "\\\\\"", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "message_", "._", "value_", "=_", "message", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "=_", "[_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "process", "\\u", "messages_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Scrape", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "scrape", "\"_", ",_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "tha", "t", " ", "handler", " ", "function", " ", "is", " ", "call", "ed", " ", "for", " ", "the", " ", "actions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message", "\\u", "string_", "=_", "\"{\\\\", "\"", "uuid", "\\\\\":", "\\\\\"", "bla", "h", "\\\\\",", "\\\\\"", "crawl", "id", "\\\\\":", "\\\\\"", "1234", "\\\\\",", "\"_", "\"\\\\\"", "appid", "\\\\\":", "\\\\\"", "testa", "pp", "\\\\\",", "\\\\\"", "action", "\\\\\":", "\\\\\"", "info", "\\\\\",", "\\\\\"", "spider", "id", "\\\\\":", "\\\\\"", "link", "\\\\\"", "}\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "message_", "._", "value_", "=_", "message", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "=_", "[_", "m_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "kaf", "ka", "\\u", "monitor_", "._", "\\u", "process", "\\u", "messages_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Action", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "action", "\"_", ",_", "e_", "._", "message_", ")_", "\\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_", "Test", "Plugins_", "(_", "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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plugins_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "default", "\\u", "handler_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "=_", "Base", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "._", "setup_", "(_", "\"", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "base", " ", "setup", " ", "shou", "ld", " ", "be", " ", "abstract", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "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 ", " _", "handler_", "._", "handle_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "base", " ", "handler", " ", "shou", "ld", " ", "be", " ", "abstract", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plugins_", "(_", "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", "scrape", "\\u", "handler_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "valid_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "url", "\"_", ":_", "\"", "www", ".", "stu", "ff", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "crawl", "id", "\"_", ":_", "\"", "abc", "124", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "appid", "\"_", ":_", "\"", "testa", "pp", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "spider", "id", "\"_", ":_", "\"", "link", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "priorit", "y", "\"_", ":_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "=_", "Scrape", "r", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "extract_", "=_", "tld", "extract_", "._", "TL", "DE", "xtra", "ct_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "it", " ", "is", " ", "adde", "d", " ", "to", " ", "redis_", "\\u\\u\\uNL\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "._", "zad", "d_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "adde", "d", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "._", "handle_", "(_", "valid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Action", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "adde", "d", "\"_", ",_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "timeo", "ut", " ", "is", " ", "added_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "._", "zad", "d_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "._", "set_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "expir", "es", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid_", "[_", "'", "expir", "es", "'_", "]_", "=_", "124", "242_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "._", "handle_", "(_", "valid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Expire", "s", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "expir", "es", "\"_", ",_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plugins_", "(_", "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", "action", "\\u", "handler_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "=_", "Action", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "._", "set_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "adde", "d", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "valid_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "uuid", "\"_", ":_", "\"", "aba", "ks", "dj", "b", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "crawl", "id", "\"_", ":_", "\"", "abc", "124", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "appid", "\"_", ":_", "\"", "testa", "pp", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "spider", "id", "\"_", ":_", "\"", "link", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "action", "\"_", ":_", "\"", "info", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\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 ", " _", "handler_", "._", "handle_", "(_", "valid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Added", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "adde", "d", "\"_", ",_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plugins_", "(_", "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", "stats", "\\u", "handler_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "=_", "Stat", "s", "Handler_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "=_", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "redis", "\\u", "conn_", "._", "set_", "=_", "Mag", "ic", "Mock_", "(_", "side", "\\u", "effect_", "=_", "Assert", "ion", "Error_", "(_", "\"", "adde", "d", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "valid_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "uuid", "\"_", ":_", "\"", "aba", "ks", "dj", "b", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "appid", "\"_", ":_", "\"", "testa", "pp", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "stats", "\"_", ":_", "\"", "all", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\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 ", " _", "handler_", "._", "handle_", "(_", "valid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "Added", " ", "not", " ", "call", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Assert", "ion", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equals_", "(_", "\"", "adde", "d", "\"_", ",_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Plugins_", "(_", "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", "bad", "\\u", "plugins_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Forg", "ot", "Schema_", "(_", "Base", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "handle_", "(_", "self_", ",_", "d_", ")_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Forg", "ot", "Handle_", "(_", "Base", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "schema_", "=_", "\"", "my", "Schema", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "handler_", "=_", "Forg", "ot", "Schema_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "._", "setup_", "(_", "\"", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "did", " ", "not", " ", "raise", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "Error_", "as_", "e_", ":_", "\\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_", "handler_", "._", "handle_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "handler_", "=_", "Forg", "ot", "Handle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "setup_", "(_", "\"", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handler_", "._", "handle_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"", "did", " ", "not", " ", "raise", " ", "error", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\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, 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, 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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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.py
[ { "content": " def get_episode(self, url, imdb, tvdb, title, date, season, episode):\n if url == None: return\n\n url = url.replace('/watch-','/tv-')\n url += '/season-%01d-episode-%01d' % (int(season), int(episode))\n url = client.replaceHTMLCodes(url)\n url = url.encode('utf-8')\n return url", "metadata": "root.source.get_episode", "header": "['class', 'source', ':', '___EOS___']", "index": 87 }, { "content": " def get_sources(self, url, hosthdDict, hostDict, locDict):\n try:\n sources = []\n\n if url == None: return sources\n\n url = urlparse.urljoin(self.base_link, url)\n\n result = client.source(url)\n result = result.decode('iso-8859-1').encode('utf-8')\n\n links = client.parseDOM(result, 'table', attrs = {'class': 'link_ite.+?'})\n\n for i in links:\n try:\n url = client.parseDOM(i, 'a', ret='href')\n if len(url) > 1: raise Exception()\n url = url[0].split('gtfo=', 1)[-1].split('&', 1)[0]\n url = base64.urlsafe_b64decode(url.encode('utf-8'))\n url = client.replaceHTMLCodes(url)\n url = url.encode('utf-8')\n\n host = urlparse.urlparse(url).netloc\n host = host.replace('www.', '').replace('embed.', '')\n host = host.rsplit('.', 1)[0]\n host = host.lower()\n if not host in hostDict: raise Exception()\n host = client.replaceHTMLCodes(host)\n host = host.encode('utf-8')\n\n quality = client.parseDOM(i, 'div', attrs = {'class': 'quality'})\n if any(x in ['[CAM]', '[TS]'] for x in quality): quality = 'CAM'\n else: quality = 'SD'\n quality = quality.encode('utf-8')\n\n sources.append({'source': host, 'quality': quality, 'provider': 'Watchfree', 'url': url})\n except:\n pass\n\n return sources\n except:\n return sources", "metadata": "root.source.get_sources", "header": "['class', 'source', ':', '___EOS___']", "index": 97 } ]
[ { "span": "url == None:", "start_line": 88, "start_column": 11, "end_line": 88, "end_column": 22 }, { "span": "url == None:", "start_line": 101, "start_column": 15, "end_line": 101, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "source_", ":_", "\\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", "episode_", "(_", "self_", ",_", "url_", ",_", "imdb_", ",_", "tvdb", "_", ",_", "title_", ",_", "date_", ",_", "season_", ",_", "episode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "url_", "==_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "url_", "._", "replace_", "(_", "'/", "watch", "-'_", ",_", "'/", "tv", "-'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "+=_", "'/", "season", "-%", "01", "d", "-", "episode", "-%", "01", "d", "'_", "%_", "(_", "int_", "(_", "season_", ")_", ",_", "int_", "(_", "episode_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "client_", "._", "replace", "HTM", "LC", "odes_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "url_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "source_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "sources_", "(_", "self_", ",_", "url_", ",_", "host", "hd", "Dict_", ",_", "host", "Dict_", ",_", "loc", "Dict_", ")_", ":_", "\\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 ", " _", "sources_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "url_", "==_", "None_", ":_", "return_", "sources_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "urlparse_", "._", "urljoin_", "(_", "self_", "._", "base", "\\u", "link_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "result_", "._", "decode_", "(_", "'", "iso", "-", "8859", "-1", "'_", ")_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "links_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "table", "'_", ",_", "attrs_", "=_", "{_", "'", "class", "'_", ":_", "'", "link", "\\u", "ite", ".+?", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "links_", ":_", "\\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 ", " ", "_", "url_", "=_", "client_", "._", "parse", "DOM_", "(_", "i_", ",_", "'", "a", "'_", ",_", "ret_", "=_", "'", "href", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "url_", ")_", ">_", "1_", ":_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "url_", "[_", "0_", "]_", "._", "split_", "(_", "'", "gtf", "o", "='_", ",_", "1_", ")_", "[_", "-_", "1_", "]_", "._", "split_", "(_", "'&'_", ",_", "1_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "base64_", "._", "urlsafe", "\\u", "b64decode_", "(_", "url_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "client_", "._", "replace", "HTM", "LC", "odes_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "url_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "urlparse_", "._", "urlparse_", "(_", "url_", ")_", "._", "netloc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "host_", "._", "replace_", "(_", "'", "www", ".'_", ",_", "''_", ")_", "._", "replace_", "(_", "'", "embed", ".'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "host_", "._", "rsplit_", "(_", "'.'_", ",_", "1_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "host_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "host_", "in_", "host", "Dict_", ":_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "client_", "._", "replace", "HTM", "LC", "odes_", "(_", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "host_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "quality_", "=_", "client_", "._", "parse", "DOM_", "(_", "i_", ",_", "'", "div", "'_", ",_", "attrs_", "=_", "{_", "'", "class", "'_", ":_", "'", "quali", "ty", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "any_", "(_", "x_", "in_", "[_", "'[", "CAM", "]'_", ",_", "'[", "TS", "]'_", "]_", "for_", "x_", "in_", "quality_", ")_", ":_", "quality_", "=_", "'", "CAM", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "quality_", "=_", "'", "SD", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "quality_", "=_", "quality_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "host_", ",_", "'", "quali", "ty", "'_", ":_", "quality_", ",_", "'", "provide", "r", "'_", ":_", "'", "Watch", "free", "'_", ",_", "'", "url", "'_", ":_", "url_", "}_", ")_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "sources_", "\\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_", "sources_", "\\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, 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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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 ]
Imprecise assert
stephrdev/django-userprofiles/userprofiles/contrib/profiles/tests/test_views.py
[ { "content": " @override_settings(USERPROFILES_PROFILE_ALLOW_EMAIL_CHANGE=True)\n def test_profile_change_email_enabled(self):\n self.client.login(username=self.data['username'], password=self.data['password'])\n\n change_url = reverse('userprofiles_profile_change')\n\n response = self.client.get(change_url)\n self.assertTrue('email' in response.context['form'].fields)\n\n self.client.post(change_url, {'email': self.data['new_email']})\n response = self.client.get(change_url)\n\n self.assertTrue(User.objects.filter(pk=self.user.pk,\n email=self.data['new_email']).exists())", "metadata": "root.ViewTests.test_profile_change_email_enabled", "header": "['class', 'ViewTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 61 } ]
[ { "span": "self.assertTrue('email' in response.context['form'].fields)", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 67 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "View", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "override", "\\u", "settings_", "(_", "USER", "PROFILE", "S", "\\u", "PROFILE", "\\u", "ALLOW", "\\u", "EMA", "IL", "\\u", "CHANGE", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "profile", "\\u", "change", "\\u", "email", "\\u", "enabled_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "client_", "._", "login_", "(_", "username_", "=_", "self_", "._", "data_", "[_", "'", "user", "name", "'_", "]_", ",_", "password_", "=_", "self_", "._", "data_", "[_", "'", "password", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "change", "\\u", "url_", "=_", "reverse_", "(_", "'", "userprofile", "s", "\\u", "profile", "\\u", "change", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "change", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "email", "'_", "in_", "response_", "._", "context_", "[_", "'", "form", "'_", "]_", "._", "fields_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client_", "._", "post_", "(_", "change", "\\u", "url_", ",_", "{_", "'", "email", "'_", ":_", "self_", "._", "data_", "[_", "'", "new", "\\u", "email", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "change", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "User_", "._", "objects_", "._", "filter_", "(_", "pk_", "=_", "self_", "._", "user_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "email_", "=_", "self_", "._", "data_", "[_", "'", "new", "\\u", "email", "'_", "]_", ")_", "._", "exists_", "(_", ")_", ")_", "\\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, 0, 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 ]
Unused local variable
CurleySamuel/PyBase/tests/test_integration.py
[ { "content": " def test_new_client_bad(self):\n try:\n c = pybase.NewClient(\"badzkquorum\")\n self.assertEqual(1, 0)\n except ZookeeperException:\n pass", "metadata": "root.TestClient.test_new_client_bad", "header": "['class', 'TestClient', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 23 }, { "content": " def test_get_bad_table(self):\n try:\n res = self.c.get(\"asdasdasd\", \"plsfail\")\n self.assertEqual(1, 0)\n except NoSuchTableException:\n pass", "metadata": "root.TestGet.test_get_bad_table", "header": "['class', 'TestGet', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 81 }, { "content": " def test_get_with_bad_filter(self):\n ft = \"badfilter\"\n try:\n res = self.c.get(table, self.row_prefix, filters=ft)\n self.assertEqual(1, 0)\n except ValueError:\n pass", "metadata": "root.TestGet.test_get_with_bad_filter", "header": "['class', 'TestGet', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 112 }, { "content": " def test_scan_with_bad_range(self):\n try:\n rsp = self.c.scan(\n table, start_key=\"hmm\", stop_key=24, filters=self.pFilter)\n self.assertEqual(1, 0)\n except TypeError:\n pass", "metadata": "root.TestScan.test_scan_with_bad_range", "header": "['class', 'TestScan', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 220 }, { "content": " def test_scan_with_bad_column_family(self):\n fam = {\"hodor\": [\"stillhodor\"]}\n try:\n rsp = self.c.scan(table, filters=self.pFilter, families=fam)\n self.assertEqual(1, 0)\n except NoSuchColumnFamilyException:\n pass", "metadata": "root.TestScan.test_scan_with_bad_column_family", "header": "['class', 'TestScan', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 233 }, { "content": " def test_delete_bad_column_family(self):\n value = {\n cf1: {\n \"oberyn\": \"\"\n },\n \"hodor\": {\n \"i am hodor\": \"\"\n }\n }\n try:\n rsp = self.c.delete(table, self.row_prefix + \"2\", value)\n self.assertEqual(0, 1)\n except NoSuchColumnFamilyException:\n pass", "metadata": "root.TestDelete.test_delete_bad_column_family", "header": "['class', 'TestDelete', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 307 }, { "content": " def test_append_bad_column_family(self):\n values = {\n \"hodor\": {\n \"oberyn\": \"is the\",\n }\n }\n try:\n rsp = self.c.append(table, self.row_prefix + \"3\", values)\n self.assertEqual(1, 0)\n except NoSuchColumnFamilyException:\n pass", "metadata": "root.TestAppend.test_append_bad_column_family", "header": "['class', 'TestAppend', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 392 }, { "content": " def test_increment_bad_column_family(self):\n new_values = {\n \"hodor\": {\n \"oberyn\": \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x05\"\n }\n }\n # TODO: Throwing RuntimeError: java.io.IOException when it should be throwing\n # column family exception.\n try:\n rsp = self.c.increment(table, self.row_prefix + \"2\", new_values)\n self.assertEqual(1, 0)\n except NoSuchColumnFamilyException:\n pass", "metadata": "root.TestIncrement.test_increment_bad_column_family", "header": "['class', 'TestIncrement', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 523 } ]
[ { "span": "c ", "start_line": 25, "start_column": 12, "end_line": 25, "end_column": 13 }, { "span": "res ", "start_line": 83, "start_column": 12, "end_line": 83, "end_column": 15 }, { "span": "res ", "start_line": 115, "start_column": 12, "end_line": 115, "end_column": 15 }, { "span": "rsp ", "start_line": 222, "start_column": 12, "end_line": 222, "end_column": 15 }, { "span": "rsp ", "start_line": 236, "start_column": 12, "end_line": 236, "end_column": 15 }, { "span": "rsp ", "start_line": 317, "start_column": 12, "end_line": 317, "end_column": 15 }, { "span": "rsp ", "start_line": 399, "start_column": 12, "end_line": 399, "end_column": 15 }, { "span": "rsp ", "start_line": 532, "start_column": 12, "end_line": 532, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Client_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "new", "\\u", "client", "\\u", "bad_", "(_", "self_", ")_", ":_", "\\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 ", " _", "c_", "=_", "pyb", "ase_", "._", "New", "Client_", "(_", "\"", "bad", "zk", "quorum", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Zoo", "keeper", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Get_", "(_", "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", "bad", "\\u", "table_", "(_", "self_", ")_", ":_", "\\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 ", " _", "res_", "=_", "self_", "._", "c_", "._", "get_", "(_", "\"", "asd", "asd", "asd", "\"_", ",_", "\"", "pls", "fail", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Suc", "h", "Table", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Get_", "(_", "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", "with", "\\u", "bad", "\\u", "filter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ft_", "=_", "\"", "bad", "filter", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "self_", "._", "c_", "._", "get_", "(_", "table_", ",_", "self_", "._", "row", "\\u", "prefix_", ",_", "filters_", "=_", "ft_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\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_", "[SEP]_", "class_", "Test", "Scan_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "scan", "\\u", "with", "\\u", "bad", "\\u", "range_", "(_", "self_", ")_", ":_", "\\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 ", " _", "rsp_", "=_", "self_", "._", "c_", "._", "scan_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "table_", ",_", "start", "\\u", "key_", "=_", "\"", "hmm", "\"_", ",_", "stop", "\\u", "key_", "=_", "24_", ",_", "filters_", "=_", "self_", "._", "p", "Filter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Scan_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "scan", "\\u", "with", "\\u", "bad", "\\u", "column", "\\u", "family_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fam", "_", "=_", "{_", "\"", "hod", "or", "\"_", ":_", "[_", "\"", "still", "hod", "or", "\"_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rsp_", "=_", "self_", "._", "c_", "._", "scan_", "(_", "table_", ",_", "filters_", "=_", "self_", "._", "p", "Filter_", ",_", "families_", "=_", "fam", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Suc", "h", "Colum", "n", "Famil", "y", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Delete_", "(_", "unittest_", "._", "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", "bad", "\\u", "column", "\\u", "family_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "cf", "1_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "obe", "ry", "n", "\"_", ":_", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "hod", "or", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "i", " ", "am", " ", "hod", "or", "\"_", ":_", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rsp_", "=_", "self_", "._", "c_", "._", "delete_", "(_", "table_", ",_", "self_", "._", "row", "\\u", "prefix_", "+_", "\"", "2", "\"_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "0_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Suc", "h", "Colum", "n", "Famil", "y", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Append_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "append", "\\u", "bad", "\\u", "column", "\\u", "family_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "hod", "or", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "obe", "ry", "n", "\"_", ":_", "\"", "is", " ", "the", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rsp_", "=_", "self_", "._", "c_", "._", "append_", "(_", "table_", ",_", "self_", "._", "row", "\\u", "prefix_", "+_", "\"", "3", "\"_", ",_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Suc", "h", "Colum", "n", "Famil", "y", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Increment", "_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "increment", "\\u", "bad", "\\u", "column", "\\u", "family_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "values_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "hod", "or", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "obe", "ry", "n", "\"_", ":_", "\"\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "0", "\\\\", "x0", "5", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "Throw", "ing", " ", "Run", "time", "Error", ":", " ", "java", ".", "io", ".", "IO", "Except", "ion", " ", "whe", "n", " ", "it", " ", "shou", "ld", " ", "be", " ", "throw", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "column", " ", "famil", "y", " ", "exception", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rsp_", "=_", "self_", "._", "c_", "._", "increment_", "(_", "table_", ",_", "self_", "._", "row", "\\u", "prefix_", "+_", "\"", "2", "\"_", ",_", "new", "\\u", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "No", "Suc", "h", "Colum", "n", "Famil", "y", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\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, 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, 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, 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 ]
Testing equality to None
thasso/pyjip/test/test_options.py
[ { "content": "def test_options_equality():\n string_opt = Option('test')\n assert string_opt == None\n string_opt.value = \"TEST1\"\n assert string_opt == \"TEST1\"\n string_opt.append(\"TEST2\")\n assert string_opt != \"TEST1\"\n assert string_opt == [\"TEST1\", \"TEST2\"]\n assert string_opt\n string_opt.value = False\n assert not string_opt", "metadata": "root.test_options_equality", "header": "['module', '___EOS___']", "index": 285 } ]
[ { "span": "string_opt == None", "start_line": 287, "start_column": 11, "end_line": 287, "end_column": 29 } ]
[]
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", "options", "\\u", "equality", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "string", "\\u", "opt_", "=_", "Option_", "(_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "string", "\\u", "opt_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "\\u", "opt_", "._", "value_", "=_", "\"", "TEST", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "string", "\\u", "opt_", "==_", "\"", "TEST", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "\\u", "opt_", "._", "append_", "(_", "\"", "TEST", "2", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "string", "\\u", "opt_", "!=_", "\"", "TEST", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "string", "\\u", "opt_", "==_", "[_", "\"", "TEST", "1", "\"_", ",_", "\"", "TEST", "2", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "string", "\\u", "opt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "\\u", "opt_", "._", "value_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "string", "\\u", "opt_", "\\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, 0, 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 ]
Except block handles 'BaseException'
anandology/pyjamas/examples/libtest/BuiltinTest.py
[ { "content": "from UnitTest import UnitTest\n\ntry:\n builtin_value = builtin.value\nexcept:\n builtin_value = None\nif False:\n import builtin\nimport builtin\n\nfrom imports.cls import CLS\nfrom imports.cls1 import CLS as CLS1\n\n\n\n\n\n#from pyjamas import log\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def testIterProperty(self):\n o = C()\n tst = []\n for y in iter(o.x):\n tst.append(y)\n self.assertTrue(tst, [1,2,3])\n tst = []\n try:\n for y in o.x:\n tst.append(y)\n self.assertTrue(tst, [1,2,3])\n except:\n self.fail(\"#490 - no function iter.__iter__ not a function\")", "metadata": "root.BuiltinTest.testIterProperty", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 59 }, { "content": " def testImport(self):\n self.assertEqual(builtin_value, None, \"The builtin is loaded before import!\")\n try:\n self.assertEqual(builtin.value, builtin.get_value())\n except:\n self.fail(\"Import failed for builtin\")\n\n from imports import overrideme\n cls1 = CLS1()\n self.assertTrue(CLS is CLS1, \"CLS is CLS1\")\n self.assertTrue(isinstance(cls1, CLS), \"isinstance(cls1, CLS)\")\n self.assertEqual(overrideme, \"not overridden\")\n import imports.override\n self.assertEqual(overrideme, \"not overridden\")\n from imports import overrideme\n try:\n self.assertTrue(overrideme.overridden is True, \"overrideme.overridden is True\")\n except:\n self.fail(\"Exception on 'overrideme.overridden is True'\")\n\n import imports\n self.assertTrue(CLS is imports.loccls.CLS, \"CLS is imports.loccls.CLS\")\n self.assertTrue(CLS is imports.upcls.CLS, \"CLS is imports.upcls.CLS\")\n\n # from ... import * tests, issue #615\n self.assertEqual(imports.all_masked, False, \"from ... import * should respect __all__, #615\")\n self.assertEqual(imports.all_override, True, \"Should override globals, #615\")\n self.assertEqual(imports.all_import1, 1)\n self.assertEqual(imports.all_import2, 3)\n self.assertEqual(imports.all_import3, 3)", "metadata": "root.BuiltinTest.testImport", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 261 }, { "content": " def testIter(self):\n\n class i:\n def __init__(self):\n self.idx = 0\n\n def __iter__(self):\n return self\n\n def next(self):\n self.idx += 1\n if self.idx == 5:\n raise StopIteration\n return self.idx\n\n\n res = []\n try:\n for j in i():\n res.append(j)\n if len(res) > 5:\n self.fail(\"too many items in user-defined iterator\")\n break\n except:\n self.fail(\"error in user-defined iterator (caught here so tests can proceed)\")\n \n self.assertEqual(res, range(1,5))", "metadata": "root.BuiltinTest.testIter", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 460 }, { "content": " def testType(self):\n try:\n self.assertTrue(type(object) is type)\n except NotImplementedError, why:\n self.fail(\"Bug #229\" + str(why))\n self.assertTrue(type([]) is type([]))\n self.assertTrue(type([]) is list)\n try:\n self.assertTrue(type([]) == list)\n except:\n self.fail(\"Bug #515\")\n self.assertTrue(type(\"\") is str, \"str\")\n self.assertTrue(type(True) is bool, \"bool\")\n self.assertTrue(type(1) is int, \"int\")\n self.assertTrue(type(1L) is long, \"long\")\n self.assertTrue(type(1.1) is float, \"float 1.1\")\n self.assertTrue(type(1.0) is float, \"float 1.0 issue #524\")", "metadata": "root.BuiltinTest.testType", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 509 } ]
[ { "span": "except:", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 7 }, { "span": "except:", "start_line": 70, "start_column": 8, "end_line": 70, "end_column": 15 }, { "span": "except:", "start_line": 265, "start_column": 8, "end_line": 265, "end_column": 15 }, { "span": "except:", "start_line": 278, "start_column": 8, "end_line": 278, "end_column": 15 }, { "span": "except:", "start_line": 483, "start_column": 8, "end_line": 483, "end_column": 15 }, { "span": "except:", "start_line": 518, "start_column": 8, "end_line": 518, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "Unit", "Test_", "import_", "Unit", "Test_", "\\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 ", " _", "bui", "lti", "n", "\\u", "value_", "=_", "builtin_", "._", "value_", "\\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 ", " _", "bui", "lti", "n", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "builtin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "builtin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "imports_", "._", "cls_", "import_", "CLS", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "imports_", "._", "cls", "1_", "import_", "CLS", "_", "as_", "CLS", "1_", "\\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_", "#", "from", " ", "pyj", "ama", "s", " ", "import", " ", "log_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "It", "er", "Property_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "o_", "=_", "C_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tst_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "y_", "in_", "iter_", "(_", "o_", "._", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tst_", "._", "append_", "(_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "tst_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tst_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "y_", "in_", "o_", "._", "x_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tst_", "._", "append_", "(_", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "tst_", ",_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", "\\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_", "._", "fail_", "(_", "\"#", "490", " ", "-", " ", "no", " ", "function", " ", "iter", ".\\u", "\\u", "iter", "\\u\\u", " ", "not", " ", "a", " ", "function", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Import_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "bui", "lti", "n", "\\u", "value_", ",_", "None_", ",_", "\"", "The", " ", "bui", "lti", "n", " ", "is", " ", "load", "ed", " ", "bef", "ore", " ", "import", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "builtin_", "._", "value_", ",_", "builtin_", "._", "get", "\\u", "value_", "(_", ")_", ")_", "\\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_", "._", "fail_", "(_", "\"", "Import", " ", "fail", "ed", " ", "for", " ", "bui", "lti", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "imports_", "import_", "override", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls", "1_", "=_", "CLS", "1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "CLS", "_", "is_", "CLS", "1_", ",_", "\"", "CLS", " ", "is", " ", "CLS", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "cls", "1_", ",_", "CLS", "_", ")_", ",_", "\"", "isin", "stance", "(", "cls", "1", ",", " ", "CLS", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "override", "me_", ",_", "\"", "not", " ", "overrid", "den", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "imports_", "._", "override_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "override", "me_", ",_", "\"", "not", " ", "overrid", "den", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "imports_", "import_", "override", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "override", "me_", "._", "overrid", "den_", "is_", "True_", ",_", "\"", "override", "me", ".", "overrid", "den", " ", "is", " ", "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 ", " _", "self_", "._", "fail_", "(_", "\"", "Except", "ion", " ", "on", " ", "'", "override", "me", ".", "overrid", "den", " ", "is", " ", "Tru", "e", "'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "imports_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "CLS", "_", "is_", "imports_", "._", "loc", "cls_", "._", "CLS", "_", ",_", "\"", "CLS", " ", "is", " ", "import", "s", ".", "loc", "cls", ".", "CLS", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "CLS", "_", "is_", "imports_", "._", "upc", "ls_", "._", "CLS", "_", ",_", "\"", "CLS", " ", "is", " ", "import", "s", ".", "upc", "ls", ".", "CLS", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "...", " ", "import", " ", "*", " ", "tests", ",", " ", "issue", " ", "#", "615", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "imports_", "._", "all", "\\u", "masked_", ",_", "False_", ",_", "\"", "from", " ", "...", " ", "import", " ", "*", " ", "shou", "ld", " ", "respec", "t", " ", "\\u\\u", "all", "\\u\\u", ",", " ", "#", "615", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "imports_", "._", "all", "\\u", "override_", ",_", "True_", ",_", "\"", "Sho", "ul", "d", " ", "override", " ", "globals", ",", " ", "#", "615", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "imports_", "._", "all", "\\u", "import", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "imports_", "._", "all", "\\u", "import", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "imports_", "._", "all", "\\u", "import", "3_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Iter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "i_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "idx_", "=_", "0_", "\\u\\u\\uNEWLINE\\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 ", " _", "return_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "next_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "idx_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "idx_", "==_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Sto", "p", "Iteration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "idx_", "\\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_", "res_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "i_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "._", "append_", "(_", "j_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "res_", ")_", ">_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "fail_", "(_", "\"", "too", " ", "many", " ", "items", " ", "in", " ", "user", "-", "defin", "ed", " ", "iter", "ator", "\"_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "error", " ", "in", " ", "user", "-", "defin", "ed", " ", "iter", "ator", " ", "(", "cau", "ght", " ", "here", " ", "so", " ", "tests", " ", "can", " ", "proceed", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "res_", ",_", "range_", "(_", "1_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Type_", "(_", "self_", ")_", ":_", "\\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_", "._", "assert", "True_", "(_", "type_", "(_", "object_", ")_", "is_", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "Error_", ",_", "why_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Bug", " ", "#", "229", "\"_", "+_", "str_", "(_", "why_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "is_", "type_", "(_", "[_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "is_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "==_", "list_", ")_", "\\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_", "._", "fail_", "(_", "\"", "Bug", " ", "#", "515", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "\"\"_", ")_", "is_", "str_", ",_", "\"", "str", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "True_", ")_", "is_", "bool_", ",_", "\"", "bool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1_", ")_", "is_", "int_", ",_", "\"", "int", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1_", "L_", ")_", "is_", "long_", ",_", "\"", "long", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1.1_", ")_", "is_", "float_", ",_", "\"", "float", " ", "1.1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1.0_", ")_", "is_", "float_", ",_", "\"", "float", " ", "1.0", " ", "issue", " ", "#", "524", "\"_", ")_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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,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, 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, 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 ]
Unused import
viewfinderco/viewfinder/resources/geodata/geolookup.py
[ { "content": "# Copyright 2012 Viewfinder Inc. All Rights Reserved.\n\n\"\"\"Parses the cities1000.txt geonames database and uses google maps\nAPI to lookup locality, administrative_area_level_1 and country using\nthe latitude and longitude listed with each city.\n\nDatafile sourced from: http://download.geonames.org/.\n\nThe contents of each lookup are written to a JSON-encoded file which\nis re-read on each invocation. Only cities in cities1000.txt which are\nnot already accounted-for in the JSON-encoded file are looked up to\navoid duplicative queries.\n\nUsage:\n\n% python resources/geonames/geolookup.py --cityfile=cities1000.txt --lookupdb=lookup.json\n\n\"\"\"\n\n__author__ = '[email protected] (Spencer Kimball)'\n\nimport json\nimport logging\nimport os\nimport sys\nimport time\n\nfrom functools import partial\nfrom operator import attrgetter\nfrom tornado import httpclient, ioloop, options\nfrom viewfinder.backend.base import util\nfrom viewfinder.resources.geodata.geoprocessor import GeoProcessor\n\noptions.define('lookupdb', default='lookup.json', help='JSON output file containing lookup data')\noptions.define('query_rate', default=10, help='allowed queries per second to google maps')\n\n\n\n\n\n\nif __name__ == '__main__':\n sys.exit(main())\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class GeoLookup(object):\n \"\"\"Main class for geolookup. Handles initial parse of JSON data\n file and spawns async HTTP queries to google maps API.\n \"\"\"\n\n", "metadata": "root.GeoLookup", "header": "['module', '___EOS___']", "index": 37 }, { "content": " def __init__(self, io_loop, geoproc):\n self._io_loop = io_loop\n self._geoproc = geoproc\n self._http_client = httpclient.AsyncHTTPClient()\n try:\n with open(options.options.lookupdb, 'r') as rf:\n self._lookup_db = json.load(rf)\n except:\n self._lookup_db = {}", "metadata": "root.GeoLookup.__init__", "header": "['class', 'GeoLookup', '(', 'object', ')', ':', '___EOS___']", "index": 41 }, { "content": " def RefreshDB(self, callback):\n \"\"\"Refreshes the lookup database by iterating over all cities in\n the geoprocessor and querying google maps for address components\n for any that are missing.\n \"\"\"\n def _OnLookup(city, barrier_cb, response):\n if response.code != 200:\n logging.error('error in google maps API query: %s' % response)\n else:\n try:\n json_response = json.loads(response.body)\n components = []\n if len(json_response['results']) > 0:\n for comp in json_response['results'][0]['address_components']:\n for t in comp['types']:\n if t in ('locality', 'administrative_area_level_1', 'country'):\n components.append(comp)\n break\n self._lookup_db[city.id] = components\n except:\n logging.exception('unable to parse google maps API response: %s' % response.body)\n barrier_cb()\n\n with util.Barrier(callback) as b:\n def _ProcessCities(cities):\n start_time = time.time()\n lookup_count = 0\n for index in xrange(len(cities)):\n city = cities[index]\n if city.id not in self._lookup_db:\n lat, lon = float(city.lat), float(city.lon)\n logging.info('looking up %s (%f, %f) via google maps API' % (city.name, lat, lon))\n if lookup_count / (1.0 + time.time() - start_time) > options.options.query_rate:\n logging.info('pausing to slow API query rate')\n return self._io_loop.add_timeout(time.time() + 1.0, partial(_ProcessCities, cities[index:]))\n lookup_count += 1\n self._http_client.fetch('http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false' %\n (lat, lon), callback=partial(_OnLookup, city, b.Callback()), method='GET')\n\n cities = self._geoproc.GetCities()\n _ProcessCities(cities)", "metadata": "root.GeoLookup.RefreshDB", "header": "['class', 'GeoLookup', '(', 'object', ')', ':', '___EOS___']", "index": 51 }, { "content": " def SaveDB(self):\n \"\"\"Saves the database to disk by writing to a temporary file and\n then renames.\n \"\"\"\n tmp_file = options.options.lookupdb + '.bak'\n try:\n with open(tmp_file, 'w') as wf:\n json.dump(self._lookup_db, wf)\n os.rename(tmp_file, options.options.lookupdb)\n except:\n logging.exception('unable to write lookup database')\n os.unlink(tmp_file)", "metadata": "root.GeoLookup.SaveDB", "header": "['class', 'GeoLookup', '(', 'object', ')', ':', '___EOS___']", "index": 93 }, { "content": "def main():\n io_loop = ioloop.IOLoop.instance()\n options.parse_command_line()\n\n geoproc = GeoProcessor()\n geolookup = GeoLookup(io_loop, geoproc)\n\n def _OnRefresh():\n geolookup.SaveDB()\n io_loop.stop()\n\n geolookup.RefreshDB(_OnRefresh)\n\n io_loop.start()\n return 0", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 107 } ]
[ { "span": "from operator import attrgetter", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 31 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "2012", " ", "View", "finde", "r", " ", "Inc", ".", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Pars", "es", " ", "the", " ", "citi", "es", "1000", ".", "txt", " ", "geon", "ames", " ", "databa", "se", " ", "and", " ", "use", "s", " ", "google", " ", "maps", "\\", "10", ";", "API", " ", "to", " ", "look", "up", " ", "locality", ",", " ", "administrati", "ve", "\\u", "area", "\\u", "level", "\\u", "1", " ", "and", " ", "countr", "y", " ", "usi", "ng", "\\", "10", ";", "the", " ", "latitude", " ", "and", " ", "longitude", " ", "liste", "d", " ", "with", " ", "each", " ", "city", ".", "\\", "10", ";", "\\", "10", ";", "Dataf", "ile", " ", "sourced", " ", "from", ":", " ", "http", "://", "download", ".", "geon", "ames", ".", "org", "/.", "\\", "10", ";", "\\", "10", ";", "The", " ", "content", "s", " ", "of", " ", "each", " ", "look", "up", " ", "are", " ", "writt", "en", " ", "to", " ", "a", " ", "JSO", "N", "-", "encode", "d", " ", "file", " ", "whi", "ch", "\\", "10", ";", "is", " ", "re", "-", "read", " ", "on", " ", "each", " ", "invocation", ".", " ", "On", "ly", " ", "citi", "es", " ", "in", " ", "citi", "es", "1000", ".", "txt", " ", "whi", "ch", " ", "are", "\\", "10", ";", "not", " ", "alr", "ead", "y", " ", "account", "ed", "-", "for", " ", "in", " ", "the", " ", "JSO", "N", "-", "encode", "d", " ", "file", " ", "are", " ", "looke", "d", " ", "up", " ", "to", "\\", "10", ";", "avoid", " ", "duplicat", "ive", " ", "querie", "s", ".", "\\", "10", ";", "\\", "10", ";", "Us", "age", ":", "\\", "10", ";", "\\", "10", ";", "%", " ", "python", " ", "resource", "s", "/", "geon", "ames", "/", "geo", "look", "up", ".", "py", " ", "--", "city", "file", "=", "citi", "es", "1000", ".", "txt", " ", "--", "look", "upd", "b", "=", "look", "up", ".", "json", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "'", "spe", "nce", "r", "@", "email", "scrub", "bed", ".", "com", " ", "(", "Spe", "nce", "r", " ", "Ki", "mba", "ll", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\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_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "functools_", "import_", "partial_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "operator_", "import_", "attrgetter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tornado_", "import_", "httpc", "lient_", ",_", "ioloop_", ",_", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "view", "finder_", "._", "backend_", "._", "base_", "import_", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "view", "finder_", "._", "resources_", "._", "geod", "ata_", "._", "geop", "rocess", "or_", "import_", "Geo", "Processor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "options_", "._", "define_", "(_", "'", "look", "upd", "b", "'_", ",_", "default_", "=_", "'", "look", "up", ".", "json", "'_", ",_", "help_", "=_", "'", "JSO", "N", " ", "output", " ", "file", " ", "contain", "ing", " ", "look", "up", " ", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "._", "define_", "(_", "'", "query", "\\u", "rate", "'_", ",_", "default_", "=_", "10_", ",_", "help_", "=_", "'", "allow", "ed", " ", "querie", "s", " ", "per", " ", "second", " ", "to", " ", "google", " ", "maps", "'_", ")_", "\\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 ", " _", "sys_", "._", "exit_", "(_", "main_", "(_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Geo", "Lookup_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Main", " ", "class", " ", "for", " ", "geo", "look", "up", ".", " ", "Handle", "s", " ", "initial", " ", "parse", " ", "of", " ", "JSO", "N", " ", "data", "\\", "10", ";", " ", " ", "file", " ", "and", " ", "spawn", "s", " ", "async", " ", "HTTP", " ", "querie", "s", " ", "to", " ", "google", " ", "maps", " ", "API", ".", "\\", "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_", "[SEP]_", "class_", "Geo", "Lookup_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "io", "\\u", "loop_", ",_", "geop", "roc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "io", "\\u", "loop_", "=_", "io", "\\u", "loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "geop", "roc_", "=_", "geop", "roc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "http", "\\u", "client_", "=_", "httpc", "lient_", "._", "Async", "HTTP", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "options_", "._", "options_", "._", "look", "upd", "b_", ",_", "'", "r", "'_", ")_", "as_", "rf_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "look", "up", "\\u", "db_", "=_", "json_", "._", "load_", "(_", "rf_", ")_", "\\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 ", " _", "self_", "._", "\\u", "look", "up", "\\u", "db_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geo", "Lookup_", "(_", "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_", "Refr", "esh", "DB_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Refr", "esh", "es", " ", "the", " ", "look", "up", " ", "databa", "se", " ", "by", " ", "iterati", "ng", " ", "over", " ", "all", " ", "citi", "es", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "geop", "rocess", "or", " ", "and", " ", "query", "ing", " ", "google", " ", "maps", " ", "for", " ", "address", " ", "component", "s", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "any", " ", "tha", "t", " ", "are", " ", "missi", "ng", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "On", "Lookup_", "(_", "city_", ",_", "barrier", "\\u", "cb_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "response_", "._", "code_", "!=_", "200_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "'", "error", " ", "in", " ", "google", " ", "maps", " ", "API", " ", "query", ":", " ", "%", "s", "'_", "%_", "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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json", "\\u", "response_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "components_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "json", "\\u", "response_", "[_", "'", "results", "'_", "]_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "comp_", "in_", "json", "\\u", "response_", "[_", "'", "results", "'_", "]_", "[_", "0_", "]_", "[_", "'", "address", "\\u", "component", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "t_", "in_", "comp_", "[_", "'", "types", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "t_", "in_", "(_", "'", "locality", "'_", ",_", "'", "administrati", "ve", "\\u", "area", "\\u", "level", "\\u", "1", "'_", ",_", "'", "countr", "y", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "components_", "._", "append_", "(_", "comp_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "look", "up", "\\u", "db_", "[_", "city_", "._", "id_", "]_", "=_", "components_", "\\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 ", " _", "logging_", "._", "exception_", "(_", "'", "una", "ble", " ", "to", " ", "parse", " ", "google", " ", "maps", " ", "API", " ", "response", ":", " ", "%", "s", "'_", "%_", "response_", "._", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "barrier", "\\u", "cb_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "util_", "._", "Barri", "er_", "(_", "callback_", ")_", "as_", "b_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "Process", "Cit", "ies_", "(_", "cities_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "look", "up", "\\u", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "index_", "in_", "xrange_", "(_", "len_", "(_", "cities_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "city_", "=_", "cities_", "[_", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "city_", "._", "id_", "not_", "in_", "self_", "._", "\\u", "look", "up", "\\u", "db_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lat_", ",_", "lon_", "=_", "float_", "(_", "city_", "._", "lat_", ")_", ",_", "float_", "(_", "city_", "._", "lon_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "'", "look", "ing", " ", "up", " ", "%", "s", " ", "(%", "f", ",", " ", "%", "f", ")", " ", "via", " ", "google", " ", "maps", " ", "API", "'_", "%_", "(_", "city_", "._", "name_", ",_", "lat_", ",_", "lon_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "look", "up", "\\u", "count_", "/_", "(_", "1.0_", "+_", "time_", "._", "time_", "(_", ")_", "-_", "start", "\\u", "time_", ")_", ">_", "options_", "._", "options_", "._", "query", "\\u", "rate_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "'", "paus", "ing", " ", "to", " ", "slow", " ", "API", " ", "query", " ", "rate", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "io", "\\u", "loop_", "._", "add", "\\u", "timeout_", "(_", "time_", "._", "time_", "(_", ")_", "+_", "1.0_", ",_", "partial_", "(_", "\\u", "Process", "Cit", "ies_", ",_", "cities_", "[_", "index_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "look", "up", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "http", "\\u", "client_", "._", "fetch_", "(_", "'", "http", "://", "maps", ".", "google", "apis", ".", "com", "/", "maps", "/", "api", "/", "geocode", "/", "json", "?", "lat", "ln", "g", "=", "%", "f", ",%", "f", "&", "sensor", "=", "fal", "se", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "lat_", ",_", "lon_", ")_", ",_", "callback_", "=_", "partial_", "(_", "\\u", "On", "Lookup_", ",_", "city_", ",_", "b_", "._", "Callback_", "(_", ")_", ")_", ",_", "method_", "=_", "'", "GET", "'_", ")_", "\\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_", "cities_", "=_", "self_", "._", "\\u", "geop", "roc_", "._", "Get", "Cit", "ies_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "Process", "Cit", "ies_", "(_", "cities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geo", "Lookup_", "(_", "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_", "Save", "DB_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Save", "s", " ", "the", " ", "databa", "se", " ", "to", " ", "disk", " ", "by", " ", "writ", "ing", " ", "to", " ", "a", " ", "temporar", "y", " ", "file", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "then", " ", "rename", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "\\u", "file_", "=_", "options_", "._", "options_", "._", "look", "upd", "b_", "+_", "'.", "bak", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "tmp", "\\u", "file_", ",_", "'", "w", "'_", ")_", "as_", "wf_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json_", "._", "dump_", "(_", "self_", "._", "\\u", "look", "up", "\\u", "db_", ",_", "wf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "rename_", "(_", "tmp", "\\u", "file_", ",_", "options_", "._", "options_", "._", "look", "upd", "b_", ")_", "\\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 ", " _", "logging_", "._", "exception_", "(_", "'", "una", "ble", " ", "to", " ", "write", " ", "look", "up", " ", "databa", "se", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "unlink_", "(_", "tmp", "\\u", "file_", ")_", "\\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_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "io", "\\u", "loop_", "=_", "ioloop_", "._", "IO", "Loop_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "._", "parse", "\\u", "command", "\\u", "line_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "geop", "roc_", "=_", "Geo", "Processor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "geo", "lookup_", "=_", "Geo", "Lookup_", "(_", "io", "\\u", "loop_", ",_", "geop", "roc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "On", "Refresh_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "geo", "lookup_", "._", "Save", "DB_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "io", "\\u", "loop_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "geo", "lookup_", "._", "Refr", "esh", "DB_", "(_", "\\u", "On", "Refresh_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "io", "\\u", "loop_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "0_", "\\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,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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, 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
cloudera/hue/desktop/core/ext-py/pycrypto-2.6.1/lib/Crypto/SelfTest/Cipher/test_DES3.py
[ { "content": "# -*- coding: utf-8 -*-\n#\n# SelfTest/Cipher/DES3.py: Self-test for the Triple-DES cipher\n#\n# Written in 2008 by Dwayne C. Litzenberger <[email protected]>\n#\n# ===================================================================\n# The contents of this file are dedicated to the public domain. To\n# the extent that dedication to the public domain is not available,\n# everyone is granted a worldwide, perpetual, royalty-free,\n# non-exclusive license to exercise all rights associated with the\n# contents of this file for any purpose whatsoever.\n# No rights are reserved.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n# ===================================================================\n\n\"\"\"Self-test suite for Crypto.Cipher.DES3\"\"\"\n\n__revision__ = \"$Id$\"\n\nfrom common import dict # For compatibility with Python 2.1 and 2.2\nfrom Crypto.Util.py3compat import *\nfrom binascii import hexlify\n\n# This is a list of (plaintext, ciphertext, key, description) tuples.\nSP800_20_A1_KEY = '01' * 24\nSP800_20_A2_PT = '00' * 8\ntest_data = [\n # Test vector from Appendix B of NIST SP 800-67\n # \"Recommendation for the Triple Data Encryption Algorithm (TDEA) Block\n # Cipher\"\n # http://csrc.nist.gov/publications/nistpubs/800-67/SP800-67.pdf\n ('54686520717566636b2062726f776e20666f78206a756d70',\n 'a826fd8ce53b855fcce21c8112256fe668d5c05dd9b6b900',\n '0123456789abcdef23456789abcdef01456789abcdef0123',\n 'NIST SP800-67 B.1'),\n\n # Test vectors \"The Multi-block Message Test (MMT) for DES and TDES\"\n # http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf\n ('326a494cd33fe756', 'b22b8d66de970692',\n '627f460e08104a1043cd265d5840eaf1313edf97df2a8a8c',\n 'DESMMT #1', dict(mode='CBC', iv='8e29f75ea77e5475')),\n\n ('84401f78fe6c10876d8ea23094ea5309', '7b1f7c7e3b1c948ebd04a75ffba7d2f5',\n '37ae5ebf46dff2dc0754b94f31cbb3855e7fd36dc870bfae',\n 'DESMMT #2', dict(mode='CBC', iv='3d1de3cc132e3b65')),\n\n # Test vectors from Appendix A of NIST SP 800-20\n # \"Modes of Operation Validation System for the Triple Data Encryption\n # Algorithm (TMOVS): Requirements and Procedures\"\n # http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf\n\n # Table A.1 - Variable Plaintext Known Answer Test\n ('8000000000000000', '95f8a5e5dd31d900', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #0'),\n ('4000000000000000', 'dd7f121ca5015619', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #1'),\n ('2000000000000000', '2e8653104f3834ea', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #2'),\n ('1000000000000000', '4bd388ff6cd81d4f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #3'),\n ('0800000000000000', '20b9e767b2fb1456', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #4'),\n ('0400000000000000', '55579380d77138ef', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #5'),\n ('0200000000000000', '6cc5defaaf04512f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #6'),\n ('0100000000000000', '0d9f279ba5d87260', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #7'),\n ('0080000000000000', 'd9031b0271bd5a0a', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #8'),\n ('0040000000000000', '424250b37c3dd951', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #9'),\n ('0020000000000000', 'b8061b7ecd9a21e5', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #10'),\n ('0010000000000000', 'f15d0f286b65bd28', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #11'),\n ('0008000000000000', 'add0cc8d6e5deba1', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #12'),\n ('0004000000000000', 'e6d5f82752ad63d1', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #13'),\n ('0002000000000000', 'ecbfe3bd3f591a5e', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #14'),\n ('0001000000000000', 'f356834379d165cd', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #15'),\n ('0000800000000000', '2b9f982f20037fa9', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #16'),\n ('0000400000000000', '889de068a16f0be6', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #17'),\n ('0000200000000000', 'e19e275d846a1298', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #18'),\n ('0000100000000000', '329a8ed523d71aec', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #19'),\n ('0000080000000000', 'e7fce22557d23c97', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #20'),\n ('0000040000000000', '12a9f5817ff2d65d', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #21'),\n ('0000020000000000', 'a484c3ad38dc9c19', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #22'),\n ('0000010000000000', 'fbe00a8a1ef8ad72', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #23'),\n ('0000008000000000', '750d079407521363', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #24'),\n ('0000004000000000', '64feed9c724c2faf', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #25'),\n ('0000002000000000', 'f02b263b328e2b60', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #26'),\n ('0000001000000000', '9d64555a9a10b852', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #27'),\n ('0000000800000000', 'd106ff0bed5255d7', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #28'),\n ('0000000400000000', 'e1652c6b138c64a5', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #29'),\n ('0000000200000000', 'e428581186ec8f46', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #30'),\n ('0000000100000000', 'aeb5f5ede22d1a36', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #31'),\n ('0000000080000000', 'e943d7568aec0c5c', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #32'),\n ('0000000040000000', 'df98c8276f54b04b', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #33'),\n ('0000000020000000', 'b160e4680f6c696f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #34'),\n ('0000000010000000', 'fa0752b07d9c4ab8', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #35'),\n ('0000000008000000', 'ca3a2b036dbc8502', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #36'),\n ('0000000004000000', '5e0905517bb59bcf', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #37'),\n ('0000000002000000', '814eeb3b91d90726', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #38'),\n ('0000000001000000', '4d49db1532919c9f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #39'),\n ('0000000000800000', '25eb5fc3f8cf0621', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #40'),\n ('0000000000400000', 'ab6a20c0620d1c6f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #41'),\n ('0000000000200000', '79e90dbc98f92cca', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #42'),\n ('0000000000100000', '866ecedd8072bb0e', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #43'),\n ('0000000000080000', '8b54536f2f3e64a8', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #44'),\n ('0000000000040000', 'ea51d3975595b86b', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #45'),\n ('0000000000020000', 'caffc6ac4542de31', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #46'),\n ('0000000000010000', '8dd45a2ddf90796c', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #47'),\n ('0000000000008000', '1029d55e880ec2d0', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #48'),\n ('0000000000004000', '5d86cb23639dbea9', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #49'),\n ('0000000000002000', '1d1ca853ae7c0c5f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #50'),\n ('0000000000001000', 'ce332329248f3228', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #51'),\n ('0000000000000800', '8405d1abe24fb942', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #52'),\n ('0000000000000400', 'e643d78090ca4207', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #53'),\n ('0000000000000200', '48221b9937748a23', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #54'),\n ('0000000000000100', 'dd7c0bbd61fafd54', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #55'),\n ('0000000000000080', '2fbc291a570db5c4', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #56'),\n ('0000000000000040', 'e07c30d7e4e26e12', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #57'),\n ('0000000000000020', '0953e2258e8e90a1', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #58'),\n ('0000000000000010', '5b711bc4ceebf2ee', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #59'),\n ('0000000000000008', 'cc083f1e6d9e85f6', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #60'),\n ('0000000000000004', 'd2fd8867d50d2dfe', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #61'),\n ('0000000000000002', '06e7ea22ce92708f', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #62'),\n ('0000000000000001', '166b40b44aba4bd6', SP800_20_A1_KEY,\n 'NIST SP800-20 A.1 #63'),\n\n # Table A.2 - Variable Key Known Answer Test\n (SP800_20_A2_PT, '95a8d72813daa94d', '8001010101010101'*3,\n 'NIST SP800-20 A.2 #0'),\n (SP800_20_A2_PT, '0eec1487dd8c26d5', '4001010101010101'*3,\n 'NIST SP800-20 A.2 #1'),\n (SP800_20_A2_PT, '7ad16ffb79c45926', '2001010101010101'*3,\n 'NIST SP800-20 A.2 #2'),\n (SP800_20_A2_PT, 'd3746294ca6a6cf3', '1001010101010101'*3,\n 'NIST SP800-20 A.2 #3'),\n (SP800_20_A2_PT, '809f5f873c1fd761', '0801010101010101'*3,\n 'NIST SP800-20 A.2 #4'),\n (SP800_20_A2_PT, 'c02faffec989d1fc', '0401010101010101'*3,\n 'NIST SP800-20 A.2 #5'),\n (SP800_20_A2_PT, '4615aa1d33e72f10', '0201010101010101'*3,\n 'NIST SP800-20 A.2 #6'),\n (SP800_20_A2_PT, '2055123350c00858', '0180010101010101'*3,\n 'NIST SP800-20 A.2 #7'),\n (SP800_20_A2_PT, 'df3b99d6577397c8', '0140010101010101'*3,\n 'NIST SP800-20 A.2 #8'),\n (SP800_20_A2_PT, '31fe17369b5288c9', '0120010101010101'*3,\n 'NIST SP800-20 A.2 #9'),\n (SP800_20_A2_PT, 'dfdd3cc64dae1642', '0110010101010101'*3,\n 'NIST SP800-20 A.2 #10'),\n (SP800_20_A2_PT, '178c83ce2b399d94', '0108010101010101'*3,\n 'NIST SP800-20 A.2 #11'),\n (SP800_20_A2_PT, '50f636324a9b7f80', '0104010101010101'*3,\n 'NIST SP800-20 A.2 #12'),\n (SP800_20_A2_PT, 'a8468ee3bc18f06d', '0102010101010101'*3,\n 'NIST SP800-20 A.2 #13'),\n (SP800_20_A2_PT, 'a2dc9e92fd3cde92', '0101800101010101'*3,\n 'NIST SP800-20 A.2 #14'),\n (SP800_20_A2_PT, 'cac09f797d031287', '0101400101010101'*3,\n 'NIST SP800-20 A.2 #15'),\n (SP800_20_A2_PT, '90ba680b22aeb525', '0101200101010101'*3,\n 'NIST SP800-20 A.2 #16'),\n (SP800_20_A2_PT, 'ce7a24f350e280b6', '0101100101010101'*3,\n 'NIST SP800-20 A.2 #17'),\n (SP800_20_A2_PT, '882bff0aa01a0b87', '0101080101010101'*3,\n 'NIST SP800-20 A.2 #18'),\n (SP800_20_A2_PT, '25610288924511c2', '0101040101010101'*3,\n 'NIST SP800-20 A.2 #19'),\n (SP800_20_A2_PT, 'c71516c29c75d170', '0101020101010101'*3,\n 'NIST SP800-20 A.2 #20'),\n (SP800_20_A2_PT, '5199c29a52c9f059', '0101018001010101'*3,\n 'NIST SP800-20 A.2 #21'),\n (SP800_20_A2_PT, 'c22f0a294a71f29f', '0101014001010101'*3,\n 'NIST SP800-20 A.2 #22'),\n (SP800_20_A2_PT, 'ee371483714c02ea', '0101012001010101'*3,\n 'NIST SP800-20 A.2 #23'),\n (SP800_20_A2_PT, 'a81fbd448f9e522f', '0101011001010101'*3,\n 'NIST SP800-20 A.2 #24'),\n (SP800_20_A2_PT, '4f644c92e192dfed', '0101010801010101'*3,\n 'NIST SP800-20 A.2 #25'),\n (SP800_20_A2_PT, '1afa9a66a6df92ae', '0101010401010101'*3,\n 'NIST SP800-20 A.2 #26'),\n (SP800_20_A2_PT, 'b3c1cc715cb879d8', '0101010201010101'*3,\n 'NIST SP800-20 A.2 #27'),\n (SP800_20_A2_PT, '19d032e64ab0bd8b', '0101010180010101'*3,\n 'NIST SP800-20 A.2 #28'),\n (SP800_20_A2_PT, '3cfaa7a7dc8720dc', '0101010140010101'*3,\n 'NIST SP800-20 A.2 #29'),\n (SP800_20_A2_PT, 'b7265f7f447ac6f3', '0101010120010101'*3,\n 'NIST SP800-20 A.2 #30'),\n (SP800_20_A2_PT, '9db73b3c0d163f54', '0101010110010101'*3,\n 'NIST SP800-20 A.2 #31'),\n (SP800_20_A2_PT, '8181b65babf4a975', '0101010108010101'*3,\n 'NIST SP800-20 A.2 #32'),\n (SP800_20_A2_PT, '93c9b64042eaa240', '0101010104010101'*3,\n 'NIST SP800-20 A.2 #33'),\n (SP800_20_A2_PT, '5570530829705592', '0101010102010101'*3,\n 'NIST SP800-20 A.2 #34'),\n (SP800_20_A2_PT, '8638809e878787a0', '0101010101800101'*3,\n 'NIST SP800-20 A.2 #35'),\n (SP800_20_A2_PT, '41b9a79af79ac208', '0101010101400101'*3,\n 'NIST SP800-20 A.2 #36'),\n (SP800_20_A2_PT, '7a9be42f2009a892', '0101010101200101'*3,\n 'NIST SP800-20 A.2 #37'),\n (SP800_20_A2_PT, '29038d56ba6d2745', '0101010101100101'*3,\n 'NIST SP800-20 A.2 #38'),\n (SP800_20_A2_PT, '5495c6abf1e5df51', '0101010101080101'*3,\n 'NIST SP800-20 A.2 #39'),\n (SP800_20_A2_PT, 'ae13dbd561488933', '0101010101040101'*3,\n 'NIST SP800-20 A.2 #40'),\n (SP800_20_A2_PT, '024d1ffa8904e389', '0101010101020101'*3,\n 'NIST SP800-20 A.2 #41'),\n (SP800_20_A2_PT, 'd1399712f99bf02e', '0101010101018001'*3,\n 'NIST SP800-20 A.2 #42'),\n (SP800_20_A2_PT, '14c1d7c1cffec79e', '0101010101014001'*3,\n 'NIST SP800-20 A.2 #43'),\n (SP800_20_A2_PT, '1de5279dae3bed6f', '0101010101012001'*3,\n 'NIST SP800-20 A.2 #44'),\n (SP800_20_A2_PT, 'e941a33f85501303', '0101010101011001'*3,\n 'NIST SP800-20 A.2 #45'),\n (SP800_20_A2_PT, 'da99dbbc9a03f379', '0101010101010801'*3,\n 'NIST SP800-20 A.2 #46'),\n (SP800_20_A2_PT, 'b7fc92f91d8e92e9', '0101010101010401'*3,\n 'NIST SP800-20 A.2 #47'),\n (SP800_20_A2_PT, 'ae8e5caa3ca04e85', '0101010101010201'*3,\n 'NIST SP800-20 A.2 #48'),\n (SP800_20_A2_PT, '9cc62df43b6eed74', '0101010101010180'*3,\n 'NIST SP800-20 A.2 #49'),\n (SP800_20_A2_PT, 'd863dbb5c59a91a0', '0101010101010140'*3,\n 'NIST SP800-20 A.2 #50'),\n (SP800_20_A2_PT, 'a1ab2190545b91d7', '0101010101010120'*3,\n 'NIST SP800-20 A.2 #51'),\n (SP800_20_A2_PT, '0875041e64c570f7', '0101010101010110'*3,\n 'NIST SP800-20 A.2 #52'),\n (SP800_20_A2_PT, '5a594528bebef1cc', '0101010101010108'*3,\n 'NIST SP800-20 A.2 #53'),\n (SP800_20_A2_PT, 'fcdb3291de21f0c0', '0101010101010104'*3,\n 'NIST SP800-20 A.2 #54'),\n (SP800_20_A2_PT, '869efd7f9f265a09', '0101010101010102'*3,\n 'NIST SP800-20 A.2 #55'),\n\n # \"Two-key 3DES\". Test vector generated using PyCrypto 2.0.1.\n # This test is designed to test the DES3 API, not the correctness of the\n # output.\n ('21e81b7ade88a259', '5c577d4d9b20c0f8',\n '9b397ebf81b1181e282f4bb8adbadc6b', 'Two-key 3DES'),\n\n # The following test vectors have been generated with gpg v1.4.0.\n # The command line used was:\n # gpg -c -z 0 --cipher-algo 3DES --passphrase secret_passphrase \\\n # --disable-mdc --s2k-mode 0 --output ct pt\n # For an explanation, see test_AES.py .\n ( 'ac1762037074324fb53ba3596f73656d69746556616c6c6579', # Plaintext, 'YosemiteValley'\n '9979238528357b90e2e0be549cb0b2d5999b9a4a447e5c5c7d', # Ciphertext\n '7ade65b460f5ea9be35f9e14aa883a2048e3824aa616c0b2', # Key (hash of 'BearsAhead')\n 'GPG Test Vector #1',\n dict(mode='OPENPGP', iv='cd47e2afb8b7e4b0', encrypted_iv='6a7eef0b58050e8b904a' ) ),\n]\n\n\nif __name__ == '__main__':\n import unittest\n suite = lambda: unittest.TestSuite(get_tests())\n unittest.main(defaultTest='suite')\n\n# vim:set ts=4 sw=4 sts=4 expandtab:\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_tests(config={}):\n from Crypto.Cipher import DES3\n from common import make_block_tests\n return make_block_tests(DES3, \"DES3\", test_data)", "metadata": "root.get_tests", "header": "['module', '___EOS___']", "index": 322 } ]
[ { "span": "from binascii import hexlify", "start_line": 30, "start_column": 0, "end_line": 30, "end_column": 28 } ]
[]
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_", "#", " ", " ", "Self", "Test", "/", "Ci", "pher", "/", "DES", "3", ".", "py", ":", " ", "Self", "-", "test", " ", "for", " ", "the", " ", "Triple", "-", "DES", " ", "cipher_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Writ", "ten", " ", "in", " ", "2008", " ", "by", " ", "Dw", "ay", "ne", " ", "C", ".", " ", "Lit", "zen", "ber", "ger", " ", "<", "dli", "tz", "@", "dli", "tz", ".", "net", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "==============", "==============", "==============", "==============", "=========", "==_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "content", "s", " ", "of", " ", "this", " ", "file", " ", "are", " ", "dedicated", " ", "to", " ", "the", " ", "public", " ", "domain", ".", " ", " ", "To_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "extent", " ", "tha", "t", " ", "ded", "ication", " ", "to", " ", "the", " ", "public", " ", "domain", " ", "is", " ", "not", " ", "avail", "able", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "everyone", " ", "is", " ", "grant", "ed", " ", "a", " ", "world", "wide", ",", " ", "perp", "etu", "al", ",", " ", "roy", "alty", "-", "free", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "non", "-", "exclu", "sive", " ", "license", " ", "to", " ", "exercise", " ", "all", " ", "rights", " ", "associate", "d", " ", "with", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "content", "s", " ", "of", " ", "this", " ", "file", " ", "for", " ", "any", " ", "purpose", " ", "whats", "oe", "ver", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", " ", "rights", " ", "are", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "\"", "AS", " ", "IS", "\",", " ", "WITH", "OUT", " ", "WAR", "RAN", "TY", " ", "OF", " ", "ANY", " ", "KIND", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", ",", " ", "INC", "LU", "DING", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", " ", "THE", " ", "WAR", "RAN", "TIES", " ", "OF_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "MER", "CHAN", "TAB", "ILI", "TY", ",", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "AND_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NON", "INF", "RING", "EME", "NT", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", " ", "AUTHOR", "S", " ", "OR", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "CLA", "IM", ",", " ", "DA", "MAGE", "S", " ", "OR", " ", "OTHER", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN", " ", "AN_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ACTI", "ON", " ", "OF", " ", "CONTR", "ACT", ",", " ", "TOR", "T", " ", "OR", " ", "OTHER", "WI", "SE", ",", " ", "ARI", "SIN", "G", " ", "FROM", ",", " ", "OUT", " ", "OF", " ", "OR", " ", "IN_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "SOFT", "WARE", " ", "OR", " ", "THE", " ", "USE", " ", "OR", " ", "OTHER", " ", "DEA", "LING", "S", " ", "IN", " ", "THE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SOFT", "WARE", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "==============", "==============", "==============", "==============", "=========", "==_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Self", "-", "test", " ", "suit", "e", " ", "for", " ", "Crypto", ".", "Ci", "pher", ".", "DES", "3", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "revision\\u\\u_", "=_", "\"$", "Id", "$\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "common_", "import_", "dict_", "#", " ", "For", " ", "compatibility", " ", "with", " ", "Pyth", "on", " ", "2.1", " ", "and", " ", "2.2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Crypto_", "._", "Util_", "._", "py3", "compat_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "binascii_", "import_", "hexlify_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "list", " ", "of", " ", "(", "plain", "text", ",", " ", "cipher", "text", ",", " ", "key", ",", " ", "description", ")", " ", "tuple", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", "=_", "'", "01", "'_", "*_", "24_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", "=_", "'", "00", "'_", "*_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "data_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "vector", " ", "from", " ", "Append", "ix", " ", "B", " ", "of", " ", "NIS", "T", " ", "SP", " ", "800", "-", "67_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Recommend", "ation", " ", "for", " ", "the", " ", "Triple", " ", "Data", " ", "Encrypt", "ion", " ", "Algorit", "hm", " ", "(", "TD", "EA", ")", " ", "Block_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ci", "pher", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "csr", "c", ".", "nist", ".", "gov", "/", "publications", "/", "nist", "pubs", "/", "800", "-", "6", "7", "/", "SP", "800", "-", "67.", "pdf_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "546", "865", "207", "175", "666", "3", "6b", "206", "272", "6f", "776", "e2", "066", "6f", "782", "0", "6a", "756", "d7", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "a8", "2", "6f", "d8", "ce", "5", "3b", "855", "fcc", "e2", "1c", "811", "225", "6f", "e", "668", "d5", "c0", "5d", "d", "9", "b6", "b9", "00", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "0123456", "789", "abcde", "f2", "3456", "789", "abcde", "f0", "145", "678", "9", "abcde", "f0", "123", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "6", "7", " ", "B", ".1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "vector", "s", " ", "\"", "The", " ", "Multi", "-", "block", " ", "Messag", "e", " ", "Test", " ", "(", "MM", "T", ")", " ", "for", " ", "DES", " ", "and", " ", "TD", "ES", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "csr", "c", ".", "nist", ".", "gov", "/", "group", "s", "/", "STM", "/", "cav", "p", "/", "document", "s", "/", "des", "/", "DES", "MM", "T", ".", "pdf_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "326", "a4", "9", "4c", "d3", "3f", "e7", "56", "'_", ",_", "'", "b2", "2b", "8d", "6", "6d", "e9", "706", "9", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "627", "f4", "60", "e0", "810", "4a", "104", "3c", "d2", "6", "5d", "584", "0e", "af", "131", "3e", "df", "9", "7d", "f2", "a8", "a8", "c", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "DES", "MM", "T", " ", "#", "1", "'_", ",_", "dict_", "(_", "mode_", "=_", "'", "CBC", "'_", ",_", "iv_", "=_", "'", "8e", "2", "9", "f7", "5e", "a7", "7e", "547", "5", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "844", "01", "f7", "8f", "e", "6c", "1087", "6d", "8e", "a2", "309", "4e", "a5", "309", "'_", ",_", "'", "7b", "1f", "7c", "7e", "3b", "1c", "948", "eb", "d0", "4a", "7", "5f", "fba", "7d", "2f", "5", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "3", "7a", "e5", "eb", "f4", "6d", "ff", "2d", "c0", "754", "b9", "4f", "3", "1c", "bb", "385", "5e", "7f", "d3", "6d", "c8", "7", "0b", "fa", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "DES", "MM", "T", " ", "#", "2", "'_", ",_", "dict_", "(_", "mode_", "=_", "'", "CBC", "'_", ",_", "iv_", "=_", "'", "3d", "1d", "e3", "cc", "132", "e3", "b6", "5", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "vector", "s", " ", "from", " ", "Append", "ix", " ", "A", " ", "of", " ", "NIS", "T", " ", "SP", " ", "800", "-", "20_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Mode", "s", " ", "of", " ", "Opera", "tion", " ", "Validat", "ion", " ", "System", " ", "for", " ", "the", " ", "Triple", " ", "Data", " ", "Encrypt", "ion_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Algorit", "hm", " ", "(", "TM", "OVS", "):", " ", "Requirements", " ", "and", " ", "Proce", "dur", "es", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "csr", "c", ".", "nist", ".", "gov", "/", "publications", "/", "nist", "pubs", "/", "800", "-", "20", "/", "800", "-", "20.", "pdf_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Table", " ", "A", ".1", " ", "-", " ", "Varia", "ble", " ", "Plai", "ntext", " ", "Kno", "wn", " ", "Answer", " ", "Test_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "8000000", "000000000", "'_", ",_", "'", "9", "5f", "8a", "5e", "5d", "d3", "1d", "900", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "0", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "4000000", "000000000", "'_", ",_", "'", "dd", "7f", "121", "ca", "501", "561", "9", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "20000000", "00000000", "'_", ",_", "'", "2e", "865", "310", "4f", "383", "4e", "a", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "100000000000", "0000", "'_", ",_", "'", "4b", "d3", "88", "ff", "6c", "d8", "1d", "4f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0800", "00000000000", "0", "'_", ",_", "'", "20", "b9", "e7", "6", "7b", "2f", "b1", "456", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0400", "00000000000", "0", "'_", ",_", "'", "555", "793", "80", "d7", "713", "8e", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "02000", "00000000000", "'_", ",_", "'", "6c", "c5", "def", "aa", "f0", "451", "2f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "010000", "000000000", "0", "'_", ",_", "'", "0d", "9", "f2", "7", "9", "ba", "5d", "872", "60", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0080", "00000000000", "0", "'_", ",_", "'", "d", "903", "1b", "027", "1b", "d5", "a0", "a", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0040", "00000000000", "0", "'_", ",_", "'", "424", "250", "b3", "7c", "3d", "d", "951", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0020", "00000000000", "0", "'_", ",_", "'", "b8", "061", "b7", "ecd", "9", "a2", "1e", "5", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "10", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00100", "00000000000", "'_", ",_", "'", "f1", "5d", "0f", "286", "b6", "5b", "d2", "8", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "11", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0008", "00000000000", "0", "'_", ",_", "'", "add", "0c", "c8", "d6", "e5", "deb", "a1", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "1", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0004", "00000000000", "0", "'_", ",_", "'", "e", "6d", "5f", "827", "5", "2a", "d6", "3d", "1", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "13", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0002", "00000000000", "0", "'_", ",_", "'", "ec", "bf", "e3", "bd", "3f", "591", "a5", "e", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "14", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000100", "000000000", "0", "'_", ",_", "'", "f3", "568", "343", "7", "9", "d1", "6", "5c", "d", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "15", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000", "8000000", "00000", "'_", ",_", "'", "2b", "9", "f9", "8", "2f", "2003", "7f", "a9", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "16", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000", "4000000", "00000", "'_", ",_", "'", "889", "de", "068", "a1", "6f", "0b", "e", "6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "1", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00002", "00000000000", "'_", ",_", "'", "e1", "9e", "275", "d8", "4", "6a", "129", "8", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "1", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000010", "000000000", "0", "'_", ",_", "'", "329", "a8", "ed", "523", "d7", "1a", "ec", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "1", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000", "8000000", "0000", "'_", ",_", "'", "e7", "fc", "e2", "255", "7d", "23", "c9", "7", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "20", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000", "4000000", "0000", "'_", ",_", "'", "1", "2a", "9", "f5", "817", "ff", "2d", "6", "5d", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "21", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000", "20000000", "000", "'_", ",_", "'", "a4", "84", "c3", "ad", "3", "8d", "c9", "c1", "9", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000001", "000000000", "0", "'_", ",_", "'", "fb", "e0", "0a", "8a", "1e", "f8", "ad", "7", "2", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "23", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000", "8000000", "000", "'_", ",_", "'", "750", "d0", "794", "075", "213", "6", "3", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "24", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000004", "000000000", "'_", ",_", "'", "64", "feed", "9c", "724", "c2", "fa", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "25", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000002", "000000000", "'_", ",_", "'", "f0", "2b", "263", "b3", "2", "8e", "2b", "60", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000001", "000000000", "'_", ",_", "'", "9", "d6", "455", "5a", "9", "a1", "0b", "852", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000", "8000000", "00", "'_", ",_", "'", "d1", "0", "6f", "f0", "bed", "525", "5d", "7", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000", "4000000", "00", "'_", ",_", "'", "e1", "652", "c6", "b1", "3", "8c", "64", "a5", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "2", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000", "20000000", "0", "'_", ",_", "'", "e4", "285", "811", "86", "ec", "8f", "4", "6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "30", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000001", "00000000", "'_", ",_", "'", "ae", "b5", "f5", "ede", "2", "2d", "1a", "3", "6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000", "8000000", "0", "'_", ",_", "'", "e9", "4", "3d", "756", "8a", "ec", "0c", "5c", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "32", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000", "4000000", "0", "'_", ",_", "'", "df", "98", "c8", "276", "f5", "4b", "04", "b", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000", "20000000", "'_", ",_", "'", "b1", "60", "e4", "680", "f6", "c6", "96", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000", "10000000", "'_", ",_", "'", "fa", "075", "2b", "0", "7d", "9c", "4a", "b8", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "8000000", "'_", ",_", "'", "ca", "3a", "2b", "036", "dbc", "850", "2", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "4000000", "'_", ",_", "'", "5e", "090", "551", "7b", "b5", "9", "bcf", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "200000", "0", "'_", ",_", "'", "814", "ee", "b3", "b9", "1d", "907", "2", "6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "1000000", "'_", ",_", "'", "4d", "4", "9", "db", "153", "291", "9c", "9", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "3", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "0800", "000", "'_", ",_", "'", "25", "eb", "5f", "c3", "f8", "cf", "062", "1", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "40", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "0400", "000", "'_", ",_", "'", "ab", "6a", "20", "c0", "620", "d1", "c6", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "02000", "00", "'_", ",_", "'", "7", "9e", "90", "dbc", "98", "f9", "2c", "ca", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "000000000", "010000", "0", "'_", ",_", "'", "866", "ece", "dd", "807", "2b", "b0", "e", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "80000", "'_", ",_", "'", "8b", "545", "3", "6f", "2f", "3e", "64", "a8", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "40000", "'_", ",_", "'", "ea", "5", "1d", "397", "559", "5b", "86", "b", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "20000", "'_", ",_", "'", "caf", "fc", "6a", "c4", "542", "de", "3", "1", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "10000", "'_", ",_", "'", "8d", "d4", "5a", "2d", "df", "907", "96", "c", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "0800", "0", "'_", ",_", "'", "102", "9", "d5", "5e", "880", "ec", "2d", "0", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "0400", "0", "'_", ",_", "'", "5d", "86", "cb", "236", "3", "9", "dbe", "a9", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "4", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "02000", "'_", ",_", "'", "1d", "1c", "a8", "5", "3a", "e7", "c0", "c5", "f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "50", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "00000000000", "0100", "0", "'_", ",_", "'", "ce", "332", "329", "248", "f3", "228", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "800", "'_", ",_", "'", "840", "5d", "1a", "be", "24", "fb", "942", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "400", "'_", ",_", "'", "e", "643", "d7", "809", "0c", "a4", "207", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "200", "'_", ",_", "'", "482", "21", "b9", "937", "748", "a2", "3", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "100", "'_", ",_", "'", "dd", "7c", "0b", "bd", "6", "1f", "af", "d5", "4", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "080", "'_", ",_", "'", "2f", "bc", "291", "a5", "7", "0d", "b5", "c4", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "56", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "040", "'_", ",_", "'", "e0", "7c", "30", "d7", "e4", "e2", "6e", "1", "2", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "020", "'_", ",_", "'", "095", "3e", "225", "8e", "8e", "90", "a1", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "010", "'_", ",_", "'", "5b", "711", "bc", "4c", "ee", "bf", "2e", "e", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "5", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "008", "'_", ",_", "'", "cc", "083", "f1", "e", "6d", "9e", "85", "f6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "60", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "004", "'_", ",_", "'", "d2", "fd", "886", "7d", "50", "d2", "df", "e", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "6", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "002", "'_", ",_", "'", "0", "6e", "7e", "a2", "2c", "e9", "270", "8f", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "6", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "0000000000000", "001", "'_", ",_", "'", "166", "b4", "0b", "4", "4a", "ba", "4b", "d6", "'_", ",_", "SP", "800", "\\u", "20", "\\u", "A1", "\\u", "KEY_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".1", " ", "#", "6", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Table", " ", "A", ".2", " ", "-", " ", "Varia", "ble", " ", "Key", " ", "Kno", "wn", " ", "Answer", " ", "Test_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "9", "5a", "8d", "728", "13", "da", "a9", "4d", "'_", ",_", "'", "800", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "0", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "0e", "ec", "148", "7d", "d8", "c2", "6d", "5", "'_", ",_", "'", "400", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "7a", "d1", "6f", "fb", "7", "9c", "459", "2", "6", "'_", ",_", "'", "200", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "d3", "746", "294", "ca", "6a", "6c", "f3", "'_", ",_", "'", "10010", "10101", "01010", "1", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "809", "f5", "f8", "7", "3c", "1f", "d7", "6", "1", "'_", ",_", "'", "080", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "c0", "2f", "aff", "ec", "989", "d1", "fc", "'_", ",_", "'", "040", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "461", "5a", "a1", "d3", "3e", "7", "2f", "10", "'_", ",_", "'", "020", "10101", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "205", "512", "335", "0c", "008", "5", "8", "'_", ",_", "'", "018", "0010", "10101", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "df", "3b", "9", "9", "d6", "577", "397", "c8", "'_", ",_", "'", "014", "0010", "10101", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "3", "1f", "e1", "736", "9", "b5", "288", "c9", "'_", ",_", "'", "0120", "01010", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "dfd", "d3", "cc", "64", "dae", "164", "2", "'_", ",_", "'", "0110", "01010", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "10", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "178", "c8", "3c", "e2", "b3", "9", "9", "d", "9", "4", "'_", ",_", "'", "010", "801", "01010", "10101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "11", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "50", "f6", "363", "24", "a9", "b7", "f8", "0", "'_", ",_", "'", "010", "401", "01010", "10101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "1", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "a8", "468", "ee", "3b", "c1", "8f", "0", "6d", "'_", ",_", "'", "0102", "01010", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "13", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "a2", "dc", "9e", "9", "2f", "d3", "cde", "9", "2", "'_", ",_", "'", "0101", "800", "10101", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "14", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "cac", "09", "f7", "9", "7d", "031", "287", "'_", ",_", "'", "0101", "400", "10101", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "15", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "90", "ba", "680", "b2", "2a", "eb", "525", "'_", ",_", "'", "0101", "200", "10101", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "16", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "ce", "7a", "24", "f3", "50", "e2", "80", "b6", "'_", ",_", "'", "0101", "10010", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "1", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "882", "bf", "f0", "aa", "01", "a0", "b8", "7", "'_", ",_", "'", "01010", "801", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "1", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "256", "102", "889", "245", "11", "c2", "'_", ",_", "'", "01010", "401", "01010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "1", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "c7", "151", "6c", "2", "9c", "7", "5d", "170", "'_", ",_", "'", "01010", "2010", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "20", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "519", "9c", "2", "9", "a5", "2c", "9", "f0", "5", "9", "'_", ",_", "'", "01010", "1800", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "21", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "c2", "2f", "0a", "294", "a7", "1f", "2", "9", "f", "'_", ",_", "'", "01010", "1400", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "ee", "371", "483", "714", "c0", "2e", "a", "'_", ",_", "'", "01010", "1200", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "23", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "a8", "1f", "bd", "448", "f9", "e5", "2", "2f", "'_", ",_", "'", "01010", "1100", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "24", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "4f", "644", "c9", "2e", "192", "df", "ed", "'_", ",_", "'", "01010", "1080", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "25", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "1a", "fa", "9", "a6", "6a", "6d", "f9", "2a", "e", "'_", ",_", "'", "01010", "1040", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "b3", "c1", "cc", "715", "cb", "879", "d8", "'_", ",_", "'", "01010", "1020", "10101", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "1", "9", "d0", "32", "e", "64", "ab", "0b", "d8", "b", "'_", ",_", "'", "01010", "101", "800", "10101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "3c", "fa", "a7", "a7", "dc", "872", "0d", "c", "'_", ",_", "'", "01010", "101", "400", "10101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "2", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "b7", "265", "f7", "f4", "4", "7a", "c6", "f3", "'_", ",_", "'", "01010", "1012", "0010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "30", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "9", "db", "7", "3b", "3c", "0d", "163", "f5", "4", "'_", ",_", "'", "01010", "1011", "0010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "818", "1b", "6", "5b", "ab", "f4", "a9", "7", "5", "'_", ",_", "'", "01010", "1010", "801", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "32", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "9", "3c", "9", "b64", "042", "ea", "a2", "40", "'_", ",_", "'", "01010", "1010", "401", "0101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "557", "053", "082", "970", "559", "2", "'_", ",_", "'", "01010", "1010", "2010", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "863", "880", "9e", "878", "787", "a0", "'_", ",_", "'", "01010", "10101", "800", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "4", "1b", "9", "a7", "9", "af", "7", "9", "ac", "208", "'_", ",_", "'", "01010", "10101", "400", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "7a", "9", "be", "4", "2f", "200", "9", "a8", "9", "2", "'_", ",_", "'", "01010", "10101", "200", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "290", "3", "8d", "56", "ba", "6d", "274", "5", "'_", ",_", "'", "01010", "10101", "10010", "1", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "549", "5c", "6a", "bf", "1e", "5d", "f5", "1", "'_", ",_", "'", "01010", "10101", "080", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "3", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "ae", "13", "dbd", "561", "488", "933", "'_", ",_", "'", "01010", "10101", "040", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "40", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "024", "d1", "ffa", "890", "4e", "389", "'_", ",_", "'", "01010", "10101", "020", "101", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "d1", "399", "712", "f9", "9", "bf", "02", "e", "'_", ",_", "'", "01010", "10101", "018", "001", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "14", "c1", "d7", "c1", "cff", "ec", "7", "9e", "'_", ",_", "'", "01010", "10101", "014", "001", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "1d", "e5", "279", "dae", "3b", "ed", "6f", "'_", ",_", "'", "01010", "10101", "0120", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "e9", "4", "1a", "3", "3f", "855", "013", "03", "'_", ",_", "'", "01010", "10101", "0110", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "da", "9", "9", "db", "bc", "9", "a0", "3f", "379", "'_", ",_", "'", "01010", "10101", "010", "801", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "6", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "b7", "fc", "9", "2f", "9", "1d", "8e", "9", "2e", "9", "'_", ",_", "'", "01010", "10101", "010", "401", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "ae", "8e", "5c", "aa", "3c", "a0", "4e", "85", "'_", ",_", "'", "01010", "10101", "0102", "01", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "8", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "9c", "c6", "2d", "f4", "3b", "6e", "ed", "7", "4", "'_", ",_", "'", "01010", "10101", "0101", "80", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "4", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "d8", "6", "3d", "bb", "5c", "5", "9", "a9", "1a", "0", "'_", ",_", "'", "01010", "10101", "0101", "40", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "50", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "a1", "ab", "219", "054", "5b", "9", "1d", "7", "'_", ",_", "'", "01010", "10101", "0101", "20", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "087", "504", "1e", "64", "c5", "7", "0f", "7", "'_", ",_", "'", "01010", "10101", "0101", "10", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "2", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "5a", "594", "528", "be", "bef", "1c", "c", "'_", ",_", "'", "01010", "10101", "01010", "8", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "fc", "db", "329", "1d", "e2", "1f", "0c", "0", "'_", ",_", "'", "01010", "10101", "01010", "4", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "4", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SP", "800", "\\u", "20", "\\u", "A2", "\\u", "PT_", ",_", "'", "869", "ef", "d7", "f9", "f2", "6", "5a", "09", "'_", ",_", "'", "01010", "10101", "01010", "2", "'_", "*_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NIS", "T", " ", "SP", "800", "-", "20", " ", "A", ".2", " ", "#", "5", "5", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Tw", "o", "-", "key", " ", "3", "DES", "\".", " ", " ", "Test", " ", "vector", " ", "generat", "ed", " ", "usi", "ng", " ", "Py", "Crypto", " ", "2.0", ".1", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "test", " ", "is", " ", "design", "ed", " ", "to", " ", "test", " ", "the", " ", "DES", "3", " ", "API", ",", " ", "not", " ", "the", " ", "correct", "ness", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "output", "._", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "21", "e8", "1b", "7a", "de", "88", "a2", "5", "9", "'_", ",_", "'", "5c", "577", "d4", "d", "9", "b2", "0c", "0f", "8", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "9", "b3", "9", "7e", "bf", "8", "1b", "118", "1e", "282", "f4", "bb", "8a", "dba", "dc", "6b", "'_", ",_", "'", "Tw", "o", "-", "key", " ", "3", "DES", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "follow", "ing", " ", "test", " ", "vector", "s", " ", "have", " ", "bee", "n", " ", "generat", "ed", " ", "with", " ", "gpg", " ", "v1", ".4", ".0", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "command", " ", "line", " ", "used", " ", "was", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "gpg", " ", "-", "c", " ", "-", "z", " ", "0", " ", "--", "cipher", "-", "algo", " ", "3", "DES", " ", "--", "passp", "hra", "se", " ", "secret", "\\u", "passp", "hra", "se", " ", "\\\\_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", "disable", "-", "md", "c", " ", "--", "s2", "k", "-", "mode", " ", "0", " ", "--", "output", " ", "ct", " ", "pt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "an", " ", "expl", "anat", "ion", ",", " ", "see", " ", "test\\u", "AE", "S", ".", "py", " ", "._", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "ac", "176", "203", "707", "432", "4f", "b5", "3b", "a3", "596", "f7", "365", "6d", "697", "465", "566", "16", "c6", "c6", "579", "'_", ",_", "#", " ", "Plai", "ntext", ",", " ", "'", "Yo", "semi", "te", "Val", "ley", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "997", "923", "852", "835", "7b", "90", "e2", "e0", "be", "549", "cb", "0b", "2d", "599", "9", "b9", "a4", "a4", "4", "7e", "5c", "5c", "7d", "'_", ",_", "#", " ", "Ci", "pher", "text_", "\\u\\u\\uNL\\u\\u\\u_", "'", "7a", "de", "6", "5b", "460", "f5", "ea", "9", "be", "3", "5f", "9e", "14", "aa", "883", "a2", "048", "e3", "824", "aa", "616", "c0", "b2", "'_", ",_", "#", " ", "Key", " ", "(", "hash", " ", "of", " ", "'", "Bear", "s", "Ah", "ead", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "'", "GPG", " ", "Test", " ", "Vector", " ", "#", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "mode_", "=_", "'", "OPEN", "PGP", "'_", ",_", "iv_", "=_", "'", "cd", "4", "7e", "2a", "fb", "8b", "7e", "4b", "0", "'_", ",_", "encrypt", "ed", "\\u", "iv_", "=_", "'", "6a", "7e", "ef", "0b", "580", "50", "e8", "b9", "04", "a", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\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_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suite_", "=_", "lambda_", ":_", "unittest_", "._", "Test", "Suite_", "(_", "get", "\\u", "tests_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unittest_", "._", "main_", "(_", "default", "Test_", "=_", "'", "suit", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "vim", ":", "set", " ", "ts", "=", "4", " ", "sw", "=", "4", " ", "sts", "=", "4", " ", "expand", "tab", ":_", "\\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_", "get", "\\u", "tests_", "(_", "config_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "Crypto_", "._", "Cipher_", "import_", "DES", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "common_", "import_", "make", "\\u", "block", "\\u", "tests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "make", "\\u", "block", "\\u", "tests_", "(_", "DES", "3_", ",_", "\"", "DES", "3", "\"_", ",_", "test\\u", "data_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Except block handles 'BaseException'
dronekit/dronekit-python/dronekit/__init__.py
[ { "content": " def __setitem__(self, key, value):\n if not (int(key) > 0 and int(key) <= self._count):\n raise Exception('Invalid channel index %s' % key)\n if not value:\n try:\n dict.__delitem__(self, str(key))\n except:\n pass\n else:\n dict.__setitem__(self, str(key), value)\n self._send()", "metadata": "root.ChannelsOverride.__setitem__", "header": "['class', 'ChannelsOverride', '(', 'dict', ')', ':', '___EOS___']", "index": 714 }, { "content": " @overrides.setter\n def overrides(self, newch):\n self._overrides._active = False\n self._overrides.clear()\n for k, v in newch.iteritems():\n if v:\n self._overrides[str(k)] = v\n else:\n try:\n del self._overrides[str(k)]\n except:\n pass\n self._overrides._active = True\n self._overrides._send()", "metadata": "root.Channels.overrides", "header": "['class', 'Channels', '(', 'dict', ')', ':', '___EOS___']", "index": 827 }, { "content": " def __init__(self, handler):\n super(Vehicle, self).__init__()\n\n self._handler = handler\n self._master = handler.master\n\n # Cache all updated attributes for wait_ready.\n # By default, we presume all \"commands\" are loaded.\n self._ready_attrs = set(['commands'])\n\n # Default parameters when calling wait_ready() or wait_ready(True).\n self._default_ready_attrs = ['parameters', 'gps_0', 'armed', 'mode', 'attitude']\n\n @self.on_attribute('*')\n def listener(_, name, value):\n self._ready_attrs.add(name)\n\n # Attaches message listeners.\n self._message_listeners = dict()\n\n @handler.forward_message\n def listener(_, msg):\n self.notify_message_listeners(msg.get_type(), msg)\n\n self._location = Locations(self)\n self._vx = None\n self._vy = None\n self._vz = None\n\n @self.on_message('GLOBAL_POSITION_INT')\n def listener(self, name, m):\n (self._vx, self._vy, self._vz) = (m.vx / 100.0, m.vy / 100.0, m.vz / 100.0)\n self.notify_attribute_listeners('velocity', self.velocity)\n\n self._pitch = None\n self._yaw = None\n self._roll = None\n self._pitchspeed = None\n self._yawspeed = None\n self._rollspeed = None\n\n @self.on_message('ATTITUDE')\n def listener(self, name, m):\n self._pitch = m.pitch\n self._yaw = m.yaw\n self._roll = m.roll\n self._pitchspeed = m.pitchspeed\n self._yawspeed = m.yawspeed\n self._rollspeed = m.rollspeed\n self.notify_attribute_listeners('attitude', self.attitude)\n\n self._heading = None\n self._airspeed = None\n self._groundspeed = None\n\n @self.on_message('VFR_HUD')\n def listener(self, name, m):\n self._heading = m.heading\n self.notify_attribute_listeners('heading', self.heading)\n self._airspeed = m.airspeed\n self.notify_attribute_listeners('airspeed', self.airspeed)\n self._groundspeed = m.groundspeed\n self.notify_attribute_listeners('groundspeed', self.groundspeed)\n\n self._rngfnd_distance = None\n self._rngfnd_voltage = None\n\n @self.on_message('RANGEFINDER')\n def listener(self, name, m):\n self._rngfnd_distance = m.distance\n self._rngfnd_voltage = m.voltage\n self.notify_attribute_listeners('rangefinder', self.rangefinder)\n\n self._mount_pitch = None\n self._mount_yaw = None\n self._mount_roll = None\n\n @self.on_message('MOUNT_STATUS')\n def listener(self, name, m):\n self._mount_pitch = m.pointing_a / 100.0\n self._mount_roll = m.pointing_b / 100.0\n self._mount_yaw = m.pointing_c / 100.0\n self.notify_attribute_listeners('mount', self.mount_status)\n\n self._capabilities = None\n self._raw_version =None\n self._autopilot_version_msg_count = 0\n\n @self.on_message('AUTOPILOT_VERSION')\n def listener(vehicle, name, m):\n self._capabilities = m.capabilities\n self._raw_version = m.flight_sw_version\n self._autopilot_version_msg_count += 1\n if self._capabilities != 0 or self._autopilot_version_msg_count > 5:\n # ArduPilot <3.4 fails to send capabilities correctly\n # straight after boot, and even older versions send\n # this back as always-0.\n vehicle.remove_message_listener('HEARTBEAT', self.send_capabilties_request)\n self.notify_attribute_listeners('autopilot_version', self._raw_version)\n\n # gimbal\n self._gimbal = Gimbal(self)\n\n # All keys are strings.\n self._channels = Channels(self, 8)\n\n @self.on_message('RC_CHANNELS_RAW')\n def listener(self, name, m):\n def set_rc(chnum, v):\n '''Private utility for handling rc channel messages'''\n # use port to allow ch nums greater than 8\n self._channels._update_channel(str(m.port * 8 + chnum), v)\n\n set_rc(1, m.chan1_raw)\n set_rc(2, m.chan2_raw)\n set_rc(3, m.chan3_raw)\n set_rc(4, m.chan4_raw)\n set_rc(5, m.chan5_raw)\n set_rc(6, m.chan6_raw)\n set_rc(7, m.chan7_raw)\n set_rc(8, m.chan8_raw)\n self.notify_attribute_listeners('channels', self.channels)\n\n self._voltage = None\n self._current = None\n self._level = None\n\n @self.on_message('SYS_STATUS')\n def listener(self, name, m):\n self._voltage = m.voltage_battery\n self._current = m.current_battery\n self._level = m.battery_remaining\n self.notify_attribute_listeners('battery', self.battery)\n\n self._eph = None\n self._epv = None\n self._satellites_visible = None\n self._fix_type = None # FIXME support multiple GPSs per vehicle - possibly by using componentId\n\n @self.on_message('GPS_RAW_INT')\n def listener(self, name, m):\n self._eph = m.eph\n self._epv = m.epv\n self._satellites_visible = m.satellites_visible\n self._fix_type = m.fix_type\n self.notify_attribute_listeners('gps_0', self.gps_0)\n\n self._current_waypoint = 0\n\n @self.on_message(['WAYPOINT_CURRENT', 'MISSION_CURRENT'])\n def listener(self, name, m):\n self._current_waypoint = m.seq\n\n self._ekf_poshorizabs = False\n self._ekf_constposmode = False\n self._ekf_predposhorizabs = False\n\n @self.on_message('EKF_STATUS_REPORT')\n def listener(self, name, m):\n # boolean: EKF's horizontal position (absolute) estimate is good\n self._ekf_poshorizabs = (m.flags & ardupilotmega.EKF_POS_HORIZ_ABS) > 0\n # boolean: EKF is in constant position mode and does not know it's absolute or relative position\n self._ekf_constposmode = (m.flags & ardupilotmega.EKF_CONST_POS_MODE) > 0\n # boolean: EKF's predicted horizontal position (absolute) estimate is good\n self._ekf_predposhorizabs = (m.flags & ardupilotmega.EKF_PRED_POS_HORIZ_ABS) > 0\n\n self.notify_attribute_listeners('ekf_ok', self.ekf_ok, cache=True)\n\n self._flightmode = 'AUTO'\n self._armed = False\n self._system_status = None\n self._autopilot_type = None#PX4, ArduPilot, etc.\n self._vehicle_type = None#quadcopter, plane, etc.\n\n @self.on_message('HEARTBEAT')\n def listener(self, name, m):\n self._armed = (m.base_mode & mavutil.mavlink.MAV_MODE_FLAG_SAFETY_ARMED) != 0\n self.notify_attribute_listeners('armed', self.armed, cache=True)\n self._autopilot_type = m.autopilot\n self._vehicle_type = m.type\n if self._is_mode_available(m.custom_mode) == False:\n raise APIException(\"mode %s not available on mavlink definition\" % m.custom_mode)\n self._flightmode = self._mode_mapping_bynumber[m.custom_mode]\n self.notify_attribute_listeners('mode', self.mode, cache=True)\n self._system_status = m.system_status\n self.notify_attribute_listeners('system_status', self.system_status, cache=True)\n\n # Waypoints.\n\n self._home_location = None\n self._wploader = mavwp.MAVWPLoader()\n self._wp_loaded = True\n self._wp_uploaded = None\n self._wpts_dirty = False\n self._commands = CommandSequence(self)\n\n @self.on_message(['WAYPOINT_COUNT', 'MISSION_COUNT'])\n def listener(self, name, msg):\n if not self._wp_loaded:\n self._wploader.clear()\n self._wploader.expected_count = msg.count\n self._master.waypoint_request_send(0)\n\n @self.on_message(['WAYPOINT', 'MISSION_ITEM'])\n def listener(self, name, msg):\n if not self._wp_loaded:\n if msg.seq == 0:\n if not (msg.x == 0 and msg.y == 0 and msg.z == 0):\n self._home_location = LocationGlobal(msg.x, msg.y, msg.z)\n\n if msg.seq > self._wploader.count():\n # Unexpected waypoint\n pass\n elif msg.seq < self._wploader.count():\n # Waypoint duplicate\n pass\n else:\n self._wploader.add(msg)\n\n if msg.seq + 1 < self._wploader.expected_count:\n self._master.waypoint_request_send(msg.seq + 1)\n else:\n self._wp_loaded = True\n self.notify_attribute_listeners('commands', self.commands)\n\n # Waypoint send to master\n @self.on_message(['WAYPOINT_REQUEST', 'MISSION_REQUEST'])\n def listener(self, name, msg):\n if self._wp_uploaded != None:\n wp = self._wploader.wp(msg.seq)\n handler.fix_targets(wp)\n self._master.mav.send(wp)\n self._wp_uploaded[msg.seq] = True\n\n # TODO: Waypoint loop listeners\n\n # Parameters.\n\n start_duration = 0.2\n repeat_duration = 1\n\n self._params_count = -1\n self._params_set = []\n self._params_loaded = False\n self._params_start = False\n self._params_map = {}\n self._params_last = monotonic.monotonic() # Last new param.\n self._params_duration = start_duration\n self._parameters = Parameters(self)\n\n @handler.forward_loop\n def listener(_):\n # Check the time duration for last \"new\" params exceeds watchdog.\n if not self._params_start:\n return\n\n if None not in self._params_set and not self._params_loaded:\n self._params_loaded = True\n self.notify_attribute_listeners('parameters', self.parameters)\n\n if not self._params_loaded and monotonic.monotonic() - self._params_last > self._params_duration:\n c = 0\n for i, v in enumerate(self._params_set):\n if v == None:\n self._master.mav.param_request_read_send(0, 0, '', i)\n c += 1\n if c > 50:\n break\n self._params_duration = repeat_duration\n self._params_last = monotonic.monotonic()\n\n @self.on_message(['PARAM_VALUE'])\n def listener(self, name, msg):\n # If we discover a new param count, assume we\n # are receiving a new param set.\n if self._params_count != msg.param_count:\n self._params_loaded = False\n self._params_start = True\n self._params_count = msg.param_count\n self._params_set = [None] * msg.param_count\n\n # Attempt to set the params. We throw an error\n # if the index is out of range of the count or\n # we lack a param_id.\n try:\n if msg.param_index < msg.param_count and msg:\n if self._params_set[msg.param_index] == None:\n self._params_last = monotonic.monotonic()\n self._params_duration = start_duration\n self._params_set[msg.param_index] = msg\n self._params_map[msg.param_id] = msg.param_value\n self._parameters.notify_attribute_listeners(msg.param_id, msg.param_value,\n cache=True)\n except:\n import traceback\n traceback.print_exc()\n\n # Heartbeats.\n\n self._heartbeat_started = False\n self._heartbeat_lastsent = 0\n self._heartbeat_lastreceived = 0\n self._heartbeat_timeout = False\n\n self._heartbeat_warning = 5\n self._heartbeat_error = 30\n self._heartbeat_system = None\n\n @handler.forward_loop\n def listener(_):\n # Send 1 heartbeat per second\n if monotonic.monotonic() - self._heartbeat_lastsent > 1:\n self._master.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_GCS,\n mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0)\n self._heartbeat_lastsent = monotonic.monotonic()\n\n # Timeouts.\n if self._heartbeat_started:\n if self._heartbeat_error and self._heartbeat_error > 0 and monotonic.monotonic(\n ) - self._heartbeat_lastreceived > self._heartbeat_error:\n raise APIException('No heartbeat in %s seconds, aborting.' %\n self._heartbeat_error)\n elif monotonic.monotonic() - self._heartbeat_lastreceived > self._heartbeat_warning:\n if self._heartbeat_timeout == False:\n errprinter('>>> Link timeout, no heartbeat in last %s seconds' %\n self._heartbeat_warning)\n self._heartbeat_timeout = True\n\n @self.on_message(['HEARTBEAT'])\n def listener(self, name, msg):\n self._heartbeat_system = msg.get_srcSystem()\n self._heartbeat_lastreceived = monotonic.monotonic()\n if self._heartbeat_timeout:\n errprinter('>>> ...link restored.')\n self._heartbeat_timeout = False\n\n self._last_heartbeat = None\n\n @handler.forward_loop\n def listener(_):\n if self._heartbeat_lastreceived:\n self._last_heartbeat = monotonic.monotonic() - self._heartbeat_lastreceived\n self.notify_attribute_listeners('last_heartbeat', self.last_heartbeat)", "metadata": "root.Vehicle.__init__", "header": "['class', 'Vehicle', '(', 'HasObservers', ')', ':', '___EOS___']", "index": 999 }, { "content": " def _is_mode_available(self, mode_code):\n try:\n return mode_code in self._mode_mapping_bynumber\n except:\n return False", "metadata": "root.Vehicle._is_mode_available", "header": "['class', 'Vehicle', '(', 'HasObservers', ')', ':', '___EOS___']", "index": 1522 }, { "content": " def clear(self):\n '''\n Clear the command list.\n\n This command will be sent to the vehicle only after you call :py:func:`upload() <Vehicle.commands.upload>`.\n '''\n\n # Add home point again.\n self.wait_ready()\n home = None\n try:\n home = self._vehicle._wploader.wp(0)\n except:\n pass\n self._vehicle._wploader.clear()\n if home:\n self._vehicle._wploader.add(home, comment='Added by DroneKit')\n self._vehicle._wpts_dirty = True", "metadata": "root.CommandSequence.clear", "header": "['class', 'CommandSequence', '(', 'object', ')', ':', '___EOS___']", "index": 2637 } ]
[ { "span": "except:", "start_line": 720, "start_column": 12, "end_line": 720, "end_column": 19 }, { "span": "except:", "start_line": 837, "start_column": 16, "end_line": 837, "end_column": 23 }, { "span": "except:", "start_line": 1292, "start_column": 12, "end_line": 1292, "end_column": 19 }, { "span": "except:", "start_line": 1525, "start_column": 8, "end_line": 1525, "end_column": 15 }, { "span": "except:", "start_line": 2649, "start_column": 8, "end_line": 2649, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Chan", "nels", "Override", "_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "setitem\\u\\u_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "(_", "int_", "(_", "key_", ")_", ">_", "0_", "and_", "int_", "(_", "key_", ")_", "<=_", "self_", "._", "\\u", "count_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Inva", "lid", " ", "channel", " ", "index", " ", "%", "s", "'_", "%_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "value_", ":_", "\\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 ", " _", "dict_", "._", "\\u\\u", "delitem\\u\\u_", "(_", "self_", ",_", "str_", "(_", "key_", ")_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dict_", "._", "\\u\\u", "setitem\\u\\u_", "(_", "self_", ",_", "str_", "(_", "key_", ")_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "send_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Channels_", "(_", "dict_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "overrides_", "._", "setter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "overrides_", "(_", "self_", ",_", "newc", "h_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "overrides_", "._", "\\u", "active_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "overrides_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "newc", "h_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "overrides_", "[_", "str_", "(_", "k_", ")_", "]_", "=_", "v_", "\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "del_", "self_", "._", "\\u", "overrides_", "[_", "str_", "(_", "k_", ")_", "]_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "overrides_", "._", "\\u", "active_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "overrides_", "._", "\\u", "send_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vehicle", "_", "(_", "Has", "Observer", "s_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Vehicle", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "handler_", "=_", "handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "master_", "=_", "handler_", "._", "master_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cache", " ", "all", " ", "update", "d", " ", "attribute", "s", " ", "for", " ", "wait", "\\u", "read", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "By", " ", "default", ",", " ", "we", " ", "presu", "me", " ", "all", " ", "\"", "command", "s", "\"", " ", "are", " ", "load", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "read", "y", "\\u", "attrs_", "=_", "set_", "(_", "[_", "'", "command", "s", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Default", " ", "parameter", "s", " ", "whe", "n", " ", "calling", " ", "wait", "\\u", "read", "y", "()", " ", "or", " ", "wait", "\\u", "read", "y", "(", "Tru", "e", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "default", "\\u", "read", "y", "\\u", "attrs_", "=_", "[_", "'", "parameter", "s", "'_", ",_", "'", "gps", "\\u", "0", "'_", ",_", "'", "arme", "d", "'_", ",_", "'", "mode", "'_", ",_", "'", "atti", "tude", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "attribute_", "(_", "'*'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "\\u_", ",_", "name_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "read", "y", "\\u", "attrs_", "._", "add_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Attache", "s", " ", "message", " ", "listeners", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "message", "\\u", "listeners_", "=_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "handler_", "._", "forward", "\\u", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "\\u_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "notif", "y", "\\u", "message", "\\u", "listeners_", "(_", "msg_", "._", "get", "\\u", "type_", "(_", ")_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "location_", "=_", "Locations_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "vx_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "vy_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "vz", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "GLOB", "AL", "\\u", "POSITION", "\\u", "INT", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "self_", "._", "\\u", "vx_", ",_", "self_", "._", "\\u", "vy_", ",_", "self_", "._", "\\u", "vz", "_", ")_", "=_", "(_", "m_", "._", "vx_", "/_", "100.0_", ",_", "m_", "._", "vy_", "/_", "100.0_", ",_", "m_", "._", "vz", "_", "/_", "100.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "velo", "city", "'_", ",_", "self_", "._", "velocity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "pitch_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "yaw_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "roll_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pitch", "speed_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "yaw", "speed_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "roll", "speed_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "ATT", "ITU", "DE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "pitch_", "=_", "m_", "._", "pitch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "yaw_", "=_", "m_", "._", "yaw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "roll_", "=_", "m_", "._", "roll_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pitch", "speed_", "=_", "m_", "._", "pitch", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "yaw", "speed_", "=_", "m_", "._", "yaw", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "roll", "speed_", "=_", "m_", "._", "roll", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "atti", "tude", "'_", ",_", "self_", "._", "atti", "tude", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "heading_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "airs", "peed", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ground", "speed_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "VF", "R", "\\u", "HU", "D", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "heading_", "=_", "m_", "._", "heading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "heading", "'_", ",_", "self_", "._", "heading_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "airs", "peed", "_", "=_", "m_", "._", "airs", "peed", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "airs", "peed", "'_", ",_", "self_", "._", "airs", "peed", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ground", "speed_", "=_", "m_", "._", "ground", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "ground", "speed", "'_", ",_", "self_", "._", "ground", "speed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "rng", "fn", "d\\u", "distance_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "rng", "fn", "d\\u", "voltage_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "RANGE", "FIND", "ER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "rng", "fn", "d\\u", "distance_", "=_", "m_", "._", "distance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "rng", "fn", "d\\u", "voltage_", "=_", "m_", "._", "voltage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "range", "finde", "r", "'_", ",_", "self_", "._", "range", "finder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "mount", "\\u", "pitch_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "mount", "\\u", "yaw_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "mount", "\\u", "roll_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "MOUNT", "\\u", "STATUS", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "mount", "\\u", "pitch_", "=_", "m_", "._", "pointi", "ng", "\\u", "a_", "/_", "100.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "mount", "\\u", "roll_", "=_", "m_", "._", "pointi", "ng", "\\u", "b_", "/_", "100.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "mount", "\\u", "yaw_", "=_", "m_", "._", "pointi", "ng", "\\u", "c_", "/_", "100.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "mount", "'_", ",_", "self_", "._", "mount", "\\u", "status_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "capabilities_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "raw", "\\u", "version_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "autop", "ilo", "t", "\\u", "version", "\\u", "msg", "\\u", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "AUTO", "PI", "LOT", "\\u", "VERSI", "ON", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "vehicle_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "capabilities_", "=_", "m_", "._", "capabilities_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "raw", "\\u", "version_", "=_", "m_", "._", "flight", "\\u", "sw", "\\u", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "autop", "ilo", "t", "\\u", "version", "\\u", "msg", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "capabilities_", "!=_", "0_", "or_", "self_", "._", "\\u", "autop", "ilo", "t", "\\u", "version", "\\u", "msg", "\\u", "count_", ">_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ar", "du", "Pilo", "t", " ", "<", "3.4", " ", "fail", "s", " ", "to", " ", "send", " ", "capab", "ilities", " ", "correct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "straight", " ", "after", " ", "boot", ",", " ", "and", " ", "even", " ", "older", " ", "version", "s", " ", "send_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "back", " ", "as", " ", "alw", "ay", "s", "-0", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vehicle_", "._", "remove", "\\u", "message", "\\u", "listener_", "(_", "'", "HEA", "RT", "BEA", "T", "'_", ",_", "self_", "._", "send", "\\u", "capab", "ilt", "ies", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "autop", "ilo", "t", "\\u", "version", "'_", ",_", "self_", "._", "\\u", "raw", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "gi", "mba", "l_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "gi", "mba", "l_", "=_", "Gi", "mba", "l_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "keys", " ", "are", " ", "string", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "channels_", "=_", "Channels_", "(_", "self_", ",_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "RC", "\\u", "CHANNELS", "\\u", "RA", "W", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "set\\u", "rc_", "(_", "chn", "um_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Priva", "te", " ", "utility", " ", "for", " ", "handling", " ", "rc", " ", "channel", " ", "message", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "use", " ", "port", " ", "to", " ", "allow", " ", "ch", " ", "nums", " ", "great", "er", " ", "than", " ", "8_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "channels_", "._", "\\u", "update", "\\u", "channel_", "(_", "str_", "(_", "m_", "._", "port_", "*_", "8_", "+_", "chn", "um_", ")_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "set\\u", "rc_", "(_", "1_", ",_", "m_", "._", "chan", "1", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "2_", ",_", "m_", "._", "chan", "2", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "3_", ",_", "m_", "._", "chan", "3", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "4_", ",_", "m_", "._", "chan", "4", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "5_", ",_", "m_", "._", "chan", "5", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "6_", ",_", "m_", "._", "chan", "6", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "7_", ",_", "m_", "._", "chan", "7", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "rc_", "(_", "8_", ",_", "m_", "._", "chan", "8", "\\u", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "channel", "s", "'_", ",_", "self_", "._", "channels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "voltage_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "current_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "level_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "SYS", "\\u", "STATUS", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "voltage_", "=_", "m_", "._", "voltage", "\\u", "battery", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "current_", "=_", "m_", "._", "current", "\\u", "battery", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "level_", "=_", "m_", "._", "battery", "\\u", "remaining_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "battery", "'_", ",_", "self_", "._", "battery", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "eph", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ep", "v_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "satellite", "s", "\\u", "visible_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "fix", "\\u", "type_", "=_", "None_", "#", " ", "FIX", "ME", " ", "support", " ", "multiple", " ", "GPS", "s", " ", "per", " ", "vehic", "le", " ", "-", " ", "possib", "ly", " ", "by", " ", "usi", "ng", " ", "component", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "GPS", "\\u", "RA", "W", "\\u", "INT", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "eph", "_", "=_", "m_", "._", "eph", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ep", "v_", "=_", "m_", "._", "ep", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "satellite", "s", "\\u", "visible_", "=_", "m_", "._", "satellite", "s", "\\u", "visible_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "fix", "\\u", "type_", "=_", "m_", "._", "fix", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "gps", "\\u", "0", "'_", ",_", "self_", "._", "gps", "\\u", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "current", "\\u", "waypoint", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "[_", "'", "WAY", "POINT", "\\u", "CURREN", "T", "'_", ",_", "'", "MISSI", "ON", "\\u", "CURREN", "T", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "current", "\\u", "waypoint", "_", "=_", "m_", "._", "seq_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "ek", "f", "\\u", "pos", "horiz", "abs_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ek", "f", "\\u", "const", "pos", "mode_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ek", "f", "\\u", "pred", "pos", "horiz", "abs_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "EK", "F", "\\u", "STATUS", "\\u", "REPORT", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "boolean", ":", " ", "EK", "F", "'", "s", " ", "horizon", "tal", " ", "position", " ", "(", "abs", "olute", ")", " ", "estimate", " ", "is", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "ek", "f", "\\u", "pos", "horiz", "abs_", "=_", "(_", "m_", "._", "flags_", "&_", "ard", "upi", "lot", "mega", "_", "._", "EK", "F", "\\u", "POS", "\\u", "HORI", "Z", "\\u", "ABS", "_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "boolean", ":", " ", "EK", "F", " ", "is", " ", "in", " ", "constant", " ", "position", " ", "mode", " ", "and", " ", "doe", "s", " ", "not", " ", "know", " ", "it", "'", "s", " ", "abs", "olute", " ", "or", " ", "relative", " ", "position_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "ek", "f", "\\u", "const", "pos", "mode_", "=_", "(_", "m_", "._", "flags_", "&_", "ard", "upi", "lot", "mega", "_", "._", "EK", "F", "\\u", "CONST", "\\u", "POS", "\\u", "MODE_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "boolean", ":", " ", "EK", "F", "'", "s", " ", "predi", "cte", "d", " ", "horizon", "tal", " ", "position", " ", "(", "abs", "olute", ")", " ", "estimate", " ", "is", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "ek", "f", "\\u", "pred", "pos", "horiz", "abs_", "=_", "(_", "m_", "._", "flags_", "&_", "ard", "upi", "lot", "mega", "_", "._", "EK", "F", "\\u", "PRE", "D", "\\u", "POS", "\\u", "HORI", "Z", "\\u", "ABS", "_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "ek", "f", "\\u", "ok", "'_", ",_", "self_", "._", "ek", "f", "\\u", "ok_", ",_", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "flight", "mode_", "=_", "'", "AUTO", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "arme", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "system", "\\u", "status_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "autop", "ilo", "t", "\\u", "type_", "=_", "None_", "#", "PX", "4", ",", " ", "Ar", "du", "Pilo", "t", ",", " ", "etc", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "vehic", "le", "\\u", "type_", "=_", "None_", "#", "quad", "cop", "ter", ",", " ", "plane", ",", " ", "etc", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "'", "HEA", "RT", "BEA", "T", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "arme", "d_", "=_", "(_", "m_", "._", "base", "\\u", "mode_", "&_", "mav", "util_", "._", "mavlink", "_", "._", "MAV", "\\u", "MODE", "\\u", "FLAG", "\\u", "SAFE", "TY", "\\u", "ARM", "ED_", ")_", "!=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "arme", "d", "'_", ",_", "self_", "._", "arme", "d_", ",_", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "autop", "ilo", "t", "\\u", "type_", "=_", "m_", "._", "autop", "ilo", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "vehic", "le", "\\u", "type_", "=_", "m_", "._", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "is", "\\u", "mode", "\\u", "available_", "(_", "m_", "._", "custom", "\\u", "mode_", ")_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "API", "Exception_", "(_", "\"", "mode", " ", "%", "s", " ", "not", " ", "avail", "able", " ", "on", " ", "mavlink", " ", "definit", "ion", "\"_", "%_", "m_", "._", "custom", "\\u", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "flight", "mode_", "=_", "self_", "._", "\\u", "mode", "\\u", "mapping", "\\u", "by", "number_", "[_", "m_", "._", "custom", "\\u", "mode_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "mode", "'_", ",_", "self_", "._", "mode_", ",_", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "system", "\\u", "status_", "=_", "m_", "._", "system", "\\u", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "system", "\\u", "status", "'_", ",_", "self_", "._", "system", "\\u", "status_", ",_", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Way", "points", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "home", "\\u", "location_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wp", "loader_", "=_", "mav", "wp_", "._", "MAV", "WP", "Loader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wp", "\\u", "loaded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wp", "\\u", "uploade", "d_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wpt", "s", "\\u", "dirty_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "commands_", "=_", "Command", "Sequence_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "[_", "'", "WAY", "POINT", "\\u", "COUNT", "'_", ",_", "'", "MISSI", "ON", "\\u", "COUNT", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "\\u", "wp", "\\u", "loaded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "wp", "loader_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wp", "loader_", "._", "expected", "\\u", "count_", "=_", "msg_", "._", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "master_", "._", "waypoint", "\\u", "request", "\\u", "send_", "(_", "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_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "[_", "'", "WAY", "POINT", "'_", ",_", "'", "MISSI", "ON", "\\u", "ITEM", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "\\u", "wp", "\\u", "loaded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "msg_", "._", "seq_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "(_", "msg_", "._", "x_", "==_", "0_", "and_", "msg_", "._", "y_", "==_", "0_", "and_", "msg_", "._", "z_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "home", "\\u", "location_", "=_", "Locat", "ion", "Global_", "(_", "msg_", "._", "x_", ",_", "msg_", "._", "y_", ",_", "msg_", "._", "z_", ")_", "\\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_", "msg_", "._", "seq_", ">_", "self_", "._", "\\u", "wp", "loader_", "._", "count_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Une", "xpe", "cte", "d", " ", "waypoint", "_", "\\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_", "elif_", "msg_", "._", "seq_", "<_", "self_", "._", "\\u", "wp", "loader_", "._", "count_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Way", "point", " ", "duplicate_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "wp", "loader_", "._", "add_", "(_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "msg_", "._", "seq_", "+_", "1_", "<_", "self_", "._", "\\u", "wp", "loader_", "._", "expected", "\\u", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "master_", "._", "waypoint", "\\u", "request", "\\u", "send_", "(_", "msg_", "._", "seq_", "+_", "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 ", " ", " _", "self_", "._", "\\u", "wp", "\\u", "loaded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "command", "s", "'_", ",_", "self_", "._", "commands_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Way", "point", " ", "send", " ", "to", " ", "master_", "\\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_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "[_", "'", "WAY", "POINT", "\\u", "REQUEST", "'_", ",_", "'", "MISSI", "ON", "\\u", "REQUEST", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "wp", "\\u", "uploade", "d_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wp_", "=_", "self_", "._", "\\u", "wp", "loader_", "._", "wp_", "(_", "msg_", "._", "seq_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "._", "fix", "\\u", "targets_", "(_", "wp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "master_", "._", "mav_", "._", "send_", "(_", "wp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wp", "\\u", "uploade", "d_", "[_", "msg_", "._", "seq_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "Way", "point", " ", "loop", " ", "listeners_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "start", "\\u", "duration_", "=_", "0.2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repeat", "\\u", "duration_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "count_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "set_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "loaded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "start_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "map_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "last_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "#", " ", "Las", "t", " ", "new", " ", "param", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "duration_", "=_", "start", "\\u", "duration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "parameters_", "=_", "Parameters_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "handler_", "._", "forward", "\\u", "loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "the", " ", "time", " ", "duration", " ", "for", " ", "last", " ", "\"", "new", "\"", " ", "params", " ", "exceed", "s", " ", "watchdog", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "\\u", "params", "\\u", "start_", ":_", "\\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_", "if_", "None_", "not_", "in_", "self_", "._", "\\u", "params", "\\u", "set_", "and_", "not_", "self_", "._", "\\u", "params", "\\u", "loaded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "params", "\\u", "loaded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "parameter", "s", "'_", ",_", "self_", "._", "parameters_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "\\u", "params", "\\u", "loaded_", "and_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "-_", "self_", "._", "\\u", "params", "\\u", "last_", ">_", "self_", "._", "\\u", "params", "\\u", "duration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "v_", "in_", "enumerate_", "(_", "self_", "._", "\\u", "params", "\\u", "set_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "v_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "master_", "._", "mav_", "._", "param", "\\u", "request", "\\u", "read", "\\u", "send_", "(_", "0_", ",_", "0_", ",_", "''_", ",_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "c_", ">_", "50_", ":_", "\\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_", "self_", "._", "\\u", "params", "\\u", "duration_", "=_", "repeat", "\\u", "duration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "last_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "\\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_", "._", "on", "\\u", "message_", "(_", "[_", "'", "PARAM", "\\u", "VALU", "E", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "discove", "r", " ", "a", " ", "new", " ", "param", " ", "count", ",", " ", "assume", " ", "we", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "are", " ", "receiv", "ing", " ", "a", " ", "new", " ", "param", " ", "set", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "params", "\\u", "count_", "!=_", "msg_", "._", "param", "\\u", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "params", "\\u", "loaded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "start_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "count_", "=_", "msg_", "._", "param", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "set_", "=_", "[_", "None_", "]_", "*_", "msg_", "._", "param", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Atte", "mpt", " ", "to", " ", "set", " ", "the", " ", "params", ".", " ", "We", " ", "throw", " ", "an", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "index", " ", "is", " ", "out", " ", "of", " ", "range", " ", "of", " ", "the", " ", "count", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "lack", " ", "a", " ", "param", "\\u", "id", "._", "\\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 ", " _", "if_", "msg_", "._", "param", "\\u", "index_", "<_", "msg_", "._", "param", "\\u", "count_", "and_", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "\\u", "params", "\\u", "set_", "[_", "msg_", "._", "param", "\\u", "index_", "]_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "\\u", "params", "\\u", "last_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "duration_", "=_", "start", "\\u", "duration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "set_", "[_", "msg_", "._", "param", "\\u", "index_", "]_", "=_", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "params", "\\u", "map_", "[_", "msg_", "._", "param", "\\u", "id_", "]_", "=_", "msg_", "._", "param", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "parameters_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "msg_", "._", "param", "\\u", "id_", ",_", "msg_", "._", "param", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cache_", "=_", "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 ", " _", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Heart", "beats", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "started_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "lasts", "ent_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "timeout_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "warning_", "=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "error_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "system_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "handler_", "._", "forward", "\\u", "loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sen", "d", " ", "1", " ", "heart", "beat", " ", "per", " ", "second_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "-_", "self_", "._", "\\u", "heart", "beat", "\\u", "lasts", "ent_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "master_", "._", "mav_", "._", "heart", "beat", "\\u", "send_", "(_", "mav", "util_", "._", "mavlink", "_", "._", "MAV", "\\u", "TYPE", "\\u", "GC", "S_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mav", "util_", "._", "mavlink", "_", "._", "MAV", "\\u", "AUTO", "PI", "LOT", "\\u", "INVALID", "_", ",_", "0_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "lasts", "ent_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Time", "outs", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "heart", "beat", "\\u", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "heart", "beat", "\\u", "error_", "and_", "self_", "._", "\\u", "heart", "beat", "\\u", "error_", ">_", "0_", "and_", "monotonic", "_", "._", "monotonic", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "-_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", ">_", "self_", "._", "\\u", "heart", "beat", "\\u", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "API", "Exception_", "(_", "'", "No", " ", "heart", "beat", " ", "in", " ", "%", "s", " ", "second", "s", ",", " ", "abort", "ing", ".'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "-_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", ">_", "self_", "._", "\\u", "heart", "beat", "\\u", "warning_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "\\u", "heart", "beat", "\\u", "timeout_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "err", "printer_", "(_", "'>>", ">", " ", "Link", " ", "timeo", "ut", ",", " ", "no", " ", "heart", "beat", " ", "in", " ", "last", " ", "%", "s", " ", "second", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "warning_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "timeout_", "=_", "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_", "@_", "self_", "._", "on", "\\u", "message_", "(_", "[_", "'", "HEA", "RT", "BEA", "T", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "self_", ",_", "name_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "heart", "beat", "\\u", "system_", "=_", "msg_", "._", "get", "\\u", "src", "System_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "heart", "beat", "\\u", "timeout_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "printer_", "(_", "'>>", ">", " ", "...", "link", " ", "restore", "d", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "heart", "beat", "\\u", "timeout_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "last", "\\u", "heartbeat_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "handler_", "._", "forward", "\\u", "loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "listener_", "(_", "\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "last", "\\u", "heartbeat_", "=_", "monotonic", "_", "._", "monotonic", "_", "(_", ")_", "-_", "self_", "._", "\\u", "heart", "beat", "\\u", "lastr", "ece", "ive", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "notif", "y", "\\u", "attribute", "\\u", "listeners_", "(_", "'", "last", "\\u", "heart", "beat", "'_", ",_", "self_", "._", "last", "\\u", "heartbeat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Vehicle", "_", "(_", "Has", "Observer", "s_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "is", "\\u", "mode", "\\u", "available_", "(_", "self_", ",_", "mode", "\\u", "code_", ")_", ":_", "\\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_", "mode", "\\u", "code_", "in_", "self_", "._", "\\u", "mode", "\\u", "mapping", "\\u", "by", "number_", "\\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_", "Command", "Sequence_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clear_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Clear", " ", "the", " ", "command", " ", "list", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "command", " ", "will", " ", "be", " ", "sent", " ", "to", " ", "the", " ", "vehic", "le", " ", "only", " ", "after", " ", "you", " ", "call", " ", ":", "py", ":", "func", ":`", "upload", "()", " ", "<", "Vehicle", ".", "command", "s", ".", "upload", ">`", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "home", " ", "point", " ", "again", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "wait", "\\u", "ready_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "home_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "home_", "=_", "self_", "._", "\\u", "vehicle_", "._", "\\u", "wp", "loader_", "._", "wp_", "(_", "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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "vehicle_", "._", "\\u", "wp", "loader_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "home_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "vehicle_", "._", "\\u", "wp", "loader_", "._", "add_", "(_", "home_", ",_", "comment_", "=_", "'", "Added", " ", "by", " ", "Dro", "ne", "Kit", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "vehicle_", "._", "\\u", "wpt", "s", "\\u", "dirty_", "=_", "True_", "\\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, 0,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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, 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, 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, 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 ]
Except block handles 'BaseException'
EricssonResearch/calvin-base/calvin/runtime/north/actormanager.py
[ { "content": " def _new_from_state(self, actor_type, state):\n \"\"\"Return a restored actor in PENDING state, raises an exception on failure.\"\"\"\n try:\n _log.analyze(self.node.id, \"+\", state)\n credentials = state.pop('credentials', None)\n try:\n state['_managed'].remove('credentials')\n except:\n pass\n a = self._new_actor(actor_type, actor_id=state['id'], credentials=credentials)\n if '_shadow_args' in state:\n # We were a shadow, do a full init\n args = state.pop('_shadow_args')\n state['_managed'].remove('_shadow_args')\n a.init(**args)\n # If still shadow don't call did_migrate\n did_migrate = isinstance(a, ShadowActor)\n else:\n did_migrate = True\n # Always do a set_state for the port's state\n a._set_state(state)\n self.node.pm.add_ports_of_actor(a)\n if did_migrate:\n a.did_migrate()\n a.setup_complete()\n except Exception as e:\n _log.exception(\"Catched new from state %s %s\" % (a, dir(a)))\n raise(e)\n return a", "metadata": "root.ActorManager._new_from_state", "header": "['class', 'ActorManager', '(', 'object', ')', ':', '___EOS___']", "index": 149 }, { "content": " def _update_requirements_placements(self, node_iter, actor_id, possible_placements, done, move=False, cb=None):\n _log.analyze(self.node.id, \"+ BEGIN\", {}, tb=True)\n actor = self.actors[actor_id]\n if actor._collect_placement_cb:\n actor._collect_placement_cb.cancel()\n actor._collect_placement_cb = None\n if done[0]:\n return\n try:\n while True:\n _log.analyze(self.node.id, \"+ ITER\", {})\n node_id = node_iter.next()\n possible_placements.add(node_id)\n except dynops.PauseIteration:\n _log.analyze(self.node.id, \"+ PAUSED\",\n {'counter': actor._collect_placement_counter,\n 'last_value': actor._collect_placement_last_value,\n 'diff': actor._collect_placement_counter - actor._collect_placement_last_value})\n # FIXME the dynops should be self triggering, but is not...\n # This is a temporary fix by keep trying\n delay = 0.0 if actor._collect_placement_counter > actor._collect_placement_last_value + 100 else 0.2\n actor._collect_placement_counter += 1\n actor._collect_placement_cb = async.DelayedCall(delay, self._update_requirements_placements,\n node_iter, actor_id, possible_placements, done=done,\n move=move, cb=cb)\n return\n except StopIteration:\n # all possible actor placements derived\n _log.analyze(self.node.id, \"+ ALL\", {})\n done[0] = True\n if move and len(possible_placements)>1:\n possible_placements.discard(self.node.id)\n if not possible_placements:\n if cb:\n cb(status=response.CalvinResponse(False))\n return\n if self.node.id in possible_placements:\n # Actor could stay, then do that\n if cb:\n cb(status=response.CalvinResponse(True))\n return\n # TODO do a better selection between possible nodes\n self.migrate(actor_id, possible_placements.pop(), callback=cb)\n _log.analyze(self.node.id, \"+ END\", {})\n except:\n _log.exception(\"actormanager:_update_requirements_placements\")", "metadata": "root.ActorManager._update_requirements_placements", "header": "['class', 'ActorManager', '(', 'object', ')', ':', '___EOS___']", "index": 238 } ]
[ { "span": "except:", "start_line": 156, "start_column": 12, "end_line": 156, "end_column": 19 }, { "span": "except:", "start_line": 282, "start_column": 8, "end_line": 282, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Act", "or", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "new", "\\u", "from", "\\u", "state_", "(_", "self_", ",_", "actor", "\\u", "type_", ",_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "a", " ", "restore", "d", " ", "actor", " ", "in", " ", "PEND", "ING", " ", "state", ",", " ", "raise", "s", " ", "an", " ", "exception", " ", "on", " ", "fail", "ure", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+\"_", ",_", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "credentials_", "=_", "state_", "._", "pop_", "(_", "'", "cred", "ential", "s", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "state_", "[_", "'\\u", "manage", "d", "'_", "]_", "._", "remove_", "(_", "'", "cred", "ential", "s", "'_", ")_", "\\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_", "a_", "=_", "self_", "._", "\\u", "new", "\\u", "actor_", "(_", "actor", "\\u", "type_", ",_", "actor", "\\u", "id_", "=_", "state_", "[_", "'", "id", "'_", "]_", ",_", "credentials_", "=_", "credentials_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'\\u", "shadow", "\\u", "args", "'_", "in_", "state_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "wer", "e", " ", "a", " ", "shadow", ",", " ", "do", " ", "a", " ", "full", " ", "init_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "state_", "._", "pop_", "(_", "'\\u", "shadow", "\\u", "args", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "[_", "'\\u", "manage", "d", "'_", "]_", "._", "remove_", "(_", "'\\u", "shadow", "\\u", "args", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "._", "init_", "(_", "**_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "still", " ", "shadow", " ", "don", "'", "t", " ", "call", " ", "did", "\\u", "migrate_", "\\u\\u\\uNL\\u\\u\\u_", "did", "\\u", "migrate_", "=_", "isinstance_", "(_", "a_", ",_", "Shad", "ow", "Actor_", ")_", "\\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 ", " _", "did", "\\u", "migrate_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Al", "way", "s", " ", "do", " ", "a", " ", "set\\u", "state", " ", "for", " ", "the", " ", "port", "'", "s", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a_", "._", "\\u", "set\\u", "state_", "(_", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "node_", "._", "pm_", "._", "add", "\\u", "port", "s", "\\u", "of", "\\u", "actor_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "did", "\\u", "migrate_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a_", "._", "did", "\\u", "migrate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a_", "._", "setup", "\\u", "complete_", "(_", ")_", "\\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 ", " _", "\\u", "log_", "._", "exception_", "(_", "\"", "Catch", "ed", " ", "new", " ", "from", " ", "state", " ", "%", "s", " ", "%", "s", "\"_", "%_", "(_", "a_", ",_", "dir_", "(_", "a_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Act", "or", "Manager_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "update", "\\u", "require", "ment", "s", "\\u", "placem", "ents_", "(_", "self_", ",_", "node", "\\u", "iter_", ",_", "actor", "\\u", "id_", ",_", "possib", "le", "\\u", "placem", "ents_", ",_", "done_", ",_", "move_", "=_", "False_", ",_", "cb_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+", " ", "BEGIN", "\"_", ",_", "{_", "}_", ",_", "tb_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor_", "=_", "self_", "._", "actors_", "[_", "actor", "\\u", "id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "cb_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "cb_", "._", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "cb_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "done_", "[_", "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_", "try_", ":_", "\\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 ", " _", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+", " ", "ITER", "\"_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "\\u", "id_", "=_", "node", "\\u", "iter_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "possib", "le", "\\u", "placem", "ents_", "._", "add_", "(_", "node", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "dyn", "ops_", "._", "Pause", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+", " ", "PAUSE", "D", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "counter", "'_", ":_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "counter_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "value", "'_", ":_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "last", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "diff", "'_", ":_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "counter_", "-_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "last", "\\u", "value_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", " ", "the", " ", "dyn", "ops", " ", "shou", "ld", " ", "be", " ", "self", " ", "trigger", "ing", ",", " ", "but", " ", "is", " ", "not", "..._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "temporar", "y", " ", "fix", " ", "by", " ", "keep", " ", "try", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "delay_", "=_", "0.0_", "if_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "counter_", ">_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "last", "\\u", "value_", "+_", "100_", "else_", "0.2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "counter_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor_", "._", "\\u", "collect", "\\u", "placem", "ent", "\\u", "cb_", "=_", "async_", "._", "Delay", "ed", "Call_", "(_", "delay_", ",_", "self_", "._", "\\u", "update", "\\u", "require", "ment", "s", "\\u", "placem", "ents_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node", "\\u", "iter_", ",_", "actor", "\\u", "id_", ",_", "possib", "le", "\\u", "placem", "ents_", ",_", "done_", "=_", "done_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "move_", "=_", "move_", ",_", "cb_", "=_", "cb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "all", " ", "possib", "le", " ", "actor", " ", "placem", "ents", " ", "derive", "d_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+", " ", "ALL", "\"_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "done_", "[_", "0_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "move_", "and_", "len_", "(_", "possib", "le", "\\u", "placem", "ents_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "possib", "le", "\\u", "placem", "ents_", "._", "discard_", "(_", "self_", "._", "node_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "possib", "le", "\\u", "placem", "ents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cb_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "cb_", "(_", "status_", "=_", "response_", "._", "Cal", "vin", "Response_", "(_", "False_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "node_", "._", "id_", "in_", "possib", "le", "\\u", "placem", "ents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Act", "or", " ", "coul", "d", " ", "stay", ",", " ", "then", " ", "do", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cb_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "cb_", "(_", "status_", "=_", "response_", "._", "Cal", "vin", "Response_", "(_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "do", " ", "a", " ", "bett", "er", " ", "selection", " ", "bet", "ween", " ", "possib", "le", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "migrate_", "(_", "actor", "\\u", "id_", ",_", "possib", "le", "\\u", "placem", "ents_", "._", "pop_", "(_", ")_", ",_", "callback_", "=_", "cb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "log_", "._", "analyze_", "(_", "self_", "._", "node_", "._", "id_", ",_", "\"+", " ", "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 ", " _", "\\u", "log_", "._", "exception_", "(_", "\"", "actor", "manage", "r", ":\\u", "update", "\\u", "require", "ment", "s", "\\u", "placem", "ents", "\"_", ")_", "\\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, 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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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, 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 ]
Unused import
chaosk/teerace/teerace/race/south_migrations/0007_auto__chg_field_bestrun_time.py
[ { "content": "# encoding: utf-8\nimport datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(SchemaMigration):\n\n\n\n\n\n models = {\n 'auth.group': {\n 'Meta': {'object_name': 'Group'},\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\n 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'})\n },\n 'auth.permission': {\n 'Meta': {'ordering': \"('content_type__app_label', 'content_type__model', 'codename')\", 'unique_together': \"(('content_type', 'codename'),)\", 'object_name': 'Permission'},\n 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['contenttypes.ContentType']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n },\n 'auth.user': {\n 'Meta': {'object_name': 'User'},\n 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\n 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Group']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n },\n 'contenttypes.contenttype': {\n 'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n },\n 'race.bestrun': {\n 'Meta': {'unique_together': \"(('user', 'map'),)\", 'object_name': 'BestRun'},\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'map': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['race.Map']\"}),\n 'points': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\n 'run': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['race.Run']\"}),\n 'time': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '3'}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\"})\n },\n 'race.map': {\n 'Meta': {'object_name': 'Map'},\n 'added_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'added_by': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\"}),\n 'author': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),\n 'crc': ('django.db.models.fields.CharField', [], {'max_length': '8', 'null': 'True', 'blank': 'True'}),\n 'download_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),\n 'grenade_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'}),\n 'has_deathtiles': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}),\n 'has_image': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'has_speedups': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}),\n 'has_teleporters': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}),\n 'has_unhookables': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}),\n 'heart_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'map_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),\n 'map_type': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': \"orm['race.MapType']\"}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}),\n 'shield_count': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True'})\n },\n 'race.maptype': {\n 'Meta': {'object_name': 'MapType'},\n 'displayed_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '20', 'db_index': 'True'})\n },\n 'race.run': {\n 'Meta': {'object_name': 'Run'},\n 'checkpoints': ('django.db.models.fields.CharField', [], {'max_length': '349', 'blank': 'True'}),\n 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'map': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['race.Map']\"}),\n 'nickname': ('django.db.models.fields.CharField', [], {'max_length': '24'}),\n 'server': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'runs'\", 'to': \"orm['race.Server']\"}),\n 'time': ('django.db.models.fields.DecimalField', [], {'max_digits': '12', 'decimal_places': '3'}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\", 'null': 'True', 'blank': 'True'})\n },\n 'race.server': {\n 'Meta': {'object_name': 'Server'},\n 'address': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),\n 'anonymous_players': ('picklefield.fields.PickledObjectField', [], {}),\n 'api_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'}),\n 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n 'last_connection_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),\n 'maintained_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'maintained_servers'\", 'to': \"orm['auth.User']\"}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'played_map': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['race.Map']\", 'null': 'True', 'blank': 'True'})\n }\n }\n\n complete_apps = ['race']", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 6 }, { "content": " def forwards(self, orm):\n \n # Changing field 'BestRun.time'\n db.alter_column('race_bestrun', 'time', self.gf('django.db.models.fields.DecimalField')(max_digits=12, decimal_places=3))", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 8 }, { "content": " def backwards(self, orm):\n \n # Changing field 'BestRun.time'\n db.alter_column('race_bestrun', 'time', self.gf('django.db.models.fields.FloatField')())", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 14 } ]
[ { "span": "import datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "from django.db import models", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "encoding", ":", " ", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "v2_", "import_", "Schema", "Migration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\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_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\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\\uDEDENT\\u\\u\\u_", "models_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "group", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Group", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "80", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "permissi", "on", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "content", "\\u", "type\\u\\u", "app", "\\u", "label", "',", " ", "'", "content", "\\u", "type\\u\\u", "model", "',", " ", "'", "code", "name", "')\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "content", "\\u", "type", "',", " ", "'", "code", "name", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Permi", "ssion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "user", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "User", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "joine", "d", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "email", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Ema", "il", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "7", "5", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "first", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "group", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Group", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "sta", "ff", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "super", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "login", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "password", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "128", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "\\u", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contenttype", "s", ".", "contenttype", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "name", "',)\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "app", "\\u", "label", "',", " ", "'", "model", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Conten", "t", "Type", "'_", ",_", "'", "db", "\\u", "table", "'_", ":_", "\"'", "django", "\\u", "content", "\\u", "type", "'\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "label", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "model", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "race", ".", "best", "run", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "user", "',", " ", "'", "map", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Bes", "t", "Run", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "map", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Map", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "points", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "0", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "run", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Run", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Deci", "mal", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "digit", "s", "'_", ":_", "'", "1", "2", "'_", ",_", "'", "decima", "l\\u", "place", "s", "'_", ":_", "'", "3", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "race", ".", "map", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Map", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adde", "d\\u", "at", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "\\u", "add", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adde", "d\\u", "by", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "crc", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "8", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "download", "\\u", "count", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "0", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "gre", "nad", "e\\u", "count", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "0", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "death", "tiles", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Null", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "image", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "speed", "ups", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Null", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "telep", "orte", "rs", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Null", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "unh", "ook", "able", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Null", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "heart", "\\u", "count", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "0", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "map", "\\u", "file", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "files", ".", "File", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "map", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "1", "'_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Map", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "shield", "\\u", "count", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "0", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "race", ".", "map", "type", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Map", "Type", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "displaye", "d\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Sl", "ug", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "20", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "race", ".", "run", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Run", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "checkpoints", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "349", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "created", "\\u", "at", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "\\u", "add", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "map", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Map", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nick", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "24", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "server", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "runs", "'\"_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Server", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "time", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Deci", "mal", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "digit", "s", "'_", ":_", "'", "1", "2", "'_", ",_", "'", "decima", "l\\u", "place", "s", "'_", ":_", "'", "3", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "race", ".", "server", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Server", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "address", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "anonym", "ous", "\\u", "player", "s", "'_", ":_", "(_", "'", "pickle", "field", ".", "fields", ".", "Pickl", "ed", "Object", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "api", "\\u", "key", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "32", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "connecti", "on", "\\u", "at", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "maintain", "ed", "\\u", "by", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "maintain", "ed", "\\u", "server", "s", "'\"_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "played", "\\u", "map", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "race", ".", "Map", "']\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "race", "'_", "]_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "forwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Chang", "ing", " ", "field", " ", "'", "Bes", "t", "Run", ".", "time", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "alter", "\\u", "column_", "(_", "'", "race", "\\u", "best", "run", "'_", ",_", "'", "time", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Deci", "mal", "Field", "'_", ")_", "(_", "max", "\\u", "digits_", "=_", "12_", ",_", "decima", "l\\u", "places_", "=_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "backwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Chang", "ing", " ", "field", " ", "'", "Bes", "t", "Run", ".", "time", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "alter", "\\u", "column_", "(_", "'", "race", "\\u", "best", "run", "'_", ",_", "'", "time", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Float", "Field", "'_", ")_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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, 0, 1, 1, 1, 1, 1, 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, 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EndOfInput\nfrom pycket.arity import Arity\nfrom pycket.base import W_Object\nfrom pycket.error import SchemeException\nfrom pycket.prims.expose import expose, expose_val, default, procedure\nfrom rpython.rlib import jit\n\n\n\n\n\n\n\nexpose_val(\"parameterization-key\", values.parameterization_key)\nexpose_val(\"print-mpair-curly-braces\", values_parameter.W_Parameter(values.w_false))\nexpose_val(\"print-pair-curly-braces\", values_parameter.W_Parameter(values.w_false))\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@expose(\"make-parameter\",\n [values.W_Object, default(values.W_Object, values.w_false)])\ndef make_parameter(init, guard):\n return values_parameter.W_Parameter(init, guard)", "metadata": "root.make_parameter", "header": "['module', '___EOS___']", "index": 10 }, { "content": "@expose(\"make-derived-parameter\",\n [values_parameter.W_BaseParameter, procedure, procedure])\ndef make_derived_parameter(param, guard, wrap):\n return values_parameter.W_DerivedParameter(param, guard, wrap)", "metadata": "root.make_derived_parameter", "header": "['module', '___EOS___']", "index": 15 }, { "content": "@expose(\"extend-parameterization\", arity=Arity.geq(1))\[email protected]_safe\ndef scheme_extend_parameterization(args):\n if len(args) == 0:\n raise SchemeException(\"extend-parameterization: expected 1 or more arguments\")\n\n config = args[0]\n argc = len(args)\n\n if argc < 2 or not isinstance(config, values_parameter.W_Parameterization) or argc % 2 != 1:\n return config\n\n parser = ArgParser(\"extend-parameterization\", args, start_at=1)\n while parser.has_more():\n param = parser.parameter()\n key = parser.object()\n config = config.extend([param], [key])\n\n return config", "metadata": "root.scheme_extend_parameterization", "header": "['module', '___EOS___']", "index": 20 }, { "content": "def call_with_parameterization(f, args, paramz, env, cont):\n cont.update_cm(values.parameterization_key, paramz)\n return f.call(args, env, cont)", "metadata": "root.call_with_parameterization", "header": "['module', '___EOS___']", "index": 40 }, { "content": "@expose(\"call-with-parameterization\",\n [values.W_Object, values_parameter.W_Parameterization], simple=False)\ndef call_w_paramz(f, paramz, env, cont):\n return call_with_parameterization(f, [], paramz, env, cont)", "metadata": "root.call_w_paramz", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def call_with_extended_paramz(f, args, keys, vals, env, cont):\n from pycket.values import parameterization_key\n # XXX seems untested?\n paramz = cont.get_mark_first(parameterization_key)\n assert isinstance(paramz, values_parameter.W_Parameterization) # XXX is this always right?\n paramz_new = paramz.extend(keys, vals)\n return call_with_parameterization(f, args, paramz_new, env, cont)", "metadata": "root.call_with_extended_paramz", "header": "['module', '___EOS___']", "index": 49 } ]
[ { "span": "from pycket.argument_parser import ArgParser, EndOfInput", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 56 }, { "span": "from pycket.base import W_Object", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 43 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyc", "ket", "_", "import_", "values_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "import_", "values", "\\u", "parameter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "._", "argu", "ment", "\\u", "parser_", "import_", "Arg", "Parser_", ",_", "End", "Of", "Input_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "._", "arity_", "import_", "Ari", "ty_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "._", "base_", "import_", "W", "\\u", "Object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "._", "error_", "import_", "Sche", "me", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyc", "ket", "_", "._", "prim", "s_", "._", "expose_", "import_", "expose_", ",_", "expos", "e\\u", "val_", ",_", "default_", ",_", "procedure_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "rpython_", "._", "rli", "b_", "import_", "jit_", "\\u\\u\\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_", "expos", "e\\u", "val_", "(_", "\"", "parameter", "izatio", "n", "-", "key", "\"_", ",_", "values_", "._", "parameter", "izatio", "n", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expos", "e\\u", "val_", "(_", "\"", "print", "-", "mpa", "ir", "-", "curl", "y", "-", "braces", "\"_", ",_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameter_", "(_", "values_", "._", "w", "\\u", "false_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expos", "e\\u", "val_", "(_", "\"", "print", "-", "pair", "-", "curl", "y", "-", "braces", "\"_", ",_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameter_", "(_", "values_", "._", "w", "\\u", "false_", ")_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "expose_", "(_", "\"", "make", "-", "parameter", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "values_", "._", "W", "\\u", "Object_", ",_", "default_", "(_", "values_", "._", "W", "\\u", "Object_", ",_", "values_", "._", "w", "\\u", "false_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "make", "\\u", "parameter_", "(_", "init_", ",_", "guard_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameter_", "(_", "init_", ",_", "guard_", ")_", "\\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_", "@_", "expose_", "(_", "\"", "make", "-", "derive", "d", "-", "parameter", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "values", "\\u", "parameter_", "._", "W", "\\u", "Base", "Parameter_", ",_", "procedure_", ",_", "procedure_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "make", "\\u", "derive", "d\\u", "parameter_", "(_", "param_", ",_", "guard_", ",_", "wrap_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "values", "\\u", "parameter_", "._", "W", "\\u", "Derive", "d", "Parameter_", "(_", "param_", ",_", "guard_", ",_", "wrap_", ")_", "\\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_", "@_", "expose_", "(_", "\"", "extend", "-", "parameter", "izatio", "n", "\"_", ",_", "arity_", "=_", "Ari", "ty_", "._", "ge", "q_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "jit_", "._", "unroll", "\\u", "safe_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "sche", "me", "\\u", "extend", "\\u", "parameter", "ization_", "(_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "args_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Sche", "me", "Exception_", "(_", "\"", "extend", "-", "parameter", "izatio", "n", ":", " ", "expected", " ", "1", " ", "or", " ", "more", " ", "argu", "ment", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "config_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "argc", "_", "=_", "len_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "argc", "_", "<_", "2_", "or_", "not_", "isinstance_", "(_", "config_", ",_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameteri", "zation_", ")_", "or_", "argc", "_", "%_", "2_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parser_", "=_", "Arg", "Parser_", "(_", "\"", "extend", "-", "parameter", "izatio", "n", "\"_", ",_", "args_", ",_", "start", "\\u", "at_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "parser_", "._", "has", "\\u", "more_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "param_", "=_", "parser_", "._", "parameter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "parser_", "._", "object_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "config_", "._", "extend_", "(_", "[_", "param_", "]_", ",_", "[_", "key_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "config_", "\\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_", "call", "\\u", "with", "\\u", "parameter", "ization_", "(_", "f_", ",_", "args_", ",_", "param", "z_", ",_", "env_", ",_", "cont_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cont_", "._", "update", "\\u", "cm_", "(_", "values_", "._", "parameter", "izatio", "n", "\\u", "key_", ",_", "param", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "f_", "._", "call_", "(_", "args_", ",_", "env_", ",_", "cont_", ")_", "\\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_", "@_", "expose_", "(_", "\"", "call", "-", "with", "-", "parameter", "izatio", "n", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "values_", "._", "W", "\\u", "Object_", ",_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameteri", "zation_", "]_", ",_", "simple_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "call", "\\u", "w", "\\u", "param", "z_", "(_", "f_", ",_", "param", "z_", ",_", "env_", ",_", "cont_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "call", "\\u", "with", "\\u", "parameter", "ization_", "(_", "f_", ",_", "[_", "]_", ",_", "param", "z_", ",_", "env_", ",_", "cont_", ")_", "\\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_", "call", "\\u", "with", "\\u", "extend", "ed", "\\u", "param", "z_", "(_", "f_", ",_", "args_", ",_", "keys_", ",_", "vals_", ",_", "env_", ",_", "cont_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "pyc", "ket", "_", "._", "values_", "import_", "parameter", "izatio", "n", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "XX", "X", " ", "see", "ms", " ", "unt", "este", "d", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "param", "z_", "=_", "cont_", "._", "get", "\\u", "mark", "\\u", "first_", "(_", "parameter", "izatio", "n", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "param", "z_", ",_", "values", "\\u", "parameter_", "._", "W", "\\u", "Parameteri", "zation_", ")_", "#", " ", "XX", "X", " ", "is", " ", "this", " ", "alw", "ay", "s", " ", "right", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param", "z", "\\u", "new_", "=_", "param", "z_", "._", "extend_", "(_", "keys_", ",_", "vals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "call", "\\u", "with", "\\u", "parameter", "ization_", "(_", "f_", ",_", "args_", ",_", "param", "z", "\\u", "new_", ",_", "env_", ",_", "cont_", ")_", "\\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, 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, 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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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 ]
Unreachable code
binux/pyspider/pyspider/message_queue/__init__.py
[ { "content": "def connect_message_queue(name, url=None, maxsize=0):\n \"\"\"\n create connection to message queue\n\n name:\n name of message queue\n\n rabbitmq:\n amqp://username:password@host:5672/%2F\n see https://www.rabbitmq.com/uri-spec.html\n beanstalk:\n beanstalk://host:11300/\n redis:\n redis://host:6379/db\n kombu:\n kombu+transport://userid:password@hostname:port/virtual_host\n see http://kombu.readthedocs.org/en/latest/userguide/connections.html#urls\n builtin:\n None\n \"\"\"\n\n if not url:\n from pyspider.libs.multiprocessing_queue import Queue\n return Queue(maxsize=maxsize)\n\n parsed = urlparse.urlparse(url)\n if parsed.scheme == 'amqp':\n from .rabbitmq import Queue\n return Queue(name, url, maxsize=maxsize)\n elif parsed.scheme == 'beanstalk':\n from .beanstalk import Queue\n return Queue(name, host=parsed.netloc, maxsize=maxsize)\n elif parsed.scheme == 'redis':\n from .redis_queue import Queue\n db = parsed.path.lstrip('/').split('/')\n try:\n db = int(db[0])\n except:\n db = 0\n\n password = parsed.password or None\n\n return Queue(name, parsed.hostname, parsed.port, db=db, maxsize=maxsize, password=password)\n else:\n if url.startswith('kombu+'):\n url = url[len('kombu+'):]\n from .kombu_queue import Queue\n return Queue(name, url, maxsize=maxsize)\n\n raise Exception('unknow connection url: %s', url)", "metadata": "root.connect_message_queue", "header": "['module', '___EOS___']", "index": 13 } ]
[ { "span": "raise Exception('unknow connection url: %s', url)", "start_line": 62, "start_column": 4, "end_line": 62, "end_column": 53 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connect", "\\u", "message", "\\u", "queue_", "(_", "name_", ",_", "url_", "=_", "None_", ",_", "maxsize_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "create", " ", "connecti", "on", " ", "to", " ", "message", " ", "queue", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "name", ":", "\\", "10", ";", " ", " ", " ", " ", "name", " ", "of", " ", "message", " ", "queue", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "rabbitmq", ":", "\\", "10", ";", " ", " ", " ", " ", "amqp", "://", "user", "name", ":", "password", "@", "host", ":", "567", "2", "/", "%", "2", "F", "\\", "10", ";", " ", " ", " ", " ", "see", " ", "https", "://", "www", ".", "rabbitmq", ".", "com", "/", "uri", "-", "spec", ".", "html", "\\", "10", ";", " ", " ", " ", " ", "beans", "talk", ":", "\\", "10", ";", " ", " ", " ", " ", "beans", "talk", "://", "host", ":", "113", "00", "/", "\\", "10", ";", " ", " ", " ", " ", "redis", ":", "\\", "10", ";", " ", " ", " ", " ", "redis", "://", "host", ":", "6379", "/", "db", "\\", "10", ";", " ", " ", " ", " ", "kom", "bu", ":", "\\", "10", ";", " ", " ", " ", " ", "kom", "bu", "+", "transport", "://", "user", "id", ":", "password", "@", "host", "name", ":", "port", "/", "virtual", "\\u", "host", "\\", "10", ";", " ", " ", " ", " ", "see", " ", "http", "://", "kom", "bu", ".", "read", "the", "docs", ".", "org", "/", "en", "/", "late", "st", "/", "user", "guide", "/", "connections", ".", "html", "#", "urls", "\\", "10", ";", " ", " ", " ", " ", "bui", "lti", "n", ":", "\\", "10", ";", " ", " ", " ", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "pys", "pid", "er_", "._", "libs_", "._", "multipro", "cess", "ing", "\\u", "queue_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Queue_", "(_", "maxsize_", "=_", "maxsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parsed_", "=_", "urlparse_", "._", "urlparse_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "parsed_", "._", "scheme_", "==_", "'", "amqp", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "._", "rabbitmq", "_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Queue_", "(_", "name_", ",_", "url_", ",_", "maxsize_", "=_", "maxsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "parsed_", "._", "scheme_", "==_", "'", "beans", "talk", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "._", "beans", "talk", "_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Queue_", "(_", "name_", ",_", "host_", "=_", "parsed_", "._", "netloc_", ",_", "maxsize_", "=_", "maxsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "parsed_", "._", "scheme_", "==_", "'", "redis", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "._", "redis", "\\u", "queue_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "parsed_", "._", "path_", "._", "lstrip_", "(_", "'/'_", ")_", "._", "split_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "=_", "int_", "(_", "db_", "[_", "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 ", " _", "db_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "password_", "=_", "parsed_", "._", "password_", "or_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Queue_", "(_", "name_", ",_", "parsed_", "._", "hostname_", ",_", "parsed_", "._", "port_", ",_", "db_", "=_", "db_", ",_", "maxsize_", "=_", "maxsize_", ",_", "password_", "=_", "password_", ")_", "\\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_", "url_", "._", "startswith_", "(_", "'", "kom", "bu", "+'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "url_", "[_", "len_", "(_", "'", "kom", "bu", "+'_", ")_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "._", "kom", "bu", "\\u", "queue_", "import_", "Queue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Queue_", "(_", "name_", ",_", "url_", ",_", "maxsize_", "=_", "maxsize_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unreachable code
anandology/pyjamas/pyjs/src/pyjs/linker.py
[ { "content": "def module_path(name, path):\n global _path_cache\n candidates = []\n packages = {}\n modules = {}\n if name.endswith('.js'):\n parts = [name]\n else:\n parts = name.split('.')\n if not name in _path_cache:\n _path_cache[name] = {}\n for p in path:\n if p in _path_cache[name]:\n if _path_cache[name][p] is None:\n continue\n return _path_cache[name][p]\n tail = []\n for pn in parts:\n tail.append(pn)\n mn = '.'.join(tail)\n cp = os.path.join(*([p] + tail))\n if mn in _path_cache:\n cache = _path_cache[mn]\n else:\n cache = {}\n _path_cache[mn] = cache\n if p in cache:\n if cache[p] is None:\n break\n elif os.path.isdir(cp) and os.path.exists(\n os.path.join(cp, '__init__.py')):\n cache[p] = os.path.join(cp, '__init__.py')\n elif os.path.exists(cp + '.py'):\n cache[p] = cp + '.py'\n elif pn.endswith('.js') and os.path.exists(cp):\n cache[p] = cp\n else:\n cache[p] = None\n if p in _path_cache[name] and not _path_cache[name][p] is None:\n return _path_cache[name][p]\n _path_cache[name][p] = None\n \n return None\n raise RuntimeError, \"Module %r not found\" % name", "metadata": "root.module_path", "header": "['module', '___EOS___']", "index": 158 }, { "content": " def visit_modules(self, module_names, platform=None, parent_file = None):\n prefix = ''\n all_names = []\n for mn in module_names:\n if not mn.endswith(\".js\"):\n prefix = ''\n for part in mn.split('.')[:-1]:\n pn = prefix + part\n prefix = pn + '.'\n if pn not in all_names:\n all_names.append(pn)\n all_names.append(mn)\n paths = self.path\n parent_base = None\n abs_name = None\n if not parent_file is None:\n for p in paths:\n if parent_file.find(p) == 0 and p != parent_file:\n parent_base = p\n abs_name = os.path.split(parent_file)[0]\n abs_name = '.'.join(abs_name[len(parent_base)+1:].split(os.sep))\n\n for mn in all_names:\n p = None\n if abs_name:\n p = module_path(abs_name + '.' + mn, [parent_base])\n if p:\n mn = abs_name + '.' + mn\n if not p:\n p = module_path(mn, paths)\n if not p:\n continue\n raise RuntimeError, \"Module %r not found. Dep of %r\" % (\n mn, self.dependencies)\n if mn==self.top_module:\n self.top_module_path = p\n override_paths=[]\n if platform:\n for pl in self.platform_parents.get(platform, []) + [platform]:\n override_path = module_path('__%s__.%s' % (pl, mn),\n paths)\n # prevent package overrides\n if override_path and not override_path.endswith('__init__.py'):\n override_paths.append(override_path)\n self.visit_module(p, override_paths, platform, module_name=mn)", "metadata": "root.BaseLinker.visit_modules", "header": "['class', 'BaseLinker', '(', 'object', ')', ':', '___EOS___']", "index": 261 } ]
[ { "span": "raise RuntimeError, \"Module %r not found\" % name", "start_line": 201, "start_column": 4, "end_line": 201, "end_column": 52 }, { "span": "raise RuntimeError, \"Module %r not found. Dep of %r\" % (\n mn, self.dependencies)", "start_line": 293, "start_column": 16, "end_line": 294, "end_column": 42 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "module", "\\u", "path_", "(_", "name_", ",_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "\\u", "path", "\\u", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "candidates_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "packages_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modules_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", "._", "endswith_", "(_", "'.", "js", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parts_", "=_", "[_", "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 ", " _", "parts_", "=_", "name_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "name_", "in_", "\\u", "path", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "p_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "p_", "in_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "[_", "p_", "]_", "is_", "None_", ":_", "\\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_", "return_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "[_", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tail_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "pn_", "in_", "parts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tail_", "._", "append_", "(_", "pn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mn_", "=_", "'.'_", "._", "join_", "(_", "tail_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cp_", "=_", "os_", "._", "path_", "._", "join_", "(_", "*_", "(_", "[_", "p_", "]_", "+_", "tail_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mn_", "in_", "\\u", "path", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "=_", "\\u", "path", "\\u", "cache_", "[_", "mn_", "]_", "\\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 ", " _", "cache_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "path", "\\u", "cache_", "[_", "mn_", "]_", "=_", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p_", "in_", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cache_", "[_", "p_", "]_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "os_", "._", "path_", "._", "isdir_", "(_", "cp_", ")_", "and_", "os_", "._", "path_", "._", "exists_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "join_", "(_", "cp_", ",_", "'\\u", "\\u", "init", "\\u\\u", ".", "py", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "[_", "p_", "]_", "=_", "os_", "._", "path_", "._", "join_", "(_", "cp_", ",_", "'\\u", "\\u", "init", "\\u\\u", ".", "py", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "os_", "._", "path_", "._", "exists_", "(_", "cp_", "+_", "'.", "py", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "[_", "p_", "]_", "=_", "cp_", "+_", "'.", "py", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "pn_", "._", "endswith_", "(_", "'.", "js", "'_", ")_", "and_", "os_", "._", "path_", "._", "exists_", "(_", "cp_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "[_", "p_", "]_", "=_", "cp_", "\\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 ", " _", "cache_", "[_", "p_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "p_", "in_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "and_", "not_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "[_", "p_", "]_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "[_", "p_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "path", "\\u", "cache_", "[_", "name_", "]_", "[_", "p_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Run", "time", "Error_", ",_", "\"", "Modul", "e", " ", "%", "r", " ", "not", " ", "found", "\"_", "%_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Linke", "r_", "(_", "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_", "visit", "\\u", "modules_", "(_", "self_", ",_", "module", "\\u", "names_", ",_", "platform_", "=_", "None_", ",_", "parent", "\\u", "file_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prefix_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "mn_", "in_", "module", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "mn_", "._", "endswith_", "(_", "\".", "js", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prefix_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "part_", "in_", "mn_", "._", "split_", "(_", "'.'_", ")_", "[_", ":_", "-_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pn_", "=_", "prefix_", "+_", "part_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prefix_", "=_", "pn_", "+_", "'.'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pn_", "not_", "in_", "all", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "all", "\\u", "names_", "._", "append_", "(_", "pn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "all", "\\u", "names_", "._", "append_", "(_", "mn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "paths_", "=_", "self_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "\\u", "base_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "abs", "\\u", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "parent", "\\u", "file_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "p_", "in_", "paths_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "parent", "\\u", "file_", "._", "find_", "(_", "p_", ")_", "==_", "0_", "and_", "p_", "!=_", "parent", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "parent", "\\u", "base_", "=_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "abs", "\\u", "name_", "=_", "os_", "._", "path_", "._", "split_", "(_", "parent", "\\u", "file_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "abs", "\\u", "name_", "=_", "'.'_", "._", "join_", "(_", "abs", "\\u", "name_", "[_", "len_", "(_", "parent", "\\u", "base_", ")_", "+_", "1_", ":_", "]_", "._", "split_", "(_", "os_", "._", "sep_", ")_", ")_", "\\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_", "mn_", "in_", "all", "\\u", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "abs", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "module", "\\u", "path_", "(_", "abs", "\\u", "name_", "+_", "'.'_", "+_", "mn_", ",_", "[_", "parent", "\\u", "base_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "mn_", "=_", "abs", "\\u", "name_", "+_", "'.'_", "+_", "mn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "=_", "module", "\\u", "path_", "(_", "mn_", ",_", "paths_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Run", "time", "Error_", ",_", "\"", "Modul", "e", " ", "%", "r", " ", "not", " ", "found", ".", " ", "Dep", " ", "of", " ", "%", "r", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "mn_", ",_", "self_", "._", "dependencies_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mn_", "==_", "self_", "._", "top", "\\u", "module_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "top", "\\u", "module", "\\u", "path_", "=_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "override", "\\u", "paths_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "platform_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "pl_", "in_", "self_", "._", "platform", "\\u", "parents_", "._", "get_", "(_", "platform_", ",_", "[_", "]_", ")_", "+_", "[_", "platform_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "override", "\\u", "path_", "=_", "module", "\\u", "path_", "(_", "'\\u", "\\u", "%", "s", "\\u\\u", ".", "%", "s", "'_", "%_", "(_", "pl_", ",_", "mn_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "paths_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "prevent", " ", "package", " ", "overrides_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "override", "\\u", "path_", "and_", "not_", "override", "\\u", "path_", "._", "endswith_", "(_", "'\\u", "\\u", "init", "\\u\\u", ".", "py", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "override", "\\u", "paths_", "._", "append_", "(_", "override", "\\u", "path_", ")_", "\\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_", "._", "visit", "\\u", "module_", "(_", "p_", ",_", "override", "\\u", "paths_", ",_", "platform_", ",_", "module", "\\u", "name_", "=_", "mn_", ")_", "\\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,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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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
statsmodels/statsmodels/statsmodels/sandbox/regression/tests/test_gmm.py
[ { "content": "def test_iv2sls_r():\n\n mod = gmm.IV2SLS(endog, exog, instrument)\n res = mod.fit()\n\n # print(res.params)\n # print(res.params - params)\n\n n, k = exog.shape\n\n assert_allclose(res.params, params, rtol=1e-7, atol=1e-9)\n # TODO: check df correction\n #assert_allclose(res.bse * np.sqrt((n - k) / (n - k - 1.)), bse,\n assert_allclose(res.bse, bse, rtol=0, atol=3e-7)", "metadata": "root.test_iv2sls_r", "header": "['module', '___EOS___']", "index": 81 }, { "content": "def test_ivgmm0_r():\n n, k = exog.shape\n nobs, k_instr = instrument.shape\n\n w0inv = np.dot(instrument.T, instrument) / nobs\n w0 = np.linalg.inv(w0inv)\n\n mod = gmm.IVGMM(endog, exog, instrument)\n res = mod.fit(np.ones(exog.shape[1], float), maxiter=0, inv_weights=w0inv,\n optim_method='bfgs',\n optim_args={'gtol':1e-8, 'disp': 0})\n\n\n assert_allclose(res.params, params, rtol=1e-4, atol=1e-4)\n # TODO : res.bse and bse are not the same, rtol=0.09 is large in this case\n #res.bse is still robust?, bse is not a sandwich ?\n assert_allclose(res.bse, bse, rtol=0.09, atol=0)\n\n score = res.model.score(res.params, w0)\n assert_allclose(score, np.zeros(score.shape), rtol=0, atol=5e-6) # atol=1e-8) ??", "metadata": "root.test_ivgmm0_r", "header": "['module', '___EOS___']", "index": 98 }, { "content": "def test_ivgmm1_stata():\n\n # copied constant to the beginning\n params_stata = np.array(\n [ 4.0335099 , 0.17242531, -0.00909883, 0.04928949, 0.04221709,\n -0.10179345, 0.12611095, -0.05961711, 0.04867956, 0.15281763,\n 0.17443605, 0.09166597, 0.09323976])\n\n # robust bse with gmm onestep\n bse_stata = np.array(\n [ 0.33503289, 0.02073947, 0.00488624, 0.0080498 , 0.00946363,\n 0.03371053, 0.03081138, 0.05171372, 0.04981322, 0.0479285 ,\n 0.06112515, 0.0554618 , 0.06084901])\n\n n, k = exog.shape\n nobs, k_instr = instrument.shape\n\n w0inv = np.dot(instrument.T, instrument) / nobs\n w0 = np.linalg.inv(w0inv)\n start = OLS(endog, exog).fit().params\n\n mod = gmm.IVGMM(endog, exog, instrument)\n res = mod.fit(start, maxiter=1, inv_weights=w0inv, optim_method='bfgs', optim_args={'gtol':1e-6, 'disp': 0})", "metadata": "root.test_ivgmm1_stata", "header": "['module', '___EOS___']", "index": 120 }, { "content": " def test_basic(self):\n res1, res2 = self.res1, self.res2\n # test both absolute and relative difference\n assert_allclose(res1.params, res2.params, rtol=5e-4, atol=0)\n assert_allclose(res1.params, res2.params, rtol=0, atol=1e-5)\n\n n = res1.model.exog.shape[0]\n dffac = 1#np.sqrt((n - 1.) / n) # currently different df in cov calculation\n assert_allclose(res1.bse * dffac, res2.HC0_se, rtol=5e-6, atol=0)\n assert_allclose(res1.bse * dffac, res2.HC0_se, rtol=0, atol=1e-7)", "metadata": "root.TestGMMOLS.test_basic", "header": "['class', 'TestGMMOLS', '(', 'object', ')', ':', '___EOS___']", "index": 171 }, { "content": " def test_other(self):\n res1, res2 = self.res1, self.res2", "metadata": "root.TestGMMOLS.test_other", "header": "['class', 'TestGMMOLS', '(', 'object', ')', ':', '___EOS___']", "index": 183 }, { "content": " def test_basic(self):\n res1, res2 = self.res1, self.res2\n # test both absolute and relative difference\n rtol, atol = self.params_tol\n assert_allclose(res1.params, res2.params, rtol=rtol, atol=0)\n assert_allclose(res1.params, res2.params, rtol=0, atol=atol)\n\n n = res1.model.exog.shape[0]\n dffac = 1 #np.sqrt((n - 1.) / n) # currently different df in cov calculation\n rtol, atol = self.bse_tol\n assert_allclose(res1.bse * dffac, res2.bse, rtol=rtol, atol=0)\n assert_allclose(res1.bse * dffac, res2.bse, rtol=0, atol=atol)", "metadata": "root.CheckGMM.test_basic", "header": "['class', 'CheckGMM', '(', 'object', ')', ':', '___EOS___']", "index": 194 }, { "content": " def test_hypothesis(self):\n res1, res2 = self.res1, self.res2\n restriction = np.eye(len(res1.params))\n res_t = res1.t_test(restriction)\n assert_allclose(res_t.tvalue, res1.tvalues, rtol=1e-12, atol=0)\n assert_allclose(res_t.pvalue, res1.pvalues, rtol=1e-12, atol=0)\n rtol, atol = self.bse_tol\n assert_allclose(res_t.tvalue, res2.tvalues, rtol=rtol*10, atol=atol)\n assert_allclose(res_t.pvalue, res2.pvalues, rtol=rtol*10, atol=atol)\n\n res_f = res1.f_test(restriction[:-1]) # without constant\n # comparison with fvalue is not possible, those are not defined\n # assert_allclose(res_f.fvalue, res1.fvalue, rtol=1e-12, atol=0)\n # assert_allclose(res_f.pvalue, res1.f_pvalue, rtol=1e-12, atol=0)\n # assert_allclose(res_f.fvalue, res2.F, rtol=1e-10, atol=0)\n # assert_allclose(res_f.pvalue, res2.Fp, rtol=1e-08, atol=0)\n\n # Smoke test for Wald\n res_wald = res1.wald_test(restriction[:-1])", "metadata": "root.CheckGMM.test_hypothesis", "header": "['class', 'CheckGMM', '(', 'object', ')', ':', '___EOS___']", "index": 214 }, { "content": " def test_bse_other(self):\n res1, res2 = self.res1, self.res2\n # try other versions for bse,\n # TODO: next two produce the same as before (looks like)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=False))))\n #weights=res1.weights))))\n # TODO: doesn't look different\n #assert_allclose(res1.bse, res2.bse, rtol=5e-06, atol=0)\n #nobs = instrument.shape[0]\n #w0inv = np.dot(instrument.T, instrument) / nobs\n q = self.res1.model.gmmobjective(self.res1.params, np.linalg.inv(self.res1.weights))\n #assert_allclose(q, res2.Q, rtol=5e-6, atol=0)", "metadata": "root.TestGMMStOnestep.test_bse_other", "header": "['class', 'TestGMMStOnestep', '(', 'CheckGMM', ')', ':', '___EOS___']", "index": 326 }, { "content": " def test_bse_other(self):\n res1, res2 = self.res1, self.res2\n\n moms = res1.model.momcond(res1.params)\n w = res1.model.calc_weightmatrix(moms)\n # try other versions for bse,\n # TODO: next two produce the same as before (looks like)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=False,\n weights=res1.weights))))\n # TODO: doesn't look different\n #assert_allclose(res1.bse, res2.bse, rtol=5e-06, atol=0)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=False,\n #use_weights=True #weights=w\n ))))\n #assert_allclose(res1.bse, res2.bse, rtol=5e-06, atol=0)\n\n #This doesn't replicate Stata oneway either\n nobs = instrument.shape[0]\n w0inv = np.dot(instrument.T, instrument) / nobs\n q = self.res1.model.gmmobjective(self.res1.params, w)#self.res1.weights)", "metadata": "root.TestGMMStOneiter.test_bse_other", "header": "['class', 'TestGMMStOneiter', '(', 'CheckGMM', ')', ':', '___EOS___']", "index": 385 }, { "content": " def test_basic(self):\n res1, res2 = self.res1, self.res2\n # test both absolute and relative difference\n assert_allclose(res1.params, res2.params, rtol=5e-05, atol=0)\n assert_allclose(res1.params, res2.params, rtol=0, atol=5e-06)\n\n n = res1.model.exog.shape[0]\n # TODO: check df correction np.sqrt(745./758 )*res1.bse matches better\n dffact = np.sqrt(745. / 758 )\n assert_allclose(res1.bse * dffact, res2.bse, rtol=5e-03, atol=0)\n assert_allclose(res1.bse * dffact, res2.bse, rtol=0, atol=5e-03)\n\n # try other versions for bse,\n # TODO: next two produce the same as before (looks like)\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=True,\n weights=res1.weights))))\n assert_allclose(res1.bse, res2.bse, rtol=5e-01, atol=0)\n\n bse = np.sqrt(np.diag((res1._cov_params(has_optimal_weights=True,\n weights=res1.weights,\n use_weights=True))))\n assert_allclose(res1.bse, res2.bse, rtol=5e-02, atol=0)\n\n # TODO: resolve this\n # try bse from previous step, is closer to Stata\n # guess: Stata ivreg2 doesn't calc for bse update after final iteration\n # need better test case, bse difference is close to numerical optimization precision\n assert_allclose(self.res3.bse, res2.bse, rtol=5e-05, atol=0)\n assert_allclose(self.res3.bse, res2.bse, rtol=0, atol=5e-06)\n\n\n\n # TODO; tvalues are not available yet, no inheritance\n #assert_allclose(res1.tvalues, res2.tvalues, rtol=5e-10, atol=0)", "metadata": "root.TestGMMSt2.test_basic", "header": "['class', 'TestGMMSt2', '(', 'object', ')', ':', '___NEWLINE___', '# this looks like an old version, trying out different comparisons', '___NL___', '# of options with Stats', '___NL___', '___EOS___']", "index": 578 }, { "content": " def test_basic(self):\n res1, res2 = self.res1, self.res2\n # test both absolute and relative difference\n assert_allclose(res1.params, res2.params, rtol=1e-9, atol=0)\n assert_allclose(res1.params, res2.params, rtol=0, atol=1e-10)\n\n n = res1.model.exog.shape[0]\n assert_allclose(res1.bse, res2.bse, rtol=1e-10, atol=0)\n assert_allclose(res1.bse, res2.bse, rtol=0, atol=1e-11)\n\n assert_allclose(res1.tvalues, res2.tvalues, rtol=5e-10, atol=0)", "metadata": "root.CheckIV2SLS.test_basic", "header": "['class', 'CheckIV2SLS', '(', 'object', ')', ':', '___EOS___']", "index": 618 }, { "content": " @classmethod\n def setup_class(self):\n exog = exog_st # with const at end\n start = OLS(endog, exog).fit().params\n nobs, k_instr = instrument.shape\n\n mod = gmm.IV2SLS(endog, exog, instrument)\n res = mod.fit()\n self.res1 = res\n\n from .results_ivreg2_griliches import results_small as results\n self.res2 = results", "metadata": "root.TestIV2SLSSt1.setup_class", "header": "['class', 'TestIV2SLSSt1', '(', 'CheckIV2SLS', ')', ':', '___EOS___']", "index": 682 } ]
[ { "span": "n,", "start_line": 89, "start_column": 4, "end_line": 89, "end_column": 5 }, { "span": "k ", "start_line": 89, "start_column": 7, "end_line": 89, "end_column": 8 }, { "span": "n,", "start_line": 99, "start_column": 4, "end_line": 99, "end_column": 5 }, { "span": "k ", "start_line": 99, "start_column": 7, "end_line": 99, "end_column": 8 }, { "span": "params_stata ", "start_line": 123, "start_column": 4, "end_line": 123, "end_column": 16 }, { "span": "bse_stata ", "start_line": 129, "start_column": 4, "end_line": 129, "end_column": 13 }, { "span": "n,", "start_line": 134, "start_column": 4, "end_line": 134, "end_column": 5 }, { "span": "k ", "start_line": 134, "start_column": 7, "end_line": 134, "end_column": 8 }, { "span": "w0 ", "start_line": 138, "start_column": 4, "end_line": 138, "end_column": 6 }, { "span": "res ", "start_line": 142, "start_column": 4, "end_line": 142, "end_column": 7 }, { "span": "n ", "start_line": 177, "start_column": 8, "end_line": 177, "end_column": 9 }, { "span": "res1,", "start_line": 184, "start_column": 8, "end_line": 184, "end_column": 12 }, { "span": "res2 ", "start_line": 184, "start_column": 14, "end_line": 184, "end_column": 18 }, { "span": "n ", "start_line": 201, "start_column": 8, "end_line": 201, "end_column": 9 }, { "span": "res_f ", "start_line": 224, "start_column": 8, "end_line": 224, "end_column": 13 }, { "span": "res_wald ", "start_line": 232, "start_column": 8, "end_line": 232, "end_column": 16 }, { "span": "bse ", "start_line": 330, "start_column": 8, "end_line": 330, "end_column": 11 }, { "span": "q ", "start_line": 336, "start_column": 8, "end_line": 336, "end_column": 9 }, { "span": "bse ", "start_line": 396, "start_column": 8, "end_line": 396, "end_column": 11 }, { "span": "w0inv ", "start_line": 403, "start_column": 8, "end_line": 403, "end_column": 13 }, { "span": "q ", "start_line": 404, "start_column": 8, "end_line": 404, "end_column": 9 }, { "span": "n ", "start_line": 584, "start_column": 8, "end_line": 584, "end_column": 9 }, { "span": "bse ", "start_line": 596, "start_column": 8, "end_line": 596, "end_column": 11 }, { "span": "n ", "start_line": 624, "start_column": 8, "end_line": 624, "end_column": 9 }, { "span": "start ", "start_line": 685, "start_column": 8, "end_line": 685, "end_column": 13 }, { "span": "nobs,", "start_line": 686, "start_column": 8, "end_line": 686, "end_column": 12 }, { "span": "k_instr ", "start_line": 686, "start_column": 14, "end_line": 686, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "iv", "2s", "ls", "\\u", "r_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mod_", "=_", "gmm", "_", "._", "IV", "2", "SL", "S_", "(_", "endo", "g_", ",_", "exo", "g_", ",_", "instrument_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "mod_", "._", "fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", "(", "res", ".", "params", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", "(", "res", ".", "params", " ", "-", " ", "params", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", ",_", "k_", "=_", "exo", "g_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res_", "._", "params_", ",_", "params_", ",_", "rtol_", "=_", "1e-", "7_", ",_", "atol_", "=_", "1e-", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "check", " ", "df", " ", "correction_", "\\u\\u\\uNL\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "res", ".", "bse", " ", "*", " ", "np", ".", "sqrt", "((", "n", " ", "-", " ", "k", ")", " ", "/", " ", "(", "n", " ", "-", " ", "k", " ", "-", " ", "1", ".)", "),", " ", "bse", ",_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res_", "._", "bse", "_", ",_", "bse", "_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "3e", "-", "7_", ")_", "\\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", "iv", "gmm", "0", "\\u", "r_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", ",_", "k_", "=_", "exo", "g_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nob", "s_", ",_", "k", "\\u", "instr_", "=_", "instrument_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "w", "0", "inv_", "=_", "np_", "._", "dot_", "(_", "instrument_", "._", "T_", ",_", "instrument_", ")_", "/_", "nob", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w0_", "=_", "np_", "._", "linalg_", "._", "inv_", "(_", "w", "0", "inv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mod_", "=_", "gmm", "_", "._", "IV", "GM", "M_", "(_", "endo", "g_", ",_", "exo", "g_", ",_", "instrument_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "mod_", "._", "fit_", "(_", "np_", "._", "ones_", "(_", "exo", "g_", "._", "shape_", "[_", "1_", "]_", ",_", "float_", ")_", ",_", "maxiter_", "=_", "0_", ",_", "inv", "\\u", "weights_", "=_", "w", "0", "inv_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "optim", "\\u", "method_", "=_", "'", "bf", "gs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "optim", "\\u", "args_", "=_", "{_", "'", "gto", "l", "'_", ":_", "1e-8_", ",_", "'", "disp", "'_", ":_", "0_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res_", "._", "params_", ",_", "params_", ",_", "rtol_", "=_", "1e-4_", ",_", "atol_", "=_", "1e-4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", ":", " ", "res", ".", "bse", " ", "and", " ", "bse", " ", "are", " ", "not", " ", "the", " ", "same", ",", " ", "rto", "l", "=", "0.09", " ", "is", " ", "large", " ", "in", " ", "this", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "#", "res", ".", "bse", " ", "is", " ", "still", " ", "robust", "?", ",", " ", "bse", " ", "is", " ", "not", " ", "a", " ", "sand", "wic", "h", " ", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res_", "._", "bse", "_", ",_", "bse", "_", ",_", "rtol_", "=_", "0.09", "_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "score_", "=_", "res_", "._", "model_", "._", "score_", "(_", "res_", "._", "params_", ",_", "w0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "score_", ",_", "np_", "._", "zeros_", "(_", "score_", "._", "shape_", ")_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "5e-", "6_", ")_", "#", " ", "atol", "=", "1e-", "8", ")", " ", "??", "_", "\\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", "iv", "gmm", "1", "\\u", "stat", "a_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "copie", "d", " ", "constant", " ", "to", " ", "the", " ", "beginn", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params", "\\u", "stat", "a_", "=_", "np_", "._", "array_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "4.0", "335", "099", "_", ",_", "0.17", "242", "531", "_", ",_", "-_", "0.009", "098", "83_", ",_", "0.04", "928", "949", "_", ",_", "0.04", "221", "709", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "-_", "0.10", "179", "345", "_", ",_", "0.12", "611", "095", "_", ",_", "-_", "0.05", "961", "711", "_", ",_", "0.04", "867", "956", "_", ",_", "0.15", "281", "763", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0.17", "443", "605", "_", ",_", "0.09", "166", "597", "_", ",_", "0.09", "323", "976", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "robust", " ", "bse", " ", "with", " ", "gmm", " ", "ones", "tep_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "\\u", "stat", "a_", "=_", "np_", "._", "array_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "0.33", "503", "289", "_", ",_", "0.02", "073", "947", "_", ",_", "0.004", "886", "24_", ",_", "0.008", "049", "8_", ",_", "0.009", "463", "63_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0.033", "710", "53_", ",_", "0.03", "081", "138_", ",_", "0.05", "171", "372", "_", ",_", "0.04", "981", "322", "_", ",_", "0.04", "792", "85_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0.06", "112", "515", "_", ",_", "0.05", "546", "18_", ",_", "0.06", "084", "901", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", ",_", "k_", "=_", "exo", "g_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nob", "s_", ",_", "k", "\\u", "instr_", "=_", "instrument_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "w", "0", "inv_", "=_", "np_", "._", "dot_", "(_", "instrument_", "._", "T_", ",_", "instrument_", ")_", "/_", "nob", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w0_", "=_", "np_", "._", "linalg_", "._", "inv_", "(_", "w", "0", "inv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "OL", "S_", "(_", "endo", "g_", ",_", "exo", "g_", ")_", "._", "fit_", "(_", ")_", "._", "params_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mod_", "=_", "gmm", "_", "._", "IV", "GM", "M_", "(_", "endo", "g_", ",_", "exo", "g_", ",_", "instrument_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "mod_", "._", "fit_", "(_", "start_", ",_", "maxiter_", "=_", "1_", ",_", "inv", "\\u", "weights_", "=_", "w", "0", "inv_", ",_", "optim", "\\u", "method_", "=_", "'", "bf", "gs", "'_", ",_", "optim", "\\u", "args_", "=_", "{_", "'", "gto", "l", "'_", ":_", "1e-6_", ",_", "'", "disp", "'_", ":_", "0_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "GM", "MOL", "S_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "basic_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "bot", "h", " ", "abs", "olute", " ", "and", " ", "relative", " ", "difference_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "5e-", "4_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "1e-5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", "=_", "res1_", "._", "model_", "._", "exo", "g_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dff", "ac_", "=_", "1_", "#", "np", ".", "sqrt", "((", "n", " ", "-", " ", "1", ".)", " ", "/", " ", "n", ")", " ", " ", " ", "#", " ", "currentl", "y", " ", "different", " ", "df", " ", "in", " ", "cov", " ", "calculati", "on_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "ac_", ",_", "res2_", "._", "HC", "0", "\\u", "se_", ",_", "rtol_", "=_", "5e-", "6_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "ac_", ",_", "res2_", "._", "HC", "0", "\\u", "se_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "1e-", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "GM", "MOL", "S_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "other_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "GM", "M_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "basic_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "bot", "h", " ", "abs", "olute", " ", "and", " ", "relative", " ", "difference_", "\\u\\u\\uNL\\u\\u\\u_", "rtol_", ",_", "atol_", "=_", "self_", "._", "params", "\\u", "tol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "rtol_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "atol_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", "=_", "res1_", "._", "model_", "._", "exo", "g_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dff", "ac_", "=_", "1_", "#", "np", ".", "sqrt", "((", "n", " ", "-", " ", "1", ".)", " ", "/", " ", "n", ")", " ", " ", " ", "#", " ", "currentl", "y", " ", "different", " ", "df", " ", "in", " ", "cov", " ", "calculati", "on_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtol_", ",_", "atol_", "=_", "self_", "._", "bse", "\\u", "tol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "ac_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "rtol_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "ac_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "atol_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Check", "GM", "M_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "hypothesis", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "restriction", "_", "=_", "np_", "._", "eye_", "(_", "len_", "(_", "res1_", "._", "params_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res", "\\u", "t_", "=_", "res1_", "._", "t", "\\u", "test_", "(_", "restriction", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res", "\\u", "t_", "._", "tval", "ue_", ",_", "res1_", "._", "tval", "ues_", ",_", "rtol_", "=_", "1e-12_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res", "\\u", "t_", "._", "pvalue_", ",_", "res1_", "._", "pvalue", "s_", ",_", "rtol_", "=_", "1e-12_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rtol_", ",_", "atol_", "=_", "self_", "._", "bse", "\\u", "tol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res", "\\u", "t_", "._", "tval", "ue_", ",_", "res2_", "._", "tval", "ues_", ",_", "rtol_", "=_", "rtol_", "*_", "10_", ",_", "atol_", "=_", "atol_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res", "\\u", "t_", "._", "pvalue_", ",_", "res2_", "._", "pvalue", "s_", ",_", "rtol_", "=_", "rtol_", "*_", "10_", ",_", "atol_", "=_", "atol_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res", "\\u", "f_", "=_", "res1_", "._", "f", "\\u", "test_", "(_", "restriction", "_", "[_", ":_", "-_", "1_", "]_", ")_", "#", " ", "with", "out", " ", "constant_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "compa", "ris", "on", " ", "with", " ", "fval", "ue", " ", "is", " ", "not", " ", "possib", "le", ",", " ", "tho", "se", " ", "are", " ", "not", " ", "defined_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "assert", "\\u", "allc", "lose", "(", "res", "\\u", "f", ".", "fval", "ue", ",", " ", "res", "1", ".", "fval", "ue", ",", " ", "rto", "l", "=", "1e-1", "2", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "assert", "\\u", "allc", "lose", "(", "res", "\\u", "f", ".", "pvalue", ",", " ", "res", "1", ".", "f", "\\u", "pvalue", ",", " ", "rto", "l", "=", "1e-1", "2", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "assert", "\\u", "allc", "lose", "(", "res", "\\u", "f", ".", "fval", "ue", ",", " ", "res", "2", ".", "F", ",", " ", "rto", "l", "=", "1e-1", "0", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "assert", "\\u", "allc", "lose", "(", "res", "\\u", "f", ".", "pvalue", ",", " ", "res", "2", ".", "Fp", ",", " ", "rto", "l", "=", "1e-0", "8", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Smo", "ke", " ", "test", " ", "for", " ", "Wal", "d_", "\\u\\u\\uNL\\u\\u\\u_", "res", "\\u", "wal", "d_", "=_", "res1_", "._", "wal", "d\\u", "test_", "(_", "restriction", "_", "[_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "GM", "MS", "t", "One", "step_", "(_", "Check", "GM", "M_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "bse", "\\u", "other_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "try", " ", "other", " ", "version", "s", " ", "for", " ", "bse", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "next", " ", "two", " ", "produce", " ", "the", " ", "same", " ", "as", " ", "bef", "ore", " ", "(", "look", "s", " ", "like", ")_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "_", "=_", "np_", "._", "sqrt_", "(_", "np_", "._", "diag_", "(_", "(_", "res1_", "._", "\\u", "cov", "\\u", "params_", "(_", "has", "\\u", "optim", "al", "\\u", "weights_", "=_", "False_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "weight", "s", "=", "res", "1", ".", "weight", "s", "))))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "doe", "sn", "'", "t", " ", "look", " ", "different", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "res", "1", ".", "bse", ",", " ", "res", "2", ".", "bse", ",", " ", "rto", "l", "=", "5e-0", "6", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "nob", "s", " ", "=", " ", "instrument", ".", "shape", "[", "0", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", "w", "0", "inv", " ", "=", " ", "np", ".", "dot", "(", "instrument", ".", "T", ",", " ", "instrument", ")", " ", "/", " ", "nob", "s_", "\\u\\u\\uNL\\u\\u\\u_", "q_", "=_", "self_", "._", "res1_", "._", "model_", "._", "gmm", "objective_", "(_", "self_", "._", "res1_", "._", "params_", ",_", "np_", "._", "linalg_", "._", "inv_", "(_", "self_", "._", "res1_", "._", "weights_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "q", ",", " ", "res", "2", ".", "Q", ",", " ", "rto", "l", "=", "5e-", "6", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "GM", "MS", "t", "One", "iter_", "(_", "Check", "GM", "M_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "bse", "\\u", "other_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mom", "s_", "=_", "res1_", "._", "model_", "._", "mom", "cond_", "(_", "res1_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", "=_", "res1_", "._", "model_", "._", "calc", "\\u", "weight", "matrix_", "(_", "mom", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "try", " ", "other", " ", "version", "s", " ", "for", " ", "bse", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "next", " ", "two", " ", "produce", " ", "the", " ", "same", " ", "as", " ", "bef", "ore", " ", "(", "look", "s", " ", "like", ")_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "_", "=_", "np_", "._", "sqrt_", "(_", "np_", "._", "diag_", "(_", "(_", "res1_", "._", "\\u", "cov", "\\u", "params_", "(_", "has", "\\u", "optim", "al", "\\u", "weights_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "weights_", "=_", "res1_", "._", "weights_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "doe", "sn", "'", "t", " ", "look", " ", "different", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "res", "1", ".", "bse", ",", " ", "res", "2", ".", "bse", ",", " ", "rto", "l", "=", "5e-0", "6", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "_", "=_", "np_", "._", "sqrt_", "(_", "np_", "._", "diag_", "(_", "(_", "res1_", "._", "\\u", "cov", "\\u", "params_", "(_", "has", "\\u", "optim", "al", "\\u", "weights_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "use", "\\u", "weight", "s", "=", "Tru", "e", " ", "#", "weight", "s", "=", "w_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "res", "1", ".", "bse", ",", " ", "res", "2", ".", "bse", ",", " ", "rto", "l", "=", "5e-0", "6", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Thi", "s", " ", "doe", "sn", "'", "t", " ", "replicate", " ", "Stat", "a", " ", "one", "way", " ", "eit", "her_", "\\u\\u\\uNL\\u\\u\\u_", "nob", "s_", "=_", "instrument_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "0", "inv_", "=_", "np_", "._", "dot_", "(_", "instrument_", "._", "T_", ",_", "instrument_", ")_", "/_", "nob", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "self_", "._", "res1_", "._", "model_", "._", "gmm", "objective_", "(_", "self_", "._", "res1_", "._", "params_", ",_", "w_", ")_", "#", "self", ".", "res", "1", ".", "weight", "s", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "GM", "MS", "t2_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "look", "s", " ", "like", " ", "an", " ", "old", " ", "version", ",", " ", "try", "ing", " ", "out", " ", "different", " ", "comparisons", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "options", " ", "with", " ", "Stats_", "\\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_", "test\\u", "basic_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "bot", "h", " ", "abs", "olute", " ", "and", " ", "relative", " ", "difference_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "5e-0", "5_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "5e-0", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", "=_", "res1_", "._", "model_", "._", "exo", "g_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "check", " ", "df", " ", "correcti", "on", " ", "np", ".", "sqrt", "(", "745", "./", "758", " ", ")*", "res", "1", ".", "bse", " ", "matche", "s", " ", "bett", "er_", "\\u\\u\\uNL\\u\\u\\u_", "dff", "act_", "=_", "np_", "._", "sqrt_", "(_", "745", "._", "/_", "758", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "act_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "5e-0", "3_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", "*_", "dff", "act_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "5e-0", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "other", " ", "version", "s", " ", "for", " ", "bse", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "next", " ", "two", " ", "produce", " ", "the", " ", "same", " ", "as", " ", "bef", "ore", " ", "(", "look", "s", " ", "like", ")_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "_", "=_", "np_", "._", "sqrt_", "(_", "np_", "._", "diag_", "(_", "(_", "res1_", "._", "\\u", "cov", "\\u", "params_", "(_", "has", "\\u", "optim", "al", "\\u", "weights_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "weights_", "=_", "res1_", "._", "weights_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "5e-0", "1_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bse", "_", "=_", "np_", "._", "sqrt_", "(_", "np_", "._", "diag_", "(_", "(_", "res1_", "._", "\\u", "cov", "\\u", "params_", "(_", "has", "\\u", "optim", "al", "\\u", "weights_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "weights_", "=_", "res1_", "._", "weights_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "weights_", "=_", "True_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "5e-0", "2_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "resolve", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "bse", " ", "from", " ", "previ", "ous", " ", "step", ",", " ", "is", " ", "close", "r", " ", "to", " ", "Stat", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "guess", ":", " ", "Stat", "a", " ", "iv", "reg", "2", " ", "doe", "sn", "'", "t", " ", "calc", " ", "for", " ", "bse", " ", "update", " ", "after", " ", "final", " ", "iteration_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", " ", "bett", "er", " ", "test", " ", "case", ",", " ", "bse", " ", "difference", " ", "is", " ", "close", " ", "to", " ", "numerical", " ", "optimization", " ", "precision_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "self_", "._", "res", "3_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "5e-0", "5_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "self_", "._", "res", "3_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "5e-0", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ";", " ", "tval", "ues", " ", "are", " ", "not", " ", "avail", "able", " ", "ye", "t", ",", " ", "no", " ", "inherita", "nce_", "\\u\\u\\uNL\\u\\u\\u_", "#", "assert", "\\u", "allc", "lose", "(", "res", "1", ".", "tval", "ues", ",", " ", "res", "2", ".", "tval", "ues", ",", " ", "rto", "l", "=", "5e-", "10", ",", " ", "atol", "=", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Check", "IV", "2", "SL", "S_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "basic_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res1_", ",_", "res2_", "=_", "self_", "._", "res1_", ",_", "self_", "._", "res2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "bot", "h", " ", "abs", "olute", " ", "and", " ", "relative", " ", "difference_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "1e-", "9_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "params_", ",_", "res2_", "._", "params_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "1e-10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", "=_", "res1_", "._", "model_", "._", "exo", "g_", "._", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "1e-10_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "bse", "_", ",_", "res2_", "._", "bse", "_", ",_", "rtol_", "=_", "0_", ",_", "atol_", "=_", "1e-1", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "allclose_", "(_", "res1_", "._", "tval", "ues_", ",_", "res2_", "._", "tval", "ues_", ",_", "rtol_", "=_", "5e-", "10_", ",_", "atol_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "IV", "2", "SL", "SS", "t1_", "(_", "Check", "IV", "2", "SL", "S_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup", "\\u", "class_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exo", "g_", "=_", "exo", "g", "\\u", "st_", "#", " ", "with", " ", "const", " ", "at", " ", "end_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "OL", "S_", "(_", "endo", "g_", ",_", "exo", "g_", ")_", "._", "fit_", "(_", ")_", "._", "params_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nob", "s_", ",_", "k", "\\u", "instr_", "=_", "instrument_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mod_", "=_", "gmm", "_", "._", "IV", "2", "SL", "S_", "(_", "endo", "g_", ",_", "exo", "g_", ",_", "instrument_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "mod_", "._", "fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "res1_", "=_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "results", "\\u", "iv", "reg", "2", "\\u", "gri", "lic", "hes", "_", "import_", "results", "\\u", "small_", "as_", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "res2_", "=_", "results_" ]
[ 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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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, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 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 ]
Unused import
lorien/grab/test/grab_deprecated.py
[ { "content": "# coding: utf-8\nfrom weblib.etree import parse_html\nfrom weblib.error import DataNotFound\nfrom grab.error import GrabMisuseError\nfrom tempfile import mkstemp\nimport os\nimport re\n\nfrom test.util import build_grab\nfrom test.util import BaseGrabTestCase\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class GrabApiTestCase(BaseGrabTestCase):\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.GrabApiTestCase", "header": "['module', '___EOS___']", "index": 12 }, { "content": " def setUp(self):\n self.server.reset()", "metadata": "root.GrabApiTestCase.setUp", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 13 }, { "content": " def test_choose_form_by_element(self):\n data = b'''\n <form><input name=\"foo\"></form>\n <form><input name=\"bar\"></form>\n '''\n g = build_grab(data)\n g.choose_form_by_element('//input[@name=\"bar\"]')\n self.assertEqual(\n g.doc('//form[2]').node(),\n g.doc.form)", "metadata": "root.GrabApiTestCase.test_choose_form_by_element", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 16 }, { "content": " def test_choose_form_by_element_noform(self):\n data = b'''\n <div>test</div>\n '''\n g = build_grab(data)\n self.assertRaises(DataNotFound, g.choose_form_by_element,\n '//input[@name=\"bar\"]')", "metadata": "root.GrabApiTestCase.test_choose_form_by_element_noform", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 27 }, { "content": " def test_form_fields(self):\n data = b'''\n <form>\n <input value=\"foo\">\n <input name=\"dis\" disabled=\"disabled\" value=\"diz\">\n <select name=\"sel\">\n <option value=\"opt1\">opt1</option)\n <option value=\"opt2\">opt2</option)\n </select>\n <input type=\"radio\" name=\"rad1\" value=\"rad1\"> \n <input type=\"checkbox\" name=\"cb1\" value=\"cb1\"> \n <input type=\"checkbox\" name=\"cb2\" value=\"cb2\" checked=\"checked\"> \n <input type=\"text\" name=\"text1\" value=\"text1\">\n <textarea name=\"area1\">area1</textarea>\n </form>\n '''\n g = build_grab(data)\n fields = {\n 'sel': 'opt1',\n 'rad1': 'rad1',\n 'cb2': 'cb2',\n 'text1': 'text1',\n 'area1': 'area1',\n }\n self.assertEqual(fields, g.form_fields())", "metadata": "root.GrabApiTestCase.test_form_fields", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 35 }, { "content": " def test_submit(self):\n data = b'''<form method=\"post\">\n <input type=\"text\" name=\"foo\" value=\"val\"></form>'''\n g = build_grab(data)\n g.choose_form(0)\n g.submit(make_request=False)\n self.assertTrue('foo' in dict(g.config['post']))", "metadata": "root.GrabApiTestCase.test_submit", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 61 }, { "content": " def test_set_input_methods(self):\n data = b'''<form><input type=\"text\" id=\"f\" name=\"foo\" value=\"val\">\n </form>'''\n g = build_grab(data)\n g.set_input_by_id('f', 'new')\n self.assertEqual(g.doc('//input/@value').text(), 'new')\n g.set_input_by_number(0, 'new2')\n self.assertEqual(g.doc('//input/@value').text(), 'new2')\n g.set_input_by_xpath('//input[@name=\"foo\"]', 'new3')\n self.assertEqual(g.doc('//input/@value').text(), 'new3')\n g.set_input('foo', 'new4')\n self.assertEqual(g.doc('//input/@value').text(), 'new4')", "metadata": "root.GrabApiTestCase.test_set_input_methods", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 69 }, { "content": " def test_form(self):\n data = b'''<form><input type=\"text\" id=\"f\" name=\"foo\" value=\"val\">\n </form>'''\n g = build_grab(data)\n self.assertEqual(g.doc('//form').node(), g.form)", "metadata": "root.GrabApiTestCase.test_form", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 82 }, { "content": " def test_load_proxylist_text_file(self):\n fh, path = mkstemp()\n with open(path, 'w') as out:\n out.write('1.1.1.1:8080')\n g = build_grab()\n g.load_proxylist(path, 'text_file', auto_init=True, auto_change=False)\n self.assertEqual(g.config['proxy'], '1.1.1.1:8080')\n os.unlink(path)", "metadata": "root.GrabApiTestCase.test_load_proxylist_text_file", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 88 }, { "content": " def test_load_proxylist_url(self):\n self.server.response['data'] = b'1.1.1.1:9090'\n g = build_grab()\n g.load_proxylist(self.server.get_url(), 'url',\n auto_init=True, auto_change=False)\n self.assertEqual(g.config['proxy'], '1.1.1.1:9090')", "metadata": "root.GrabApiTestCase.test_load_proxylist_url", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 97 }, { "content": " def test_load_proxylist_invalid_input(self):\n g = build_grab()\n self.assertRaises(GrabMisuseError, g.load_proxylist,\n None, 'zzz')", "metadata": "root.GrabApiTestCase.test_load_proxylist_invalid_input", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 104 }, { "content": " def test_response_property(self):\n g = build_grab()\n self.assertEqual(g.response, g.doc)\n g.response = g.doc\n self.assertEqual(g.response, g.doc)", "metadata": "root.GrabApiTestCase.test_response_property", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 109 }, { "content": " def test_pyquery(self):\n data = b'''<form><input type=\"text\" id=\"f\" name=\"foo\" value=\"val\">\n </form>'''\n g = build_grab(data)\n self.assertEqual(g.doc('//input').node().value,\n g.pyquery('input')[0].value)", "metadata": "root.GrabApiTestCase.test_pyquery", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 115 }, { "content": " def test_assert_xpath(self):\n data = b'''<h1>tet</h1>'''\n g = build_grab(data)\n g.assert_xpath('//h1')\n self.assertRaises(DataNotFound, g.assert_xpath, '//h2')", "metadata": "root.GrabApiTestCase.test_assert_xpath", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 122 }, { "content": " def test_assert_css(self):\n data = b'''<h1>tet</h1>'''\n g = build_grab(data)\n g.assert_css('h1')\n self.assertRaises(DataNotFound, g.assert_css, 'h2')", "metadata": "root.GrabApiTestCase.test_assert_css", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 128 }, { "content": " def test_deprecated_filter_argument(self):\n data = b'''<h1>tet</h1>'''\n g = build_grab(data)\n self.assertRaises(GrabMisuseError, g.xpath_number, '//h1',\n filter=lambda: True)\n self.assertRaises(GrabMisuseError, g.xpath_text, '//h1',\n filter=lambda: True)\n self.assertRaises(GrabMisuseError, g.xpath_list, '//h1',\n filter=lambda: True)\n self.assertRaises(GrabMisuseError, g.xpath_one, '//h1',\n filter=lambda: True)\n self.assertRaises(GrabMisuseError, g.xpath, '//h1',\n filter=lambda: True)", "metadata": "root.GrabApiTestCase.test_deprecated_filter_argument", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 134 }, { "content": " def test_css(self):\n data = b'''<h1>tet</h1>'''\n g = build_grab(data)\n self.assertEqual(g.doc('//h1').node(), g.css('h1'))", "metadata": "root.GrabApiTestCase.test_css", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 148 }, { "content": " def test_xpath(self):\n data = b'''<h1>tet</h1>'''\n g = build_grab(data)\n self.assertEqual(g.doc('//h1').node(), g.xpath('//h1'))", "metadata": "root.GrabApiTestCase.test_xpath", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 153 }, { "content": " def test_find_link_rex(self):\n data = b'''<a href=\"http://ya.ru/\">ya.ru</a>'''\n g = build_grab(data)\n self.assertEqual('http://ya.ru/',\n g.find_link_rex(re.compile('ya\\.ru'),\n make_absolute=True))\n self.assertEqual(None,\n g.find_link_rex(re.compile('google\\.ru'),\n make_absolute=True))", "metadata": "root.GrabApiTestCase.test_find_link_rex", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 158 }, { "content": " def test_find_link(self):\n data = b'''<a href=\"http://ya.ru/\">ya.ru</a>'''\n g = build_grab(data)\n self.assertEqual('http://ya.ru/',\n g.find_link(b'ya.ru',\n make_absolute=True))\n self.assertEqual(None,\n g.find_link(b'google.ru',\n make_absolute=True))\n self.assertRaises(GrabMisuseError, g.find_link,\n u'asdf')", "metadata": "root.GrabApiTestCase.test_find_link", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 168 }, { "content": " def test_build_html_tree(self):\n data = b'<div>test</div>'\n g = build_grab(data)\n self.assertEqual(g.doc.tree, g.build_html_tree())", "metadata": "root.GrabApiTestCase.test_build_html_tree", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 180 }, { "content": " def test_build_xml_tree(self):\n data = b'<div>test</div>'\n g = build_grab(data, content_type='xml')\n self.assertEqual(g.doc.tree, g.build_xml_tree())", "metadata": "root.GrabApiTestCase.test_build_xml_tree", "header": "['class', 'GrabApiTestCase', '(', 'BaseGrabTestCase', ')', ':', '___EOS___']", "index": 185 } ]
[ { "span": "from weblib.etree import parse_html", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 35 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "codi", "ng", ":", " ", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "web", "lib_", "._", "etree_", "import_", "parse", "\\u", "html_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "web", "lib_", "._", "error_", "import_", "Data", "Not", "Found_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "grab_", "._", "error_", "import_", "Grab", "Mis", "use", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tempfile_", "import_", "mkstemp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "test_", "._", "util_", "import_", "build", "\\u", "grab_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "test_", "._", "util_", "import_", "Base", "Grab", "Test", "Case_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "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_", "\\u\\u\\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_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\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 ", " _", "self_", "._", "server_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "choose", "\\u", "form", "\\u", "by", "\\u", "element_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "\\", "10", ";", " ", " ", " ", " ", "<", "form", "><", "input", " ", "name", "=\"", "foo", "\">", "</", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "form", "><", "input", " ", "name", "=\"", "bar", "\">", "</", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "choose", "\\u", "form", "\\u", "by", "\\u", "element_", "(_", "'//", "input", "[", "@", "name", "=\"", "bar", "\"]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "doc_", "(_", "'//", "form", "[", "2", "]'_", ")_", "._", "node_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "doc_", "._", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "choose", "\\u", "form", "\\u", "by", "\\u", "element", "\\u", "nofo", "rm_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "\\", "10", ";", " ", " ", " ", " ", "<", "div", ">", "test", "</", "div", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Data", "Not", "Found_", ",_", "g_", "._", "choose", "\\u", "form", "\\u", "by", "\\u", "element_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'//", "input", "[", "@", "name", "=\"", "bar", "\"]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "form", "\\u", "fields_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "\\", "10", ";", " ", " ", " ", " ", "<", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "value", "=\"", "foo", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "name", "=\"", "dis", "\"", " ", "disable", "d", "=\"", "disable", "d", "\"", " ", "value", "=\"", "di", "z", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "select", " ", "name", "=\"", "sel", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "option", " ", "value", "=\"", "opt", "1", "\">", "opt", "1", "</", "option", ")", "\\", "10", ";", " ", " ", " ", " ", "<", "option", " ", "value", "=\"", "opt", "2", "\">", "opt", "2", "</", "option", ")", "\\", "10", ";", " ", " ", " ", " ", "</", "select", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "radio", "\"", " ", "name", "=\"", "rad", "1", "\"", " ", "value", "=\"", "rad", "1", "\">", " ", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "checkb", "ox", "\"", " ", "name", "=\"", "cb", "1", "\"", " ", "value", "=\"", "cb", "1", "\">", " ", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "checkb", "ox", "\"", " ", "name", "=\"", "cb", "2", "\"", " ", "value", "=\"", "cb", "2", "\"", " ", "checke", "d", "=\"", "checke", "d", "\">", " ", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "text1", "\"", " ", "value", "=\"", "text1", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "text", "area", " ", "name", "=\"", "area", "1", "\">", "area", "1", "</", "text", "area", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sel", "'_", ":_", "'", "opt", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rad", "1", "'_", ":_", "'", "rad", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "cb", "2", "'_", ":_", "'", "cb", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text1", "'_", ":_", "'", "text1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "area", "1", "'_", ":_", "'", "area", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "fields_", ",_", "g_", "._", "form", "\\u", "fields_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "submit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "form", " ", "method", "=\"", "post", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "val", "\">", "</", "form", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "choose", "\\u", "form_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "submit_", "(_", "make", "\\u", "request_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "foo", "'_", "in_", "dict_", "(_", "g_", "._", "config_", "[_", "'", "post", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "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", "input", "\\u", "methods_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "form", "><", "input", " ", "type", "=\"", "text", "\"", " ", "id", "=\"", "f", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "val", "\">", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "set\\u", "input", "\\u", "by", "\\u", "id_", "(_", "'", "f", "'_", ",_", "'", "new", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "input", "/", "@", "value", "'_", ")_", "._", "text_", "(_", ")_", ",_", "'", "new", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "set\\u", "input", "\\u", "by", "\\u", "number_", "(_", "0_", ",_", "'", "new", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "input", "/", "@", "value", "'_", ")_", "._", "text_", "(_", ")_", ",_", "'", "new", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "set\\u", "input", "\\u", "by", "\\u", "xpath_", "(_", "'//", "input", "[", "@", "name", "=\"", "foo", "\"]'_", ",_", "'", "new", "3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "input", "/", "@", "value", "'_", ")_", "._", "text_", "(_", ")_", ",_", "'", "new", "3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "set\\u", "input_", "(_", "'", "foo", "'_", ",_", "'", "new", "4", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "input", "/", "@", "value", "'_", ")_", "._", "text_", "(_", ")_", ",_", "'", "new", "4", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "form_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "form", "><", "input", " ", "type", "=\"", "text", "\"", " ", "id", "=\"", "f", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "val", "\">", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "form", "'_", ")_", "._", "node_", "(_", ")_", ",_", "g_", "._", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "proxy", "list", "\\u", "text", "\\u", "file_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fh_", ",_", "path_", "=_", "mkstemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "path_", ",_", "'", "w", "'_", ")_", "as_", "out_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "out_", "._", "write_", "(_", "'", "1.1", ".1", ".1", ":", "808", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "load", "\\u", "proxy", "list_", "(_", "path_", ",_", "'", "text", "\\u", "file", "'_", ",_", "auto", "\\u", "init_", "=_", "True_", ",_", "auto", "\\u", "change_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "config_", "[_", "'", "proxy", "'_", "]_", ",_", "'", "1.1", ".1", ".1", ":", "808", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "unlink_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "proxy", "list", "\\u", "url_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server_", "._", "response_", "[_", "'", "data", "'_", "]_", "=_", "b", "'", "1.1", ".1", ".1", ":", "9090", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "load", "\\u", "proxy", "list_", "(_", "self_", "._", "server_", "._", "get", "\\u", "url_", "(_", ")_", ",_", "'", "url", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "auto", "\\u", "init_", "=_", "True_", ",_", "auto", "\\u", "change_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "config_", "[_", "'", "proxy", "'_", "]_", ",_", "'", "1.1", ".1", ".1", ":", "9090", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "load", "\\u", "proxy", "list", "\\u", "invalid", "\\u", "input_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "g_", "=_", "build", "\\u", "grab_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "load", "\\u", "proxy", "list_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "'", "zzz", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "response", "\\u", "property_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "g_", "=_", "build", "\\u", "grab_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "response_", ",_", "g_", "._", "doc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "response_", "=_", "g_", "._", "doc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "response_", ",_", "g_", "._", "doc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "pyq", "uery_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "form", "><", "input", " ", "type", "=\"", "text", "\"", " ", "id", "=\"", "f", "\"", " ", "name", "=\"", "foo", "\"", " ", "value", "=\"", "val", "\">", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "input", "'_", ")_", "._", "node_", "(_", ")_", "._", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "pyq", "uery_", "(_", "'", "input", "'_", ")_", "[_", "0_", "]_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "assert", "\\u", "xpath_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "h1", ">", "tet", "</", "h1", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "assert", "\\u", "xpath_", "(_", "'//", "h1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Data", "Not", "Found_", ",_", "g_", "._", "assert", "\\u", "xpath_", ",_", "'//", "h2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "assert", "\\u", "css_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "h1", ">", "tet", "</", "h1", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "._", "assert", "\\u", "css_", "(_", "'", "h1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Data", "Not", "Found_", ",_", "g_", "._", "assert", "\\u", "css_", ",_", "'", "h2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "depre", "cated", "\\u", "filter", "\\u", "argument_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "h1", ">", "tet", "</", "h1", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "xpa", "th", "\\u", "number_", ",_", "'//", "h1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "filter_", "=_", "lambda_", ":_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "xpa", "th", "\\u", "text_", ",_", "'//", "h1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "filter_", "=_", "lambda_", ":_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "xpa", "th", "\\u", "list_", ",_", "'//", "h1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "filter_", "=_", "lambda_", ":_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "xpa", "th", "\\u", "one_", ",_", "'//", "h1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "filter_", "=_", "lambda_", ":_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "xpath_", ",_", "'//", "h1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "filter_", "=_", "lambda_", ":_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "css_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "h1", ">", "tet", "</", "h1", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "h1", "'_", ")_", "._", "node_", "(_", ")_", ",_", "g_", "._", "css_", "(_", "'", "h1", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "xpath_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "h1", ">", "tet", "</", "h1", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "(_", "'//", "h1", "'_", ")_", "._", "node_", "(_", ")_", ",_", "g_", "._", "xpath_", "(_", "'//", "h1", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "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", "link", "\\u", "rex", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "a", " ", "href", "=\"", "http", "://", "ya", ".", "ru", "/\"", ">", "ya", ".", "ru", "</", "a", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "http", "://", "ya", ".", "ru", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "find", "\\u", "link", "\\u", "rex", "_", "(_", "re_", "._", "compile_", "(_", "'", "ya", "\\\\.", "ru", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "absolute_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "find", "\\u", "link", "\\u", "rex", "_", "(_", "re_", "._", "compile_", "(_", "'", "google", "\\\\.", "ru", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "absolute_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "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", "link_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'''", "<", "a", " ", "href", "=\"", "http", "://", "ya", ".", "ru", "/\"", ">", "ya", ".", "ru", "</", "a", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "'", "http", "://", "ya", ".", "ru", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "find", "\\u", "link_", "(_", "b", "'", "ya", ".", "ru", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "absolute_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "._", "find", "\\u", "link_", "(_", "b", "'", "google", ".", "ru", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "\\u", "absolute_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Grab", "Mis", "use", "Error_", ",_", "g_", "._", "find", "\\u", "link_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "asd", "f", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "build", "\\u", "html", "\\u", "tree_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'<", "div", ">", "test", "</", "div", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "._", "tree_", ",_", "g_", "._", "build", "\\u", "html", "\\u", "tree_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grab", "Ap", "i", "Test", "Case_", "(_", "Base", "Grab", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "build", "\\u", "xml", "\\u", "tree_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "b", "'<", "div", ">", "test", "</", "div", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "build", "\\u", "grab_", "(_", "data_", ",_", "content", "\\u", "type_", "=_", "'", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "g_", "._", "doc_", "._", "tree_", ",_", "g_", "._", "build", "\\u", "xml", "\\u", "tree_", "(_", ")_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 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, 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, 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, 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 ]
Unused import
aldebaran/qibuild/python/qibuild/test/test_qibuild_python.py
[ { "content": "## Copyright (c) 2012-2016 Aldebaran Robotics. All rights reserved.\n## Use of this source code is governed by a BSD-style license that can be\n## found in the COPYING file.\n\n\"\"\" Finding a Python qimodule from C++\n\nThis is higly libqi specific\n\n\"\"\"\nimport os\n\nimport qisys.sh\n\nfrom qipy.test.conftest import qipy_action\nfrom qitest.test.conftest import qitest_action\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_finding_qi_python_modules(qipy_action, qibuild_action, qitest_action):\n qipy_action.add_test_project(\"foomodules\")\n # Need to have qibuild inside the virtualenv for\n # qipy run -- qitest run to work\n this_dir = os.path.dirname(__file__)\n top_dir = os.path.join(this_dir, \"..\", \"..\", \"..\")\n qipy_action.worktree.add_project(top_dir)\n\n # Hack to make the worktree inside qibuild_action aware\n # that there are python projects registered\n worktree = qibuild_action.build_worktree.worktree\n worktree.reload()\n\n project = qibuild_action.add_test_project(\"usefoopymodule\")\n\n qipy_action(\"bootstrap\")\n with qisys.sh.change_cwd(project.path):\n qibuild_action(\"configure\")\n qipy_action(\"run\", \"--no-exec\", \"--\", \"qitest\", \"run\")", "metadata": "root.test_finding_qi_python_modules", "header": "['module', '___EOS___']", "index": 16 } ]
[ { "span": "from qipy.test.conftest import qipy_action", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 42 }, { "span": "from qitest.test.conftest import qitest_action", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 46 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "##", " ", "Copy", "right", " ", "(", "c", ")", " ", "2012", "-", "2016", " ", "Al", "deb", "aran", " ", "Robot", "ics", ".", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Us", "e", " ", "of", " ", "this", " ", "source", " ", "code", " ", "is", " ", "govern", "ed", " ", "by", " ", "a", " ", "BS", "D", "-", "style", " ", "license", " ", "tha", "t", " ", "can", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "found", " ", "in", " ", "the", " ", "COPY", "ING", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", "Finding", " ", "a", " ", "Pyth", "on", " ", "qi", "module", " ", "from", " ", "C", "++", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "is", " ", "hi", "gly", " ", "lib", "qi", " ", "specific", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "qi", "sys_", "._", "sh_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "qi", "py_", "._", "test_", "._", "conftest", "_", "import_", "qi", "py", "\\u", "action_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "qi", "test_", "._", "test_", "._", "conftest", "_", "import_", "qi", "test\\u", "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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "finding", "\\u", "qi", "\\u", "python", "\\u", "modules_", "(_", "qi", "py", "\\u", "action_", ",_", "qi", "build", "\\u", "action_", ",_", "qi", "test\\u", "action_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qi", "py", "\\u", "action_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "foo", "module", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ne", "ed", " ", "to", " ", "have", " ", "qi", "build", " ", "insi", "de", " ", "the", " ", "virtualenv", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "qi", "py", " ", "run", " ", "--", " ", "qi", "test", " ", "run", " ", "to", " ", "work_", "\\u\\u\\uNL\\u\\u\\u_", "this", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "top", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "this", "\\u", "dir_", ",_", "\"..\"_", ",_", "\"..\"_", ",_", "\"..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qi", "py", "\\u", "action_", "._", "work", "tree_", "._", "add", "\\u", "project_", "(_", "top", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Hack", " ", "to", " ", "make", " ", "the", " ", "work", "tree", " ", "insi", "de", " ", "qi", "build", "\\u", "action", " ", "aware_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "there", " ", "are", " ", "python", " ", "project", "s", " ", "registered_", "\\u\\u\\uNL\\u\\u\\u_", "work", "tree_", "=_", "qi", "build", "\\u", "action_", "._", "build", "\\u", "work", "tree_", "._", "work", "tree_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "work", "tree_", "._", "reload_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "qi", "build", "\\u", "action_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "usef", "oop", "ymo", "dul", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qi", "py", "\\u", "action_", "(_", "\"", "boots", "trap", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "qi", "sys_", "._", "sh_", "._", "change", "\\u", "cwd_", "(_", "project_", "._", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qi", "build", "\\u", "action_", "(_", "\"", "configur", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qi", "py", "\\u", "action_", "(_", "\"", "run", "\"_", ",_", "\"--", "no", "-", "exec", "\"_", ",_", "\"--\"_", ",_", "\"", "qi", "test", "\"_", ",_", "\"", "run", "\"_", ")_" ]
[ 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, 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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 ]
Unused import
niwinz/django-greenqueue/greenqueue/backends/zeromq.py
[ { "content": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\n\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.utils.importlib import import_module\nfrom django.utils.timezone import now\n\nfrom greenqueue.utils import Singleton\nfrom .base import BaseService\nfrom .. import settings, shortcuts\n\nimport logging, os, datetime\nlog = logging.getLogger('greenqueue')\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ZMQService(BaseService):\n socket = None\n\n\n", "metadata": "root.ZMQService", "header": "['module', '___EOS___']", "index": 16 }, { "content": " def start(self):\n self.manager = shortcuts.load_worker_class().instance()\n if self.manager.greenlet:\n zmq = import_module(\"gevent_zeromq\").zmq\n else:\n zmq = import_module('zmq')\n\n self.manager.start()\n\n ctx = zmq.Context.instance()\n socket = ctx.socket(zmq.PULL)\n socket.bind(settings.GREENQUEUE_BIND_ADDRESS)\n\n log.info(u\"greenqueue: now connected to {address}. (pid {pid})\".format(\n address = settings.GREENQUEUE_BIND_ADDRESS,\n pid = os.getpid()\n ))\n\n while True:\n message = socket.recv_pyobj()\n ok, name = self.validate_message(message)\n if not ok:\n log.error(\"greenqueue: ignoring invalid message\")\n continue\n\n self.manager.handle_message(name, message)", "metadata": "root.ZMQService.start", "header": "['class', 'ZMQService', '(', 'BaseService', ')', ':', '___EOS___']", "index": 19 }, { "content": " def create_socket(self):\n zmq = import_module('zmq')\n ctx = zmq.Context.instance()\n\n socket = ctx.socket(zmq.PUSH)\n socket.connect(settings.GREENQUEUE_BIND_ADDRESS)\n return socket", "metadata": "root.ZMQService.create_socket", "header": "['class', 'ZMQService', '(', 'BaseService', ')', ':', '___EOS___']", "index": 46 }, { "content": " def send(self, name, args=[], kwargs={}, eta=None, countdown=None):\n new_uuid = self.create_new_uuid()\n\n message_object = {\n 'name': name,\n 'args': args,\n 'kwargs':kwargs,\n 'uuid': new_uuid,\n }\n\n if eta is not None:\n message_object['eta'] = eta.isoformat()\n elif countdown is not None:\n eta = now() + datetime.timedelta(seconds=countdown)\n message_object['eta'] = eta.isoformat()\n\n socket = self.create_socket()\n socket.send_pyobj(message_object)\n return new_uuid", "metadata": "root.ZMQService.send", "header": "['class', 'ZMQService', '(', 'BaseService', ')', ':', '___EOS___']", "index": 54 } ]
[ { "span": "from django.core.exceptions import ImproperlyConfigured", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 55 }, { "span": "from greenqueue.utils import Singleton", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 38 } ]
[]
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_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Impro", "perl", "y", "Configured_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "importlib_", "import_", "import", "\\u", "module_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "timezone_", "import_", "now_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "green", "queue_", "._", "utils_", "import_", "Singleton_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "base_", "import_", "Base", "Service_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "import_", "settings_", ",_", "shortcuts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", ",_", "os_", ",_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "'", "green", "queue", "'_", ")_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "ZM", "QS", "ervice", "_", "(_", "Base", "Service_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "socket_", "=_", "None_", "\\u\\u\\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_", "ZM", "QS", "ervice", "_", "(_", "Base", "Service_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "start_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "manager_", "=_", "shortcuts_", "._", "load", "\\u", "worker", "\\u", "class_", "(_", ")_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "manager_", "._", "greenlet", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zmq_", "=_", "import", "\\u", "module_", "(_", "\"", "gev", "ent", "\\u", "zero", "mq", "\"_", ")_", "._", "zmq_", "\\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 ", " _", "zmq_", "=_", "import", "\\u", "module_", "(_", "'", "zmq", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "manager_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctx_", "=_", "zmq_", "._", "Context_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socket_", "=_", "ctx_", "._", "socket_", "(_", "zmq_", "._", "PUL", "L_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socket_", "._", "bind_", "(_", "settings_", "._", "GREEN", "QUEUE", "\\u", "BIND", "\\u", "ADDRESS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "._", "info_", "(_", "u", "\"", "green", "queue", ":", " ", "now", " ", "connect", "ed", " ", "to", " ", "{", "address", "}.", " ", "(", "pid", " ", "{", "pid", "})\"_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "address_", "=_", "settings_", "._", "GREEN", "QUEUE", "\\u", "BIND", "\\u", "ADDRESS_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pid_", "=_", "os_", "._", "getpid_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\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 ", " _", "message_", "=_", "socket_", "._", "recv", "\\u", "pyobj", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ok_", ",_", "name_", "=_", "self_", "._", "validat", "e\\u", "message_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "ok_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "\"", "green", "queue", ":", " ", "ign", "orin", "g", " ", "invalid", " ", "message", "\"_", ")_", "\\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_", "._", "manager_", "._", "handle", "\\u", "message_", "(_", "name_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ZM", "QS", "ervice", "_", "(_", "Base", "Service_", ")_", ":_", "\\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_", "create", "\\u", "socket_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "zmq_", "=_", "import", "\\u", "module_", "(_", "'", "zmq", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx_", "=_", "zmq_", "._", "Context_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "socket_", "=_", "ctx_", "._", "socket_", "(_", "zmq_", "._", "PUSH", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socket_", "._", "connect_", "(_", "settings_", "._", "GREEN", "QUEUE", "\\u", "BIND", "\\u", "ADDRESS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ZM", "QS", "ervice", "_", "(_", "Base", "Service_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send_", "(_", "self_", ",_", "name_", ",_", "args_", "=_", "[_", "]_", ",_", "kwargs_", "=_", "{_", "}_", ",_", "eta_", "=_", "None_", ",_", "countdown", "_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "uuid_", "=_", "self_", "._", "create", "\\u", "new", "\\u", "uuid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "message", "\\u", "object_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "args", "'_", ":_", "args_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kwarg", "s", "'_", ":_", "kwargs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "uuid", "'_", ":_", "new", "\\u", "uuid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "eta_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message", "\\u", "object_", "[_", "'", "eta", "'_", "]_", "=_", "eta_", "._", "isoformat_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "countdown", "_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eta_", "=_", "now_", "(_", ")_", "+_", "datetime_", "._", "timedelta_", "(_", "seconds_", "=_", "countdown", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message", "\\u", "object_", "[_", "'", "eta", "'_", "]_", "=_", "eta_", "._", "isoformat_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "socket_", "=_", "self_", "._", "create", "\\u", "socket_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socket_", "._", "send", "\\u", "pyobj", "_", "(_", "message", "\\u", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "new", "\\u", "uuid_" ]
[ 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, 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, 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, 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, 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 ]
Unused import
behave/behave/behave4cmd0/__all_steps__.py
[ { "content": "# -*- coding: utf-8 -*-\n\"\"\"\nImport all step definitions of this step-library.\nStep definitions are automatically registered in \"behave.step_registry\".\n\"\"\"\n\nfrom __future__ import absolute_import\n\n# -- IMPORT STEP-LIBRARY: behave4cmd0\nimport behave4cmd0.command_steps\nimport behave4cmd0.note_steps\nimport behave4cmd0.log.steps\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import behave4cmd0.command_steps", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 32 }, { "span": "import behave4cmd0.note_steps", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 29 }, { "span": "import behave4cmd0.log.steps", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 28 } ]
[]
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", ";", "Import", " ", "all", " ", "step", " ", "definit", "ion", "s", " ", "of", " ", "this", " ", "step", "-", "librar", "y", ".", "\\", "10", ";", "Step", " ", "definit", "ion", "s", " ", "are", " ", "automati", "call", "y", " ", "register", "ed", " ", "in", " ", "\"", "behave", ".", "step", "\\u", "registr", "y", "\".\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "IMPORT", " ", "STEP", "-", "LIBRARY", ":", " ", "behave", "4c", "md", "0_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "behave", "4c", "md", "0_", "._", "command", "\\u", "steps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "behave", "4c", "md", "0_", "._", "note", "\\u", "steps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "behave", "4c", "md", "0_", "._", "log_", "._", "steps_" ]
[ 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
Non-callable called
CollabQ/CollabQ/openid/association.py
[ { "content": "class Association(object):\n \"\"\"\n This class represents an association between a server and a\n consumer. In general, users of this library will never see\n instances of this object. The only exception is if you implement\n a custom C{L{OpenIDStore<openid.store.interface.OpenIDStore>}}.\n\n If you do implement such a store, it will need to store the values\n of the C{L{handle}}, C{L{secret}}, C{L{issued}}, C{L{lifetime}}, and\n C{L{assoc_type}} instance variables.\n\n @ivar handle: This is the handle the server gave this association.\n\n @type handle: C{str}\n\n\n @ivar secret: This is the shared secret the server generated for\n this association.\n\n @type secret: C{str}\n\n\n @ivar issued: This is the time this association was issued, in\n seconds since 00:00 GMT, January 1, 1970. (ie, a unix\n timestamp)\n\n @type issued: C{int}\n\n\n @ivar lifetime: This is the amount of time this association is\n good for, measured in seconds since the association was\n issued.\n\n @type lifetime: C{int}\n\n\n @ivar assoc_type: This is the type of association this instance\n represents. The only valid value of this field at this time\n is C{'HMAC-SHA1'}, but new types may be defined in the future.\n\n @type assoc_type: C{str}\n\n\n @sort: __init__, fromExpiresIn, getExpiresIn, __eq__, __ne__,\n handle, secret, issued, lifetime, assoc_type\n \"\"\"\n\n # The ordering and name of keys as stored by serialize\n assoc_keys = [\n 'version',\n 'handle',\n 'secret',\n 'issued',\n 'lifetime',\n 'assoc_type',\n ]\n\n\n _macs = {\n 'HMAC-SHA1': cryptutil.hmacSha1,\n 'HMAC-SHA256': cryptutil.hmacSha256,\n }\n\n\n\n fromExpiresIn = classmethod(fromExpiresIn)\n\n\n\n expiresIn = property(getExpiresIn)\n\n\n\n\n\n deserialize = classmethod(deserialize)\n\n\n\n\n\n\n\n", "metadata": "root.Association", "header": "['module', '___EOS___']", "index": 196 }, { "content": " def fromExpiresIn(cls, expires_in, handle, secret, assoc_type):\n \"\"\"\n This is an alternate constructor used by the OpenID consumer\n library to create associations. C{L{OpenIDStore\n <openid.store.interface.OpenIDStore>}} implementations\n shouldn't use this constructor.\n\n\n @param expires_in: This is the amount of time this association\n is good for, measured in seconds since the association was\n issued.\n\n @type expires_in: C{int}\n\n\n @param handle: This is the handle the server gave this\n association.\n\n @type handle: C{str}\n\n\n @param secret: This is the shared secret the server generated\n for this association.\n\n @type secret: C{str}\n\n\n @param assoc_type: This is the type of association this\n instance represents. The only valid value of this field\n at this time is C{'HMAC-SHA1'}, but new types may be\n defined in the future.\n\n @type assoc_type: C{str}\n \"\"\"\n issued = int(time.time())\n lifetime = expires_in\n return cls(handle, secret, issued, lifetime, assoc_type)", "metadata": "root.Association.fromExpiresIn", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 260 }, { "content": " def __init__(self, handle, secret, issued, lifetime, assoc_type):\n \"\"\"\n This is the standard constructor for creating an association.\n\n\n @param handle: This is the handle the server gave this\n association.\n\n @type handle: C{str}\n\n\n @param secret: This is the shared secret the server generated\n for this association.\n\n @type secret: C{str}\n\n\n @param issued: This is the time this association was issued,\n in seconds since 00:00 GMT, January 1, 1970. (ie, a unix\n timestamp)\n\n @type issued: C{int}\n\n\n @param lifetime: This is the amount of time this association\n is good for, measured in seconds since the association was\n issued.\n\n @type lifetime: C{int}\n\n\n @param assoc_type: This is the type of association this\n instance represents. The only valid value of this field\n at this time is C{'HMAC-SHA1'}, but new types may be\n defined in the future.\n\n @type assoc_type: C{str}\n \"\"\"\n if assoc_type not in all_association_types:\n fmt = '%r is not a supported association type'\n raise ValueError(fmt % (assoc_type,))\n\n# secret_size = getSecretSize(assoc_type)\n# if len(secret) != secret_size:\n# fmt = 'Wrong size secret (%s bytes) for association type %s'\n# raise ValueError(fmt % (len(secret), assoc_type))\n\n self.handle = handle\n self.secret = secret\n self.issued = issued\n self.lifetime = lifetime\n self.assoc_type = assoc_type", "metadata": "root.Association.__init__", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 300 }, { "content": " def getExpiresIn(self, now=None):\n \"\"\"\n This returns the number of seconds this association is still\n valid for, or C{0} if the association is no longer valid.\n\n\n @return: The number of seconds this association is still valid\n for, or C{0} if the association is no longer valid.\n\n @rtype: C{int}\n \"\"\"\n if now is None:\n now = int(time.time())\n\n return max(0, self.issued + self.lifetime - now)", "metadata": "root.Association.getExpiresIn", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 353 }, { "content": " def __eq__(self, other):\n \"\"\"\n This checks to see if two C{L{Association}} instances\n represent the same association.\n\n\n @return: C{True} if the two instances represent the same\n association, C{False} otherwise.\n\n @rtype: C{bool}\n \"\"\"\n return type(self) is type(other) and self.__dict__ == other.__dict__", "metadata": "root.Association.__eq__", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 371 }, { "content": " def __ne__(self, other):\n \"\"\"\n This checks to see if two C{L{Association}} instances\n represent different associations.\n\n\n @return: C{True} if the two instances represent different\n associations, C{False} otherwise.\n\n @rtype: C{bool}\n \"\"\"\n return not (self == other)", "metadata": "root.Association.__ne__", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 384 }, { "content": " def serialize(self):\n \"\"\"\n Convert an association to KV form.\n\n @return: String in KV form suitable for deserialization by\n deserialize.\n\n @rtype: str\n \"\"\"\n data = {\n 'version':'2',\n 'handle':self.handle,\n 'secret':oidutil.toBase64(self.secret),\n 'issued':str(int(self.issued)),\n 'lifetime':str(int(self.lifetime)),\n 'assoc_type':self.assoc_type\n }\n\n assert len(data) == len(self.assoc_keys)\n pairs = []\n for field_name in self.assoc_keys:\n pairs.append((field_name, data[field_name]))\n\n return kvform.seqToKV(pairs, strict=True)", "metadata": "root.Association.serialize", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 397 }, { "content": " def deserialize(cls, assoc_s):\n \"\"\"\n Parse an association as stored by serialize().\n\n inverse of serialize\n\n\n @param assoc_s: Association as serialized by serialize()\n\n @type assoc_s: str\n\n\n @return: instance of this class\n \"\"\"\n pairs = kvform.kvToSeq(assoc_s, strict=True)\n keys = []\n values = []\n for k, v in pairs:\n keys.append(k)\n values.append(v)\n\n if keys != cls.assoc_keys:\n raise ValueError('Unexpected key values: %r', keys)\n\n version, handle, secret, issued, lifetime, assoc_type = values\n if version != '2':\n raise ValueError('Unknown version: %r' % version)\n issued = int(issued)\n lifetime = int(lifetime)\n secret = oidutil.fromBase64(secret)\n return cls(handle, secret, issued, lifetime, assoc_type)", "metadata": "root.Association.deserialize", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 422 }, { "content": " def sign(self, pairs):\n \"\"\"\n Generate a signature for a sequence of (key, value) pairs\n\n\n @param pairs: The pairs to sign, in order\n\n @type pairs: sequence of (str, str)\n\n\n @return: The binary signature of this sequence of pairs\n\n @rtype: str\n \"\"\"\n kv = kvform.seqToKV(pairs)\n\n try:\n mac = self._macs[self.assoc_type]\n except KeyError:\n raise ValueError(\n 'Unknown association type: %r' % (self.assoc_type,))\n\n return mac(self.secret, kv)", "metadata": "root.Association.sign", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 456 }, { "content": " def getMessageSignature(self, message):\n \"\"\"Return the signature of a message.\n\n If I am not a sign-all association, the message must have a\n signed list.\n\n @return: the signature, base64 encoded\n\n @rtype: str\n\n @raises ValueError: If there is no signed list and I am not a sign-all\n type of association.\n \"\"\"\n pairs = self._makePairs(message)\n return oidutil.toBase64(self.sign(pairs))", "metadata": "root.Association.getMessageSignature", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 481 }, { "content": " def signMessage(self, message):\n \"\"\"Add a signature (and a signed list) to a message.\n\n @return: a new Message object with a signature\n @rtype: L{openid.message.Message}\n \"\"\"\n if (message.hasKey(OPENID_NS, 'sig') or\n message.hasKey(OPENID_NS, 'signed')):\n raise ValueError('Message already has signed list or signature')\n\n extant_handle = message.getArg(OPENID_NS, 'assoc_handle')\n if extant_handle and extant_handle != self.handle:\n raise ValueError(\"Message has a different association handle\")\n\n signed_message = message.copy()\n signed_message.setArg(OPENID_NS, 'assoc_handle', self.handle)\n message_keys = signed_message.toPostArgs().keys()\n signed_list = [k[7:] for k in message_keys\n if k.startswith('openid.')]\n signed_list.append('signed')\n signed_list.sort()\n signed_message.setArg(OPENID_NS, 'signed', ','.join(signed_list))\n sig = self.getMessageSignature(signed_message)\n signed_message.setArg(OPENID_NS, 'sig', sig)\n return signed_message", "metadata": "root.Association.signMessage", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 497 }, { "content": " def checkMessageSignature(self, message):\n \"\"\"Given a message with a signature, calculate a new signature\n and return whether it matches the signature in the message.\n\n @raises ValueError: if the message has no signature or no signature\n can be calculated for it.\n \"\"\" \n message_sig = message.getArg(OPENID_NS, 'sig')\n if not message_sig:\n raise ValueError(\"%s has no sig.\" % (message,))\n calculated_sig = self.getMessageSignature(message)\n return calculated_sig == message_sig", "metadata": "root.Association.checkMessageSignature", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 523 }, { "content": " def _makePairs(self, message):\n signed = message.getArg(OPENID_NS, 'signed')\n if not signed:\n raise ValueError('Message has no signed list: %s' % (message,))\n\n signed_list = signed.split(',')\n pairs = []\n data = message.toPostArgs()\n for field in signed_list:\n pairs.append((field, data.get('openid.' + field, '')))\n return pairs", "metadata": "root.Association._makePairs", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 537 }, { "content": " def __repr__(self):\n return \"<%s.%s %s %s>\" % (\n self.__class__.__module__,\n self.__class__.__name__,\n self.assoc_type,\n self.handle)", "metadata": "root.Association.__repr__", "header": "['class', 'Association', '(', 'object', ')', ':', '___EOS___']", "index": 549 } ]
[ { "span": "cls(handle, secret, issued, lifetime, assoc_type)", "start_line": 296, "start_column": 15, "end_line": 296, "end_column": 64 }, { "span": "cls(handle, secret, issued, lifetime, assoc_type)", "start_line": 452, "start_column": 15, "end_line": 452, "end_column": 64 } ]
[ { "span": "class Association(object):", "start_line": 196, "start_column": 0, "end_line": 196, "end_column": 26 }, { "span": "cls,", "start_line": 260, "start_column": 22, "end_line": 260, "end_column": 25 }, { "span": "cls,", "start_line": 422, "start_column": 20, "end_line": 422, "end_column": 23 } ]
1
false
[ "[CLS]_", "Non", "_", "-_", "callable_", "called_", "[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_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "class", " ", "represent", "s", " ", "an", " ", "associ", "ation", " ", "bet", "ween", " ", "a", " ", "server", " ", "and", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "consume", "r", ".", " ", " ", "In", " ", "genera", "l", ",", " ", "users", " ", "of", " ", "this", " ", "librar", "y", " ", "will", " ", "neve", "r", " ", "see", "\\", "10", ";", " ", " ", " ", " ", "instance", "s", " ", "of", " ", "this", " ", "object", ".", " ", " ", "The", " ", "only", " ", "exception", " ", "is", " ", "if", " ", "you", " ", "implement", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "custom", " ", "C", "{", "L", "{", "Open", "IDS", "tore", "<", "openid", ".", "store", ".", "interface", ".", "Open", "IDS", "tore", ">}", "}.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "you", " ", "do", " ", "implement", " ", "suc", "h", " ", "a", " ", "store", ",", " ", "it", " ", "will", " ", "need", " ", "to", " ", "store", " ", "the", " ", "values", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "the", " ", "C", "{", "L", "{", "handle", "}}", ",", " ", "C", "{", "L", "{", "secret", "}}", ",", " ", "C", "{", "L", "{", "issue", "d", "}}", ",", " ", "C", "{", "L", "{", "life", "time", "}}", ",", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "C", "{", "L", "{", "assoc", "\\u", "type", "}}", " ", "instance", " ", "variab", "les", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "ivar", " ", "handle", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "handle", " ", "the", " ", "server", " ", "ga", "ve", " ", "this", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "handle", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "ivar", " ", "secret", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "shared", " ", "secret", " ", "the", " ", "server", " ", "generat", "ed", " ", "for", "\\", "10", ";", " ", " ", " ", " ", "this", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "secret", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "ivar", " ", "issue", "d", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "time", " ", "this", " ", "associ", "ation", " ", "was", " ", "issue", "d", ",", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "second", "s", " ", "sinc", "e", " ", "00", ":", "00", " ", "GM", "T", ",", " ", "Januar", "y", " ", "1", ",", " ", "197", "0.", " ", " ", "(", "ie", ",", " ", "a", " ", "unix", "\\", "10", ";", " ", " ", " ", " ", "timestamp", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "issue", "d", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "ivar", " ", "life", "time", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "amo", "unt", " ", "of", " ", "time", " ", "this", " ", "associ", "ation", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "good", " ", "for", ",", " ", "measure", "d", " ", "in", " ", "second", "s", " ", "sinc", "e", " ", "the", " ", "associ", "ation", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "issue", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "life", "time", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "ivar", " ", "assoc", "\\u", "type", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "type", " ", "of", " ", "associ", "ation", " ", "this", " ", "instance", "\\", "10", ";", " ", " ", " ", " ", "represent", "s", ".", " ", " ", "The", " ", "only", " ", "valid", " ", "value", " ", "of", " ", "this", " ", "field", " ", "at", " ", "this", " ", "time", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "C", "{", "'", "HMAC", "-", "SHA", "1", "'}", ",", " ", "but", " ", "new", " ", "types", " ", "may", " ", "be", " ", "defin", "ed", " ", "in", " ", "the", " ", "future", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "assoc", "\\u", "type", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "sort", ":", " ", "\\u\\u", "init", "\\u\\u", ",", " ", "from", "Expire", "s", "In", ",", " ", "get", "Expire", "s", "In", ",", " ", "\\u\\u", "eq", "\\u\\u", ",", " ", "\\u\\u", "ne", "\\u\\u", ",", "\\", "10", ";", " ", " ", " ", " ", "handle", ",", " ", "secret", ",", " ", "issue", "d", ",", " ", "life", "time", ",", " ", "assoc", "\\u", "type", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "orderi", "ng", " ", "and", " ", "name", " ", "of", " ", "keys", " ", "as", " ", "store", "d", " ", "by", " ", "serialize_", "\\u\\u\\uNL\\u\\u\\u_", "assoc", "\\u", "keys_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "version", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "handle", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "secret", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "life", "time", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "assoc", "\\u", "type", "'_", ",_", "\\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", "macs", "_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "HMAC", "-", "SHA", "1", "'_", ":_", "crypt", "util_", "._", "hmac", "Sha", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "HMAC", "-", "SHA", "256", "'_", ":_", "crypt", "util_", "._", "hmac", "Sha", "256_", ",_", "\\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_", "from", "Expire", "s", "In_", "=_", "classmethod_", "(_", "from", "Expire", "s", "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_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expir", "es", "In_", "=_", "property_", "(_", "get", "Expire", "s", "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_", "\\u\\u\\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_", "deserialize_", "=_", "classmethod_", "(_", "deserialize_", ")_", "\\u\\u\\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_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "from", "Expire", "s", "In_", "(_", "cls_", ",_", "expir", "es", "\\u", "in_", ",_", "handle_", ",_", "secret_", ",_", "assoc", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "an", " ", "alternat", "e", " ", "construct", "or", " ", "used", " ", "by", " ", "the", " ", "Open", "ID", " ", "consume", "r", "\\", "10", ";", " ", " ", " ", " ", "librar", "y", " ", "to", " ", "create", " ", "associations", ".", " ", " ", "C", "{", "L", "{", "Open", "IDS", "tore", "\\", "10", ";", " ", " ", " ", " ", "<", "openid", ".", "store", ".", "interface", ".", "Open", "IDS", "tore", ">}", "}", " ", "implementation", "s", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", "n", "'", "t", " ", "use", " ", "this", " ", "construct", "or", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "expir", "es", "\\u", "in", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "amo", "unt", " ", "of", " ", "time", " ", "this", " ", "associ", "ation", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "good", " ", "for", ",", " ", "measure", "d", " ", "in", " ", "second", "s", " ", "sinc", "e", " ", "the", " ", "associ", "ation", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "issue", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "expir", "es", "\\u", "in", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "handle", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "handle", " ", "the", " ", "server", " ", "ga", "ve", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "handle", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "secret", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "shared", " ", "secret", " ", "the", " ", "server", " ", "generat", "ed", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "this", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "secret", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "assoc", "\\u", "type", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "type", " ", "of", " ", "associ", "ation", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "instance", " ", "represent", "s", ".", " ", " ", "The", " ", "only", " ", "valid", " ", "value", " ", "of", " ", "this", " ", "field", "\\", "10", ";", " ", " ", " ", " ", "at", " ", "this", " ", "time", " ", "is", " ", "C", "{", "'", "HMAC", "-", "SHA", "1", "'}", ",", " ", "but", " ", "new", " ", "types", " ", "may", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "defin", "ed", " ", "in", " ", "the", " ", "future", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "assoc", "\\u", "type", ":", " ", "C", "{", "str", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "issue", "d_", "=_", "int_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lifetime_", "=_", "expir", "es", "\\u", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "(_", "handle_", ",_", "secret_", ",_", "issue", "d_", ",_", "lifetime_", ",_", "assoc", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "handle_", ",_", "secret_", ",_", "issue", "d_", ",_", "lifetime_", ",_", "assoc", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "the", " ", "standard", " ", "construct", "or", " ", "for", " ", "creati", "ng", " ", "an", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "handle", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "handle", " ", "the", " ", "server", " ", "ga", "ve", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "handle", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "secret", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "shared", " ", "secret", " ", "the", " ", "server", " ", "generat", "ed", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "this", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "secret", ":", " ", "C", "{", "str", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "issue", "d", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "time", " ", "this", " ", "associ", "ation", " ", "was", " ", "issue", "d", ",", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "second", "s", " ", "sinc", "e", " ", "00", ":", "00", " ", "GM", "T", ",", " ", "Januar", "y", " ", "1", ",", " ", "197", "0.", " ", " ", "(", "ie", ",", " ", "a", " ", "unix", "\\", "10", ";", " ", " ", " ", " ", "timestamp", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "issue", "d", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "life", "time", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "amo", "unt", " ", "of", " ", "time", " ", "this", " ", "associ", "ation", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "good", " ", "for", ",", " ", "measure", "d", " ", "in", " ", "second", "s", " ", "sinc", "e", " ", "the", " ", "associ", "ation", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "issue", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "life", "time", ":", " ", "C", "{", "int", "}", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "assoc", "\\u", "type", ":", " ", "Thi", "s", " ", "is", " ", "the", " ", "type", " ", "of", " ", "associ", "ation", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "instance", " ", "represent", "s", ".", " ", " ", "The", " ", "only", " ", "valid", " ", "value", " ", "of", " ", "this", " ", "field", "\\", "10", ";", " ", " ", " ", " ", "at", " ", "this", " ", "time", " ", "is", " ", "C", "{", "'", "HMAC", "-", "SHA", "1", "'}", ",", " ", "but", " ", "new", " ", "types", " ", "may", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "defin", "ed", " ", "in", " ", "the", " ", "future", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "assoc", "\\u", "type", ":", " ", "C", "{", "str", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "assoc", "\\u", "type_", "not_", "in_", "all", "\\u", "associ", "ation", "\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fmt_", "=_", "'%", "r", " ", "is", " ", "not", " ", "a", " ", "support", "ed", " ", "associ", "ation", " ", "type", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Value", "Error_", "(_", "fmt_", "%_", "(_", "assoc", "\\u", "type_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "secret", "\\u", "size", " ", "=", " ", "get", "Sec", "ret", "Size", "(", "assoc", "\\u", "type", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "if", " ", "len", "(", "secret", ")", " ", "!=", " ", "secret", "\\u", "size", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "fmt", " ", "=", " ", "'", "Wro", "ng", " ", "size", " ", "secret", " ", "(%", "s", " ", "bytes", ")", " ", "for", " ", "associ", "ation", " ", "type", " ", "%", "s", "'_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "raise", " ", "Value", "Error", "(", "fmt", " ", "%", " ", "(", "len", "(", "secret", "),", " ", "assoc", "\\u", "type", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "handle_", "=_", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "secret_", "=_", "secret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "issue", "d_", "=_", "issue", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lifetime_", "=_", "lifetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assoc", "\\u", "type_", "=_", "assoc", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Expire", "s", "In_", "(_", "self_", ",_", "now_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "return", "s", " ", "the", " ", "number", " ", "of", " ", "second", "s", " ", "this", " ", "associ", "ation", " ", "is", " ", "still", "\\", "10", ";", " ", " ", " ", " ", "valid", " ", "for", ",", " ", "or", " ", "C", "{", "0", "}", " ", "if", " ", "the", " ", "associ", "ation", " ", "is", " ", "no", " ", "long", "er", " ", "valid", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "The", " ", "number", " ", "of", " ", "second", "s", " ", "this", " ", "associ", "ation", " ", "is", " ", "still", " ", "valid", "\\", "10", ";", " ", " ", " ", " ", "for", ",", " ", "or", " ", "C", "{", "0", "}", " ", "if", " ", "the", " ", "associ", "ation", " ", "is", " ", "no", " ", "long", "er", " ", "valid", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "C", "{", "int", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "now_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "now_", "=_", "int_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "max_", "(_", "0_", ",_", "self_", "._", "issue", "d_", "+_", "self_", "._", "lifetime_", "-_", "now_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "checks", " ", "to", " ", "see", " ", "if", " ", "two", " ", "C", "{", "L", "{", "Assoc", "iation", "}}", " ", "instance", "s", "\\", "10", ";", " ", " ", " ", " ", "represent", " ", "the", " ", "same", " ", "associ", "ation", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "Tru", "e", "}", " ", "if", " ", "the", " ", "two", " ", "instance", "s", " ", "represent", " ", "the", " ", "same", "\\", "10", ";", " ", " ", " ", " ", "associ", "ation", ",", " ", "C", "{", "Fal", "se", "}", " ", "other", "wis", "e", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "C", "{", "bool", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "type_", "(_", "self_", ")_", "is_", "type_", "(_", "other_", ")_", "and_", "self_", "._", "\\u\\u", "dict\\u\\u_", "==_", "other_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "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_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "checks", " ", "to", " ", "see", " ", "if", " ", "two", " ", "C", "{", "L", "{", "Assoc", "iation", "}}", " ", "instance", "s", "\\", "10", ";", " ", " ", " ", " ", "represent", " ", "different", " ", "associations", ".", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "C", "{", "Tru", "e", "}", " ", "if", " ", "the", " ", "two", " ", "instance", "s", " ", "represent", " ", "different", "\\", "10", ";", " ", " ", " ", " ", "associations", ",", " ", "C", "{", "Fal", "se", "}", " ", "other", "wis", "e", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "C", "{", "bool", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "not_", "(_", "self_", "==_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "serialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Convert", " ", "an", " ", "associ", "ation", " ", "to", " ", "KV", " ", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "String", " ", "in", " ", "KV", " ", "form", " ", "suit", "able", " ", "for", " ", "deser", "iali", "zatio", "n", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "deserialize", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "str", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "version", "'_", ":_", "'", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "handle", "'_", ":_", "self_", "._", "handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "secret", "'_", ":_", "oid", "util_", "._", "to", "Base", "64_", "(_", "self_", "._", "secret_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "issue", "d", "'_", ":_", "str_", "(_", "int_", "(_", "self_", "._", "issue", "d_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "life", "time", "'_", ":_", "str_", "(_", "int_", "(_", "self_", "._", "lifetime_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "assoc", "\\u", "type", "'_", ":_", "self_", "._", "assoc", "\\u", "type_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "data_", ")_", "==_", "len_", "(_", "self_", "._", "assoc", "\\u", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pairs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field", "\\u", "name_", "in_", "self_", "._", "assoc", "\\u", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pairs_", "._", "append_", "(_", "(_", "field", "\\u", "name_", ",_", "data_", "[_", "field", "\\u", "name_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "kv", "form_", "._", "seq", "To", "KV", "_", "(_", "pairs_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "deserialize_", "(_", "cls_", ",_", "assoc", "\\u", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Pars", "e", " ", "an", " ", "associ", "ation", " ", "as", " ", "store", "d", " ", "by", " ", "serialize", "()", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "inv", "erse", " ", "of", " ", "serialize", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "assoc", "\\u", "s", ":", " ", "Assoc", "iation", " ", "as", " ", "serialize", "d", " ", "by", " ", "serialize", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "assoc", "\\u", "s", ":", " ", "str", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "instance", " ", "of", " ", "this", " ", "class", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pairs_", "=_", "kv", "form_", "._", "kv", "To", "Seq_", "(_", "assoc", "\\u", "s_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "keys_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "pairs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "._", "append_", "(_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "._", "append_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "keys_", "!=_", "cls_", "._", "assoc", "\\u", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Une", "xpe", "cte", "d", " ", "key", " ", "values", ":", " ", "%", "r", "'_", ",_", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", ",_", "handle_", ",_", "secret_", ",_", "issue", "d_", ",_", "lifetime_", ",_", "assoc", "\\u", "type_", "=_", "values_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "version_", "!=_", "'", "2", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Un", "know", "n", " ", "version", ":", " ", "%", "r", "'_", "%_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "issue", "d_", "=_", "int_", "(_", "issue", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lifetime_", "=_", "int_", "(_", "lifetime_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "secret_", "=_", "oid", "util_", "._", "from", "Base", "64_", "(_", "secret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "(_", "handle_", ",_", "secret_", ",_", "issue", "d_", ",_", "lifetime_", ",_", "assoc", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "sign_", "(_", "self_", ",_", "pairs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Generate", " ", "a", " ", "signa", "ture", " ", "for", " ", "a", " ", "sequence", " ", "of", " ", "(", "key", ",", " ", "value", ")", " ", "pair", "s", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "pair", "s", ":", " ", "The", " ", "pair", "s", " ", "to", " ", "sign", ",", " ", "in", " ", "order", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "pair", "s", ":", " ", "sequence", " ", "of", " ", "(", "str", ",", " ", "str", ")", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "The", " ", "binar", "y", " ", "signa", "ture", " ", "of", " ", "this", " ", "sequence", " ", "of", " ", "pair", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "str", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kv_", "=_", "kv", "form_", "._", "seq", "To", "KV", "_", "(_", "pairs_", ")_", "\\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 ", " _", "mac_", "=_", "self_", "._", "\\u", "macs", "_", "[_", "self_", "._", "assoc", "\\u", "type_", "]_", "\\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 ", " _", "raise_", "Value", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Un", "know", "n", " ", "associ", "ation", " ", "type", ":", " ", "%", "r", "'_", "%_", "(_", "self_", "._", "assoc", "\\u", "type_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "mac_", "(_", "self_", "._", "secret_", ",_", "kv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Messag", "e", "Signature_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "the", " ", "signa", "ture", " ", "of", " ", "a", " ", "message", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "I", " ", "am", " ", "not", " ", "a", " ", "sign", "-", "all", " ", "associ", "ation", ",", " ", "the", " ", "message", " ", "must", " ", "have", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "sign", "ed", " ", "list", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "the", " ", "signa", "ture", ",", " ", "base64", " ", "encode", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "str", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "raise", "s", " ", "Value", "Error", ":", " ", "If", " ", "there", " ", "is", " ", "no", " ", "sign", "ed", " ", "list", " ", "and", " ", "I", " ", "am", " ", "not", " ", "a", " ", "sign", "-", "all", "\\", "10", ";", " ", " ", " ", " ", "type", " ", "of", " ", "associ", "ation", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pairs_", "=_", "self_", "._", "\\u", "make", "Pairs_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "oid", "util_", "._", "to", "Base", "64_", "(_", "self_", "._", "sign_", "(_", "pairs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sign", "Message_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "a", " ", "signa", "ture", " ", "(", "and", " ", "a", " ", "sign", "ed", " ", "list", ")", " ", "to", " ", "a", " ", "message", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "a", " ", "new", " ", "Messag", "e", " ", "object", " ", "with", " ", "a", " ", "signa", "ture", "\\", "10", ";", " ", " ", " ", " ", "@", "rty", "pe", ":", " ", "L", "{", "openid", ".", "message", ".", "Messag", "e", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "message_", "._", "has", "Key_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sig", "'_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "._", "has", "Key_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sign", "ed", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Messag", "e", " ", "alr", "ead", "y", " ", "has", " ", "sign", "ed", " ", "list", " ", "or", " ", "signa", "ture", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ext", "ant", "\\u", "handle_", "=_", "message_", "._", "get", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "assoc", "\\u", "handle", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ext", "ant", "\\u", "handle_", "and_", "ext", "ant", "\\u", "handle_", "!=_", "self_", "._", "handle_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "Messag", "e", " ", "has", " ", "a", " ", "different", " ", "associ", "ation", " ", "handle", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sign", "ed", "\\u", "message_", "=_", "message_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "message_", "._", "set", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "assoc", "\\u", "handle", "'_", ",_", "self_", "._", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message", "\\u", "keys_", "=_", "sign", "ed", "\\u", "message_", "._", "to", "Post", "Args_", "(_", ")_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "list_", "=_", "[_", "k_", "[_", "7_", ":_", "]_", "for_", "k_", "in_", "message", "\\u", "keys_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "k_", "._", "startswith_", "(_", "'", "openid", ".'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "list_", "._", "append_", "(_", "'", "sign", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "list_", "._", "sort_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "message_", "._", "set", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sign", "ed", "'_", ",_", "','_", "._", "join_", "(_", "sign", "ed", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sig_", "=_", "self_", "._", "get", "Messag", "e", "Signature_", "(_", "sign", "ed", "\\u", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sign", "ed", "\\u", "message_", "._", "set", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sig", "'_", ",_", "sig_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "sign", "ed", "\\u", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Messag", "e", "Signature_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Give", "n", " ", "a", " ", "message", " ", "with", " ", "a", " ", "signa", "ture", ",", " ", "calcul", "ate", " ", "a", " ", "new", " ", "signa", "ture", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "return", " ", "whe", "ther", " ", "it", " ", "matche", "s", " ", "the", " ", "signa", "ture", " ", "in", " ", "the", " ", "message", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "raise", "s", " ", "Value", "Error", ":", " ", "if", " ", "the", " ", "message", " ", "has", " ", "no", " ", "signa", "ture", " ", "or", " ", "no", " ", "signa", "ture", "\\", "10", ";", " ", " ", " ", " ", "can", " ", "be", " ", "calculated", " ", "for", " ", "it", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message", "\\u", "sig_", "=_", "message_", "._", "get", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sig", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "message", "\\u", "sig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"%", "s", " ", "has", " ", "no", " ", "sig", ".\"_", "%_", "(_", "message_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "calculated", "\\u", "sig_", "=_", "self_", "._", "get", "Messag", "e", "Signature_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "calculated", "\\u", "sig_", "==_", "message", "\\u", "sig_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "make", "Pairs_", "(_", "self_", ",_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "signed_", "=_", "message_", "._", "get", "Arg_", "(_", "OPEN", "ID", "\\u", "NS_", ",_", "'", "sign", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "signed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "Messag", "e", " ", "has", " ", "no", " ", "sign", "ed", " ", "list", ":", " ", "%", "s", "'_", "%_", "(_", "message_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sign", "ed", "\\u", "list_", "=_", "signed_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pairs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "message_", "._", "to", "Post", "Args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field_", "in_", "sign", "ed", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pairs_", "._", "append_", "(_", "(_", "field_", ",_", "data_", "._", "get_", "(_", "'", "openid", ".'_", "+_", "field_", ",_", "''_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "pairs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Association_", "(_", "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_", "\"<", "%", "s", ".", "%", "s", " ", "%", "s", " ", "%", "s", ">\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "module\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assoc", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "handle_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 3, 1, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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 ]
Unused import
dnouri/nolearn/nolearn/cache.py
[ { "content": "\"\"\"This module contains a decorator :func:`cached` that can be used to\ncache the results of any Python functions to disk.\n\nThis is useful when you have functions that take a long time to\ncompute their value, and you want to cache the results of those\nfunctions between runs.\n\nPython's :mod:`pickle` is used to serialize data. All cache files go\ninto the `cache/` directory inside your working directory.\n\n`@cached` uses a cache key function to find out if it has the value\nfor some given function arguments cached on disk. The way it\ncalculates that cache key by default is to simply use the string\nrepresentation of all arguments passed into the function. Thus, the\ndefault cache key function looks like this:\n\n.. code-block:: python\n\n def default_cache_key(*args, **kwargs):\n return str(args) + str(sorted(kwargs.items()))\n\nHere is an example use of the :func:`cached` decorator:\n\n.. code-block:: python\n\n import math\n @cached()\n def fac(x):\n print 'called!'\n return math.factorial(x)\n\n fac(20)\n called!\n 2432902008176640000\n fac(20)\n 2432902008176640000\n\nOften you will want to use a more intelligent cache key, one that\ntakes more things into account. Here's an example cache key function\nfor a cache decorator used with a `transform` method of a scikit-learn\n:class:`~sklearn.base.BaseEstimator`:\n\n.. doctest::\n\n >>> def transform_cache_key(self, X):\n ... return ','.join([\n ... str(X[:20]),\n ... str(X[-20:]),\n ... str(X.shape),\n ... str(sorted(self.get_params().items())),\n ... ])\n\nThis function puts the first and the last twenty rows of the matrix\n`X` into the cache key. On top of that, it adds the shape of the\nmatrix `X.shape` along with the items in `self.get_params`, which with\na scikit-learn :class:`~sklearn.base.BaseEstimator` class is the\ndictionary of model parameters. This makes sure that even though the\ninput matrix is the same, it will still calculate the value again if\nthe value of `self.get_params()` is different.\n\nYour estimator class can then use the decorator like so:\n\n.. code-block:: python\n\n class MyEstimator(BaseEstimator):\n @cached(transform_cache_key)\n def transform(self, X):\n # ...\n\"\"\"\n\nfrom functools import wraps\nimport hashlib\nimport logging\nimport random\nimport os\nimport string\nimport traceback\n\nfrom joblib import numpy_pickle\n\n\nCACHE_PATH = 'cache/'\nif not os.path.exists(CACHE_PATH): # pragma: no cover\n os.mkdir(CACHE_PATH)\n\nlogger = logging.getLogger(__name__)\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def default_cache_key(*args, **kwargs):\n return str(args) + str(sorted(kwargs.items()))", "metadata": "root.default_cache_key", "header": "['module', '___EOS___']", "index": 88 }, { "content": "class DontCache(Exception):\n pass", "metadata": "root.DontCache", "header": "['module', '___EOS___']", "index": 92 }, { "content": "def cached(cache_key=default_cache_key, cache_path=None):\n def cached(func):\n @wraps(func)\n def wrapper(*args, **kwargs):\n # Calculation of the cache key is delegated to a function\n # that's passed in via the decorator call\n # (`default_cache_key` by default).\n try:\n key = str(cache_key(*args, **kwargs)).encode('ascii')\n except DontCache:\n return func(*args, **kwargs)\n\n hashed_key = hashlib.sha1(key).hexdigest()[:8]\n\n # We construct the filename using the cache key. If the\n # file exists, unpickle and return the value.\n filename = os.path.join(\n cache_path or CACHE_PATH,\n '{}.{}-cache-{}'.format(\n func.__module__, func.__name__, hashed_key))\n\n if os.path.exists(filename):\n filesize = os.path.getsize(filename)\n size = \"%0.1f MB\" % (filesize / (1024 * 1024.0))\n logger.debug(\" * cache hit: {} ({})\".format(filename, size))\n return numpy_pickle.load(filename)\n else:\n logger.debug(\" * cache miss: {}\".format(filename))\n value = func(*args, **kwargs)\n tmp_filename = '{}-{}.tmp'.format(\n filename,\n ''.join(random.sample(string.ascii_letters, 4)),\n )\n try:\n numpy_pickle.dump(value, tmp_filename, compress=9)\n os.rename(tmp_filename, filename)\n except Exception:\n logger.exception(\n \"Saving pickle {} resulted in Exception\".format(\n filename))\n return value\n\n wrapper.uncached = func\n return wrapper\n return cached", "metadata": "root.cached", "header": "['module', '___EOS___']", "index": 96 } ]
[ { "span": "import traceback", "start_line": 76, "start_column": 0, "end_line": 76, "end_column": 16 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Thi", "s", " ", "module", " ", "contain", "s", " ", "a", " ", "decorat", "or", " ", ":", "func", ":`", "cache", "d", "`", " ", "tha", "t", " ", "can", " ", "be", " ", "used", " ", "to", "\\", "10", ";", "cache", " ", "the", " ", "results", " ", "of", " ", "any", " ", "Pyth", "on", " ", "function", "s", " ", "to", " ", "disk", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "is", " ", "usef", "ul", " ", "whe", "n", " ", "you", " ", "have", " ", "function", "s", " ", "tha", "t", " ", "take", " ", "a", " ", "long", " ", "time", " ", "to", "\\", "10", ";", "compute", " ", "thei", "r", " ", "value", ",", " ", "and", " ", "you", " ", "want", " ", "to", " ", "cache", " ", "the", " ", "results", " ", "of", " ", "tho", "se", "\\", "10", ";", "function", "s", " ", "bet", "ween", " ", "runs", ".", "\\", "10", ";", "\\", "10", ";", "Pyth", "on", "'", "s", " ", ":", "mod", ":`", "pickle", "`", " ", "is", " ", "used", " ", "to", " ", "serialize", " ", "data", ".", " ", " ", "All", " ", "cache", " ", "files", " ", "go", "\\", "10", ";", "int", "o", " ", "the", " ", "`", "cache", "/", "`", " ", "director", "y", " ", "insi", "de", " ", "your", " ", "working", " ", "director", "y", ".", "\\", "10", ";", "\\", "10", ";", "`", "@", "cache", "d", "`", " ", "use", "s", " ", "a", " ", "cache", " ", "key", " ", "function", " ", "to", " ", "find", " ", "out", " ", "if", " ", "it", " ", "has", " ", "the", " ", "value", "\\", "10", ";", "for", " ", "some", " ", "give", "n", " ", "function", " ", "argu", "ment", "s", " ", "cache", "d", " ", "on", " ", "disk", ".", " ", " ", "The", " ", "way", " ", "it", "\\", "10", ";", "calcul", "ates", " ", "tha", "t", " ", "cache", " ", "key", " ", "by", " ", "default", " ", "is", " ", "to", " ", "simp", "ly", " ", "use", " ", "the", " ", "string", "\\", "10", ";", "represent", "ation", " ", "of", " ", "all", " ", "argu", "ment", "s", " ", "pass", "ed", " ", "int", "o", " ", "the", " ", "function", ".", " ", " ", "Thu", "s", ",", " ", "the", "\\", "10", ";", "default", " ", "cache", " ", "key", " ", "function", " ", "look", "s", " ", "like", " ", "this", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "default", "\\u", "cache", "\\u", "key", "(*", "args", ",", " ", "**", "kwarg", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "str", "(", "args", ")", " ", "+", " ", "str", "(", "sorte", "d", "(", "kwarg", "s", ".", "items", "())", ")", "\\", "10", ";", "\\", "10", ";", "Her", "e", " ", "is", " ", "an", " ", "example", " ", "use", " ", "of", " ", "the", " ", ":", "func", ":`", "cache", "d", "`", " ", "decorat", "or", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "import", " ", "math", "\\", "10", ";", " ", " ", " ", " ", "@", "cache", "d", "()", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "fac", "(", "x", "):", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "'", "call", "ed", "!'", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "math", ".", "factori", "al", "(", "x", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "fac", "(", "20", ")", "\\", "10", ";", " ", " ", " ", " ", "call", "ed", "!", "\\", "10", ";", " ", " ", " ", " ", "243", "290", "2008", "176", "640", "000", "\\", "10", ";", " ", " ", " ", " ", "fac", "(", "20", ")", "\\", "10", ";", " ", " ", " ", " ", "243", "290", "2008", "176", "640", "000", "\\", "10", ";", "\\", "10", ";", "Of", "ten", " ", "you", " ", "will", " ", "want", " ", "to", " ", "use", " ", "a", " ", "more", " ", "intelligen", "t", " ", "cache", " ", "key", ",", " ", "one", " ", "tha", "t", "\\", "10", ";", "take", "s", " ", "more", " ", "thing", "s", " ", "int", "o", " ", "account", ".", " ", " ", "Her", "e", "'", "s", " ", "an", " ", "example", " ", "cache", " ", "key", " ", "function", "\\", "10", ";", "for", " ", "a", " ", "cache", " ", "decorat", "or", " ", "used", " ", "with", " ", "a", " ", "`", "transform", "`", " ", "method", " ", "of", " ", "a", " ", "scikit", "-", "learn", "\\", "10", ";", ":", "class", ":`", "~", "skl", "earn", ".", "base", ".", "Base", "Estimat", "or", "`", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "docte", "st", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "def", " ", "transform", "\\u", "cache", "\\u", "key", "(", "self", ",", " ", "X", "):", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "return", " ", "','", ".", "join", "([", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "str", "(", "X", "[:", "20", "])", ",", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "str", "(", "X", "[-", "20", ":]", "),", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "str", "(", "X", ".", "shape", "),", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "str", "(", "sorte", "d", "(", "self", ".", "get", "\\u", "params", "()", ".", "items", "())", "),", "\\", "10", ";", " ", " ", " ", " ", "...", " ", " ", " ", " ", " ", "])", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "function", " ", "puts", " ", "the", " ", "first", " ", "and", " ", "the", " ", "last", " ", "twent", "y", " ", "rows", " ", "of", " ", "the", " ", "matrix", "\\", "10", ";", "`", "X", "`", " ", "int", "o", " ", "the", " ", "cache", " ", "key", ".", " ", " ", "On", " ", "top", " ", "of", " ", "tha", "t", ",", " ", "it", " ", "adds", " ", "the", " ", "shape", " ", "of", " ", "the", "\\", "10", ";", "matrix", " ", "`", "X", ".", "shape", "`", " ", "along", " ", "with", " ", "the", " ", "items", " ", "in", " ", "`", "self", ".", "get", "\\u", "params", "`", ",", " ", "whi", "ch", " ", "with", "\\", "10", ";", "a", " ", "scikit", "-", "learn", " ", ":", "class", ":`", "~", "skl", "earn", ".", "base", ".", "Base", "Estimat", "or", "`", " ", "class", " ", "is", " ", "the", "\\", "10", ";", "dictionar", "y", " ", "of", " ", "model", " ", "parameter", "s", ".", " ", " ", "Thi", "s", " ", "make", "s", " ", "sure", " ", "tha", "t", " ", "even", " ", "tho", "ugh", " ", "the", "\\", "10", ";", "input", " ", "matrix", " ", "is", " ", "the", " ", "same", ",", " ", "it", " ", "will", " ", "still", " ", "calcul", "ate", " ", "the", " ", "value", " ", "again", " ", "if", "\\", "10", ";", "the", " ", "value", " ", "of", " ", "`", "self", ".", "get", "\\u", "params", "()`", " ", "is", " ", "different", ".", "\\", "10", ";", "\\", "10", ";", "You", "r", " ", "esti", "mat", "or", " ", "class", " ", "can", " ", "then", " ", "use", " ", "the", " ", "decorat", "or", " ", "like", " ", "so", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "class", " ", "My", "Estimat", "or", "(", "Base", "Estimat", "or", "):", "\\", "10", ";", " ", " ", " ", " ", "@", "cache", "d", "(", "transform", "\\u", "cache", "\\u", "key", ")", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "transform", "(", "self", ",", " ", "X", "):", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "...", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "functools_", "import_", "wraps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "joblib", "_", "import_", "nump", "y", "\\u", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "CACHE", "\\u", "PATH_", "=_", "'", "cache", "/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "CACHE", "\\u", "PATH_", ")_", ":_", "#", " ", "pragma", ":", " ", "no", " ", "cover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkdir_", "(_", "CACHE", "\\u", "PATH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\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\\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_", "default", "\\u", "cache", "\\u", "key_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "str_", "(_", "args_", ")_", "+_", "str_", "(_", "sorted_", "(_", "kwargs_", "._", "items_", "(_", ")_", ")_", ")_", "\\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_", "Don", "t", "Cache_", "(_", "Exception_", ")_", ":_", "\\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_", "def_", "cached_", "(_", "cache", "\\u", "key_", "=_", "default", "\\u", "cache", "\\u", "key_", ",_", "cache", "\\u", "path_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "cached_", "(_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "wraps_", "(_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapper_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Calculat", "ion", " ", "of", " ", "the", " ", "cache", " ", "key", " ", "is", " ", "delegate", "d", " ", "to", " ", "a", " ", "function_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", "'", "s", " ", "pass", "ed", " ", "in", " ", "via", " ", "the", " ", "decorat", "or", " ", "call_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "`", "default", "\\u", "cache", "\\u", "key", "`", " ", "by", " ", "default", ").", "_", "\\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 ", " _", "key_", "=_", "str_", "(_", "cache", "\\u", "key_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ")_", "._", "encode_", "(_", "'", "ascii", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Don", "t", "Cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "func_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hashed", "\\u", "key_", "=_", "hashlib_", "._", "sha1_", "(_", "key_", ")_", "._", "hexdigest_", "(_", ")_", "[_", ":_", "8_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "construct", " ", "the", " ", "filename", " ", "usi", "ng", " ", "the", " ", "cache", " ", "key", ".", " ", " ", "If", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "file", " ", "exist", "s", ",", " ", "unpickle", " ", "and", " ", "return", " ", "the", " ", "value", "._", "\\u\\u\\uNL\\u\\u\\u_", "filename_", "=_", "os_", "._", "path_", "._", "join_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "\\u", "path_", "or_", "CACHE", "\\u", "PATH_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'{}", ".{}", "-", "cache", "-{}", "'_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "func_", "._", "\\u\\u", "module\\u\\u_", ",_", "func_", "._", "\\u\\u", "name\\u\\u_", ",_", "hashed", "\\u", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filesize_", "=_", "os_", "._", "path_", "._", "getsize_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "size_", "=_", "\"%", "0.", "1f", " ", "MB", "\"_", "%_", "(_", "filesize_", "/_", "(_", "1024_", "*_", "1024.", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "\"", " ", "*", " ", "cache", " ", "hit", ":", " ", "{}", " ", "({})\"_", "._", "format_", "(_", "filename_", ",_", "size_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "nump", "y", "\\u", "pickle_", "._", "load_", "(_", "filename_", ")_", "\\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 ", " _", "logger_", "._", "debug_", "(_", "\"", " ", "*", " ", "cache", " ", "miss", ":", " ", "{}\"_", "._", "format_", "(_", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "func_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmp", "\\u", "filename_", "=_", "'{}", "-{}", ".", "tmp", "'_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "filename_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", "._", "join_", "(_", "random_", "._", "sample_", "(_", "string_", "._", "ascii", "\\u", "letters_", ",_", "4_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "nump", "y", "\\u", "pickle_", "._", "dump_", "(_", "value_", ",_", "tmp", "\\u", "filename_", ",_", "compress_", "=_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "rename_", "(_", "tmp", "\\u", "filename_", ",_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logger_", "._", "exception_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sav", "ing", " ", "pickle", " ", "{}", " ", "result", "ed", " ", "in", " ", "Except", "ion", "\"_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "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_", "wrapper_", "._", "unca", "ched", "_", "=_", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "wrapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "cached_" ]
[ 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,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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 ]
Unreachable code
openstack/python-group-based-policy-client/gbpclient/gbpshell.py
[ { "content": " def run_subcommand(self, argv):\n subcommand = self.command_manager.find_command(argv)\n cmd_factory, cmd_name, sub_argv = subcommand\n cmd = cmd_factory(self, self.options)\n err = None\n result = 1\n try:\n self.prepare_to_run_command(cmd)\n full_name = (cmd_name\n if self.interactive_mode\n else ' '.join([self.NAME, cmd_name])\n )\n cmd_parser = cmd.get_parser(full_name)\n return run_command(cmd, cmd_parser, sub_argv)\n except Exception as err:\n if self.options.verbose_level >= self.DEBUG_LEVEL:\n self.log.exception(unicode(err))\n else:\n self.log.error(unicode(err))\n try:\n self.clean_up(cmd, result, err)\n except Exception as err2:\n if self.options.verbose_level >= self.DEBUG_LEVEL:\n self.log.exception(unicode(err2))\n else:\n self.log.error(_('Could not clean up: %s'), unicode(err2))\n if self.options.verbose_level >= self.DEBUG_LEVEL:\n raise\n else:\n try:\n self.clean_up(cmd, result, None)\n except Exception as err3:\n if self.options.verbose_level >= self.DEBUG_LEVEL:\n self.log.exception(unicode(err3))\n else:\n self.log.error(_('Could not clean up: %s'), unicode(err3))\n return result", "metadata": "root.GBPShell.run_subcommand", "header": "['class', 'GBPShell', '(', 'app', '.', 'App', ')', ':', '___NEWLINE___', '___NL___', '# verbose logging levels', '___NL___', '___EOS___']", "index": 660 } ]
[ { "span": "try:", "start_line": 689, "start_column": 12, "end_line": 689, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "GB", "PS", "hell", "_", "(_", "app_", "._", "App_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "verbo", "se", " ", "logg", "ing", " ", "levels_", "\\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_", "run", "\\u", "subcommand_", "(_", "self_", ",_", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subcommand_", "=_", "self_", "._", "command", "\\u", "manager_", "._", "find", "\\u", "command_", "(_", "argv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd", "\\u", "factory_", ",_", "cmd", "\\u", "name_", ",_", "sub\\u", "argv_", "=_", "subcommand_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "cmd", "\\u", "factory_", "(_", "self_", ",_", "self_", "._", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "prepar", "e\\u", "to", "\\u", "run", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "full", "\\u", "name_", "=_", "(_", "cmd", "\\u", "name_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "interactive", "\\u", "mode_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "'", " ", "'_", "._", "join_", "(_", "[_", "self_", "._", "NAME_", ",_", "cmd", "\\u", "name_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd", "\\u", "parser_", "=_", "cmd_", "._", "get", "\\u", "parser_", "(_", "full", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "run", "\\u", "command_", "(_", "cmd_", ",_", "cmd", "\\u", "parser_", ",_", "sub\\u", "argv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "options_", "._", "verbo", "se", "\\u", "level_", ">=_", "self_", "._", "DEBU", "G", "\\u", "LEVEL_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "exception_", "(_", "unicode_", "(_", "err_", ")_", ")_", "\\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_", "._", "error_", "(_", "unicode_", "(_", "err_", ")_", ")_", "\\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 ", " _", "self_", "._", "clean", "\\u", "up_", "(_", "cmd_", ",_", "result_", ",_", "err_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "err", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "options_", "._", "verbo", "se", "\\u", "level_", ">=_", "self_", "._", "DEBU", "G", "\\u", "LEVEL_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "log_", "._", "exception_", "(_", "unicode_", "(_", "err", "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 ", " ", "_", "self_", "._", "log_", "._", "error_", "(_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "clean", " ", "up", ":", " ", "%", "s", "'_", ")_", ",_", "unicode_", "(_", "err", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "options_", "._", "verbo", "se", "\\u", "level_", ">=_", "self_", "._", "DEBU", "G", "\\u", "LEVEL_", ":_", "\\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_", "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 ", " _", "self_", "._", "clean", "\\u", "up_", "(_", "cmd_", ",_", "result_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "err", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "options_", "._", "verbo", "se", "\\u", "level_", ">=_", "self_", "._", "DEBU", "G", "\\u", "LEVEL_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "log_", "._", "exception_", "(_", "unicode_", "(_", "err", "3_", ")_", ")_", "\\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_", "._", "error_", "(_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "clean", " ", "up", ":", " ", "%", "s", "'_", ")_", ",_", "unicode_", "(_", "err", "3_", ")_", ")_", "\\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_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 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, 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 ]
Except block handles 'BaseException'
Cclleemm/FriendlyTorrent/src/tornado/BitTornado/download_bt1.py
[ { "content": "def get_response(file, url, errorfunc):\n try:\n if file:\n h = open(file, 'rb')\n try:\n line = h.read(10) # quick test to see if responsefile contains a dict\n front,garbage = line.split(':',1)\n assert front[0] == 'd'\n int(front[1:])\n except:\n errorfunc(file+' is not a valid responsefile')\n return None\n try:\n h.seek(0)\n except:\n try:\n h.close()\n except:\n pass\n h = open(file, 'rb')\n else:\n try:\n h = urlopen(url)\n except:\n errorfunc(url+' bad url')\n return None\n response = h.read()\n \n except IOError, e:\n errorfunc('problem getting response info - ' + str(e))\n return None\n try: \n h.close()\n except:\n pass\n try:\n try:\n response = bdecode(response)\n except:\n errorfunc(\"warning: bad data in responsefile\")\n response = bdecode(response, sloppy=1)\n check_message(response)\n except ValueError, e:\n errorfunc(\"got bad file info - \" + str(e))\n return None\n\n return response", "metadata": "root.get_response", "header": "['module', '___EOS___']", "index": 270 }, { "content": " def initFiles(self, old_style = False, statusfunc = None):\n if self.doneflag.isSet():\n return None\n if not statusfunc:\n statusfunc = self.statusfunc\n\n disabled_files = None\n if self.selector_enabled:\n self.priority = self.config['priority']\n if self.priority:\n try:\n self.priority = self.priority.split(',')\n assert len(self.priority) == len(self.files)\n self.priority = [int(p) for p in self.priority]\n for p in self.priority:\n assert p >= -1\n assert p <= 2\n except:\n self.errorfunc('bad priority list given, ignored')\n self.priority = None\n\n data = self.appdataobj.getTorrentData(self.infohash)\n try:\n d = data['resume data']['priority']\n assert len(d) == len(self.files)\n disabled_files = [x == -1 for x in d]\n except:\n try:\n disabled_files = [x == -1 for x in self.priority]\n except:\n pass\n\n try:\n try:\n self.storage = Storage(self.files, self.info['piece length'],\n self.doneflag, self.config, disabled_files)\n except IOError, e:\n self.errorfunc('trouble accessing files - ' + str(e))\n return None\n if self.doneflag.isSet():\n return None\n\n self.storagewrapper = StorageWrapper(self.storage, self.config['download_slice_size'],\n self.pieces, self.info['piece length'], self._finished, self._failed,\n statusfunc, self.doneflag, self.config['check_hashes'],\n self._data_flunked, self.rawserver.add_task,\n self.config, self.unpauseflag)\n \n except ValueError, e:\n self._failed('bad data - ' + str(e))\n except IOError, e:\n self._failed('IOError - ' + str(e))\n if self.doneflag.isSet():\n return None\n\n if self.selector_enabled:\n self.fileselector = FileSelector(self.files, self.info['piece length'],\n self.appdataobj.getPieceDir(self.infohash),\n self.storage, self.storagewrapper,\n self.rawserver.add_task,\n self._failed)\n if data:\n data = data.get('resume data')\n if data:\n self.fileselector.unpickle(data)\n \n self.checking = True\n if old_style:\n return self.storagewrapper.old_style_init()\n return self.storagewrapper.initialize", "metadata": "root.BT1Download.initFiles", "header": "['class', 'BT1Download', ':', '___EOS___']", "index": 481 }, { "content": " def shutdown(self, torrentdata = {}):\n if self.checking or self.started:\n self.storagewrapper.sync()\n self.storage.close()\n self.rerequest_stopped()\n if self.fileselector and self.started:\n if not self.failed:\n self.fileselector.finish()\n torrentdata['resume data'] = self.fileselector.pickle()\n try:\n self.appdataobj.writeTorrentData(self.infohash,torrentdata)\n except:\n self.appdataobj.deleteTorrentData(self.infohash) # clear it\n return not self.failed and not self.excflag.isSet()\n # if returns false, you may wish to auto-restart the torrent", "metadata": "root.BT1Download.shutdown", "header": "['class', 'BT1Download', ':', '___EOS___']", "index": 731 }, { "content": " def getResponse(self):\n try:\n return self.response\n except:\n return None", "metadata": "root.BT1Download.getResponse", "header": "['class', 'BT1Download', ':', '___EOS___']", "index": 813 } ]
[ { "span": "except:", "start_line": 279, "start_column": 12, "end_line": 279, "end_column": 19 }, { "span": "except:", "start_line": 284, "start_column": 12, "end_line": 284, "end_column": 19 }, { "span": "except:", "start_line": 287, "start_column": 16, "end_line": 287, "end_column": 23 }, { "span": "except:", "start_line": 293, "start_column": 12, "end_line": 293, "end_column": 19 }, { "span": "except:", "start_line": 303, "start_column": 4, "end_line": 303, "end_column": 11 }, { "span": "except:", "start_line": 308, "start_column": 8, "end_line": 308, "end_column": 15 }, { "span": "except:", "start_line": 498, "start_column": 16, "end_line": 498, "end_column": 23 }, { "span": "except:", "start_line": 507, "start_column": 12, "end_line": 507, "end_column": 19 }, { "span": "except:", "start_line": 510, "start_column": 16, "end_line": 510, "end_column": 23 }, { "span": "except:", "start_line": 742, "start_column": 12, "end_line": 742, "end_column": 19 }, { "span": "except:", "start_line": 816, "start_column": 8, "end_line": 816, "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_", "get", "\\u", "response_", "(_", "file_", ",_", "url_", ",_", "error", "func_", ")_", ":_", "\\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 ", " _", "if_", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "h_", "=_", "open_", "(_", "file_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "h_", "._", "read_", "(_", "10_", ")_", "#", " ", "quick", " ", "test", " ", "to", " ", "see", " ", "if", " ", "response", "file", " ", "contain", "s", " ", "a", " ", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "front_", ",_", "gar", "bage", "_", "=_", "line_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "front_", "[_", "0_", "]_", "==_", "'", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "int_", "(_", "front_", "[_", "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 ", " _", "error", "func_", "(_", "file_", "+_", "'", " ", "is", " ", "not", " ", "a", " ", "valid", " ", "response", "file", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\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 ", " _", "h_", "._", "seek_", "(_", "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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "h_", "._", "close_", "(_", ")_", "\\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_", "h_", "=_", "open_", "(_", "file_", ",_", "'", "rb", "'_", ")_", "\\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 ", " _", "h_", "=_", "urlopen_", "(_", "url_", ")_", "\\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 ", " _", "error", "func_", "(_", "url_", "+_", "'", " ", "bad", " ", "url", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "h_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "func_", "(_", "'", "problem", " ", "getti", "ng", " ", "response", " ", "info", " ", "-", " ", "'_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\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 ", " _", "h_", "._", "close_", "(_", ")_", "\\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_", "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 ", " _", "response_", "=_", "bde", "code_", "(_", "response_", ")_", "\\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 ", " _", "error", "func_", "(_", "\"", "warn", "ing", ":", " ", "bad", " ", "data", " ", "in", " ", "response", "file", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "bde", "code_", "(_", "response_", ",_", "slo", "ppy", "_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "check", "\\u", "message_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "func_", "(_", "\"", "got", " ", "bad", " ", "file", " ", "info", " ", "-", " ", "\"_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BT", "1", "Download_", ":_", "\\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_", "init", "Files_", "(_", "self_", ",_", "old", "\\u", "style_", "=_", "False_", ",_", "status", "func_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "don", "ef", "lag_", "._", "is", "Set_", "(_", ")_", ":_", "\\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_", "not_", "status", "func_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status", "func_", "=_", "self_", "._", "status", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "disable", "d\\u", "files_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "select", "or", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "priority_", "=_", "self_", "._", "config_", "[_", "'", "priorit", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "priority_", ":_", "\\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_", "._", "priority_", "=_", "self_", "._", "priority_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "self_", "._", "priority_", ")_", "==_", "len_", "(_", "self_", "._", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "priority_", "=_", "[_", "int_", "(_", "p_", ")_", "for_", "p_", "in_", "self_", "._", "priority_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "p_", "in_", "self_", "._", "priority_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "assert_", "p_", ">=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "p_", "<=_", "2_", "\\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 ", " ", "_", "self_", "._", "error", "func_", "(_", "'", "bad", " ", "priorit", "y", " ", "list", " ", "give", "n", ",", " ", "ignore", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "priority_", "=_", "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_", "data_", "=_", "self_", "._", "appd", "ata", "obj_", "._", "get", "Torrent", "Data_", "(_", "self_", "._", "info", "hash_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "data_", "[_", "'", "resum", "e", " ", "data", "'_", "]_", "[_", "'", "priorit", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "d_", ")_", "==_", "len_", "(_", "self_", "._", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disable", "d\\u", "files_", "=_", "[_", "x_", "==_", "-_", "1_", "for_", "x_", "in_", "d_", "]_", "\\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 ", " ", "_", "disable", "d\\u", "files_", "=_", "[_", "x_", "==_", "-_", "1_", "for_", "x_", "in_", "self_", "._", "priority_", "]_", "\\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\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "storage_", "=_", "Storage_", "(_", "self_", "._", "files_", ",_", "self_", "._", "info_", "[_", "'", "piece", " ", "length", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "don", "ef", "lag_", ",_", "self_", "._", "config_", ",_", "disable", "d\\u", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "error", "func_", "(_", "'", "trouble", " ", "accessi", "ng", " ", "files", " ", "-", " ", "'_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "don", "ef", "lag_", "._", "is", "Set_", "(_", ")_", ":_", "\\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_", "self_", "._", "storage", "wrapper_", "=_", "Stor", "age", "Wrapper_", "(_", "self_", "._", "storage_", ",_", "self_", "._", "config_", "[_", "'", "download", "\\u", "slice", "\\u", "size", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "pieces_", ",_", "self_", "._", "info_", "[_", "'", "piece", " ", "length", "'_", "]_", ",_", "self_", "._", "\\u", "finished_", ",_", "self_", "._", "\\u", "failed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "status", "func_", ",_", "self_", "._", "don", "ef", "lag_", ",_", "self_", "._", "config_", "[_", "'", "check", "\\u", "hashe", "s", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "data\\u", "flu", "nke", "d_", ",_", "self_", "._", "raws", "erver_", "._", "add", "\\u", "task_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "config_", ",_", "self_", "._", "unpa", "usef", "lag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "failed_", "(_", "'", "bad", " ", "data", " ", "-", " ", "'_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "failed_", "(_", "'", "IO", "Error", " ", "-", " ", "'_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "don", "ef", "lag_", "._", "is", "Set_", "(_", ")_", ":_", "\\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_", "if_", "self_", "._", "select", "or", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "filese", "lect", "or_", "=_", "File", "Selector_", "(_", "self_", "._", "files_", ",_", "self_", "._", "info_", "[_", "'", "piece", " ", "length", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "appd", "ata", "obj_", "._", "get", "Piece", "Dir_", "(_", "self_", "._", "info", "hash_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "storage_", ",_", "self_", "._", "storage", "wrapper_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "raws", "erver_", "._", "add", "\\u", "task_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "failed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "data_", "._", "get_", "(_", "'", "resum", "e", " ", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "filese", "lect", "or_", "._", "unpickle", "_", "(_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "checking", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "style_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "storage", "wrapper_", "._", "old", "\\u", "style", "\\u", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "storage", "wrapper_", "._", "initialize_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BT", "1", "Download_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "shutdown_", "(_", "self_", ",_", "torr", "ent", "data_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "checking", "_", "or_", "self_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "storage", "wrapper_", "._", "sync_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "storage_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "rer", "eque", "st", "\\u", "stopped_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "filese", "lect", "or_", "and_", "self_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "failed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "filese", "lect", "or_", "._", "finish_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "torr", "ent", "data_", "[_", "'", "resum", "e", " ", "data", "'_", "]_", "=_", "self_", "._", "filese", "lect", "or_", "._", "pickle_", "(_", ")_", "\\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 ", " _", "self_", "._", "appd", "ata", "obj_", "._", "write", "Torrent", "Data_", "(_", "self_", "._", "info", "hash_", ",_", "torr", "ent", "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 ", " _", "self_", "._", "appd", "ata", "obj_", "._", "delete", "Torrent", "Data_", "(_", "self_", "._", "info", "hash_", ")_", "#", " ", "clear", " ", "it_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "not_", "self_", "._", "failed_", "and_", "not_", "self_", "._", "exc", "flag_", "._", "is", "Set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "return", "s", " ", "fal", "se", ",", " ", "you", " ", "may", " ", "wish", " ", "to", " ", "auto", "-", "restart", " ", "the", " ", "torrent_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "BT", "1", "Download_", ":_", "\\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", "Response_", "(_", "self_", ")_", ":_", "\\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_", "self_", "._", "response_", "\\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_" ]
[ 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, 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, 0, 1, 1, 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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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, 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, 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, 0, 1, 1, 2, 2, 2, 2, 2, 2 ]
Missing call to `__init__` during object initialization
AppScale/appscale/AppServer/lib/jinja2-2.6/jinja2/nodes.py
[ { "content": " def __init__(self, *fields, **attributes):\n if self.abstract:\n raise TypeError('abstract nodes are not instanciable')\n if fields:\n if len(fields) != len(self.fields):\n if not self.fields:\n raise TypeError('%r takes 0 arguments' %\n self.__class__.__name__)\n raise TypeError('%r takes 0 or %d argument%s' % (\n self.__class__.__name__,\n len(self.fields),\n len(self.fields) != 1 and 's' or ''\n ))\n for name, arg in izip(self.fields, fields):\n setattr(self, name, arg)\n for attr in self.attributes:\n setattr(self, attr, attributes.pop(attr, None))\n if attributes:\n raise TypeError('unknown attribute %r' %\n iter(attributes).next())", "metadata": "root.Node.__init__", "header": "['class', 'Node', '(', 'object', ')', ':', '___EOS___']", "index": 125 }, { "content": "class InternalName(Expr):\n \"\"\"An internal name in the compiler. You cannot create these nodes\n yourself but the parser provides a\n :meth:`~jinja2.parser.Parser.free_identifier` method that creates\n a new identifier for you. This identifier is not available from the\n template and is not threated specially by the compiler.\n \"\"\"\n fields = ('name',)\n", "metadata": "root.InternalName", "header": "['module', '___EOS___']", "index": 820 }, { "content": " def __init__(self):\n raise TypeError('Can\\'t create internal names. Use the '\n '`free_identifier` method on a parser.')", "metadata": "root.InternalName.__init__", "header": "['class', 'InternalName', '(', 'Expr', ')', ':', '___EOS___']", "index": 829 } ]
[ { "span": "class InternalName(Expr):", "start_line": 820, "start_column": 0, "end_line": 820, "end_column": 25 } ]
[ { "span": "def __init__(self, *fields, **attributes):", "start_line": 125, "start_column": 4, "end_line": 125, "end_column": 46 }, { "span": "def __init__(self):", "start_line": 829, "start_column": 4, "end_line": 829, "end_column": 23 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "fields_", ",_", "**_", "attributes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "abstract_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "'", "abstract", " ", "nodes", " ", "are", " ", "not", " ", "instan", "cia", "ble", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "fields_", ")_", "!=_", "len_", "(_", "self_", "._", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Type", "Error_", "(_", "'%", "r", " ", "take", "s", " ", "0", " ", "argu", "ment", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Type", "Error_", "(_", "'%", "r", " ", "take", "s", " ", "0", " ", "or", " ", "%", "d", " ", "argu", "ment", "%", "s", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "self_", "._", "fields_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "self_", "._", "fields_", ")_", "!=_", "1_", "and_", "'", "s", "'_", "or_", "''_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "name_", ",_", "arg_", "in_", "izip_", "(_", "self_", "._", "fields_", ",_", "fields_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "self_", ",_", "name_", ",_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "attr_", "in_", "self_", "._", "attributes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "self_", ",_", "attr_", ",_", "attributes_", "._", "pop_", "(_", "attr_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "attributes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "'", "unknown", " ", "attribute", " ", "%", "r", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "iter_", "(_", "attributes_", ")_", "._", "next_", "(_", ")_", ")_", "\\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_", "Intern", "al", "Name_", "(_", "Expr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "An", " ", "internal", " ", "name", " ", "in", " ", "the", " ", "compiler", ".", " ", " ", "You", " ", "cann", "ot", " ", "create", " ", "these", " ", "nodes", "\\", "10", ";", " ", " ", " ", " ", "your", "self", " ", "but", " ", "the", " ", "parser", " ", "provide", "s", " ", "a", "\\", "10", ";", " ", " ", " ", " ", ":", "meth", ":`", "~", "jin", "ja", "2", ".", "parser", ".", "Parser", ".", "free", "\\u", "identifi", "er", "`", " ", "method", " ", "tha", "t", " ", "create", "s", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "new", " ", "identifi", "er", " ", "for", " ", "you", ".", " ", " ", "Thi", "s", " ", "identifi", "er", " ", "is", " ", "not", " ", "avail", "able", " ", "from", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "template", " ", "and", " ", "is", " ", "not", " ", "threat", "ed", " ", "special", "ly", " ", "by", " ", "the", " ", "compiler", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "=_", "(_", "'", "name", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Intern", "al", "Name_", "(_", "Expr_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "'", "Can", "\\\\'", "t", " ", "create", " ", "internal", " ", "names", ".", " ", " ", "Us", "e", " ", "the", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'`", "free", "\\u", "identifi", "er", "`", " ", "method", " ", "on", " ", "a", " ", "parser", ".'_", ")_", "\\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, 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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 2, 2, 2 ]
Unused local variable
FishPi/FishPi-POCV---Command---Control/fishpi/perception/world.py
[ { "content": " def update(self, data):\n \"\"\" Update observed speed, heading, location from model and sensor data. \"\"\"\n if data.has_time:\n #data.timestamp\n #data.datestamp\n pass\n\n if data.has_compass:\n compass_heading = data.compass_heading\n compass_pitch = data.compass_pitch\n compass_roll = data.compass_roll\n \n if data.has_GPS and data.fix:\n lat = data.lat\n lon = data.lon\n # heading only vaild above speed x\n gps_heading = data.gps_heading\n gps_speed = data.speed\n altitude = data.altitude\n num_sat = data.num_sat\n \n # temp - use GPS speed\n if data.has_GPS and data.fix:\n self._observed_speed = 0.0 #gps_speed\n\n # temp - average compass and GPS headings\n if data.has_compass and data.has_GPS and data.fix:\n self._observed_heading = (compass_heading + gps_heading) / 2.0\n elif data.has_compass:\n self._observed_heading = compass_heading\n elif data.has_GPS and data.fix:\n self._observed_heading = gps_heading", "metadata": "root.PerceptionUnit.update", "header": "['class', 'PerceptionUnit', ':', '___EOS___']", "index": 32 } ]
[ { "span": "compass_pitch ", "start_line": 41, "start_column": 12, "end_line": 41, "end_column": 25 }, { "span": "compass_roll ", "start_line": 42, "start_column": 12, "end_line": 42, "end_column": 24 }, { "span": "lat ", "start_line": 45, "start_column": 12, "end_line": 45, "end_column": 15 }, { "span": "lon ", "start_line": 46, "start_column": 12, "end_line": 46, "end_column": 15 }, { "span": "gps_speed ", "start_line": 49, "start_column": 12, "end_line": 49, "end_column": 21 }, { "span": "altitude ", "start_line": 50, "start_column": 12, "end_line": 50, "end_column": 20 }, { "span": "num_sat ", "start_line": 51, "start_column": 12, "end_line": 51, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Perce", "ption", "Unit_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Update", " ", "observe", "d", " ", "speed", ",", " ", "heading", ",", " ", "location", " ", "from", " ", "model", " ", "and", " ", "sensor", " ", "data", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "data_", "._", "has", "\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "data", ".", "timestamp_", "\\u\\u\\uNL\\u\\u\\u_", "#", "data", ".", "dates", "tamp", "_", "\\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_", "if_", "data_", "._", "has", "\\u", "compass", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "compass", "\\u", "heading_", "=_", "data_", "._", "compass", "\\u", "heading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compass", "\\u", "pitch_", "=_", "data_", "._", "compass", "\\u", "pitch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compass", "\\u", "roll_", "=_", "data_", "._", "compass", "\\u", "roll_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "data_", "._", "has", "\\u", "GPS", "_", "and_", "data_", "._", "fix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lat_", "=_", "data_", "._", "lat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lon_", "=_", "data_", "._", "lon_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "heading", " ", "only", " ", "vail", "d", " ", "above", " ", "speed", " ", "x_", "\\u\\u\\uNL\\u\\u\\u_", "gps", "\\u", "heading_", "=_", "data_", "._", "gps", "\\u", "heading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gps", "\\u", "speed_", "=_", "data_", "._", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "altitude_", "=_", "data_", "._", "altitude_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "sat_", "=_", "data_", "._", "num", "\\u", "sat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "temp", " ", "-", " ", "use", " ", "GPS", " ", "speed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "data_", "._", "has", "\\u", "GPS", "_", "and_", "data_", "._", "fix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "observe", "d\\u", "speed_", "=_", "0.0_", "#", "gps", "\\u", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "temp", " ", "-", " ", "averag", "e", " ", "compass", " ", "and", " ", "GPS", " ", "headings_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "data_", "._", "has", "\\u", "compass", "_", "and_", "data_", "._", "has", "\\u", "GPS", "_", "and_", "data_", "._", "fix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "observe", "d\\u", "heading_", "=_", "(_", "compass", "\\u", "heading_", "+_", "gps", "\\u", "heading_", ")_", "/_", "2.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "data_", "._", "has", "\\u", "compass", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "observe", "d\\u", "heading_", "=_", "compass", "\\u", "heading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "data_", "._", "has", "\\u", "GPS", "_", "and_", "data_", "._", "fix_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "observe", "d\\u", "heading_", "=_", "gps", "\\u", "heading_", "\\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, 0, 1, 1, 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, 0, 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, 0, 1, 1, 2, 2, 2, 2, 2, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
schematics/schematics/schematics/transforms.py
[ { "content": "def import_loop(cls, instance_or_dict, field_converter=None, trusted_data=None,\n mapping=None, partial=False, strict=False, init_values=False,\n apply_defaults=False, convert=True, validate=False, new=False,\n oo=False, recursive=False, app_data=None, context=None):\n \"\"\"\n The import loop is designed to take untrusted data and convert it into the\n native types, as described in ``cls``. It does this by calling\n ``field_converter`` on every field.\n\n Errors are aggregated and returned by throwing a ``ModelConversionError``.\n\n :param cls:\n The class for the model.\n :param instance_or_dict:\n A dict of data to be converted into types according to ``cls``.\n :param field_converter:\n This function is applied to every field found in ``instance_or_dict``.\n :param trusted_data:\n A ``dict``-like structure that may contain already validated data.\n :param partial:\n Allow partial data to validate; useful for PATCH requests.\n Essentially drops the ``required=True`` arguments from field\n definitions. Default: False\n :param strict:\n Complain about unrecognized keys. Default: False\n :param apply_defaults:\n Whether to set fields to their default values when not present in input data.\n :param app_data:\n An arbitrary container for application-specific data that needs to\n be available during the conversion.\n :param context:\n A ``Context`` object that encapsulates configuration options and ``app_data``.\n The context object is created upon the initial invocation of ``import_loop``\n and is then propagated through the entire process.\n \"\"\"\n if instance_or_dict is None:\n got_data = False\n else:\n got_data = True\n\n if got_data and not isinstance(instance_or_dict, (cls, dict)):\n raise ConversionError('Model conversion requires a model or dict')\n\n context = Context._make(context)\n try:\n context.initialized\n except:\n if type(field_converter) is types.FunctionType:\n field_converter = BasicConverter(field_converter)\n context._setdefaults({\n 'initialized': True,\n 'field_converter': field_converter,\n 'trusted_data': trusted_data or {},\n 'mapping': mapping or {},\n 'partial': partial,\n 'strict': strict,\n 'init_values': init_values,\n 'apply_defaults': apply_defaults,\n 'convert': convert,\n 'validate': validate,\n 'new': new,\n 'oo': oo,\n 'recursive': recursive,\n 'app_data': app_data if app_data is not None else {}\n })\n\n instance_or_dict = context.field_converter.pre(cls, instance_or_dict, context)\n\n _field_converter = context.field_converter\n _model_mapping = context.mapping.get('model_mapping')\n\n data = dict(context.trusted_data) if context.trusted_data else {}\n errors = {}\n\n if got_data:\n # Determine all acceptable field input names\n all_fields = cls._valid_input_keys\n if context.mapping:\n mapped_keys = (set(itertools.chain(*(\n listify(input_keys) for target_key, input_keys in context.mapping.items()\n if target_key != 'model_mapping'))))\n all_fields = all_fields | mapped_keys\n if context.strict:\n # Check for rogues if strict is set\n rogue_fields = set(instance_or_dict) - all_fields\n if rogue_fields:\n for field in rogue_fields:\n errors[field] = 'Rogue field'\n\n for field_name, field in cls._field_list:\n\n value = Undefined\n serialized_field_name = field.serialized_name or field_name\n\n if got_data:\n for key in field.get_input_keys(context.mapping):\n if key and key in instance_or_dict:\n value = instance_or_dict[key]\n break\n\n if value is Undefined:\n if field_name in data:\n continue\n if context.apply_defaults:\n value = field.default\n if value is Undefined and context.init_values:\n value = None\n\n if got_data:\n if field.is_compound:\n if context.trusted_data and context.recursive:\n td = context.trusted_data.get(field_name)\n else:\n td = {}\n if _model_mapping:\n submap = _model_mapping.get(field_name)\n else:\n submap = {}\n field_context = context._branch(trusted_data=td, mapping=submap)\n else:\n field_context = context\n try:\n value = _field_converter(field, value, field_context)\n except (FieldError, CompoundError) as exc:\n errors[serialized_field_name] = exc\n if isinstance(exc, DataError):\n data[field_name] = exc.partial_data\n continue\n\n if not context.oo and value is Undefined:\n continue\n\n data[field_name] = value\n\n if errors:\n partial_data = dict(((key, value) for key, value in data.items() if value is not Undefined))\n raise DataError(errors, partial_data)\n\n data = context.field_converter.post(cls, data, context)\n\n return data", "metadata": "root.import_loop", "header": "['module', '___EOS___']", "index": 27 }, { "content": "def export_loop(cls, instance_or_dict, field_converter=None, role=None, raise_error_on_role=True,\n export_level=None, app_data=None, context=None):\n \"\"\"\n The export_loop function is intended to be a general loop definition that\n can be used for any form of data shaping, such as application of roles or\n how a field is transformed.\n\n :param cls:\n The model definition.\n :param instance_or_dict:\n The structure where fields from cls are mapped to values. The only\n expectionation for this structure is that it implements a ``dict``\n interface.\n :param field_converter:\n This function is applied to every field found in ``instance_or_dict``.\n :param role:\n The role used to determine if fields should be left out of the\n transformation.\n :param raise_error_on_role:\n This parameter enforces strict behavior which requires substructures\n to have the same role definition as their parent structures.\n :param app_data:\n An arbitrary container for application-specific data that needs to\n be available during the conversion.\n :param context:\n A ``Context`` object that encapsulates configuration options and ``app_data``.\n The context object is created upon the initial invocation of ``import_loop``\n and is then propagated through the entire process.\n \"\"\"\n context = Context._make(context)\n try:\n context.initialized\n except:\n if type(field_converter) is types.FunctionType:\n field_converter = BasicConverter(field_converter)\n context._setdefaults({\n 'initialized': True,\n 'field_converter': field_converter,\n 'role': role,\n 'raise_error_on_role': raise_error_on_role,\n 'export_level': export_level,\n 'app_data': app_data if app_data is not None else {}\n })\n\n instance_or_dict = context.field_converter.pre(cls, instance_or_dict, context)\n\n if cls._options.export_order:\n data = OrderedDict()\n else:\n data = {}\n\n filter_func = cls._options.roles.get(context.role)\n if filter_func is None:\n if context.role and context.raise_error_on_role:\n error_msg = '%s Model has no role \"%s\"'\n raise ValueError(error_msg % (cls.__name__, context.role))\n else:\n filter_func = cls._options.roles.get(\"default\")\n\n _field_converter = context.field_converter\n\n for field_name, field, value in atoms(cls, instance_or_dict):\n serialized_name = field.serialized_name or field_name\n\n if filter_func is not None and filter_func(field_name, value):\n continue\n\n _export_level = field.get_export_level(context)\n\n if _export_level == DROP:\n continue\n\n elif value not in (None, Undefined):\n value = _field_converter(field, value, context)\n\n if value is Undefined:\n if _export_level <= DEFAULT:\n continue\n elif value is None:\n if _export_level <= NOT_NONE:\n continue\n elif field.is_compound and len(value) == 0:\n if _export_level <= NONEMPTY:\n continue\n\n if value is Undefined:\n value = None\n\n data[serialized_name] = value\n\n data = context.field_converter.post(cls, data, context)\n\n return data", "metadata": "root.export_loop", "header": "['module', '___EOS___']", "index": 170 } ]
[ { "span": "except:", "start_line": 73, "start_column": 4, "end_line": 73, "end_column": 11 }, { "span": "except:", "start_line": 202, "start_column": 4, "end_line": 202, "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_", "import", "\\u", "loop_", "(_", "cls_", ",_", "instance", "\\u", "or", "\\u", "dict_", ",_", "field", "\\u", "converter_", "=_", "None_", ",_", "trusted", "\\u", "data_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mapping_", "=_", "None_", ",_", "partial_", "=_", "False_", ",_", "strict_", "=_", "False_", ",_", "init", "\\u", "values_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "appl", "y", "\\u", "defaults_", "=_", "False_", ",_", "convert_", "=_", "True_", ",_", "validate_", "=_", "False_", ",_", "new_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "oo_", "=_", "False_", ",_", "recursive_", "=_", "False_", ",_", "app", "\\u", "data_", "=_", "None_", ",_", "context_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "import", " ", "loop", " ", "is", " ", "design", "ed", " ", "to", " ", "take", " ", "untr", "uste", "d", " ", "data", " ", "and", " ", "convert", " ", "it", " ", "int", "o", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "nativ", "e", " ", "types", ",", " ", "as", " ", "descri", "bed", " ", "in", " ", "``", "cls", "``.", " ", " ", "It", " ", "doe", "s", " ", "this", " ", "by", " ", "calling", "\\", "10", ";", " ", " ", " ", " ", "``", "field", "\\u", "converter", "``", " ", "on", " ", "every", " ", "field", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Error", "s", " ", "are", " ", "aggregated", " ", "and", " ", "return", "ed", " ", "by", " ", "throw", "ing", " ", "a", " ", "``", "Model", "Conversion", "Error", "``.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "cls", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "class", " ", "for", " ", "the", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "instance", "\\u", "or", "\\u", "dict", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "dict", " ", "of", " ", "data", " ", "to", " ", "be", " ", "convert", "ed", " ", "int", "o", " ", "types", " ", "according", " ", "to", " ", "``", "cls", "``.", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "field", "\\u", "converter", ":", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "applied", " ", "to", " ", "every", " ", "field", " ", "found", " ", "in", " ", "``", "instance", "\\u", "or", "\\u", "dict", "``.", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "trusted", "\\u", "data", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "``", "dict", "``-", "like", " ", "structure", " ", "tha", "t", " ", "may", " ", "contain", " ", "alr", "ead", "y", " ", "validat", "ed", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "partial", ":", "\\", "10", ";", " ", " ", " ", " ", "All", "ow", " ", "partial", " ", "data", " ", "to", " ", "validat", "e", ";", " ", "usef", "ul", " ", "for", " ", "PATCH", " ", "request", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "Ess", "ential", "ly", " ", "drops", " ", "the", " ", "``", "require", "d", "=", "Tru", "e", "``", " ", "argu", "ment", "s", " ", "from", " ", "field", "\\", "10", ";", " ", " ", " ", " ", "definit", "ion", "s", ".", " ", "Default", ":", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "strict", ":", "\\", "10", ";", " ", " ", " ", " ", "Comp", "lain", " ", "abo", "ut", " ", "unre", "cogni", "zed", " ", "keys", ".", " ", "Default", ":", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "appl", "y", "\\u", "default", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "Whe", "ther", " ", "to", " ", "set", " ", "fields", " ", "to", " ", "thei", "r", " ", "default", " ", "values", " ", "whe", "n", " ", "not", " ", "presen", "t", " ", "in", " ", "input", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "app", "\\u", "data", ":", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "arbitra", "ry", " ", "container", " ", "for", " ", "applica", "tion", "-", "specific", " ", "data", " ", "tha", "t", " ", "need", "s", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "avail", "able", " ", "dur", "ing", " ", "the", " ", "conve", "rsi", "on", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "context", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "``", "Context", "``", " ", "object", " ", "tha", "t", " ", "encapsulat", "es", " ", "configura", "tion", " ", "options", " ", "and", " ", "``", "app", "\\u", "data", "``.", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "context", " ", "object", " ", "is", " ", "created", " ", "upo", "n", " ", "the", " ", "initial", " ", "invocation", " ", "of", " ", "``", "import", "\\u", "loop", "``", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "is", " ", "then", " ", "propagate", "d", " ", "through", " ", "the", " ", "entire", " ", "process", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "instance", "\\u", "or", "\\u", "dict_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "got", "\\u", "data_", "=_", "False_", "\\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 ", " _", "got", "\\u", "data_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "got", "\\u", "data_", "and_", "not_", "isinstance_", "(_", "instance", "\\u", "or", "\\u", "dict_", ",_", "(_", "cls_", ",_", "dict_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Conversion", "Error_", "(_", "'", "Model", " ", "conve", "rsi", "on", " ", "require", "s", " ", "a", " ", "model", " ", "or", " ", "dict", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "=_", "Context_", "._", "\\u", "make_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "initialized_", "\\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_", "type_", "(_", "field", "\\u", "converter_", ")_", "is_", "types_", "._", "Function", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "converter_", "=_", "Basic", "Converter_", "(_", "field", "\\u", "converter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "._", "\\u", "setdefault", "s_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "initialize", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "field", "\\u", "converter", "'_", ":_", "field", "\\u", "converter_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "trusted", "\\u", "data", "'_", ":_", "trusted", "\\u", "data_", "or_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mapping", "'_", ":_", "mapping_", "or_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "partial", "'_", ":_", "partial_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "strict", "'_", ":_", "strict_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "init", "\\u", "values", "'_", ":_", "init", "\\u", "values_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "appl", "y", "\\u", "default", "s", "'_", ":_", "appl", "y", "\\u", "defaults_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "convert", "'_", ":_", "convert_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "validat", "e", "'_", ":_", "validate_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "new", "'_", ":_", "new_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "oo", "'_", ":_", "oo_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "recurs", "ive", "'_", ":_", "recursive_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "data", "'_", ":_", "app", "\\u", "data_", "if_", "app", "\\u", "data_", "is_", "not_", "None_", "else_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "instance", "\\u", "or", "\\u", "dict_", "=_", "context_", "._", "field", "\\u", "converter_", "._", "pre_", "(_", "cls_", ",_", "instance", "\\u", "or", "\\u", "dict_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "field", "\\u", "converter_", "=_", "context_", "._", "field", "\\u", "converter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "model", "\\u", "mapping_", "=_", "context_", "._", "mapping_", "._", "get_", "(_", "'", "model", "\\u", "mapping", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "dict_", "(_", "context_", "._", "trusted", "\\u", "data_", ")_", "if_", "context_", "._", "trusted", "\\u", "data_", "else_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "errors_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "got", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Det", "erm", "ine", " ", "all", " ", "acceptabl", "e", " ", "field", " ", "input", " ", "names_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "all", "\\u", "fields_", "=_", "cls_", "._", "\\u", "valid", "\\u", "input", "\\u", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "context_", "._", "mapping_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapp", "ed", "\\u", "keys_", "=_", "(_", "set_", "(_", "itertools_", "._", "chain_", "(_", "*_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "listi", "fy_", "(_", "input", "\\u", "keys_", ")_", "for_", "target", "\\u", "key_", ",_", "input", "\\u", "keys_", "in_", "context_", "._", "mapping_", "._", "items_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "target", "\\u", "key_", "!=_", "'", "model", "\\u", "mapping", "'_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "fields_", "=_", "all", "\\u", "fields_", "|_", "mapp", "ed", "\\u", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "context_", "._", "strict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "rog", "ues", " ", "if", " ", "strict", " ", "is", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rog", "ue", "\\u", "fields_", "=_", "set_", "(_", "instance", "\\u", "or", "\\u", "dict_", ")_", "-_", "all", "\\u", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rog", "ue", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "field_", "in_", "rog", "ue", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "errors_", "[_", "field_", "]_", "=_", "'", "Ro", "gue", " ", "field", "'_", "\\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_", "for_", "field", "\\u", "name_", ",_", "field_", "in_", "cls_", "._", "\\u", "field", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "Unde", "fined", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "serialize", "d\\u", "field", "\\u", "name_", "=_", "field_", "._", "serialize", "d\\u", "name_", "or_", "field", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "got", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", "in_", "field_", "._", "get", "\\u", "input", "\\u", "keys_", "(_", "context_", "._", "mapping_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "and_", "key_", "in_", "instance", "\\u", "or", "\\u", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "instance", "\\u", "or", "\\u", "dict_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\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_", "if_", "value_", "is_", "Unde", "fined", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "field", "\\u", "name_", "in_", "data_", ":_", "\\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_", "if_", "context_", "._", "appl", "y", "\\u", "defaults_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "field_", "._", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "value_", "is_", "Unde", "fined", "_", "and_", "context_", "._", "init", "\\u", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "got", "\\u", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "field_", "._", "is", "\\u", "compound_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "context_", "._", "trusted", "\\u", "data_", "and_", "context_", "._", "recursive_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "td_", "=_", "context_", "._", "trusted", "\\u", "data_", "._", "get_", "(_", "field", "\\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 ", " ", "_", "td_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u", "model", "\\u", "mapping_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "subma", "p_", "=_", "\\u", "model", "\\u", "mapping_", "._", "get_", "(_", "field", "\\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 ", " ", "_", "subma", "p_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "field", "\\u", "context_", "=_", "context_", "._", "\\u", "branch_", "(_", "trusted", "\\u", "data_", "=_", "td_", ",_", "mapping_", "=_", "subma", "p_", ")_", "\\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", "context_", "=_", "context_", "\\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 ", " _", "value_", "=_", "\\u", "field", "\\u", "converter_", "(_", "field_", ",_", "value_", ",_", "field", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Field", "Error_", ",_", "Compo", "und", "Error_", ")_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errors_", "[_", "serialize", "d\\u", "field", "\\u", "name_", "]_", "=_", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "exc_", ",_", "Data", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "data_", "[_", "field", "\\u", "name_", "]_", "=_", "exc_", "._", "partial", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "continue_", "\\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_", "context_", "._", "oo_", "and_", "value_", "is_", "Unde", "fined", "_", ":_", "\\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_", "data_", "[_", "field", "\\u", "name_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "errors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "partial", "\\u", "data_", "=_", "dict_", "(_", "(_", "(_", "key_", ",_", "value_", ")_", "for_", "key_", ",_", "value_", "in_", "data_", "._", "items_", "(_", ")_", "if_", "value_", "is_", "not_", "Unde", "fined", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Data", "Error_", "(_", "errors_", ",_", "partial", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "=_", "context_", "._", "field", "\\u", "converter_", "._", "post_", "(_", "cls_", ",_", "data_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "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_", "export", "\\u", "loop_", "(_", "cls_", ",_", "instance", "\\u", "or", "\\u", "dict_", ",_", "field", "\\u", "converter_", "=_", "None_", ",_", "role_", "=_", "None_", ",_", "raise", "\\u", "error", "\\u", "on", "\\u", "role_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "export", "\\u", "level_", "=_", "None_", ",_", "app", "\\u", "data_", "=_", "None_", ",_", "context_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "export", "\\u", "loop", " ", "function", " ", "is", " ", "inten", "ded", " ", "to", " ", "be", " ", "a", " ", "genera", "l", " ", "loop", " ", "definit", "ion", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "can", " ", "be", " ", "used", " ", "for", " ", "any", " ", "form", " ", "of", " ", "data", " ", "sha", "ping", ",", " ", "suc", "h", " ", "as", " ", "applica", "tion", " ", "of", " ", "role", "s", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "how", " ", "a", " ", "field", " ", "is", " ", "transforme", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "cls", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "model", " ", "definit", "ion", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "instance", "\\u", "or", "\\u", "dict", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "structure", " ", "where", " ", "fields", " ", "from", " ", "cls", " ", "are", " ", "mapp", "ed", " ", "to", " ", "values", ".", " ", "The", " ", "only", "\\", "10", ";", " ", " ", " ", " ", "expect", "iona", "tion", " ", "for", " ", "this", " ", "structure", " ", "is", " ", "tha", "t", " ", "it", " ", "implement", "s", " ", "a", " ", "``", "dict", "``", "\\", "10", ";", " ", " ", " ", " ", "interface", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "field", "\\u", "converter", ":", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "applied", " ", "to", " ", "every", " ", "field", " ", "found", " ", "in", " ", "``", "instance", "\\u", "or", "\\u", "dict", "``.", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "role", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "role", " ", "used", " ", "to", " ", "dete", "rmin", "e", " ", "if", " ", "fields", " ", "shou", "ld", " ", "be", " ", "left", " ", "out", " ", "of", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "transformation", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "raise", "\\u", "error", "\\u", "on", "\\u", "role", ":", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "parameter", " ", "enforce", "s", " ", "strict", " ", "behavior", " ", "whi", "ch", " ", "require", "s", " ", "substr", "ucture", "s", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "have", " ", "the", " ", "same", " ", "role", " ", "definit", "ion", " ", "as", " ", "thei", "r", " ", "parent", " ", "structure", "s", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "app", "\\u", "data", ":", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "arbitra", "ry", " ", "container", " ", "for", " ", "applica", "tion", "-", "specific", " ", "data", " ", "tha", "t", " ", "need", "s", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "avail", "able", " ", "dur", "ing", " ", "the", " ", "conve", "rsi", "on", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "context", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "``", "Context", "``", " ", "object", " ", "tha", "t", " ", "encapsulat", "es", " ", "configura", "tion", " ", "options", " ", "and", " ", "``", "app", "\\u", "data", "``.", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "context", " ", "object", " ", "is", " ", "created", " ", "upo", "n", " ", "the", " ", "initial", " ", "invocation", " ", "of", " ", "``", "import", "\\u", "loop", "``", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "is", " ", "then", " ", "propagate", "d", " ", "through", " ", "the", " ", "entire", " ", "process", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "=_", "Context_", "._", "\\u", "make_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "initialized_", "\\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_", "type_", "(_", "field", "\\u", "converter_", ")_", "is_", "types_", "._", "Function", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "converter_", "=_", "Basic", "Converter_", "(_", "field", "\\u", "converter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "._", "\\u", "setdefault", "s_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "initialize", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "field", "\\u", "converter", "'_", ":_", "field", "\\u", "converter_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "role", "'_", ":_", "role_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "raise", "\\u", "error", "\\u", "on", "\\u", "role", "'_", ":_", "raise", "\\u", "error", "\\u", "on", "\\u", "role_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "export", "\\u", "level", "'_", ":_", "export", "\\u", "level_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "data", "'_", ":_", "app", "\\u", "data_", "if_", "app", "\\u", "data_", "is_", "not_", "None_", "else_", "{_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "instance", "\\u", "or", "\\u", "dict_", "=_", "context_", "._", "field", "\\u", "converter_", "._", "pre_", "(_", "cls_", ",_", "instance", "\\u", "or", "\\u", "dict_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cls_", "._", "\\u", "options_", "._", "export", "\\u", "order_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "Order", "ed", "Dict_", "(_", ")_", "\\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 ", " _", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "filter", "\\u", "func_", "=_", "cls_", "._", "\\u", "options_", "._", "roles_", "._", "get_", "(_", "context_", "._", "role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "filter", "\\u", "func_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "context_", "._", "role_", "and_", "context_", "._", "raise", "\\u", "error", "\\u", "on", "\\u", "role_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error", "\\u", "msg_", "=_", "'%", "s", " ", "Model", " ", "has", " ", "no", " ", "role", " ", "\"%", "s", "\"'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Value", "Error_", "(_", "error", "\\u", "msg_", "%_", "(_", "cls_", "._", "\\u\\u", "name\\u\\u_", ",_", "context_", "._", "role_", ")_", ")_", "\\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 ", " _", "filter", "\\u", "func_", "=_", "cls_", "._", "\\u", "options_", "._", "roles_", "._", "get_", "(_", "\"", "default", "\"_", ")_", "\\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", "field", "\\u", "converter_", "=_", "context_", "._", "field", "\\u", "converter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "field", "\\u", "name_", ",_", "field_", ",_", "value_", "in_", "atoms_", "(_", "cls_", ",_", "instance", "\\u", "or", "\\u", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "serialize", "d\\u", "name_", "=_", "field_", "._", "serialize", "d\\u", "name_", "or_", "field", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "filter", "\\u", "func_", "is_", "not_", "None_", "and_", "filter", "\\u", "func_", "(_", "field", "\\u", "name_", ",_", "value_", ")_", ":_", "\\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_", "\\u", "export", "\\u", "level_", "=_", "field_", "._", "get", "\\u", "export", "\\u", "level_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u", "export", "\\u", "level_", "==_", "DROP", "_", ":_", "\\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_", "elif_", "value_", "not_", "in_", "(_", "None_", ",_", "Unde", "fined", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "\\u", "field", "\\u", "converter_", "(_", "field_", ",_", "value_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "value_", "is_", "Unde", "fined", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "export", "\\u", "level_", "<=_", "DEFAULT_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "value_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "export", "\\u", "level_", "<=_", "NOT", "\\u", "NONE_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "field_", "._", "is", "\\u", "compound_", "and_", "len_", "(_", "value_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "export", "\\u", "level_", "<=_", "NON", "EMPTY_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "value_", "is_", "Unde", "fined", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "[_", "serialize", "d\\u", "name_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "data_", "=_", "context_", "._", "field", "\\u", "converter_", "._", "post_", "(_", "cls_", ",_", "data_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "data_", "\\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, 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 ]
Unreachable code
rlabbe/filterpy/filterpy/stats/stats.py
[ { "content": "def _is_inside_ellipse(x, y, ex, ey, orientation, width, height):\n\n co = np.cos(orientation)\n so = np.sin(orientation)\n\n xx = x*co + y*so\n yy = y*co - x*so\n\n return (xx / width)**2 + (yy / height)**2 <= 1.\n\n\n return ((x-ex)*co - (y-ey)*so)**2/width**2 + \\\n ((x-ex)*so + (y-ey)*co)**2/height**2 <= 1", "metadata": "root._is_inside_ellipse", "header": "['module', '___EOS___']", "index": 585 } ]
[ { "span": "return ((x-ex)*co - (y-ey)*so)**2/width**2 + \\\n ((x-ex)*so + (y-ey)*co)**2/height**2 <= 1", "start_line": 596, "start_column": 4, "end_line": 597, "end_column": 52 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "is", "\\u", "insi", "de", "\\u", "ellipse_", "(_", "x_", ",_", "y_", ",_", "ex_", ",_", "ey_", ",_", "orientation_", ",_", "width_", ",_", "height_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "co_", "=_", "np_", "._", "cos_", "(_", "orientation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "so_", "=_", "np_", "._", "sin_", "(_", "orientation_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xx_", "=_", "x_", "*_", "co_", "+_", "y_", "*_", "so_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yy_", "=_", "y_", "*_", "co_", "-_", "x_", "*_", "so_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "xx_", "/_", "width_", ")_", "**_", "2_", "+_", "(_", "yy_", "/_", "height_", ")_", "**_", "2_", "<=_", "1._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "(_", "x_", "-_", "ex_", ")_", "*_", "co_", "-_", "(_", "y_", "-_", "ey_", ")_", "*_", "so_", ")_", "**_", "2_", "/_", "width_", "**_", "2_", "+_", "(_", "(_", "x_", "-_", "ex_", ")_", "*_", "so_", "+_", "(_", "y_", "-_", "ey_", ")_", "*_", "co_", ")_", "**_", "2_", "/_", "height_", "**_", "2_", "<=_", "1_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Except block handles 'BaseException'
nlloyd/SubliminalCollaborator/libs/twisted/internet/kqreactor.py
[ { "content": " def removeReader(self, reader):\n \"\"\"\n Implement L{IReactorFDSet.removeReader}.\n \"\"\"\n wasLost = False\n try:\n fd = reader.fileno()\n except:\n fd = -1\n if fd == -1:\n for fd, fdes in self._selectables.items():\n if reader is fdes:\n wasLost = True\n break\n else:\n return\n if fd in self._reads:\n del self._reads[fd]\n if fd not in self._writes:\n del self._selectables[fd]\n if not wasLost:\n try:\n self._updateRegistration(fd, KQ_FILTER_READ, KQ_EV_DELETE)\n except OSError:\n pass", "metadata": "root.KQueueReactor.removeReader", "header": "['class', 'KQueueReactor', '(', 'posixbase', '.', 'PosixReactorBase', ')', ':', '___EOS___']", "index": 153 }, { "content": " def removeWriter(self, writer):\n \"\"\"\n Implement L{IReactorFDSet.removeWriter}.\n \"\"\"\n wasLost = False\n try:\n fd = writer.fileno()\n except:\n fd = -1\n if fd == -1:\n for fd, fdes in self._selectables.items():\n if writer is fdes:\n wasLost = True\n break\n else:\n return\n if fd in self._writes:\n del self._writes[fd]\n if fd not in self._reads:\n del self._selectables[fd]\n if not wasLost:\n try:\n self._updateRegistration(fd, KQ_FILTER_WRITE, KQ_EV_DELETE)\n except OSError:\n pass", "metadata": "root.KQueueReactor.removeWriter", "header": "['class', 'KQueueReactor', '(', 'posixbase', '.', 'PosixReactorBase', ')', ':', '___EOS___']", "index": 180 }, { "content": " def _doWriteOrRead(self, selectable, fd, event):\n \"\"\"\n Private method called when a FD is ready for reading, writing or was\n lost. Do the work and raise errors where necessary.\n \"\"\"\n why = None\n inRead = False\n (filter, flags, data, fflags) = (\n event.filter, event.flags, event.data, event.fflags)\n\n if flags & KQ_EV_EOF and data and fflags:\n why = main.CONNECTION_LOST\n else:\n try:\n if selectable.fileno() == -1:\n inRead = False\n why = posixbase._NO_FILEDESC\n else:\n if filter == KQ_FILTER_READ:\n inRead = True\n why = selectable.doRead()\n if filter == KQ_FILTER_WRITE:\n inRead = False\n why = selectable.doWrite()\n except:\n # Any exception from application code gets logged and will\n # cause us to disconnect the selectable.\n why = failure.Failure()\n log.err(why, \"An exception was raised from application code\" \\\n \" while processing a reactor selectable\")\n\n if why:\n self._disconnectSelectable(selectable, why, inRead)", "metadata": "root.KQueueReactor._doWriteOrRead", "header": "['class', 'KQueueReactor', '(', 'posixbase', '.', 'PosixReactorBase', ')', ':', '___EOS___']", "index": 258 } ]
[ { "span": "except:", "start_line": 160, "start_column": 8, "end_line": 160, "end_column": 15 }, { "span": "except:", "start_line": 187, "start_column": 8, "end_line": 187, "end_column": 15 }, { "span": "except:", "start_line": 282, "start_column": 12, "end_line": 282, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "KQ", "ueue", "Reactor", "_", "(_", "posix", "base_", "._", "Posi", "x", "Reactor", "Base_", ")_", ":_", "\\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_", "remove", "Reader_", "(_", "self_", ",_", "reader_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Impl", "ement", " ", "L", "{", "IR", "eac", "tor", "FD", "Set", ".", "remove", "Read", "er", "}.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "was", "Lost", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "reader_", "._", "fileno_", "(_", ")_", "\\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 ", " _", "fd_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fd_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "fd_", ",_", "fde", "s_", "in_", "self_", "._", "\\u", "selectable", "s_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "reader_", "is_", "fde", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "was", "Lost", "_", "=_", "True_", "\\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 ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fd_", "in_", "self_", "._", "\\u", "reads_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "reads_", "[_", "fd_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fd_", "not_", "in_", "self_", "._", "\\u", "writes", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "selectable", "s_", "[_", "fd_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "was", "Lost", "_", ":_", "\\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_", "._", "\\u", "update", "Registration", "_", "(_", "fd_", ",_", "KQ", "\\u", "FILTER", "\\u", "READ_", ",_", "KQ", "\\u", "EV", "\\u", "DELETE_", ")_", "\\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 ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "KQ", "ueue", "Reactor", "_", "(_", "posix", "base_", "._", "Posi", "x", "Reactor", "Base_", ")_", ":_", "\\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_", "remove", "Writer_", "(_", "self_", ",_", "writer_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Impl", "ement", " ", "L", "{", "IR", "eac", "tor", "FD", "Set", ".", "remove", "Write", "r", "}.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "was", "Lost", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "writer_", "._", "fileno_", "(_", ")_", "\\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 ", " _", "fd_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fd_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "fd_", ",_", "fde", "s_", "in_", "self_", "._", "\\u", "selectable", "s_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "writer_", "is_", "fde", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "was", "Lost", "_", "=_", "True_", "\\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 ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fd_", "in_", "self_", "._", "\\u", "writes", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "writes", "_", "[_", "fd_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fd_", "not_", "in_", "self_", "._", "\\u", "reads_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "selectable", "s_", "[_", "fd_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "was", "Lost", "_", ":_", "\\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_", "._", "\\u", "update", "Registration", "_", "(_", "fd_", ",_", "KQ", "\\u", "FILTER", "\\u", "WRITE_", ",_", "KQ", "\\u", "EV", "\\u", "DELETE_", ")_", "\\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 ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "KQ", "ueue", "Reactor", "_", "(_", "posix", "base_", "._", "Posi", "x", "Reactor", "Base_", ")_", ":_", "\\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", "do", "Write", "Or", "Read_", "(_", "self_", ",_", "selectable", "_", ",_", "fd_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Priva", "te", " ", "method", " ", "call", "ed", " ", "whe", "n", " ", "a", " ", "FD", " ", "is", " ", "read", "y", " ", "for", " ", "readi", "ng", ",", " ", "writ", "ing", " ", "or", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "lost", ".", " ", "Do", " ", "the", " ", "work", " ", "and", " ", "raise", " ", "error", "s", " ", "where", " ", "necessar", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "why_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "Read_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "filter_", ",_", "flags_", ",_", "data_", ",_", "ffl", "ags_", ")_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "._", "filter_", ",_", "event_", "._", "flags_", ",_", "event_", "._", "data_", ",_", "event_", "._", "ffl", "ags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "flags_", "&_", "KQ", "\\u", "EV", "\\u", "EOF_", "and_", "data_", "and_", "ffl", "ags_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "why_", "=_", "main_", "._", "CONNECTION", "\\u", "LOS", "T_", "\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "selectable", "_", "._", "fileno_", "(_", ")_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "in", "Read_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "why_", "=_", "posix", "base_", "._", "\\u", "NO", "\\u", "FILE", "DESC_", "\\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_", "filter_", "==_", "KQ", "\\u", "FILTER", "\\u", "READ_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "in", "Read_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "why_", "=_", "selectable", "_", "._", "do", "Read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "filter_", "==_", "KQ", "\\u", "FILTER", "\\u", "WRITE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "in", "Read_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "why_", "=_", "selectable", "_", "._", "do", "Write_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Any", " ", "exception", " ", "from", " ", "applica", "tion", " ", "code", " ", "gets", " ", "logged", " ", "and", " ", "will", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "caus", "e", " ", "us", " ", "to", " ", "discon", "nect", " ", "the", " ", "selectable", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "why_", "=_", "failure_", "._", "Failure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "err_", "(_", "why_", ",_", "\"", "An", " ", "exception", " ", "was", " ", "raise", "d", " ", "from", " ", "applica", "tion", " ", "code", "\"_", "\"", " ", "whi", "le", " ", "process", "ing", " ", "a", " ", "react", "or", " ", "selectable", "\"_", ")_", "\\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_", "why_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "discon", "nect", "Select", "able_", "(_", "selectable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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, 0, 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 ]
Unreachable code
dragondjf/QMarkdowner/tftpy/TftpContexts.py
[ { "content": " def start(self):\n log.info(\"Sending tftp upload request to %s\" % self.host)\n log.info(\" filename -> %s\" % self.file_to_transfer)\n log.info(\" options -> %s\" % self.options)\n\n self.metrics.start_time = time.time()\n log.debug(\"Set metrics.start_time to %s\" % self.metrics.start_time)\n\n # FIXME: put this in a sendWRQ method?\n pkt = TftpPacketWRQ()\n pkt.filename = self.file_to_transfer\n pkt.mode = \"octet\" # FIXME - shouldn't hardcode this\n pkt.options = self.options\n self.sock.sendto(pkt.encode().buffer, (self.host, self.port))\n self.next_block = 1\n self.last_pkt = pkt\n # FIXME: should we centralize sendto operations so we can refactor all\n # saving of the packet to the last_pkt field?\n\n self.state = TftpStateSentWRQ(self)\n\n while self.state:\n try:\n log.debug(\"State is %s\" % self.state)\n self.cycle()\n except TftpTimeout, err:\n log.error(str(err))\n self.retry_count += 1\n if self.retry_count >= TIMEOUT_RETRIES:\n log.debug(\"hit max retries, giving up\")\n raise\n else:\n log.warn(\"resending last packet\")\n self.state.resendLast()\n raise\n break", "metadata": "root.TftpContextClientUpload.start", "header": "['class', 'TftpContextClientUpload', '(', 'TftpContext', ')', ':', '___EOS___']", "index": 269 } ]
[ { "span": "break", "start_line": 304, "start_column": 16, "end_line": 304, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Tf", "tp", "Context", "Client", "Upload_", "(_", "Tf", "tp", "Context_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "info_", "(_", "\"", "Sen", "ding", " ", "tft", "p", " ", "upload", " ", "request", " ", "to", " ", "%", "s", "\"_", "%_", "self_", "._", "host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "info_", "(_", "\"", " ", " ", " ", " ", "filename", " ", "->", " ", "%", "s", "\"_", "%_", "self_", "._", "file", "\\u", "to", "\\u", "transfer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "info_", "(_", "\"", " ", " ", " ", " ", "options", " ", "->", " ", "%", "s", "\"_", "%_", "self_", "._", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "metrics_", "._", "start", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "._", "debug_", "(_", "\"", "Set", " ", "metric", "s", ".", "start", "\\u", "time", " ", "to", " ", "%", "s", "\"_", "%_", "self_", "._", "metrics_", "._", "start", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "put", " ", "this", " ", "in", " ", "a", " ", "send", "WR", "Q", " ", "method", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "pkt_", "=_", "Tf", "tp", "Packe", "t", "WR", "Q_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pkt_", "._", "filename_", "=_", "self_", "._", "file", "\\u", "to", "\\u", "transfer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pkt_", "._", "mode_", "=_", "\"", "oct", "et", "\"_", "#", " ", "FIX", "ME", " ", "-", " ", "shou", "ld", "n", "'", "t", " ", "hard", "code", " ", "this_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pkt_", "._", "options_", "=_", "self_", "._", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sock_", "._", "sendto_", "(_", "pkt_", "._", "encode_", "(_", ")_", "._", "buffer_", ",_", "(_", "self_", "._", "host_", ",_", "self_", "._", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "next", "\\u", "block_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "pkt_", "=_", "pkt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "shou", "ld", " ", "we", " ", "centrali", "ze", " ", "send", "to", " ", "operati", "ons", " ", "so", " ", "we", " ", "can", " ", "refactor", " ", "all_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "saving", " ", "of", " ", "the", " ", "packet", " ", "to", " ", "the", " ", "last", "\\u", "pkt", " ", "field", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "state_", "=_", "Tf", "tp", "State", "Sent", "WR", "Q_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "self_", "._", "state_", ":_", "\\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 ", " _", "log_", "._", "debug_", "(_", "\"", "State", " ", "is", " ", "%", "s", "\"_", "%_", "self_", "._", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cycle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Tf", "tp", "Timeout_", ",_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "str_", "(_", "err_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "retr", "y", "\\u", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "retr", "y", "\\u", "count_", ">=_", "TIME", "OUT", "\\u", "RETRIE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "log_", "._", "debug_", "(_", "\"", "hit", " ", "max", " ", "retrie", "s", ",", " ", "gi", "ving", " ", "up", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\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_", "._", "warn_", "(_", "\"", "resen", "ding", " ", "last", " ", "packet", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "state_", "._", "resen", "d", "Last_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
enthought/mayavi/tvtk/tvtk_base_handler.py
[ { "content": "\"\"\" Handler and UI elements for tvtk objects.\n\"\"\"\n# Author: Vibha Srinivasan <[email protected]>\n# Copyright (c) 2008-2016, Enthought, Inc.\n# License: BSD Style.\n\nfrom traits.api import HasTraits, Str, Instance, Property, Button, List, Enum\nfrom traitsui.handler import Handler\nfrom traitsui.ui_info import UIInfo\nfrom traitsui.item import Item\nfrom traitsui.view import View\nfrom traits.trait_base import user_name_for, xgetattr\n\n\n\n\n\n\n\n\n#### EOF ###################################################################\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def TableEditor(*args, **kw):\n from .value_column import ObjectColumn, ValueColumn\n from traitsui.api import TableEditor as _E\n return _E(columns=[ObjectColumn(name='name'), ValueColumn(name='value')])", "metadata": "root.TableEditor", "header": "['module', '___EOS___']", "index": 13 }, { "content": "class TraitsViewObject(HasTraits):\n \"\"\" Wrapper for all items to be included in the full traits view of the TVTKBase\n object.\n \"\"\"\n\n # Trait name (name of the trait that is to be included in the view).\n name = Str\n\n # The TVTKBase object for which we are building a view.\n parent = Instance(HasTraits)", "metadata": "root.TraitsViewObject", "header": "['module', '___EOS___']", "index": 19 }, { "content": "class TVTKBaseHandler(Handler):\n \"\"\" A handler for the TVTKBase object.\n \"\"\"\n\n # A reference to the UIInfo object.\n info = Instance(UIInfo)\n\n # Type of view (of info.object) to display.\n view_type = Enum(['Basic', 'Advanced'])\n\n # The view for the object (that is, info.object)\n view = Property(depends_on='view_type')\n\n # List of TraitsViewObject items, where each item contains information\n # about the trait to display as a row in a table editor.\n _full_traits_list = Property(List, editor=TableEditor)\n\n\n\n", "metadata": "root.TVTKBaseHandler", "header": "['module', '___EOS___']", "index": 32 }, { "content": " def init_info(self, info):\n \"\"\" Informs the handler what the UIInfo object for a View will be.\n Overridden here to save a reference to the info object.\n \"\"\"\n self.info = info\n return", "metadata": "root.TVTKBaseHandler.init_info", "header": "['class', 'TVTKBaseHandler', '(', 'Handler', ')', ':', '___EOS___']", "index": 49 }, { "content": " def _get__full_traits_list(self):\n \"\"\" Returns a list of objects to be included in the table editor for\n the full traits view.\n \"\"\"\n return [TraitsViewObject(name=name, parent = self.info.object)\n for name in self.info.object._full_traitnames_list_]", "metadata": "root.TVTKBaseHandler._get__full_traits_list", "header": "['class', 'TVTKBaseHandler', '(', 'Handler', ')', ':', '___EOS___']", "index": 57 }, { "content": " def _get_view(self):\n \"\"\" Returns the view (for info.object) to be displayed in the\n InstanceEditor.\n \"\"\"\n if self.view_type == \"Basic\":\n view = self.info.object.trait_view('view')\n else:\n view = self.info.object.trait_view('full_traits_view')\n # This method is called when the default traits view for the object is\n # displayed. The default traits view already has a title, so do not\n # display a title for the contained view.\n view.title = ''\n return view", "metadata": "root.TVTKBaseHandler._get_view", "header": "['class', 'TVTKBaseHandler', '(', 'Handler', ')', ':', '___EOS___']", "index": 64 } ]
[ { "span": "from traits.api import HasTraits, Str, Instance, Property, Button, List, Enum", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 77 }, { "span": "from traitsui.item import Item", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 30 }, { "span": "from traitsui.view import View", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 30 }, { "span": "from traits.trait_base import user_name_for, xgetattr", "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_", "\"\"\"", " ", "Handle", "r", " ", "and", " ", "UI", " ", "element", "s", " ", "for", " ", "tv", "tk", " ", "object", "s", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Author", ":", " ", "Vi", "bh", "a", " ", "Sr", "ini", "vas", "an", " ", "<", "vib", "ha", "@", "enth", "ou", "ght", ".", "com", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2008", "-", "2016", ",", " ", " ", "Ent", "hou", "ght", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ":", " ", "BS", "D", " ", "Style", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits_", "._", "api_", "import_", "Has", "Trait", "s_", ",_", "Str_", ",_", "Instance_", ",_", "Property_", ",_", "Button_", ",_", "List_", ",_", "Enum_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "handler_", "import_", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "ui", "\\u", "info_", "import_", "UI", "Info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "item_", "import_", "Item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "view_", "import_", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits_", "._", "tra", "it", "\\u", "base_", "import_", "user", "\\u", "name", "\\u", "for_", ",_", "xg", "eta", "ttr", "_", "\\u\\u\\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\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###", "#", " ", "EO", "F", " ", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\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_", "Table", "Editor_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "._", "value", "\\u", "column_", "import_", "Object", "Column_", ",_", "Value", "Column_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "api_", "import_", "Table", "Editor_", "as_", "\\u", "E_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u", "E_", "(_", "columns_", "=_", "[_", "Object", "Column_", "(_", "name_", "=_", "'", "name", "'_", ")_", ",_", "Value", "Column_", "(_", "name_", "=_", "'", "value", "'_", ")_", "]_", ")_", "\\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_", "Trait", "s", "View", "Object_", "(_", "Has", "Trait", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Wrapper", " ", "for", " ", "all", " ", "items", " ", "to", " ", "be", " ", "include", "d", " ", "in", " ", "the", " ", "full", " ", "traits", " ", "view", " ", "of", " ", "the", " ", "TV", "TK", "Base", "\\", "10", ";", " ", " ", " ", "object", ".", "\\", "10", ";", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Trait", " ", "name", " ", "(", "name", " ", "of", " ", "the", " ", "tra", "it", " ", "tha", "t", " ", "is", " ", "to", " ", "be", " ", "include", "d", " ", "in", " ", "the", " ", "view", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "Str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "TV", "TK", "Base", " ", "object", " ", "for", " ", "whi", "ch", " ", "we", " ", "are", " ", "buildi", "ng", " ", "a", " ", "view", "._", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "=_", "Instance_", "(_", "Has", "Trait", "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_", "TV", "TK", "Base", "Handler_", "(_", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "A", " ", "handler", " ", "for", " ", "the", " ", "TV", "TK", "Base", " ", "object", ".", "\\", "10", ";", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "reference", " ", "to", " ", "the", " ", "UI", "Info", " ", "object", "._", "\\u\\u\\uNL\\u\\u\\u_", "info_", "=_", "Instance_", "(_", "UI", "Info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Type", " ", "of", " ", "view", " ", "(", "of", " ", "info", ".", "object", ")", " ", "to", " ", "display", "._", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "type_", "=_", "Enum_", "(_", "[_", "'", "Basic", "'_", ",_", "'", "Advance", "d", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "view", " ", "for", " ", "the", " ", "object", " ", "(", "tha", "t", " ", "is", ",", " ", "info", ".", "object", ")_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "Property_", "(_", "depend", "s", "\\u", "on_", "=_", "'", "view", "\\u", "type", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "List", " ", "of", " ", "Trait", "s", "View", "Object", " ", "items", ",", " ", "where", " ", "each", " ", "item", " ", "contain", "s", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "abo", "ut", " ", "the", " ", "tra", "it", " ", "to", " ", "display", " ", "as", " ", "a", " ", "row", " ", "in", " ", "a", " ", "table", " ", "editor", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "full", "\\u", "traits", "\\u", "list_", "=_", "Property_", "(_", "List_", ",_", "editor_", "=_", "Table", "Editor_", ")_", "\\u\\u\\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_", "TV", "TK", "Base", "Handler_", "(_", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "init", "\\u", "info_", "(_", "self_", ",_", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Infor", "ms", " ", "the", " ", "handler", " ", "what", " ", "the", " ", "UI", "Info", " ", "object", " ", "for", " ", "a", " ", "View", " ", "will", " ", "be", ".", "\\", "10", ";", " ", " ", " ", "Over", "rid", "den", " ", "here", " ", "to", " ", "save", " ", "a", " ", "reference", " ", "to", " ", "the", " ", "info", " ", "object", ".", "\\", "10", ";", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info_", "=_", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TV", "TK", "Base", "Handler_", "(_", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u\\u", "full", "\\u", "traits", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Return", "s", " ", "a", " ", "list", " ", "of", " ", "object", "s", " ", "to", " ", "be", " ", "include", "d", " ", "in", " ", "the", " ", "table", " ", "editor", " ", "for", "\\", "10", ";", " ", " ", " ", "the", " ", "full", " ", "traits", " ", "view", ".", "\\", "10", ";", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "Trait", "s", "View", "Object_", "(_", "name_", "=_", "name_", ",_", "parent_", "=_", "self_", "._", "info_", "._", "object_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "name_", "in_", "self_", "._", "info_", "._", "object_", "._", "\\u", "full", "\\u", "tra", "it", "names", "\\u", "list\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TV", "TK", "Base", "Handler_", "(_", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Return", "s", " ", "the", " ", "view", " ", "(", "for", " ", "info", ".", "object", ")", " ", "to", " ", "be", " ", "displaye", "d", " ", "in", " ", "the", "\\", "10", ";", " ", " ", "Insta", "nce", "Edit", "or", ".", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "view", "\\u", "type_", "==_", "\"", "Basic", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "view_", "=_", "self_", "._", "info_", "._", "object_", "._", "tra", "it", "\\u", "view_", "(_", "'", "view", "'_", ")_", "\\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 ", " _", "view_", "=_", "self_", "._", "info_", "._", "object_", "._", "tra", "it", "\\u", "view_", "(_", "'", "full", "\\u", "traits", "\\u", "view", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "method", " ", "is", " ", "call", "ed", " ", "whe", "n", " ", "the", " ", "default", " ", "traits", " ", "view", " ", "for", " ", "the", " ", "object", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "displaye", "d", ".", " ", "The", " ", "default", " ", "traits", " ", "view", " ", "alr", "ead", "y", " ", "has", " ", "a", " ", "title", ",", " ", "so", " ", "do", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "display", " ", "a", " ", "title", " ", "for", " ", "the", " ", "contain", "ed", " ", "view", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view_", "._", "title_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "view_", "\\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, 0, 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, 0, 1, 1, 1, 1, 1, 1, 2, 0, 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, 2, 2, 2, 2, 2, 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, 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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 ]
Unused import
WatchPeopleCode/WatchPeopleCode/migrations/versions/f3488b67bc7_.py
[ { "content": "\"\"\"empty message\n\nRevision ID: f3488b67bc7\nRevises: 189d203be5f7\nCreate Date: 2015-04-27 22:49:43.805548\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = 'f3488b67bc7'\ndown_revision = '189d203be5f7'\n\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def upgrade():\n ### commands auto generated by Alembic - please adjust! ###\n pass\n ### end Alembic commands ###", "metadata": "root.upgrade", "header": "['module', '___EOS___']", "index": 16 }, { "content": "def downgrade():\n ### commands auto generated by Alembic - please adjust! ###\n pass\n ### end Alembic commands ###", "metadata": "root.downgrade", "header": "['module', '___EOS___']", "index": 22 } ]
[ { "span": "from alembic import op", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 22 }, { "span": "import sqlalchemy as sa", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 23 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "empty", " ", "message", "\\", "10", ";", "\\", "10", ";", "Revi", "sion", " ", "ID", ":", " ", "f3", "488", "b6", "7b", "c7", "\\", "10", ";", "Revi", "ses", ":", " ", "189", "d2", "03", "be", "5f", "7", "\\", "10", ";", "Creat", "e", " ", "Date", ":", " ", "201", "5", "-0", "4", "-", "2", "7", " ", "2", "2", ":", "4", "9", ":", "43.", "805", "548", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "revis", "ion", " ", "identifi", "ers", ",", " ", "used", " ", "by", " ", "Ale", "mbic", "._", "\\u\\u\\uNL\\u\\u\\u_", "revision_", "=_", "'", "f3", "488", "b6", "7b", "c7", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "down", "\\u", "revision_", "=_", "'", "189", "d2", "03", "be", "5f", "7", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "alembic_", "import_", "op_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sqlalchemy_", "as_", "sa_", "\\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\\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_", "upgrade_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", " ", "command", "s", " ", "auto", " ", "generat", "ed", " ", "by", " ", "Ale", "mbic", " ", "-", " ", "plea", "se", " ", "adjust", "!", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", " ", "end", " ", "Ale", "mbic", " ", "command", "s", " ", "###", "_", "\\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_", "downgrade_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", " ", "command", "s", " ", "auto", " ", "generat", "ed", " ", "by", " ", "Ale", "mbic", " ", "-", " ", "plea", "se", " ", "adjust", "!", " ", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", " ", "end", " ", "Ale", "mbic", " ", "command", "s", " ", "###", "_", "\\u\\u\\uNL\\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, 0, 1, 1, 1, 2, 0, 1, 1, 1, 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 ]
Testing equality to None
dropbox/hermes/hermes/handlers/api.py
[ { "content": " def get(self):\n \"\"\"**Get all EventTypes**\n\n **Example Request:**\n\n .. sourcecode:: http\n\n GET /api/v1/eventtypes HTTP/1.1\n Host: localhost\n\n **Example response:**\n\n .. sourcecode:: http\n\n HTTP/1.1 200 OK\n Content-Type: application/json\n\n {\n \"status\": \"ok\",\n \"limit\": 10,\n \"offset\": 0,\n \"totalEventTypes\": 3,\n \"eventTypes\": [\n {\n \"id\": 1,\n \"category\": \"foo\",\n \"state\": \"bar\",\n \"description\": \"Foo bar all the way\",\n \"href\": \"/api/v1/eventtypes/1\"\n },\n ...\n ],\n }\n\n :query string category: (*optional*) Filter EventTypes by category.\n :query string state: (*optional*) Filter EventTypes by state.\n :query int limit: (*optional*) Limit result to N resources.\n :query int offset: (*optional*) Skip the first N resources.\n :query boolean startingTypes: (*optional*) Return the event types that can create non-intermediate Labors\n\n :statuscode 200: The request was successful.\n :statuscode 401: The request was made without being logged in.\n \"\"\"\n category = self.get_argument(\"category\", None)\n state = self.get_argument(\"state\", None)\n starting_types = self.get_argument(\"startingTypes\", False);\n\n event_types = self.session.query(EventType)\n if category is not None:\n event_types = event_types.filter_by(category=category)\n\n if state is not None:\n event_types = event_types.filter_by(state=state)\n\n if starting_types:\n starting_event_types = (\n self.session.query(Fate)\n .filter(Fate.follows_id == None)\n .group_by(Fate.creation_type_id).all()\n )\n event_types = (\n event_types.filter(EventType.id.in_(\n e_type.creation_type_id for e_type in starting_event_types\n ))\n )\n\n offset, limit, expand = self.get_pagination_values()\n event_types, total = self.paginate_query(event_types, offset, limit)\n\n json = {\n \"limit\": limit,\n \"offset\": offset,\n \"totalEventTypes\": total,\n \"eventTypes\": (\n [\n event_type.to_dict(\n base_uri=self.href_prefix, expand=set(expand)\n )\n for event_type in event_types.all()\n ]\n ),\n }\n\n self.success(json)", "metadata": "root.EventTypesHandler.get", "header": "['class', 'EventTypesHandler', '(', 'ApiHandler', ')', ':', '___EOS___']", "index": 601 }, { "content": " def get(self):\n \"\"\"**Get all Labors**\n\n **Example Request:**\n\n .. sourcecode:: http\n\n GET /api/v1/labors HTTP/1.1\n Host: localhost\n\n **Example response:**\n\n .. sourcecode:: http\n\n HTTP/1.1 200 OK\n Content-Type: application/json\n\n {\n \"status\": \"ok\",\n \"limit\": int,\n \"offset\": int,\n \"totalFates\": int,\n \"labors\": [\n {\n \"id\": 23,\n \"startingLaborId\": null,\n \"href\": \"/api/v1/labors/23\",\n \"for_owner\": false,\n \"for_creator\": true,\n \"questId\": 5,\n \"hostId\": 26,\n \"creationTime\": timestamp,\n \"ackTime\": timestamp,\n \"targetTime\": timestamp\n \"ackUser\": string,\n \"completionTime\": timestamp,\n \"creationEventId\": 127,\n \"completionEventId\": 212,\n },\n ...\n ],\n }\n\n :query string hostname: (*optional*) filter Labors by a particular hostname\n :query string startingLaborId: (*optional*) get Labors by the Id or the Id of the starting labor\n :query string hostQuery: (*optional*) the query to send to the plugin to come up with the list of hostnames\n :query string userQuery: (*optional*) get labors for machines owned by this user or for which this user is responsible\n :query string category: (*optional*) limit labors to ones where the starting event type is of this category\n :query string state: (*optional*) limit labors to ones where the starting event type is of this state\n :query boolean open: if true, filter Labors to those still open\n :query int questId: the id of the quest we want to filter by\n :query string expand: (*optional*) supports hosts, eventtypes, events, quests\n :query int limit: (*optional*) Limit result to N resources.\n :query int offset: (*optional*) Skip the first N resources.\n\n :statuscode 200: The request was successful.\n :statuscode 401: The request was made without being logged in.\n \"\"\"\n hostname = self.get_argument(\"hostname\", None)\n starting_labor_id = self.get_argument(\"startingLaborId\", None)\n open_flag = self.get_argument(\"open\", None)\n quest_id = self.get_argument(\"questId\", None)\n host_query = self.get_argument(\"hostQuery\", None)\n user_query = self.get_argument(\"userQuery\", None)\n category = self.get_argument(\"category\", None)\n state = self.get_argument(\"state\", None)\n\n labors = self.session.query(Labor)\n\n # if filtering by category or state, find the event types that match\n # these conditions and add them to the query\n if category or state:\n event_types = self.session.query(EventType)\n if category:\n event_types = event_types.filter(\n EventType.category == category\n )\n if state:\n event_types = event_types.filter(\n EventType.state == state\n )\n valid_event_types = [event_type.id for event_type in event_types]\n labors = labors.join(Labor.creation_event).join(Event.event_type).filter(\n EventType.id.in_(valid_event_types)\n )\n\n # if specifying to filter by open or closed state, add that to the query\n if open_flag and open_flag.lower() == \"true\":\n labors = labors.filter(Labor.completion_event_id == None)\n if open_flag and open_flag.lower() == \"false\":\n labors = labors.filter(Labor.completion_event_id != None)\n\n if quest_id:\n labors = labors.filter(Labor.quest_id == quest_id)\n\n if starting_labor_id:\n labors = labors.filter(or_(\n Labor.id == starting_labor_id,\n Labor.starting_labor_id == starting_labor_id\n ))\n\n # if user wants to filter by a specific host, verify that the host is\n # good and add that to the query\n if hostname is not None:\n try:\n host = (\n self.session.query(Host).filter(\n Host.hostname == hostname\n ).one()\n )\n except sqlalchemy.orm.exc.NoResultFound:\n raise exc.BadRequest(\"No host {} found\".format(hostname))\n\n labors = (\n labors.filter(Labor.host == host)\n .order_by(desc(Labor.creation_time))\n )\n\n # if the user specified a host query, we need to translate that into a\n # list of hostnames to use.\n host_query_hostnames = []\n if host_query:\n response = PluginHelper.request_get(params={\"query\": host_query})\n if (\n response.status_code == 200\n and response.json()[\"status\"] == \"ok\"\n ):\n # FIXME -- couldn't this just be hostnames.extend?\n for hostname in response.json()[\"results\"]:\n host_query_hostnames.append(hostname)\n else:\n raise exc.BadRequest(\"Bad host query: {}\".format(host_query))\n\n # if the user wants to filter by user, let's first find the hostnames\n # of machines the user would be responsible for\n user_query_hostnames = []\n user_created_quests = []\n if user_query:\n response = PluginHelper.request_get(params={\"user\": user_query})\n if (\n response.status_code == 200\n and response.json()[\"status\"] == \"ok\"\n ):\n for hostname in response.json()[\"results\"]:\n user_query_hostnames.append(hostname)\n else:\n raise exc.BadRequest(\"Bad user query: {}\".format(user_query))\n\n user_created_quests =[\n quest.id for quest in\n (\n self.session.query(Quest).filter(\n Quest.creator == user_query\n ).all()\n )\n ]\n\n # since we may have used multiple ways to get hostname lists, compile\n # into a final list of hostnames we care about\n hostnames = []\n if host_query and user_query:\n hostnames = list(\n set(host_query_hostnames) & set(user_query_hostnames)\n )\n elif host_query:\n hostnames = host_query_hostnames\n elif user_query:\n hostnames = user_query_hostnames\n\n # if we are just doing a simple host_query, we can just filter by\n # the hostnames we collected. Otherwise, if we are doing a user_query\n # we need not just hosts owned by the user, but also labors that belong\n # to a quest creator that matches the user name\n if host_query or user_query:\n if not hostnames:\n raise exc.BadRequest(\"Querying on 0 hosts\")\n\n hosts = (\n self.session.query(Host).filter(\n Host.hostname.in_(hostnames)\n )\n )\n host_ids = [host.id for host in hosts]\n if not user_query:\n labors = labors.filter(and_(\n Labor.host_id.in_(host_ids),\n Labor.for_owner == 1\n ))\n elif hostnames and user_query:\n labors = labors.filter(or_(\n and_(\n Labor.host_id.in_(host_ids),\n Labor.for_owner == 1\n ),\n and_(\n Labor.for_creator == 1,\n Labor.quest_id.in_(user_created_quests)\n )\n ))\n\n offset, limit, expand = self.get_pagination_values()\n labors, total = self.paginate_query(labors, offset, limit)\n\n labors = labors.from_self().order_by(Labor.creation_time)\n\n json = {\n \"limit\": limit,\n \"offset\": offset,\n \"totalLabors\": total,\n \"labors\": [\n labor.to_dict(\n base_uri=self.href_prefix, expand=set(expand)\n ) for labor in labors\n ],\n }\n\n self.success(json)", "metadata": "root.LaborsHandler.get", "header": "['class', 'LaborsHandler', '(', 'ApiHandler', ')', ':', '___EOS___']", "index": 1670 }, { "content": " def get(self):\n \"\"\"**Get all Quests**\n\n **Example Request:**\n\n .. sourcecode:: http\n\n GET /api/v1/quests?progressInfo=true HTTP/1.1\n Host: localhost\n\n **Example response:**\n\n .. sourcecode:: http\n\n HTTP/1.1 200 OK\n Content-Type: application/json\n\n {\n \"status\": \"ok\",\n \"limit\": int,\n \"offset\": int,\n \"totalQuests\": int,\n \"quests\": [\n {\n \"id\": 1,\n \"href\": \"/api/v1/quests/1\",\n \"creator\": \"johnny\",\n \"embarkTime\": timestamp,\n \"targetTime\": timestamp,\n \"completionTime\": timestamp,\n \"description\": \"This is a quest almighty\",\n \"totalLabors\": 20,\n \"openLabors\": 10,\n \"percentComplete\": 50,\n \"labors\": [],\n },\n ...\n ],\n }\n\n :query boolean filterClosed: (*optional*) if true, filter out completed Quests\n :query boolean progressInfo: (*optional*) if true, include progress information\n :query string byCreator: (*optional*) if set, filter the quests by a particular creator\n :query string hostnames: (*optional*) filter to quests that pertain to a particular host\n :query string hostQuery: (*optional*) filter quests to those involving hosts returned by the external query\n :query int limit: (*optional*) Limit result to N resources.\n :query int offset: (*optional*) Skip the first N resources.\n\n :statuscode 200: The request was successful.\n :statuscode 401: The request was made without being logged in.\n \"\"\"\n filter_closed = self.get_argument(\"filterClosed\", None)\n progress_info = self.get_argument(\"progressInfo\", None)\n by_creator = self.get_argument(\"byCreator\", None)\n hostnames = self.get_argument(\"hostnames\", None)\n host_query = self.get_argument(\"hostQuery\", None)\n\n if hostnames:\n hostnames = hostnames.split(\",\")\n else:\n hostnames = []\n\n if host_query:\n response = PluginHelper.request_get(params={\"query\": host_query})\n if (\n response.status_code == 200\n and response.json()[\"status\"] == \"ok\"\n ):\n for hostname in response.json()[\"results\"]:\n hostnames.append(hostname)\n else:\n raise exc.BadRequest(\"Bad host query: {}\".format(host_query))\n\n # We used to sort in reverse embark time so that the default would be\n # to show the latest quests but we don't want to do that anymore\n # quests = self.session.query(Quest).order_by(desc(Quest.embark_time))\n quests = self.session.query(Quest).order_by(Quest.embark_time)\n\n if hostnames:\n quests = (\n quests.join(Quest.labors).join(Labor.host)\n .filter(Host.hostname.in_(hostnames))\n ).group_by(Quest)\n\n if filter_closed:\n quests = quests.filter(Quest.completion_time == None)\n\n if by_creator:\n quests = quests.filter(Quest.creator == by_creator)\n\n offset, limit, expand = self.get_pagination_values()\n quests, total = self.paginate_query(quests, offset, limit)\n\n quests = quests.from_self().order_by(Quest.embark_time)\n\n quests_json = []\n for quest in quests.all():\n quest_json = quest.to_dict(\n base_uri=self.href_prefix,\n expand=set(expand)\n )\n if progress_info:\n quest_json = quest.calculate_progress(quest_json)\n quests_json.append(quest_json)\n\n json = {\n \"limit\": limit,\n \"offset\": offset,\n \"totalQuests\": total,\n \"quests\": quests_json\n }\n\n self.success(json)", "metadata": "root.QuestsHandler.get", "header": "['class', 'QuestsHandler', '(', 'ApiHandler', ')', ':', '___EOS___']", "index": 2216 } ]
[ { "span": "Fate.follows_id == None)", "start_line": 658, "start_column": 28, "end_line": 658, "end_column": 51 }, { "span": "Labor.completion_event_id == None)", "start_line": 1758, "start_column": 35, "end_line": 1758, "end_column": 68 }, { "span": "Quest.completion_time == None)", "start_line": 2301, "start_column": 35, "end_line": 2301, "end_column": 64 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Event", "Type", "s", "Handler_", "(_", "Ap", "i", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "**", "Get", " ", "all", " ", "Event", "Type", "s", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "Request", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "GET", " ", "/", "api", "/", "v1", "/", "event", "types", " ", "HTTP", "/", "1.1", "\\", "10", ";", " ", " ", " ", " ", "Host", ":", " ", "local", "host", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "response", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "HTTP", "/", "1.1", " ", "200", " ", "OK", "\\", "10", ";", " ", " ", " ", " ", "Conten", "t", "-", "Type", ":", " ", "applica", "tion", "/", "json", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "status", "\":", " ", "\"", "ok", "\",", "\\", "10", ";", " ", " ", " ", " ", "\"", "limit", "\":", " ", "10", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "offset", "\":", " ", "0", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "total", "Event", "Type", "s", "\":", " ", "3", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "event", "Type", "s", "\":", " ", "[", "\\", "10", ";", " ", " ", "{", "\\", "10", ";", " ", " ", "\"", "id", "\":", " ", "1", ",", "\\", "10", ";", " ", " ", "\"", "category", "\":", " ", "\"", "foo", "\",", "\\", "10", ";", " ", " ", "\"", "state", "\":", " ", "\"", "bar", "\",", "\\", "10", ";", " ", " ", "\"", "description", "\":", " ", "\"", "Foo", " ", "bar", " ", "all", " ", "the", " ", "way", "\",", "\\", "10", ";", " ", " ", "\"", "href", "\":", " ", "\"/", "api", "/", "v1", "/", "event", "types", "/", "1", "\"", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "...", "\\", "10", ";", " ", " ", " ", " ", "],", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "category", ":", " ", "(*", "option", "al", "*)", " ", "Filter", " ", "Event", "Type", "s", " ", "by", " ", "category", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "state", ":", " ", "(*", "option", "al", "*)", " ", "Filter", " ", "Event", "Type", "s", " ", "by", " ", "state", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "limit", ":", " ", "(*", "option", "al", "*)", " ", "Limit", " ", "result", " ", "to", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "offset", ":", " ", "(*", "option", "al", "*)", " ", "Ski", "p", " ", "the", " ", "first", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "boolean", " ", "startin", "g", "Type", "s", ":", " ", "(*", "option", "al", "*)", " ", "Return", " ", "the", " ", "event", " ", "types", " ", "tha", "t", " ", "can", " ", "create", " ", "non", "-", "intermediate", " ", "Labo", "rs", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "200", ":", " ", "The", " ", "request", " ", "was", " ", "success", "ful", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "401", ":", " ", "The", " ", "request", " ", "was", " ", "made", " ", "with", "out", " ", "bei", "ng", " ", "logged", " ", "in", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "category", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "state", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "startin", "g", "\\u", "types_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "startin", "g", "Type", "s", "\"_", ",_", "False_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "event", "\\u", "types_", "=_", "self_", "._", "session_", "._", "query_", "(_", "Event", "Type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "category_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "types_", "=_", "event", "\\u", "types_", "._", "filter", "\\u", "by_", "(_", "category_", "=_", "category_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "state_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "types_", "=_", "event", "\\u", "types_", "._", "filter", "\\u", "by_", "(_", "state_", "=_", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "startin", "g", "\\u", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "startin", "g", "\\u", "event", "\\u", "types_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "query_", "(_", "Fat", "e_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter_", "(_", "Fat", "e_", "._", "follow", "s", "\\u", "id_", "==_", "None_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "group", "\\u", "by_", "(_", "Fat", "e_", "._", "creati", "on", "\\u", "type", "\\u", "id_", ")_", "._", "all_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "event", "\\u", "types_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "event", "\\u", "types_", "._", "filter_", "(_", "Event", "Type_", "._", "id_", "._", "in\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "e\\u", "type_", "._", "creati", "on", "\\u", "type", "\\u", "id_", "for_", "e\\u", "type_", "in_", "startin", "g", "\\u", "event", "\\u", "types_", "\\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_", "offset_", ",_", "limit_", ",_", "expand_", "=_", "self_", "._", "get", "\\u", "pagina", "tion", "\\u", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "event", "\\u", "types_", ",_", "total_", "=_", "self_", "._", "paginate", "\\u", "query_", "(_", "event", "\\u", "types_", ",_", "offset_", ",_", "limit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "limit", "\"_", ":_", "limit_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "offset", "\"_", ":_", "offset_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "total", "Event", "Type", "s", "\"_", ":_", "total_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "event", "Type", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "event", "\\u", "type_", "._", "to", "\\u", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "base", "\\u", "uri_", "=_", "self_", "._", "href", "\\u", "prefix_", ",_", "expand_", "=_", "set_", "(_", "expand_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "event", "\\u", "type_", "in_", "event", "\\u", "types_", "._", "all_", "(_", ")_", "\\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_", "self_", "._", "success_", "(_", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Labo", "rs", "Handler_", "(_", "Ap", "i", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "**", "Get", " ", "all", " ", "Labo", "rs", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "Request", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "GET", " ", "/", "api", "/", "v1", "/", "labor", "s", " ", "HTTP", "/", "1.1", "\\", "10", ";", " ", " ", " ", " ", "Host", ":", " ", "local", "host", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "response", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "HTTP", "/", "1.1", " ", "200", " ", "OK", "\\", "10", ";", " ", " ", " ", " ", "Conten", "t", "-", "Type", ":", " ", "applica", "tion", "/", "json", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "status", "\":", " ", "\"", "ok", "\",", "\\", "10", ";", " ", " ", " ", " ", "\"", "limit", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "offset", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "total", "Fat", "es", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "labor", "s", "\":", " ", "[", "\\", "10", ";", " ", " ", "{", "\\", "10", ";", " ", " ", "\"", "id", "\":", " ", "23", ",", "\\", "10", ";", " ", " ", "\"", "startin", "g", "Labo", "r", "Id", "\":", " ", "null", ",", "\\", "10", ";", " ", " ", "\"", "href", "\":", " ", "\"/", "api", "/", "v1", "/", "labor", "s", "/", "23", "\",", "\\", "10", ";", " ", " ", "\"", "for", "\\u", "owner", "\":", " ", "fal", "se", ",", "\\", "10", ";", " ", " ", "\"", "for", "\\u", "creat", "or", "\":", " ", "true", ",", "\\", "10", ";", " ", " ", "\"", "quest", "Id", "\":", " ", "5", ",", "\\", "10", ";", " ", " ", "\"", "host", "Id", "\":", " ", "2", "6", ",", "\\", "10", ";", " ", " ", "\"", "creati", "on", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "ack", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "target", "Time", "\":", " ", "timestamp", "\\", "10", ";", " ", " ", "\"", "ack", "User", "\":", " ", "string", ",", "\\", "10", ";", " ", " ", "\"", "completion", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "creati", "on", "Event", "Id", "\":", " ", "127", ",", "\\", "10", ";", " ", " ", "\"", "completion", "Event", "Id", "\":", " ", "212", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "...", "\\", "10", ";", " ", " ", " ", " ", "],", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "host", "name", ":", " ", "(*", "option", "al", "*)", " ", "filter", " ", "Labo", "rs", " ", "by", " ", "a", " ", "partic", "ular", " ", "host", "name", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "startin", "g", "Labo", "r", "Id", ":", " ", "(*", "option", "al", "*)", " ", "get", " ", "Labo", "rs", " ", "by", " ", "the", " ", "Id", " ", "or", " ", "the", " ", "Id", " ", "of", " ", "the", " ", "startin", "g", " ", "labor", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "host", "Query", ":", " ", "(*", "option", "al", "*)", " ", "the", " ", "query", " ", "to", " ", "send", " ", "to", " ", "the", " ", "plugin", " ", "to", " ", "come", " ", "up", " ", "with", " ", "the", " ", "list", " ", "of", " ", "hostnames", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "user", "Query", ":", " ", "(*", "option", "al", "*)", " ", "get", " ", "labor", "s", " ", "for", " ", "machine", "s", " ", "owned", " ", "by", " ", "this", " ", "user", " ", "or", " ", "for", " ", "whi", "ch", " ", "this", " ", "user", " ", "is", " ", "responsib", "le", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "category", ":", " ", "(*", "option", "al", "*)", " ", "limit", " ", "labor", "s", " ", "to", " ", "ones", " ", "where", " ", "the", " ", "startin", "g", " ", "event", " ", "type", " ", "is", " ", "of", " ", "this", " ", "category", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "state", ":", " ", "(*", "option", "al", "*)", " ", "limit", " ", "labor", "s", " ", "to", " ", "ones", " ", "where", " ", "the", " ", "startin", "g", " ", "event", " ", "type", " ", "is", " ", "of", " ", "this", " ", "state", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "boolean", " ", "open", ":", " ", "if", " ", "true", ",", " ", "filter", " ", "Labo", "rs", " ", "to", " ", "tho", "se", " ", "still", " ", "open", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "quest", "Id", ":", " ", "the", " ", "id", " ", "of", " ", "the", " ", "quest", " ", "we", " ", "want", " ", "to", " ", "filter", " ", "by", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "expand", ":", " ", "(*", "option", "al", "*)", " ", "support", "s", " ", "host", "s", ",", " ", "event", "types", ",", " ", "events", ",", " ", "quest", "s", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "limit", ":", " ", "(*", "option", "al", "*)", " ", "Limit", " ", "result", " ", "to", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "offset", ":", " ", "(*", "option", "al", "*)", " ", "Ski", "p", " ", "the", " ", "first", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "200", ":", " ", "The", " ", "request", " ", "was", " ", "success", "ful", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "401", ":", " ", "The", " ", "request", " ", "was", " ", "made", " ", "with", "out", " ", "bei", "ng", " ", "logged", " ", "in", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hostname_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "host", "name", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "startin", "g", "\\u", "labor", "\\u", "id_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "startin", "g", "Labo", "r", "Id", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open", "\\u", "flag_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "open", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "quest", "\\u", "id_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "quest", "Id", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "\\u", "query_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "host", "Query", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "query_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "user", "Query", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "category_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "category", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "state_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "state", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "labor", "s_", "=_", "self_", "._", "session_", "._", "query_", "(_", "Labo", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "filtering", " ", "by", " ", "category", " ", "or", " ", "state", ",", " ", "find", " ", "the", " ", "event", " ", "types", " ", "tha", "t", " ", "match_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "these", " ", "condition", "s", " ", "and", " ", "add", " ", "them", " ", "to", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "category_", "or_", "state_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "types_", "=_", "self_", "._", "session_", "._", "query_", "(_", "Event", "Type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "category_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "types_", "=_", "event", "\\u", "types_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Event", "Type_", "._", "category_", "==_", "category_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "state_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "types_", "=_", "event", "\\u", "types_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Event", "Type_", "._", "state_", "==_", "state_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "valid", "\\u", "event", "\\u", "types_", "=_", "[_", "event", "\\u", "type_", "._", "id_", "for_", "event", "\\u", "type_", "in_", "event", "\\u", "types_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labor", "s_", "=_", "labor", "s_", "._", "join_", "(_", "Labo", "r_", "._", "creati", "on", "\\u", "event_", ")_", "._", "join_", "(_", "Event_", "._", "event", "\\u", "type_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Event", "Type_", "._", "id_", "._", "in\\u_", "(_", "valid", "\\u", "event", "\\u", "types_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "speci", "fy", "ing", " ", "to", " ", "filter", " ", "by", " ", "open", " ", "or", " ", "close", "d", " ", "state", ",", " ", "add", " ", "tha", "t", " ", "to", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "open", "\\u", "flag_", "and_", "open", "\\u", "flag_", "._", "lower_", "(_", ")_", "==_", "\"", "true", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "Labo", "r_", "._", "completion", "\\u", "event", "\\u", "id_", "==_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "open", "\\u", "flag_", "and_", "open", "\\u", "flag_", "._", "lower_", "(_", ")_", "==_", "\"", "fal", "se", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "Labo", "r_", "._", "completion", "\\u", "event", "\\u", "id_", "!=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "quest", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "Labo", "r_", "._", "quest", "\\u", "id_", "==_", "quest", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "startin", "g", "\\u", "labor", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "or\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "id_", "==_", "startin", "g", "\\u", "labor", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "startin", "g", "\\u", "labor", "\\u", "id_", "==_", "startin", "g", "\\u", "labor", "\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "user", " ", "want", "s", " ", "to", " ", "filter", " ", "by", " ", "a", " ", "specific", " ", "host", ",", " ", "verify", " ", "tha", "t", " ", "the", " ", "host", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "good", " ", "and", " ", "add", " ", "tha", "t", " ", "to", " ", "the", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hostname_", "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 ", " _", "host_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "query_", "(_", "Host_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Host_", "._", "hostname_", "==_", "hostname_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "one_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\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 ", " _", "raise_", "exc_", "._", "Ba", "d", "Request_", "(_", "\"", "No", " ", "host", " ", "{}", " ", "found", "\"_", "._", "format_", "(_", "hostname_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "labor", "s_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "labor", "s_", "._", "filter_", "(_", "Labo", "r_", "._", "host_", "==_", "host_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "order", "\\u", "by_", "(_", "desc_", "(_", "Labo", "r_", "._", "creati", "on", "\\u", "time_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "user", " ", "specified", " ", "a", " ", "host", " ", "query", ",", " ", "we", " ", "need", " ", "to", " ", "translat", "e", " ", "tha", "t", " ", "int", "o", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "list", " ", "of", " ", "hostnames", " ", "to", " ", "use", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "host", "\\u", "query", "\\u", "hostnames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "host", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "Plug", "in", "Helper_", "._", "request", "\\u", "get_", "(_", "params_", "=_", "{_", "\"", "query", "\"_", ":_", "host", "\\u", "query_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "._", "status", "\\u", "code_", "==_", "200_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "status", "\"_", "]_", "==_", "\"", "ok", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", " ", "--", " ", "coul", "dn", "'", "t", " ", "this", " ", "just", " ", "be", " ", "hostnames", ".", "extend", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "hostname_", "in_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "results", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "host", "\\u", "query", "\\u", "hostnames", "_", "._", "append_", "(_", "hostname_", ")_", "\\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_", "exc_", "._", "Ba", "d", "Request_", "(_", "\"", "Ba", "d", " ", "host", " ", "query", ":", " ", "{}\"_", "._", "format_", "(_", "host", "\\u", "query_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "user", " ", "want", "s", " ", "to", " ", "filter", " ", "by", " ", "user", ",", " ", "let", "'", "s", " ", "first", " ", "find", " ", "the", " ", "hostnames", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "machine", "s", " ", "the", " ", "user", " ", "wou", "ld", " ", "be", " ", "responsib", "le", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user", "\\u", "query", "\\u", "hostnames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "created", "\\u", "quest", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "Plug", "in", "Helper_", "._", "request", "\\u", "get_", "(_", "params_", "=_", "{_", "\"", "user", "\"_", ":_", "user", "\\u", "query_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "._", "status", "\\u", "code_", "==_", "200_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "status", "\"_", "]_", "==_", "\"", "ok", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "hostname_", "in_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "results", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "user", "\\u", "query", "\\u", "hostnames", "_", "._", "append_", "(_", "hostname_", ")_", "\\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_", "exc_", "._", "Ba", "d", "Request_", "(_", "\"", "Ba", "d", " ", "user", " ", "query", ":", " ", "{}\"_", "._", "format_", "(_", "user", "\\u", "query_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user", "\\u", "created", "\\u", "quest", "s_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "quest_", "._", "id_", "for_", "quest_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "query_", "(_", "Quest", "_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Quest", "_", "._", "creator_", "==_", "user", "\\u", "query_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "all_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sinc", "e", " ", "we", " ", "may", " ", "have", " ", "used", " ", "multiple", " ", "way", "s", " ", "to", " ", "get", " ", "host", "name", " ", "lists", ",", " ", "compile_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "int", "o", " ", "a", " ", "final", " ", "list", " ", "of", " ", "hostnames", " ", "we", " ", "care", " ", "about_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hostnames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "host", "\\u", "query_", "and_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostnames", "_", "=_", "list_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "set_", "(_", "host", "\\u", "query", "\\u", "hostnames", "_", ")_", "&_", "set_", "(_", "user", "\\u", "query", "\\u", "hostnames", "_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "host", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostnames", "_", "=_", "host", "\\u", "query", "\\u", "hostnames", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostnames", "_", "=_", "user", "\\u", "query", "\\u", "hostnames", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "are", " ", "just", " ", "doi", "ng", " ", "a", " ", "simple", " ", "host", "\\u", "query", ",", " ", "we", " ", "can", " ", "just", " ", "filter", " ", "by_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "hostnames", " ", "we", " ", "collected", ".", " ", " ", "Ot", "her", "wis", "e", ",", " ", "if", " ", "we", " ", "are", " ", "doi", "ng", " ", "a", " ", "user", "\\u", "query_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "need", " ", "not", " ", "just", " ", "host", "s", " ", "owned", " ", "by", " ", "the", " ", "user", ",", " ", "but", " ", "als", "o", " ", "labor", "s", " ", "tha", "t", " ", "belo", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "a", " ", "quest", " ", "creat", "or", " ", "tha", "t", " ", "matche", "s", " ", "the", " ", "user", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "host", "\\u", "query_", "or_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "hostnames", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "exc_", "._", "Ba", "d", "Request_", "(_", "\"", "Query", "ing", " ", "on", " ", "0", " ", "host", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hosts_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "session_", "._", "query_", "(_", "Host_", ")_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Host_", "._", "hostname_", "._", "in\\u_", "(_", "hostnames", "_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "\\u", "ids_", "=_", "[_", "host_", "._", "id_", "for_", "host_", "in_", "hosts_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "and\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "host", "\\u", "id_", "._", "in\\u_", "(_", "host", "\\u", "ids_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "for", "\\u", "owner_", "==_", "1_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "hostnames", "_", "and_", "user", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labor", "s_", "=_", "labor", "s_", "._", "filter_", "(_", "or\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "and\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "host", "\\u", "id_", "._", "in\\u_", "(_", "host", "\\u", "ids_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "for", "\\u", "owner_", "==_", "1_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "and\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "for", "\\u", "creator_", "==_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Labo", "r_", "._", "quest", "\\u", "id_", "._", "in\\u_", "(_", "user", "\\u", "created", "\\u", "quest", "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\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "offset_", ",_", "limit_", ",_", "expand_", "=_", "self_", "._", "get", "\\u", "pagina", "tion", "\\u", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labor", "s_", ",_", "total_", "=_", "self_", "._", "paginate", "\\u", "query_", "(_", "labor", "s_", ",_", "offset_", ",_", "limit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "labor", "s_", "=_", "labor", "s_", "._", "from", "\\u", "self_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "Labo", "r_", "._", "creati", "on", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "limit", "\"_", ":_", "limit_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "offset", "\"_", ":_", "offset_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "total", "Labo", "rs", "\"_", ":_", "total_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "labor", "s", "\"_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "labor", "_", "._", "to", "\\u", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "base", "\\u", "uri_", "=_", "self_", "._", "href", "\\u", "prefix_", ",_", "expand_", "=_", "set_", "(_", "expand_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "for_", "labor", "_", "in_", "labor", "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_", "self_", "._", "success_", "(_", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Quest", "s", "Handler_", "(_", "Ap", "i", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "**", "Get", " ", "all", " ", "Quest", "s", "**", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "Request", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "GET", " ", "/", "api", "/", "v1", "/", "quest", "s", "?", "progress", "Info", "=", "true", " ", "HTTP", "/", "1.1", "\\", "10", ";", " ", " ", " ", " ", "Host", ":", " ", "local", "host", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "**", "Exam", "ple", " ", "response", ":*", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "source", "code", "::", " ", "http", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "HTTP", "/", "1.1", " ", "200", " ", "OK", "\\", "10", ";", " ", " ", " ", " ", "Conten", "t", "-", "Type", ":", " ", "applica", "tion", "/", "json", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "\"", "status", "\":", " ", "\"", "ok", "\",", "\\", "10", ";", " ", " ", " ", " ", "\"", "limit", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "offset", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "total", "Quest", "s", "\":", " ", "int", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "quest", "s", "\":", " ", "[", "\\", "10", ";", " ", " ", "{", "\\", "10", ";", " ", " ", "\"", "id", "\":", " ", "1", ",", "\\", "10", ";", " ", " ", "\"", "href", "\":", " ", "\"/", "api", "/", "v1", "/", "quest", "s", "/", "1", "\",", "\\", "10", ";", " ", " ", "\"", "creat", "or", "\":", " ", "\"", "john", "ny", "\",", "\\", "10", ";", " ", " ", "\"", "emb", "ark", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "target", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "completion", "Time", "\":", " ", "timestamp", ",", "\\", "10", ";", " ", " ", "\"", "description", "\":", " ", "\"", "Thi", "s", " ", "is", " ", "a", " ", "quest", " ", "alm", "ight", "y", "\",", "\\", "10", ";", " ", " ", "\"", "total", "Labo", "rs", "\":", " ", "20", ",", "\\", "10", ";", " ", " ", "\"", "open", "Labo", "rs", "\":", " ", "10", ",", "\\", "10", ";", " ", " ", "\"", "percent", "Complete", "\":", " ", "50", ",", "\\", "10", ";", " ", " ", "\"", "labor", "s", "\":", " ", "[]", ",", "\\", "10", ";", " ", " ", "},", "\\", "10", ";", " ", " ", "...", "\\", "10", ";", " ", " ", " ", " ", "],", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "boolean", " ", "filter", "Clos", "ed", ":", " ", "(*", "option", "al", "*)", " ", "if", " ", "true", ",", " ", "filter", " ", "out", " ", "complete", "d", " ", "Quest", "s", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "boolean", " ", "progress", "Info", ":", " ", "(*", "option", "al", "*)", " ", "if", " ", "true", ",", " ", "include", " ", "progress", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "by", "Creat", "or", ":", " ", "(*", "option", "al", "*)", " ", "if", " ", "set", ",", " ", "filter", " ", "the", " ", "quest", "s", " ", "by", " ", "a", " ", "partic", "ular", " ", "creat", "or", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "hostnames", ":", " ", "(*", "option", "al", "*)", " ", "filter", " ", "to", " ", "quest", "s", " ", "tha", "t", " ", "pert", "ain", " ", "to", " ", "a", " ", "partic", "ular", " ", "host", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "string", " ", "host", "Query", ":", " ", "(*", "option", "al", "*)", " ", "filter", " ", "quest", "s", " ", "to", " ", "tho", "se", " ", "involv", "ing", " ", "host", "s", " ", "return", "ed", " ", "by", " ", "the", " ", "external", " ", "query", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "limit", ":", " ", "(*", "option", "al", "*)", " ", "Limit", " ", "result", " ", "to", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "query", " ", "int", " ", "offset", ":", " ", "(*", "option", "al", "*)", " ", "Ski", "p", " ", "the", " ", "first", " ", "N", " ", "resource", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "200", ":", " ", "The", " ", "request", " ", "was", " ", "success", "ful", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "statusc", "ode", " ", "401", ":", " ", "The", " ", "request", " ", "was", " ", "made", " ", "with", "out", " ", "bei", "ng", " ", "logged", " ", "in", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "\\u", "closed_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "filter", "Clos", "ed", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "progress", "\\u", "info_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "progress", "Info", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "by", "\\u", "creator_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "by", "Creat", "or", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hostnames", "_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "hostnames", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "\\u", "query_", "=_", "self_", "._", "get", "\\u", "argument_", "(_", "\"", "host", "Query", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hostnames", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostnames", "_", "=_", "hostnames", "_", "._", "split_", "(_", "\",\"_", ")_", "\\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 ", " _", "hostnames", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "host", "\\u", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "Plug", "in", "Helper_", "._", "request", "\\u", "get_", "(_", "params_", "=_", "{_", "\"", "query", "\"_", ":_", "host", "\\u", "query_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "._", "status", "\\u", "code_", "==_", "200_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "status", "\"_", "]_", "==_", "\"", "ok", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "hostname_", "in_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "results", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "hostnames", "_", "._", "append_", "(_", "hostname_", ")_", "\\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_", "exc_", "._", "Ba", "d", "Request_", "(_", "\"", "Ba", "d", " ", "host", " ", "query", ":", " ", "{}\"_", "._", "format_", "(_", "host", "\\u", "query_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "used", " ", "to", " ", "sort", " ", "in", " ", "reverse", " ", "emb", "ark", " ", "time", " ", "so", " ", "tha", "t", " ", "the", " ", "default", " ", "wou", "ld", " ", "be_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "show", " ", "the", " ", "late", "st", " ", "quest", "s", " ", "but", " ", "we", " ", "don", "'", "t", " ", "want", " ", "to", " ", "do", " ", "tha", "t", " ", "any", "more_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "quest", "s", " ", "=", " ", "self", ".", "session", ".", "query", "(", "Quest", ").", "order", "\\u", "by", "(", "desc", "(", "Quest", ".", "emb", "ark", "\\u", "time", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "quest", "s_", "=_", "self_", "._", "session_", "._", "query_", "(_", "Quest", "_", ")_", "._", "order", "\\u", "by_", "(_", "Quest", "_", "._", "emb", "ark", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hostnames", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quest", "s_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "quest", "s_", "._", "join_", "(_", "Quest", "_", "._", "labor", "s_", ")_", "._", "join_", "(_", "Labo", "r_", "._", "host_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "filter_", "(_", "Host_", "._", "hostname_", "._", "in\\u_", "(_", "hostnames", "_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "group", "\\u", "by_", "(_", "Quest", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "filter", "\\u", "closed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quest", "s_", "=_", "quest", "s_", "._", "filter_", "(_", "Quest", "_", "._", "completion", "\\u", "time_", "==_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "by", "\\u", "creator_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quest", "s_", "=_", "quest", "s_", "._", "filter_", "(_", "Quest", "_", "._", "creator_", "==_", "by", "\\u", "creator_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "offset_", ",_", "limit_", ",_", "expand_", "=_", "self_", "._", "get", "\\u", "pagina", "tion", "\\u", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "quest", "s_", ",_", "total_", "=_", "self_", "._", "paginate", "\\u", "query_", "(_", "quest", "s_", ",_", "offset_", ",_", "limit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "quest", "s_", "=_", "quest", "s_", "._", "from", "\\u", "self_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "Quest", "_", "._", "emb", "ark", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "quest", "s", "\\u", "json_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "quest_", "in_", "quest", "s_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quest", "\\u", "json_", "=_", "quest_", "._", "to", "\\u", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "base", "\\u", "uri_", "=_", "self_", "._", "href", "\\u", "prefix_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expand_", "=_", "set_", "(_", "expand_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "progress", "\\u", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quest", "\\u", "json_", "=_", "quest_", "._", "calcul", "ate", "\\u", "progress_", "(_", "quest", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "quest", "s", "\\u", "json_", "._", "append_", "(_", "quest", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "json_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "limit", "\"_", ":_", "limit_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "offset", "\"_", ":_", "offset_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "total", "Quest", "s", "\"_", ":_", "total_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "quest", "s", "\"_", ":_", "quest", "s", "\\u", "json_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "success_", "(_", "json_", ")_", "\\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, 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f-8 -*-\n\n#Copyright 2015 RAPP\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# Author: Athanassios Kintsakis\n# contact: [email protected]\n\nimport rospy\nimport sys\nimport calendar\nimport time\nfrom datetime import datetime\nfrom os.path import expanduser\nfrom collections import OrderedDict\n\n\n\nfrom rapp_platform_ros_communications.srv import (\n createOntologyAliasSrv,\n createOntologyAliasSrvRequest,\n createOntologyAliasSrvResponse,\n recordUserCognitiveTestPerformanceSrv,\n recordUserCognitiveTestPerformanceSrvRequest,\n recordUserCognitiveTestPerformanceSrvResponse,\n recordUserPerformanceCognitiveTestsSrv,\n recordUserPerformanceCognitiveTestsSrvRequest,\n recordUserPerformanceCognitiveTestsSrvResponse\n )\n\nfrom rapp_platform_ros_communications.msg import (\n StringArrayMsg\n )\n\n## @class RecordUserCognitiveTestPerformance\n# @brief Provides the necessary functions for selecting a cognitive exercise test\n#\n# It implements the cognitive exercise record user cognitive test performance service\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class RecordUserCognitiveTestPerformance:\n\n ## @brief The callback function of the cognitive exercise record user cognitive test performance service\n # @param req [rapp_platform_ros_communications::recordUserCognitiveTestPerformanceSrvRequest::Request&] The ROS service request\n # @param res [rapp_platform_ros_communications::recordUserCognitiveTestPerformanceSrvResponse::Response&] The ROS service response\n # @exception Exception IndexError\n # @exception Exception AIOError", "metadata": "root.RecordUserCognitiveTestPerformance", "header": "['module', '___EOS___']", "index": 50 }, { "content": " def recordPerformance(self,req):\n try:\n res = recordUserCognitiveTestPerformanceSrvResponse()\n \n serv_topic = rospy.get_param('rapp_knowrob_wrapper_create_ontology_alias')\n knowrob_service = rospy.ServiceProxy(serv_topic, createOntologyAliasSrv)\n createOntologyAliasReq = createOntologyAliasSrvRequest()\n createOntologyAliasReq.username=req.username\n createOntologyAliasResponse = knowrob_service(createOntologyAliasReq)\n if(createOntologyAliasResponse.success!=True):\n res.trace=createOntologyAliasResponse.trace\n res.error=createOntologyAliasResponse.error\n res.success=False\n return res\n\n serv_topic = rospy.get_param('rapp_knowrob_wrapper_record_user_cognitive_tests_performance')\n knowrob_service = rospy.ServiceProxy(serv_topic, recordUserPerformanceCognitiveTestsSrv)\n userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest()\n userPerformanceEntry.test=req.test\n userPerformanceEntry.patient_ontology_alias=createOntologyAliasResponse.ontology_alias\n userPerformanceEntry.timestamp=int(time.time())\n userPerformanceEntry.score=req.score\n userPerformanceEntryResponse = knowrob_service(userPerformanceEntry)\n \n if(userPerformanceEntryResponse.success!=True):\n res.trace=userPerformanceEntryResponse.trace\n res.trace.append(\"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type\")\n res.error=userPerformanceEntryResponse.error+\"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type\"\n res.success=False\n return res\n else:\n res.success=True\n res.userCognitiveTestPerformanceEntry=userPerformanceEntryResponse.cognitive_test_performance_entry\n\n except IndexError:\n res.trace.append(\"Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format\")\n res.success=False\n except IOError:\n print \"Error: can\\'t find login file or read data\"\n res.success=False\n res.trace.append(\"Error: can\\'t find login file or read data\")\n return res", "metadata": "root.RecordUserCognitiveTestPerformance.recordPerformance", "header": "['class', 'RecordUserCognitiveTestPerformance', ':', '___NEWLINE___', '___NL___', '## @brief The callback function of the cognitive exercise record user cognitive test performance service', '___NL___', '# @param req [rapp_platform_ros_communications::recordUserCognitiveTestPerformanceSrvRequest::Request&] The ROS service request', '___NL___', '# @param res [rapp_platform_ros_communications::recordUserCognitiveTestPerformanceSrvResponse::Response&] The ROS service response', '___NL___', '# @exception Exception IndexError', '___NL___', '# @exception Exception AIOError', '___NL___', '___EOS___']", "index": 57 } ]
[ { "span": "import sys", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 10 }, { "span": "import calendar", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 15 }, { "span": "from os.path import expanduser", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 30 }, { "span": "from collections import OrderedDict", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 35 }, { "span": "from rapp_platform_ros_communications.srv import (\n createOntologyAliasSrv,\n createOntologyAliasSrvRequest,\n createOntologyAliasSrvResponse,\n recordUserCognitiveTestPerformanceSrv,\n recordUserCognitiveTestPerformanceSrvRequest,\n recordUserCognitiveTestPerformanceSrvResponse,\n recordUserPerformanceCognitiveTestsSrv,\n recordUserPerformanceCognitiveTestsSrvRequest,\n recordUserPerformanceCognitiveTestsSrvResponse\n )", "start_line": 30, "start_column": 0, "end_line": 40, "end_column": 3 }, { "span": "from rapp_platform_ros_communications.msg import (\n StringArrayMsg\n )", "start_line": 42, "start_column": 0, "end_line": 44, "end_column": 3 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-*-", " ", "encode", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Copy", "right", " ", "201", "5", " ", "RA", "PP", "_", "\\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_", "#", " ", "Author", ":", " ", "Ath", "ana", "ssi", "os", " ", "Kin", "tsa", "kis", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contact", ":", " ", "aki", "nts", "aki", "s", "@", "isse", "l", ".", "ee", ".", "auth", ".", "gr_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "rospy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "calendar_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "._", "path_", "import_", "expanduser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "Order", "ed", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s_", "._", "srv_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Perform", "anc", "e", "Cog", "niti", "ve", "Test", "s", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Perform", "anc", "e", "Cog", "niti", "ve", "Test", "s", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "User", "Perform", "anc", "e", "Cog", "niti", "ve", "Test", "s", "Sr", "v", "Response_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s_", "._", "msg_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "String", "Array", "Msg_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "@", "class", " ", "Record", "User", "Cog", "niti", "ve", "Test", "Perform", "ance_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "brief", " ", "Prov", "ides", " ", "the", " ", "necessar", "y", " ", "function", "s", " ", "for", " ", "selecti", "ng", " ", "a", " ", "cogni", "tiv", "e", " ", "exercise", " ", "test_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", " ", "implement", "s", " ", "the", " ", "cogni", "tiv", "e", " ", "exercise", " ", "record", " ", "user", " ", "cogni", "tiv", "e", " ", "test", " ", "perform", "anc", "e", " ", "service_", "\\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_", "Record", "User", "Cog", "niti", "ve", "Test", "Perform", "ance_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "@", "brief", " ", "The", " ", "callback", " ", "function", " ", "of", " ", "the", " ", "cogni", "tiv", "e", " ", "exercise", " ", "record", " ", "user", " ", "cogni", "tiv", "e", " ", "test", " ", "perform", "anc", "e", " ", "service_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "req", " ", "[", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s", "::", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Request", "::", "Request", "&]", " ", "The", " ", "ROS", " ", "service", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "res", " ", "[", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s", "::", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Respons", "e", "::", "Respons", "e", "&]", " ", "The", " ", "ROS", " ", "service", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "exception", " ", "Except", "ion", " ", "Index", "Error_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "exception", " ", "Except", "ion", " ", "AI", "OE", "rror_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Record", "User", "Cog", "niti", "ve", "Test", "Perform", "ance_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "@", "brief", " ", "The", " ", "callback", " ", "function", " ", "of", " ", "the", " ", "cogni", "tiv", "e", " ", "exercise", " ", "record", " ", "user", " ", "cogni", "tiv", "e", " ", "test", " ", "perform", "anc", "e", " ", "service_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "req", " ", "[", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s", "::", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Request", "::", "Request", "&]", " ", "The", " ", "ROS", " ", "service", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "param", " ", "res", " ", "[", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s", "::", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Respons", "e", "::", "Respons", "e", "&]", " ", "The", " ", "ROS", " ", "service", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "exception", " ", "Except", "ion", " ", "Index", "Error_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "exception", " ", "Except", "ion", " ", "AI", "OE", "rror_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "record", "Perform", "ance_", "(_", "self_", ",_", "req_", ")_", ":_", "\\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 ", " _", "res_", "=_", "record", "User", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Sr", "v", "Response_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "serv", "\\u", "topic_", "=_", "rospy_", "._", "get", "\\u", "param_", "(_", "'", "rapp", "\\u", "know", "rob", "\\u", "wrapp", "er", "\\u", "create", "\\u", "ontology", "\\u", "alias", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "know", "rob", "\\u", "service_", "=_", "rospy_", "._", "Service", "Proxy_", "(_", "serv", "\\u", "topic_", ",_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Req_", "=_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v", "Request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Req_", "._", "username_", "=_", "req_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Response_", "=_", "know", "rob", "\\u", "service_", "(_", "create", "Ont", "olog", "y", "Ali", "as", "Req_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "create", "Ont", "olog", "y", "Ali", "as", "Response_", "._", "success_", "!=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "._", "trace_", "=_", "create", "Ont", "olog", "y", "Ali", "as", "Response_", "._", "trace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "error_", "=_", "create", "Ont", "olog", "y", "Ali", "as", "Response_", "._", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "success_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "serv", "\\u", "topic_", "=_", "rospy_", "._", "get", "\\u", "param_", "(_", "'", "rapp", "\\u", "know", "rob", "\\u", "wrapp", "er", "\\u", "record", "\\u", "user", "\\u", "cogni", "tiv", "e\\u", "tests", "\\u", "perform", "anc", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "know", "rob", "\\u", "service_", "=_", "rospy_", "._", "Service", "Proxy_", "(_", "serv", "\\u", "topic_", ",_", "record", "User", "Perform", "anc", "e", "Cog", "niti", "ve", "Test", "s", "Sr", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entry_", "=_", "record", "User", "Perform", "anc", "e", "Cog", "niti", "ve", "Test", "s", "Sr", "v", "Request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entry_", "._", "test_", "=_", "req_", "._", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entry_", "._", "patien", "t", "\\u", "ontology", "\\u", "alias_", "=_", "create", "Ont", "olog", "y", "Ali", "as", "Response_", "._", "ontology", "\\u", "alias_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entry_", "._", "timestamp_", "=_", "int_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entry_", "._", "score_", "=_", "req_", "._", "score_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "Perform", "anc", "e", "Entr", "y", "Response_", "=_", "know", "rob", "\\u", "service_", "(_", "user", "Perform", "anc", "e", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "user", "Perform", "anc", "e", "Entr", "y", "Response_", "._", "success_", "!=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "._", "trace_", "=_", "user", "Perform", "anc", "e", "Entr", "y", "Response_", "._", "trace_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "trace_", "._", "append_", "(_", "\"", "Submit", "ting", " ", "query", " ", "to", " ", "ontology", " ", "fail", "ed", ",", " ", "eit", "her", " ", "test", " ", "or", " ", "user", " ", "ontology", " ", "alias", " ", "do", " ", "not", " ", "exist", " ", "or", " ", "test", " ", "not", " ", "of", " ", "the", " ", "give", "n", " ", "type", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "error_", "=_", "user", "Perform", "anc", "e", "Entr", "y", "Response_", "._", "error_", "+_", "\"", "Submit", "ting", " ", "query", " ", "to", " ", "ontology", " ", "fail", "ed", ",", " ", "eit", "her", " ", "test", " ", "or", " ", "user", " ", "ontology", " ", "alias", " ", "do", " ", "not", " ", "exist", " ", "or", " ", "test", " ", "not", " ", "of", " ", "the", " ", "give", "n", " ", "type", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "success_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "res_", "\\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_", "._", "success_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "user", "Cog", "niti", "ve", "Test", "Perform", "anc", "e", "Entry_", "=_", "user", "Perform", "anc", "e", "Entr", "y", "Response_", "._", "cogni", "tiv", "e\\u", "test\\u", "perform", "anc", "e\\u", "entry_", "\\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_", "Index", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "._", "trace_", "._", "append_", "(_", "\"", "Wro", "ng", " ", "Query", " ", "Inp", "ut", " ", "Format", ",", " ", "check", " ", "for", " ", "empty", " ", "require", "d", " ", "column", "s", " ", "list", " ", "or", " ", "wrong", "/", "incomplete", " ", "Query", " ", "data", " ", "format", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "success_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Error", ":", " ", "can", "\\\\'", "t", " ", "find", " ", "login", " ", "file", " ", "or", " ", "read", " ", "data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "success_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "._", "trace_", "._", "append_", "(_", "\"", "Error", ":", " ", "can", "\\\\'", "t", " ", "find", " ", "login", " ", "file", " ", "or", " ", "read", " ", "data", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "res_"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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 ]
Module is imported with 'import' and 'import from'
rapp-project/rapp-platform/rapp_cognitive_exercise/src/test_selector.py
[ { "content": "#!/usr/bin/env python\n# -*- encode: utf-8 -*-\n\n#Copyright 2015 RAPP\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# Author: Athanassios Kintsakis\n# contact: [email protected]\n\n\nimport rospkg\nimport rospy\nimport sys\nimport xml.etree.ElementTree as ET\nimport calendar\nimport time\nimport random\nfrom datetime import datetime\nfrom os.path import expanduser\nfrom collections import OrderedDict\nfrom random import randint\nfrom codecs import open\n\n\nfrom rapp_platform_ros_communications.srv import (\n ontologySubSuperClassesOfSrv,\n ontologySubSuperClassesOfSrvRequest,\n ontologySubSuperClassesOfSrvResponse,\n testSelectorSrv,\n testSelectorSrvResponse,\n createOntologyAliasSrv,\n createOntologyAliasSrvRequest,\n createOntologyAliasSrvResponse,\n userPerformanceCognitveTestsSrv,\n userPerformanceCognitveTestsSrvRequest,\n userPerformanceCognitveTestsSrvResponse,\n cognitiveTestsOfTypeSrv,\n cognitiveTestsOfTypeSrvRequest,\n cognitiveTestsOfTypeSrvResponse,\n fetchDataSrv,\n fetchDataSrvRequest,\n fetchDataSrvResponse\n )\n\nfrom rapp_platform_ros_communications.msg import (\n StringArrayMsg\n )\n\n## @class TestSelector\n# @brief Provides the necessary functions for selecting a cognitive exercise test\n#\n# It implements the cognitive exercise chooser service\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import random", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "with_", "'", "import", "'_", "and_", "'", "import", " ", "from", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-*-", " ", "encode", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Copy", "right", " ", "201", "5", " ", "RA", "PP", "_", "\\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_", "#", " ", "Author", ":", " ", "Ath", "ana", "ssi", "os", " ", "Kin", "tsa", "kis", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contact", ":", " ", "aki", "nts", "aki", "s", "@", "isse", "l", ".", "ee", ".", "auth", ".", "gr_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "ros", "pkg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "rospy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "xml_", "._", "etree_", "._", "Element", "Tree_", "as_", "ET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "calendar_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "._", "path_", "import_", "expanduser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "Order", "ed", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "random_", "import_", "randint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "codecs_", "import_", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s_", "._", "srv_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "ontology", "Sub", "Super", "Class", "es", "Of", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ontology", "Sub", "Super", "Class", "es", "Of", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ontology", "Sub", "Super", "Class", "es", "Of", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "test", "Select", "or", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "test", "Select", "or", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "create", "Ont", "olog", "y", "Ali", "as", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user", "Perform", "anc", "e", "Cog", "nit", "ve", "Test", "s", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user", "Perform", "anc", "e", "Cog", "nit", "ve", "Test", "s", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user", "Perform", "anc", "e", "Cog", "nit", "ve", "Test", "s", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cogni", "tiv", "e", "Test", "s", "Of", "Type", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cogni", "tiv", "e", "Test", "s", "Of", "Type", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cogni", "tiv", "e", "Test", "s", "Of", "Type", "Sr", "v", "Response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fetch", "Data", "Sr", "v_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fetch", "Data", "Sr", "v", "Request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fetch", "Data", "Sr", "v", "Response_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "rapp", "\\u", "platform", "\\u", "ros", "\\u", "communication", "s_", "._", "msg_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "String", "Array", "Msg_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "@", "class", " ", "Test", "Selector_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "brief", " ", "Prov", "ides", " ", "the", " ", "necessar", "y", " ", "function", "s", " ", "for", " ", "selecti", "ng", " ", "a", " ", "cogni", "tiv", "e", " ", "exercise", " ", "test_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", " ", "implement", "s", " ", "the", " ", "cogni", "tiv", "e", " ", "exercise", " ", "choose", "r", " ", "service_", "\\u\\u\\uNL\\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, 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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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 ]
Testing equality to None
pantsbuild/pants/src/python/pants/scm/git.py
[ { "content": " def readlink(self, relpath):\n # TODO: Relatively inefficient, but easier than changing read_object, unfortunately.\n if type(self.lstat(relpath)) != self.Symlink:\n return None\n obj, path_so_far = self._safe_read_object(relpath, max_symlinks=1)\n if obj == None:\n return None\n return path_so_far", "metadata": "root.GitRepositoryReader.readlink", "header": "['class', 'GitRepositoryReader', '(', 'object', ')', ':', '___EOS___']", "index": 390 } ]
[ { "span": "obj == None:", "start_line": 395, "start_column": 7, "end_line": 395, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Git", "Repos", "itor", "y", "Reader_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "readli", "nk_", "(_", "self_", ",_", "relpath_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "Relative", "ly", " ", "ine", "ffic", "ient", ",", " ", "but", " ", "easi", "er", " ", "than", " ", "chang", "ing", " ", "read", "\\u", "object", ",", " ", "unfo", "rtu", "nat", "el", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "self_", "._", "lsta", "t_", "(_", "relpath_", ")_", ")_", "!=_", "self_", "._", "Sym", "link_", ":_", "\\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_", "obj_", ",_", "path", "\\u", "so", "\\u", "far_", "=_", "self_", "._", "\\u", "safe", "\\u", "read", "\\u", "object_", "(_", "relpath_", ",_", "max", "\\u", "symlinks", "_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "obj_", "==_", "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_", "path", "\\u", "so", "\\u", "far_", "\\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, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
pycollada/pycollada/collada/util.py
[ { "content": " def __setslice__(self, i, j, newItems):\n _get = self.__getitem__\n _add = self._addindex\n _del = self._delindex\n newItems = list(newItems)\n # remove indexing of items to remove\n for ind in xrange(i, j):\n _del(_get(ind))\n # add new indexing\n if isinstance(newList, IndexedList):\n self._index.update(newList._index)\n else:\n for obj in newList:\n _add(obj)\n # replace items\n return list.__setslice__(self, i, j, newList)", "metadata": "root.IndexedList.__setslice__", "header": "['class', 'IndexedList', '(', 'list', ')', ':', '___EOS___']", "index": 207 }, { "content": " def insert(self, ind, new_obj):\n # ensure that ind is a numeric index\n try:\n obj = list.__getitem__(self, ind)\n except (IndexError, TypeError):\n obj = self._index[ind]\n ind = list.index(self, obj)\n self._addindex(new_obj)\n return list.insert(self, ind, new_obj)", "metadata": "root.IndexedList.insert", "header": "['class', 'IndexedList', '(', 'list', ')', ':', '___EOS___']", "index": 238 } ]
[ { "span": "newItems ", "start_line": 211, "start_column": 8, "end_line": 211, "end_column": 16 }, { "span": "obj ", "start_line": 241, "start_column": 12, "end_line": 241, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Indexe", "d", "List_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "sets", "lice", "\\u\\u_", "(_", "self_", ",_", "i_", ",_", "j_", ",_", "new", "Items_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "get_", "=_", "self_", "._", "\\u\\u", "getitem\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "add_", "=_", "self_", "._", "\\u", "addin", "dex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "del_", "=_", "self_", "._", "\\u", "deli", "ndex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "Items_", "=_", "list_", "(_", "new", "Items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "indexing", " ", "of", " ", "items", " ", "to", " ", "remove_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ind_", "in_", "xrange_", "(_", "i_", ",_", "j_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "del_", "(_", "\\u", "get_", "(_", "ind_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "add", " ", "new", " ", "indexing", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "new", "List_", ",_", "Indexe", "d", "List_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "index_", "._", "update_", "(_", "new", "List_", "._", "\\u", "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 ", " _", "for_", "obj_", "in_", "new", "List_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "add_", "(_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "replace", " ", "items_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "list_", "._", "\\u\\u", "sets", "lice", "\\u\\u_", "(_", "self_", ",_", "i_", ",_", "j_", ",_", "new", "List_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Indexe", "d", "List_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "insert_", "(_", "self_", ",_", "ind_", ",_", "new", "\\u", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ensure", " ", "tha", "t", " ", "ind", " ", "is", " ", "a", " ", "numeri", "c", " ", "index_", "\\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 ", " _", "obj_", "=_", "list_", "._", "\\u\\u", "getitem\\u\\u_", "(_", "self_", ",_", "ind_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Index", "Error_", ",_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "self_", "._", "\\u", "index_", "[_", "ind_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ind_", "=_", "list_", "._", "index_", "(_", "self_", ",_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "addin", "dex_", "(_", "new", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "list_", "._", "insert_", "(_", "self_", ",_", "ind_", ",_", "new", "\\u", "obj_", ")_", "\\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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
pycollada/pycollada/collada/geometry.py
[ { "content": "####################################################################\n# #\n# THIS FILE IS PART OF THE pycollada LIBRARY SOURCE CODE. #\n# USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS #\n# GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE #\n# IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. #\n# #\n# THE pycollada SOURCE CODE IS (C) COPYRIGHT 2011 #\n# by Jeff Terrace and contributors #\n# #\n####################################################################\n\n\"\"\"Contains objects for representing a geometry.\"\"\"\n\nimport numpy\n\nfrom collada import source\nfrom collada import triangleset\nfrom collada import lineset\nfrom collada import polylist\nfrom collada import polygons\nfrom collada import primitive\nfrom collada.common import DaeObject, E, tag\nfrom collada.common import DaeIncompleteError, DaeBrokenRefError, \\\n DaeMalformedError, DaeUnsupportedError\nfrom collada.xmlutil import etree as ElementTree\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Geometry(DaeObject):\n \"\"\"A class containing the data coming from a COLLADA <geometry> tag\"\"\"\n\n\n\n\n\n\n\n\n\n", "metadata": "root.Geometry", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def __init__(self, collada, id, name, sourcebyid, primitives=None,\n xmlnode=None, double_sided=False):\n \"\"\"Create a geometry instance\n\n :param collada.Collada collada:\n The collada object this geometry belongs to\n :param str id:\n A unique string identifier for the geometry\n :param str name:\n A text string naming the geometry\n :param sourcebyid:\n A list of :class:`collada.source.Source` objects or\n a dictionary mapping source ids to the actual objects\n :param list primitives:\n List of primitive objects contained within the geometry.\n Do not set this argument manually. Instead, create a\n :class:`collada.geometry.Geometry` first and then append\n to :attr:`primitives` with the `create*` functions.\n :param xmlnode:\n When loaded, the xmlnode it comes from.\n :param bool double_sided:\n Whether or not the geometry should be rendered double sided\n\n \"\"\"\n self.collada = collada\n \"\"\"The :class:`collada.Collada` object this geometry belongs to\"\"\"\n\n self.id = id\n \"\"\"The unique string identifier for the geometry\"\"\"\n\n self.name = name\n \"\"\"The text string naming the geometry\"\"\"\n\n self.double_sided = double_sided\n \"\"\"A boolean indicating whether or not the geometry should be rendered double sided\"\"\"\n\n self.sourceById = sourcebyid\n \"\"\"A dictionary containing :class:`collada.source.Source` objects indexed by their id.\"\"\"\n\n if isinstance(sourcebyid, list):\n self.sourceById = {}\n for src in sourcebyid:\n self.sourceById[src.id] = src\n\n self.primitives = []\n \"\"\"List of primitives (base type :class:`collada.primitive.Primitive`) inside this geometry.\"\"\"\n if primitives is not None:\n self.primitives = primitives\n\n if xmlnode != None:\n self.xmlnode = xmlnode\n \"\"\"ElementTree representation of the geometry.\"\"\"\n else:\n sourcenodes = []\n verticesnode = None\n for srcid, src in self.sourceById.items():\n sourcenodes.append(src.xmlnode)\n if verticesnode is None:\n #pick first source to be in the useless <vertices> tag\n verticesnode = E.vertices(E.input(semantic='POSITION', source=\"#%s\"%srcid),\n id=srcid + '-vertices')\n meshnode = E.mesh(*sourcenodes)\n meshnode.append(verticesnode)\n self.xmlnode = E.geometry(meshnode)\n if len(self.id) > 0: self.xmlnode.set(\"id\", self.id)\n if len(self.name) > 0: self.xmlnode.set(\"name\", self.name)", "metadata": "root.Geometry.__init__", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 31 }, { "content": " def createLineSet(self, indices, inputlist, materialid):\n \"\"\"Create a set of lines for use in this geometry instance.\n\n :param numpy.array indices:\n unshaped numpy array that contains the indices for\n the inputs referenced in inputlist\n :param collada.source.InputList inputlist:\n The inputs for this primitive\n :param str materialid:\n A string containing a symbol that will get used to bind this lineset\n to a material when instantiating into a scene\n\n :rtype: :class:`collada.lineset.LineSet`\n \"\"\"\n inputdict = primitive.Primitive._getInputsFromList(self.collada, self.sourceById, inputlist.getList())\n return lineset.LineSet(inputdict, materialid, indices)", "metadata": "root.Geometry.createLineSet", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 98 }, { "content": " def createTriangleSet(self, indices, inputlist, materialid):\n \"\"\"Create a set of triangles for use in this geometry instance.\n\n :param numpy.array indices:\n unshaped numpy array that contains the indices for\n the inputs referenced in inputlist\n :param collada.source.InputList inputlist:\n The inputs for this primitive\n :param str materialid:\n A string containing a symbol that will get used to bind this triangleset\n to a material when instantiating into a scene\n\n :rtype: :class:`collada.triangleset.TriangleSet`\n \"\"\"\n inputdict = primitive.Primitive._getInputsFromList(self.collada, self.sourceById, inputlist.getList())\n return triangleset.TriangleSet(inputdict, materialid, indices)", "metadata": "root.Geometry.createTriangleSet", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 115 }, { "content": " def createPolylist(self, indices, vcounts, inputlist, materialid):\n \"\"\"Create a polylist for use with this geometry instance.\n\n :param numpy.array indices:\n unshaped numpy array that contains the indices for\n the inputs referenced in inputlist\n :param numpy.array vcounts:\n unshaped numpy array that contains the vertex count\n for each polygon in this polylist\n :param collada.source.InputList inputlist:\n The inputs for this primitive\n :param str materialid:\n A string containing a symbol that will get used to bind this polylist\n to a material when instantiating into a scene\n\n :rtype: :class:`collada.polylist.Polylist`\n \"\"\"\n inputdict = primitive.Primitive._getInputsFromList(self.collada, self.sourceById, inputlist.getList())\n return polylist.Polylist(inputdict, materialid, indices, vcounts)", "metadata": "root.Geometry.createPolylist", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 132 }, { "content": " def createPolygons(self, indices, inputlist, materialid):\n \"\"\"Create a polygons for use with this geometry instance.\n\n :param numpy.array indices:\n list of unshaped numpy arrays that each contain the indices for\n a single polygon\n :param collada.source.InputList inputlist:\n The inputs for this primitive\n :param str materialid:\n A string containing a symbol that will get used to bind this polygons\n to a material when instantiating into a scene\n\n :rtype: :class:`collada.polygons.Polygons`\n \"\"\"\n inputdict = primitive.Primitive._getInputsFromList(self.collada, self.sourceById, inputlist.getList())\n return polygons.Polygons(inputdict, materialid, indices)", "metadata": "root.Geometry.createPolygons", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 152 }, { "content": " @staticmethod\n def load( collada, localscope, node ):\n id = node.get(\"id\") or \"\"\n name = node.get(\"name\") or \"\"\n meshnode = node.find(tag('mesh'))\n if meshnode is None: raise DaeUnsupportedError('Unknown geometry node')\n sourcebyid = {}\n sources = []\n sourcenodes = node.findall('%s/%s'%(tag('mesh'), tag('source')))\n for sourcenode in sourcenodes:\n ch = source.Source.load(collada, {}, sourcenode)\n sources.append(ch)\n sourcebyid[ch.id] = ch\n\n verticesnode = meshnode.find(tag('vertices'))\n if verticesnode is None:\n vertexsource = None\n else:\n inputnodes = {}\n for inputnode in verticesnode.findall(tag('input')):\n semantic = inputnode.get('semantic')\n inputsource = inputnode.get('source')\n if not semantic or not inputsource or not inputsource.startswith('#'):\n raise DaeIncompleteError('Bad input definition inside vertices')\n inputnodes[semantic] = sourcebyid.get(inputsource[1:])\n if (not verticesnode.get('id') or len(inputnodes)==0 or\n not 'POSITION' in inputnodes):\n raise DaeIncompleteError('Bad vertices definition in mesh')\n sourcebyid[verticesnode.get('id')] = inputnodes\n vertexsource = verticesnode.get('id')\n\n double_sided_node = node.find('.//%s//%s' % (tag('extra'), tag('double_sided')))\n double_sided = False\n if double_sided_node is not None and double_sided_node.text is not None:\n try:\n val = int(double_sided_node.text)\n if val == 1:\n double_sided = True\n except ValueError: pass\n\n _primitives = []\n for subnode in meshnode:\n if subnode.tag == tag('polylist'):\n _primitives.append( polylist.Polylist.load( collada, sourcebyid, subnode ) )\n elif subnode.tag == tag('triangles'):\n _primitives.append( triangleset.TriangleSet.load( collada, sourcebyid, subnode ) )\n elif subnode.tag == tag('lines'):\n _primitives.append( lineset.LineSet.load( collada, sourcebyid, subnode ) )\n elif subnode.tag == tag('polygons'):\n _primitives.append( polygons.Polygons.load( collada, sourcebyid, subnode ) )\n elif subnode.tag != tag('source') and subnode.tag != tag('vertices') and subnode.tag != tag('extra'):\n raise DaeUnsupportedError('Unknown geometry tag %s' % subnode.tag)\n geom = Geometry(collada, id, name, sourcebyid, _primitives, xmlnode=node, double_sided=double_sided )\n return geom", "metadata": "root.Geometry.load", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 169 }, { "content": " def save(self):\n \"\"\"Saves the geometry back to :attr:`xmlnode`\"\"\"\n meshnode = self.xmlnode.find(tag('mesh'))\n for src in self.sourceById.values():\n if isinstance(src, source.Source):\n src.save()\n if src.xmlnode not in meshnode.getchildren():\n meshnode.insert(0, src.xmlnode)\n\n deletenodes = []\n for oldsrcnode in meshnode.findall(tag('source')):\n if oldsrcnode not in [src.xmlnode\n for src in self.sourceById.values()\n if isinstance(src, source.Source)]:\n deletenodes.append(oldsrcnode)\n for d in deletenodes:\n meshnode.remove(d)\n\n #Look through primitives to find a vertex source\n vnode = self.xmlnode.find(tag('mesh')).find(tag('vertices'))\n\n #delete any inputs in vertices tag that no longer exist and find the vertex input\n delete_inputs = []\n for input_node in vnode.findall(tag('input')):\n if input_node.get('semantic') == 'POSITION':\n input_vnode = input_node\n else:\n srcid = input_node.get('source')[1:]\n if srcid not in self.sourceById:\n delete_inputs.append(input_node)\n\n for node in delete_inputs:\n vnode.remove(node)\n\n vert_sources = []\n for prim in self.primitives:\n for src in prim.sources['VERTEX']:\n vert_sources.append(src[2][1:])\n\n vert_src = vnode.get('id')\n vert_ref = input_vnode.get('source')[1:]\n\n if not(vert_src in vert_sources or vert_ref in vert_sources) and len(vert_sources) > 0:\n if vert_ref in self.sourceById and vert_ref in vert_sources:\n new_source = vert_ref\n else:\n new_source = vert_sources[0]\n self.sourceById[new_source + '-vertices'] = self.sourceById[new_source]\n input_vnode.set('source', '#' + new_source)\n vnode.set('id', new_source + '-vertices')\n\n #any source references in primitives that are pointing to the\n # same source that the vertices tag is pointing to to instead\n # point to the vertices id\n vert_src = vnode.get('id')\n vert_ref = input_vnode.get('source')[1:]\n for prim in self.primitives:\n for node in prim.xmlnode.findall(tag('input')):\n src = node.get('source')[1:]\n if src == vert_ref:\n node.set('source', '#%s' % vert_src)\n\n self.xmlnode.set('id', self.id)\n self.xmlnode.set('name', self.name)\n\n for prim in self.primitives:\n if type(prim) is triangleset.TriangleSet and prim.xmlnode.tag != tag('triangles'):\n prim._recreateXmlNode()\n if prim.xmlnode not in meshnode.getchildren():\n meshnode.append(prim.xmlnode)\n\n deletenodes = []\n primnodes = [prim.xmlnode for prim in self.primitives]\n for child in meshnode.getchildren():\n if child.tag != tag('vertices') and child.tag != tag('source') and child not in primnodes:\n deletenodes.append(child)\n for d in deletenodes:\n meshnode.remove(d)", "metadata": "root.Geometry.save", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 224 }, { "content": " def bind(self, matrix, materialnodebysymbol):\n \"\"\"Binds this geometry to a transform matrix and material mapping.\n The geometry's points get transformed by the given matrix and its\n inputs get mapped to the given materials.\n\n :param numpy.array matrix:\n A 4x4 numpy float matrix\n :param dict materialnodebysymbol:\n A dictionary with the material symbols inside the primitive\n assigned to :class:`collada.scene.MaterialNode` defined in the\n scene\n\n :rtype: :class:`collada.geometry.BoundGeometry`\n\n \"\"\"\n return BoundGeometry(self, matrix, materialnodebysymbol)", "metadata": "root.Geometry.bind", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 303 }, { "content": " def __str__(self):\n return '<Geometry id=%s, %d primitives>' % (self.id, len(self.primitives))", "metadata": "root.Geometry.__str__", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 320 }, { "content": " def __repr__(self):\n return str(self)", "metadata": "root.Geometry.__repr__", "header": "['class', 'Geometry', '(', 'DaeObject', ')', ':', '___EOS___']", "index": 323 }, { "content": "class BoundGeometry( object ):\n \"\"\"A geometry bound to a transform matrix and material mapping.\n This gets created when a geometry is instantiated in a scene.\n Do not create this manually.\"\"\"\n\n\n\n\n", "metadata": "root.BoundGeometry", "header": "['module', '___EOS___']", "index": 327 }, { "content": " def __init__(self, geom, matrix, materialnodebysymbol):\n self.matrix = matrix\n \"\"\"The matrix bound to\"\"\"\n self.materialnodebysymbol = materialnodebysymbol\n \"\"\"Dictionary with the material symbols inside the primitive\n assigned to :class:`collada.scene.MaterialNode` defined in the\n scene\"\"\"\n self._primitives = geom.primitives\n self.original = geom\n \"\"\"The original :class:`collada.geometry.Geometry` object this\n is bound to\"\"\"", "metadata": "root.BoundGeometry.__init__", "header": "['class', 'BoundGeometry', '(', 'object', ')', ':', '___EOS___']", "index": 332 }, { "content": " def __len__(self):\n \"\"\"Returns the number of primitives in the bound geometry\"\"\"\n return len(self._primitives)", "metadata": "root.BoundGeometry.__len__", "header": "['class', 'BoundGeometry', '(', 'object', ')', ':', '___EOS___']", "index": 344 }, { "content": " def primitives(self):\n \"\"\"Returns an iterator that iterates through the primitives in\n the bound geometry. Each value returned will be of base type\n :class:`collada.primitive.BoundPrimitive`\"\"\"\n for p in self._primitives:\n boundp = p.bind( self.matrix, self.materialnodebysymbol )\n yield boundp", "metadata": "root.BoundGeometry.primitives", "header": "['class', 'BoundGeometry', '(', 'object', ')', ':', '___EOS___']", "index": 348 }, { "content": " def __str__(self):\n return '<BoundGeometry id=%s, %d primitives>' % (self.original.id, len(self))", "metadata": "root.BoundGeometry.__str__", "header": "['class', 'BoundGeometry', '(', 'object', ')', ':', '___EOS___']", "index": 356 }, { "content": " def __repr__(self):\n return str(self)", "metadata": "root.BoundGeometry.__repr__", "header": "['class', 'BoundGeometry', '(', 'object', ')', ':', '___EOS___']", "index": 359 } ]
[ { "span": "import numpy", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 12 }, { "span": "from collada.common import DaeIncompleteError, DaeBrokenRefError, \\\n DaeMalformedError, DaeUnsupportedError", "start_line": 23, "start_column": 0, "end_line": 24, "end_column": 46 }, { "span": "from collada.xmlutil import etree as ElementTree", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 48 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THIS", " ", "FILE", " ", "IS", " ", "PART", " ", "OF", " ", "THE", " ", "pyco", "lla", "da", " ", "LIBRARY", " ", "SOU", "RC", "E", " ", "CODE", ".", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "USE", ",", " ", "DISTRI", "BUT", "ION", " ", "AND", " ", "REP", "RO", "DU", "CTION", " ", "OF", " ", "THIS", " ", "LIBRARY", " ", "SOU", "RC", "E", " ", "IS", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "GO", "VER", "NED", " ", "BY", " ", "A", " ", "BS", "D", "-", "STYLE", " ", "SOU", "RC", "E", " ", "LICENSE", " ", "INCLUDE", "D", " ", "WITH", " ", "THIS", " ", "SOU", "RC", "E", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IN", " ", "'", "COPY", "ING", "'.", " ", "PLE", "AS", "E", " ", "READ", " ", "THE", "SE", " ", "TERM", "S", " ", "BEFORE", " ", "DISTRI", "BUT", "ING", ".", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "pyco", "lla", "da", " ", "SOU", "RC", "E", " ", "CODE", " ", "IS", " ", "(", "C", ")", " ", "COPY", "RIG", "HT", " ", "2011", " ", " ", " ", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "by", " ", "Je", "ff", " ", "Terra", "ce", " ", "and", " ", "contributor", "s", " ", " ", " ", " ", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", " ", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Contain", "s", " ", "object", "s", " ", "for", " ", "represent", "ing", " ", "a", " ", "geom", "etry", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "numpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "colla", "da_", "import_", "source_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "import_", "triangle", "set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "import_", "lines", "et_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "import_", "poly", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "import_", "polygons_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "import_", "primitive_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "._", "common_", "import_", "Da", "e", "Object_", ",_", "E_", ",_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "._", "common_", "import_", "Da", "e", "Incomp", "lete", "Error_", ",_", "Da", "e", "Bro", "ken", "Ref", "Error_", ",_", "Da", "e", "Mal", "formed", "Error_", ",_", "Da", "e", "Unsu", "ppo", "rted", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "colla", "da_", "._", "xml", "util_", "import_", "etree_", "as_", "Element", "Tree_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "class", " ", "contain", "ing", " ", "the", " ", "data", " ", "comi", "ng", " ", "from", " ", "a", " ", "COLL", "ADA", " ", "<", "geom", "etry", ">", " ", "tag", "\"\"\"_", "\\u\\u\\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_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "colla", "da_", ",_", "id_", ",_", "name_", ",_", "source", "by", "id_", ",_", "primitives_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xml", "node_", "=_", "None_", ",_", "double", "\\u", "side", "d_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "geom", "etry", " ", "instance", "\\", "10", ";", "\\", "10", ";", " ", " ", ":", "param", " ", "colla", "da", ".", "Colla", "da", " ", "colla", "da", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "colla", "da", " ", "object", " ", "this", " ", "geom", "etry", " ", "belo", "ngs", " ", "to", "\\", "10", ";", " ", " ", ":", "param", " ", "str", " ", "id", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "unique", " ", "string", " ", "identifi", "er", " ", "for", " ", "the", " ", "geom", "etry", "\\", "10", ";", " ", " ", ":", "param", " ", "str", " ", "name", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "text", " ", "string", " ", "nami", "ng", " ", "the", " ", "geom", "etry", "\\", "10", ";", " ", " ", ":", "param", " ", "source", "by", "id", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "list", " ", "of", " ", ":", "class", ":`", "colla", "da", ".", "source", ".", "Sou", "rce", "`", " ", "object", "s", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "dictionar", "y", " ", "mapping", " ", "source", " ", "ids", " ", "to", " ", "the", " ", "actual", " ", "object", "s", "\\", "10", ";", " ", " ", ":", "param", " ", "list", " ", "primi", "tives", ":", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "of", " ", "primi", "tiv", "e", " ", "object", "s", " ", "contain", "ed", " ", "within", " ", "the", " ", "geom", "etry", ".", "\\", "10", ";", " ", " ", " ", " ", "Do", " ", "not", " ", "set", " ", "this", " ", "argu", "ment", " ", "manu", "ally", ".", " ", "Ins", "tea", "d", ",", " ", "create", " ", "a", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "colla", "da", ".", "geom", "etry", ".", "Geometr", "y", "`", " ", "first", " ", "and", " ", "then", " ", "append", "\\", "10", ";", " ", " ", " ", " ", "to", " ", ":", "attr", ":`", "primi", "tives", "`", " ", "with", " ", "the", " ", "`", "create", "*", "`", " ", "function", "s", ".", "\\", "10", ";", " ", " ", ":", "param", " ", "xml", "node", ":", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "load", "ed", ",", " ", "the", " ", "xml", "node", " ", "it", " ", "come", "s", " ", "from", ".", "\\", "10", ";", " ", " ", ":", "param", " ", "bool", " ", "double", "\\u", "side", "d", ":", "\\", "10", ";", " ", " ", " ", " ", "Whe", "ther", " ", "or", " ", "not", " ", "the", " ", "geom", "etry", " ", "shou", "ld", " ", "be", " ", "render", "ed", " ", "double", " ", "side", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "colla", "da_", "=_", "colla", "da_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "The", " ", ":", "class", ":`", "colla", "da", ".", "Colla", "da", "`", " ", "object", " ", "this", " ", "geom", "etry", " ", "belo", "ngs", " ", "to", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "id_", "=_", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "The", " ", "unique", " ", "string", " ", "identifi", "er", " ", "for", " ", "the", " ", "geom", "etry", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "The", " ", "text", " ", "string", " ", "nami", "ng", " ", "the", " ", "geom", "etry", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "double", "\\u", "side", "d_", "=_", "double", "\\u", "side", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "A", " ", "boolean", " ", "indicati", "ng", " ", "whe", "ther", " ", "or", " ", "not", " ", "the", " ", "geom", "etry", " ", "shou", "ld", " ", "be", " ", "render", "ed", " ", "double", " ", "side", "d", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "source", "By", "Id_", "=_", "source", "by", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "A", " ", "dictionar", "y", " ", "contain", "ing", " ", ":", "class", ":`", "colla", "da", ".", "source", ".", "Sou", "rce", "`", " ", "object", "s", " ", "indexe", "d", " ", "by", " ", "thei", "r", " ", "id", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "source", "by", "id_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "source", "By", "Id_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "src_", "in_", "source", "by", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "source", "By", "Id_", "[_", "src_", "._", "id_", "]_", "=_", "src_", "\\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_", "._", "primitives_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "List", " ", "of", " ", "primi", "tives", " ", "(", "base", " ", "type", " ", ":", "class", ":`", "colla", "da", ".", "primi", "tiv", "e", ".", "Primitive", "`)", " ", "insi", "de", " ", "this", " ", "geom", "etry", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "primitives_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "primitives_", "=_", "primitives_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "xml", "node_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "xml", "node_", "=_", "xml", "node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "Element", "Tree", " ", "represent", "ation", " ", "of", " ", "the", " ", "geom", "etry", ".\"\"\"_", "\\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 ", " _", "source", "nodes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vertice", "sno", "de_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "src", "id_", ",_", "src_", "in_", "self_", "._", "source", "By", "Id_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "source", "nodes_", "._", "append_", "(_", "src_", "._", "xml", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "vertice", "sno", "de_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "pick", " ", "first", " ", "source", " ", "to", " ", "be", " ", "in", " ", "the", " ", "usel", "ess", " ", "<", "vertice", "s", ">", " ", "tag_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "vertice", "sno", "de_", "=_", "E_", "._", "vertices_", "(_", "E_", "._", "input_", "(_", "sema", "ntic", "_", "=_", "'", "POSITION", "'_", ",_", "source_", "=_", "\"#", "%", "s", "\"_", "%_", "src", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "src", "id_", "+_", "'-", "vertice", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mesh", "node_", "=_", "E_", "._", "mesh_", "(_", "*_", "source", "nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mesh", "node_", "._", "append_", "(_", "vertice", "sno", "de_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "xml", "node_", "=_", "E_", "._", "geometry_", "(_", "mesh", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "id_", ")_", ">_", "0_", ":_", "self_", "._", "xml", "node_", "._", "set_", "(_", "\"", "id", "\"_", ",_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "name_", ")_", ">_", "0_", ":_", "self_", "._", "xml", "node_", "._", "set_", "(_", "\"", "name", "\"_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "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_", "create", "Line", "Set_", "(_", "self_", ",_", "indices_", ",_", "input", "list_", ",_", "material", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "set", " ", "of", " ", "lines", " ", "for", " ", "use", " ", "in", " ", "this", " ", "geom", "etry", " ", "instance", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "indice", "s", ":", "\\", "10", ";", " ", " ", "unsh", "ape", "d", " ", "nump", "y", " ", "array", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "indice", "s", " ", "for", "\\", "10", ";", " ", " ", "the", " ", "inputs", " ", "referenced", " ", "in", " ", "input", "list", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "colla", "da", ".", "source", ".", "Inp", "ut", "List", " ", "input", "list", ":", "\\", "10", ";", " ", " ", "The", " ", "inputs", " ", "for", " ", "this", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "str", " ", "material", "id", ":", "\\", "10", ";", " ", " ", "A", " ", "string", " ", "contain", "ing", " ", "a", " ", "symbol", " ", "tha", "t", " ", "will", " ", "get", " ", "used", " ", "to", " ", "bind", " ", "this", " ", "lines", "et", "\\", "10", ";", " ", " ", "to", " ", "a", " ", "material", " ", "whe", "n", " ", "instant", "iati", "ng", " ", "int", "o", " ", "a", " ", "scen", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "colla", "da", ".", "lines", "et", ".", "Line", "Set", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputd", "ict_", "=_", "primitive_", "._", "Primitive", "_", "._", "\\u", "get", "Inp", "uts", "Fro", "m", "List_", "(_", "self_", "._", "colla", "da_", ",_", "self_", "._", "source", "By", "Id_", ",_", "input", "list_", "._", "get", "List_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "lines", "et_", "._", "Line", "Set_", "(_", "inputd", "ict_", ",_", "material", "id_", ",_", "indices_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "Triangle", "Set_", "(_", "self_", ",_", "indices_", ",_", "input", "list_", ",_", "material", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "set", " ", "of", " ", "triangle", "s", " ", "for", " ", "use", " ", "in", " ", "this", " ", "geom", "etry", " ", "instance", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "indice", "s", ":", "\\", "10", ";", " ", " ", "unsh", "ape", "d", " ", "nump", "y", " ", "array", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "indice", "s", " ", "for", "\\", "10", ";", " ", " ", "the", " ", "inputs", " ", "referenced", " ", "in", " ", "input", "list", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "colla", "da", ".", "source", ".", "Inp", "ut", "List", " ", "input", "list", ":", "\\", "10", ";", " ", " ", "The", " ", "inputs", " ", "for", " ", "this", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "str", " ", "material", "id", ":", "\\", "10", ";", " ", " ", "A", " ", "string", " ", "contain", "ing", " ", "a", " ", "symbol", " ", "tha", "t", " ", "will", " ", "get", " ", "used", " ", "to", " ", "bind", " ", "this", " ", "triangle", "set", "\\", "10", ";", " ", " ", "to", " ", "a", " ", "material", " ", "whe", "n", " ", "instant", "iati", "ng", " ", "int", "o", " ", "a", " ", "scen", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "colla", "da", ".", "triangle", "set", ".", "Triangle", "Set", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputd", "ict_", "=_", "primitive_", "._", "Primitive", "_", "._", "\\u", "get", "Inp", "uts", "Fro", "m", "List_", "(_", "self_", "._", "colla", "da_", ",_", "self_", "._", "source", "By", "Id_", ",_", "input", "list_", "._", "get", "List_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "triangle", "set_", "._", "Triangle", "Set_", "(_", "inputd", "ict_", ",_", "material", "id_", ",_", "indices_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "Poly", "list_", "(_", "self_", ",_", "indices_", ",_", "vco", "unt", "s_", ",_", "input", "list_", ",_", "material", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "poly", "list", " ", "for", " ", "use", " ", "with", " ", "this", " ", "geom", "etry", " ", "instance", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "indice", "s", ":", "\\", "10", ";", " ", " ", "unsh", "ape", "d", " ", "nump", "y", " ", "array", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "indice", "s", " ", "for", "\\", "10", ";", " ", " ", "the", " ", "inputs", " ", "referenced", " ", "in", " ", "input", "list", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "vco", "unt", "s", ":", "\\", "10", ";", " ", " ", "unsh", "ape", "d", " ", "nump", "y", " ", "array", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "vertex", " ", "count", "\\", "10", ";", " ", " ", "for", " ", "each", " ", "poly", "gon", " ", "in", " ", "this", " ", "poly", "list", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "colla", "da", ".", "source", ".", "Inp", "ut", "List", " ", "input", "list", ":", "\\", "10", ";", " ", " ", "The", " ", "inputs", " ", "for", " ", "this", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "str", " ", "material", "id", ":", "\\", "10", ";", " ", " ", "A", " ", "string", " ", "contain", "ing", " ", "a", " ", "symbol", " ", "tha", "t", " ", "will", " ", "get", " ", "used", " ", "to", " ", "bind", " ", "this", " ", "poly", "list", "\\", "10", ";", " ", " ", "to", " ", "a", " ", "material", " ", "whe", "n", " ", "instant", "iati", "ng", " ", "int", "o", " ", "a", " ", "scen", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "colla", "da", ".", "poly", "list", ".", "Poly", "list", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputd", "ict_", "=_", "primitive_", "._", "Primitive", "_", "._", "\\u", "get", "Inp", "uts", "Fro", "m", "List_", "(_", "self_", "._", "colla", "da_", ",_", "self_", "._", "source", "By", "Id_", ",_", "input", "list_", "._", "get", "List_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "poly", "list_", "._", "Poly", "list_", "(_", "inputd", "ict_", ",_", "material", "id_", ",_", "indices_", ",_", "vco", "unt", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "Polygon", "s_", "(_", "self_", ",_", "indices_", ",_", "input", "list_", ",_", "material", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "polygons", " ", "for", " ", "use", " ", "with", " ", "this", " ", "geom", "etry", " ", "instance", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "indice", "s", ":", "\\", "10", ";", " ", " ", "list", " ", "of", " ", "unsh", "ape", "d", " ", "nump", "y", " ", "arrays", " ", "tha", "t", " ", "each", " ", "contain", " ", "the", " ", "indice", "s", " ", "for", "\\", "10", ";", " ", " ", "a", " ", "single", " ", "poly", "gon", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "colla", "da", ".", "source", ".", "Inp", "ut", "List", " ", "input", "list", ":", "\\", "10", ";", " ", " ", "The", " ", "inputs", " ", "for", " ", "this", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "str", " ", "material", "id", ":", "\\", "10", ";", " ", " ", "A", " ", "string", " ", "contain", "ing", " ", "a", " ", "symbol", " ", "tha", "t", " ", "will", " ", "get", " ", "used", " ", "to", " ", "bind", " ", "this", " ", "polygons", "\\", "10", ";", " ", " ", "to", " ", "a", " ", "material", " ", "whe", "n", " ", "instant", "iati", "ng", " ", "int", "o", " ", "a", " ", "scen", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "colla", "da", ".", "polygons", ".", "Polygon", "s", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputd", "ict_", "=_", "primitive_", "._", "Primitive", "_", "._", "\\u", "get", "Inp", "uts", "Fro", "m", "List_", "(_", "self_", "._", "colla", "da_", ",_", "self_", "._", "source", "By", "Id_", ",_", "input", "list_", "._", "get", "List_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "polygons_", "._", "Polygon", "s_", "(_", "inputd", "ict_", ",_", "material", "id_", ",_", "indices_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "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_", "load_", "(_", "colla", "da_", ",_", "locals", "cope", "_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "id_", "=_", "node_", "._", "get_", "(_", "\"", "id", "\"_", ")_", "or_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "node_", "._", "get_", "(_", "\"", "name", "\"_", ")_", "or_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mesh", "node_", "=_", "node_", "._", "find_", "(_", "tag_", "(_", "'", "mesh", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mesh", "node_", "is_", "None_", ":_", "raise_", "Da", "e", "Unsu", "ppo", "rted", "Error_", "(_", "'", "Un", "know", "n", " ", "geom", "etry", " ", "node", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "by", "id_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "nodes_", "=_", "node_", "._", "findall_", "(_", "'%", "s", "/", "%", "s", "'_", "%_", "(_", "tag_", "(_", "'", "mesh", "'_", ")_", ",_", "tag_", "(_", "'", "source", "'_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "source", "node_", "in_", "source", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ch_", "=_", "source_", "._", "Source_", "._", "load_", "(_", "colla", "da_", ",_", "{_", "}_", ",_", "source", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "._", "append_", "(_", "ch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "by", "id_", "[_", "ch_", "._", "id_", "]_", "=_", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vertice", "sno", "de_", "=_", "mesh", "node_", "._", "find_", "(_", "tag_", "(_", "'", "vertice", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "vertice", "sno", "de_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vertex", "source_", "=_", "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 ", " _", "input", "nodes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "input", "node_", "in_", "vertice", "sno", "de_", "._", "findall_", "(_", "tag_", "(_", "'", "input", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sema", "ntic", "_", "=_", "input", "node_", "._", "get_", "(_", "'", "sema", "ntic", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputs", "ource_", "=_", "input", "node_", "._", "get_", "(_", "'", "source", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "sema", "ntic", "_", "or_", "not_", "inputs", "ource_", "or_", "not_", "inputs", "ource_", "._", "startswith_", "(_", "'#'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Da", "e", "Incomp", "lete", "Error_", "(_", "'", "Ba", "d", " ", "input", " ", "definit", "ion", " ", "insi", "de", " ", "vertice", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "input", "nodes_", "[_", "sema", "ntic", "_", "]_", "=_", "source", "by", "id_", "._", "get_", "(_", "inputs", "ource_", "[_", "1_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "vertice", "sno", "de_", "._", "get_", "(_", "'", "id", "'_", ")_", "or_", "len_", "(_", "input", "nodes_", ")_", "==_", "0_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "'", "POSITION", "'_", "in_", "input", "nodes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Da", "e", "Incomp", "lete", "Error_", "(_", "'", "Ba", "d", " ", "vertice", "s", " ", "definit", "ion", " ", "in", " ", "mesh", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "source", "by", "id_", "[_", "vertice", "sno", "de_", "._", "get_", "(_", "'", "id", "'_", ")_", "]_", "=_", "input", "nodes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vertex", "source_", "=_", "vertice", "sno", "de_", "._", "get_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "double", "\\u", "side", "d\\u", "node_", "=_", "node_", "._", "find_", "(_", "'./", "/", "%", "s", "//", "%", "s", "'_", "%_", "(_", "tag_", "(_", "'", "extra", "'_", ")_", ",_", "tag_", "(_", "'", "double", "\\u", "side", "d", "'_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "double", "\\u", "side", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "double", "\\u", "side", "d\\u", "node_", "is_", "not_", "None_", "and_", "double", "\\u", "side", "d\\u", "node_", "._", "text_", "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 ", " _", "val_", "=_", "int_", "(_", "double", "\\u", "side", "d\\u", "node_", "._", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "val_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "double", "\\u", "side", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "primitives_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "subnode", "_", "in_", "mesh", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "subnode", "_", "._", "tag_", "==_", "tag_", "(_", "'", "poly", "list", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "primitives_", "._", "append_", "(_", "poly", "list_", "._", "Poly", "list_", "._", "load_", "(_", "colla", "da_", ",_", "source", "by", "id_", ",_", "subnode", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "subnode", "_", "._", "tag_", "==_", "tag_", "(_", "'", "triangle", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "primitives_", "._", "append_", "(_", "triangle", "set_", "._", "Triangle", "Set_", "._", "load_", "(_", "colla", "da_", ",_", "source", "by", "id_", ",_", "subnode", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "subnode", "_", "._", "tag_", "==_", "tag_", "(_", "'", "lines", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "primitives_", "._", "append_", "(_", "lines", "et_", "._", "Line", "Set_", "._", "load_", "(_", "colla", "da_", ",_", "source", "by", "id_", ",_", "subnode", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "subnode", "_", "._", "tag_", "==_", "tag_", "(_", "'", "polygons", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "primitives_", "._", "append_", "(_", "polygons_", "._", "Polygon", "s_", "._", "load_", "(_", "colla", "da_", ",_", "source", "by", "id_", ",_", "subnode", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "subnode", "_", "._", "tag_", "!=_", "tag_", "(_", "'", "source", "'_", ")_", "and_", "subnode", "_", "._", "tag_", "!=_", "tag_", "(_", "'", "vertice", "s", "'_", ")_", "and_", "subnode", "_", "._", "tag_", "!=_", "tag_", "(_", "'", "extra", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Da", "e", "Unsu", "ppo", "rted", "Error_", "(_", "'", "Un", "know", "n", " ", "geom", "etry", " ", "tag", " ", "%", "s", "'_", "%_", "subnode", "_", "._", "tag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "geom_", "=_", "Geometry_", "(_", "colla", "da_", ",_", "id_", ",_", "name_", ",_", "source", "by", "id_", ",_", "\\u", "primitives_", ",_", "xml", "node_", "=_", "node_", ",_", "double", "\\u", "side", "d_", "=_", "double", "\\u", "side", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "geom_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Save", "s", " ", "the", " ", "geom", "etry", " ", "back", " ", "to", " ", ":", "attr", ":`", "xml", "node", "`\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mesh", "node_", "=_", "self_", "._", "xml", "node_", "._", "find_", "(_", "tag_", "(_", "'", "mesh", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "src_", "in_", "self_", "._", "source", "By", "Id_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "src_", ",_", "source_", "._", "Source_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "src_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "src_", "._", "xml", "node_", "not_", "in_", "mesh", "node_", "._", "getch", "ildren_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "mesh", "node_", "._", "insert_", "(_", "0_", ",_", "src_", "._", "xml", "node_", ")_", "\\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_", "delete", "nodes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "olds", "rc", "node_", "in_", "mesh", "node_", "._", "findall_", "(_", "tag_", "(_", "'", "source", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "olds", "rc", "node_", "not_", "in_", "[_", "src_", "._", "xml", "node_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "src_", "in_", "self_", "._", "source", "By", "Id_", "._", "values_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "src_", ",_", "source_", "._", "Source_", ")_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "delete", "nodes_", "._", "append_", "(_", "olds", "rc", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "d_", "in_", "delete", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mesh", "node_", "._", "remove_", "(_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Look", " ", "through", " ", "primi", "tives", " ", "to", " ", "find", " ", "a", " ", "vertex", " ", "source_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vn", "ode_", "=_", "self_", "._", "xml", "node_", "._", "find_", "(_", "tag_", "(_", "'", "mesh", "'_", ")_", ")_", "._", "find_", "(_", "tag_", "(_", "'", "vertice", "s", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "delete", " ", "any", " ", "inputs", " ", "in", " ", "vertice", "s", " ", "tag", " ", "tha", "t", " ", "no", " ", "long", "er", " ", "exist", " ", "and", " ", "find", " ", "the", " ", "vertex", " ", "input_", "\\u\\u\\uNL\\u\\u\\u_", "delete", "\\u", "inputs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "input", "\\u", "node_", "in_", "vn", "ode_", "._", "findall_", "(_", "tag_", "(_", "'", "input", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "input", "\\u", "node_", "._", "get_", "(_", "'", "sema", "ntic", "'_", ")_", "==_", "'", "POSITION", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "input", "\\u", "vn", "ode_", "=_", "input", "\\u", "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 ", " _", "src", "id_", "=_", "input", "\\u", "node_", "._", "get_", "(_", "'", "source", "'_", ")_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "src", "id_", "not_", "in_", "self_", "._", "source", "By", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "delete", "\\u", "inputs_", "._", "append_", "(_", "input", "\\u", "node_", ")_", "\\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_", "node_", "in_", "delete", "\\u", "inputs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vn", "ode_", "._", "remove_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vert", "\\u", "sources_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "prim", "_", "in_", "self_", "._", "primitives_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "src_", "in_", "prim", "_", "._", "sources_", "[_", "'", "VERTEX", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vert", "\\u", "sources_", "._", "append_", "(_", "src_", "[_", "2_", "]_", "[_", "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_", "vert", "\\u", "src_", "=_", "vn", "ode_", "._", "get_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vert", "\\u", "ref_", "=_", "input", "\\u", "vn", "ode_", "._", "get_", "(_", "'", "source", "'_", ")_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "(_", "vert", "\\u", "src_", "in_", "vert", "\\u", "sources_", "or_", "vert", "\\u", "ref_", "in_", "vert", "\\u", "sources_", ")_", "and_", "len_", "(_", "vert", "\\u", "sources_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "vert", "\\u", "ref_", "in_", "self_", "._", "source", "By", "Id_", "and_", "vert", "\\u", "ref_", "in_", "vert", "\\u", "sources_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "source_", "=_", "vert", "\\u", "ref_", "\\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", "source_", "=_", "vert", "\\u", "sources_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "source", "By", "Id_", "[_", "new", "\\u", "source_", "+_", "'-", "vertice", "s", "'_", "]_", "=_", "self_", "._", "source", "By", "Id_", "[_", "new", "\\u", "source_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input", "\\u", "vn", "ode_", "._", "set_", "(_", "'", "source", "'_", ",_", "'#'_", "+_", "new", "\\u", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vn", "ode_", "._", "set_", "(_", "'", "id", "'_", ",_", "new", "\\u", "source_", "+_", "'-", "vertice", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "any", " ", "source", " ", "reference", "s", " ", "in", " ", "primi", "tives", " ", "tha", "t", " ", "are", " ", "pointi", "ng", " ", "to", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "same", " ", "source", " ", "tha", "t", " ", "the", " ", "vertice", "s", " ", "tag", " ", "is", " ", "pointi", "ng", " ", "to", " ", "to", " ", "inst", "ead_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "point", " ", "to", " ", "the", " ", "vertice", "s", " ", "id_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vert", "\\u", "src_", "=_", "vn", "ode_", "._", "get_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vert", "\\u", "ref_", "=_", "input", "\\u", "vn", "ode_", "._", "get_", "(_", "'", "source", "'_", ")_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "prim", "_", "in_", "self_", "._", "primitives_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "node_", "in_", "prim", "_", "._", "xml", "node_", "._", "findall_", "(_", "tag_", "(_", "'", "input", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "src_", "=_", "node_", "._", "get_", "(_", "'", "source", "'_", ")_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "src_", "==_", "vert", "\\u", "ref_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "node_", "._", "set_", "(_", "'", "source", "'_", ",_", "'#", "%", "s", "'_", "%_", "vert", "\\u", "src_", ")_", "\\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_", "._", "xml", "node_", "._", "set_", "(_", "'", "id", "'_", ",_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "xml", "node_", "._", "set_", "(_", "'", "name", "'_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "prim", "_", "in_", "self_", "._", "primitives_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "prim", "_", ")_", "is_", "triangle", "set_", "._", "Triangle", "Set_", "and_", "prim", "_", "._", "xml", "node_", "._", "tag_", "!=_", "tag_", "(_", "'", "triangle", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prim", "_", "._", "\\u", "recreate", "Xm", "l", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "prim", "_", "._", "xml", "node_", "not_", "in_", "mesh", "node_", "._", "getch", "ildren_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mesh", "node_", "._", "append_", "(_", "prim", "_", "._", "xml", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "delete", "nodes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prim", "nodes_", "=_", "[_", "prim", "_", "._", "xml", "node_", "for_", "prim", "_", "in_", "self_", "._", "primitives_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "mesh", "node_", "._", "getch", "ildren_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "child_", "._", "tag_", "!=_", "tag_", "(_", "'", "vertice", "s", "'_", ")_", "and_", "child_", "._", "tag_", "!=_", "tag_", "(_", "'", "source", "'_", ")_", "and_", "child_", "not_", "in_", "prim", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "delete", "nodes_", "._", "append_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "d_", "in_", "delete", "nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mesh", "node_", "._", "remove_", "(_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "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_", "bind_", "(_", "self_", ",_", "matrix_", ",_", "material", "node", "bys", "ymbo", "l_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Bind", "s", " ", "this", " ", "geom", "etry", " ", "to", " ", "a", " ", "transform", " ", "matrix", " ", "and", " ", "material", " ", "mapping", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "geom", "etry", "'", "s", " ", "points", " ", "get", " ", "transforme", "d", " ", "by", " ", "the", " ", "give", "n", " ", "matrix", " ", "and", " ", "its", "\\", "10", ";", " ", " ", " ", " ", "inputs", " ", "get", " ", "mapp", "ed", " ", "to", " ", "the", " ", "give", "n", " ", "material", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "nump", "y", ".", "array", " ", "matrix", ":", "\\", "10", ";", " ", " ", "A", " ", "4", "x4", " ", "nump", "y", " ", "float", " ", "matrix", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "dict", " ", "material", "node", "bys", "ymbo", "l", ":", "\\", "10", ";", " ", " ", "A", " ", "dictionar", "y", " ", "with", " ", "the", " ", "material", " ", "symbols", " ", "insi", "de", " ", "the", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", "assign", "ed", " ", "to", " ", ":", "class", ":`", "colla", "da", ".", "scen", "e", ".", "Materia", "l", "Node", "`", " ", "defin", "ed", " ", "in", " ", "the", "\\", "10", ";", " ", " ", "scen", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "colla", "da", ".", "geom", "etry", ".", "Bound", "Geometr", "y", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Bound", "Geometry_", "(_", "self_", ",_", "matrix_", ",_", "material", "node", "bys", "ymbo", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "Object_", ")_", ":_", "\\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_", "'<", "Geometr", "y", " ", "id", "=", "%", "s", ",", " ", "%", "d", " ", "primi", "tives", ">'_", "%_", "(_", "self_", "._", "id_", ",_", "len_", "(_", "self_", "._", "primitives_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Geometry_", "(_", "Da", "e", "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_", "str_", "(_", "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_", "Bound", "Geometry_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "geom", "etry", " ", "bound", " ", "to", " ", "a", " ", "transform", " ", "matrix", " ", "and", " ", "material", " ", "mapping", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "gets", " ", "created", " ", "whe", "n", " ", "a", " ", "geom", "etry", " ", "is", " ", "instantiate", "d", " ", "in", " ", "a", " ", "scen", "e", ".", "\\", "10", ";", " ", " ", " ", " ", "Do", " ", "not", " ", "create", " ", "this", " ", "manu", "ally", ".\"\"\"_", "\\u\\u\\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_", "Bound", "Geometry_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "geom_", ",_", "matrix_", ",_", "material", "node", "bys", "ymbo", "l_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "matrix_", "=_", "matrix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "The", " ", "matrix", " ", "bound", " ", "to", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "material", "node", "bys", "ymbo", "l_", "=_", "material", "node", "bys", "ymbo", "l_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "Dict", "ionar", "y", " ", "with", " ", "the", " ", "material", " ", "symbols", " ", "insi", "de", " ", "the", " ", "primi", "tiv", "e", "\\", "10", ";", " ", " ", "assign", "ed", " ", "to", " ", ":", "class", ":`", "colla", "da", ".", "scen", "e", ".", "Materia", "l", "Node", "`", " ", "defin", "ed", " ", "in", " ", "the", "\\", "10", ";", " ", " ", "scen", "e", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "primitives_", "=_", "geom_", "._", "primitives_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "original_", "=_", "geom_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "The", " ", "original", " ", ":", "class", ":`", "colla", "da", ".", "geom", "etry", ".", "Geometr", "y", "`", " ", "object", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "bound", " ", "to", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bound", "Geometry_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "len\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "number", " ", "of", " ", "primi", "tives", " ", "in", " ", "the", " ", "bound", " ", "geom", "etry", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "len_", "(_", "self_", "._", "\\u", "primitives_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bound", "Geometry_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "primitives_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "an", " ", "iter", "ator", " ", "tha", "t", " ", "iterate", "s", " ", "through", " ", "the", " ", "primi", "tives", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "bound", " ", "geom", "etry", ".", " ", "Ea", "ch", " ", "value", " ", "return", "ed", " ", "will", " ", "be", " ", "of", " ", "base", " ", "type", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "colla", "da", ".", "primi", "tiv", "e", ".", "Bound", "Primitive", "`\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "p_", "in_", "self_", "._", "\\u", "primitives_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bound", "p_", "=_", "p_", "._", "bind_", "(_", "self_", "._", "matrix_", ",_", "self_", "._", "material", "node", "bys", "ymbo", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "bound", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bound", "Geometry_", "(_", "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", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Bound", "Geometr", "y", " ", "id", "=", "%", "s", ",", " ", "%", "d", " ", "primi", "tives", ">'_", "%_", "(_", "self_", "._", "original_", "._", "id_", ",_", "len_", "(_", "self_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bound", "Geometry_", "(_", "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_", "str_", "(_", "self_", ")_" ]
[ 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,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 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, 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, 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, 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 ]
Unused local variable
honza/nigel/matchers/points.py
[ { "content": " def respond(self, message, user=None):\n if user not in names:\n return\n\n message = message.strip()\n\n # Update points left\n latest_date = r.get(DATE)\n now = datetime.utcnow().date()\n\n if not latest_date:\n latest_date = utc_str()\n r.set(DATE, latest_date)\n else:\n delta = now - from_utc_str(latest_date).date()\n if delta.days > 0:\n for person in names:\n r.hset(person, 'left', DAILY_ALLOWANCE)\n\n r.set(DATE, utc_str())\n\n if message.startswith(('leaderboard', 'scoreboard',)):\n values = map(self.get_points, people)\n values = filter(None, values)\n\n if not values:\n return\n\n values.sort(key=lambda x: x[1])\n values.reverse()\n self.speak(\", \".join([\"%s: %s\" % v for v in values]))\n return\n\n if message.startswith('quota'):\n value = r.hget(user, 'left')\n self.speak(user + ': you have %s left' % value)\n return\n\n res = re.findall(pattern, message)\n\n if not res:\n return\n\n u, op, value = res[0]\n value = int(value)\n\n if user == u:\n self.speak(user + ': lol, did you really just try to give points to yourself?')\n return\n\n if u not in names:\n return\n\n source_user_hash = r.hgetall(user)\n dest_user_hash = r.hgetall(u)\n\n if not source_user_hash:\n source_user_hash = {\n 'score': 0,\n 'left': DAILY_ALLOWANCE\n }\n\n if not dest_user_hash:\n dest_user_hash = {\n 'score': 0,\n 'left': DAILY_ALLOWANCE\n }\n\n if op == '+':\n if int(source_user_hash.get('left', 0)) < value:\n # Not enough points left for the day\n self.speak(user + ': not enough points left, lol')\n return\n\n if op == '+':\n r.hincrby(u, 'score', value)\n r.hincrby(user, 'left', value * -1)\n\n if op == '-':\n if int(source_user_hash.get('score', 0)) < value:\n # Not enough of own points\n self.speak(user + ': not enough score, lol')\n else:\n r.hincrby(u, 'score', value * -1)\n r.hincrby(user, 'score', value * -1)", "metadata": "root.PointsMatcher.respond", "header": "['class', 'PointsMatcher', '(', 'BaseMatcher', ')', ':', '___EOS___']", "index": 74 } ]
[ { "span": "dest_user_hash ", "start_line": 137, "start_column": 12, "end_line": 137, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Point", "s", "Matcher_", "(_", "Base", "Matcher_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "respond_", "(_", "self_", ",_", "message_", ",_", "user_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "user_", "not_", "in_", "names_", ":_", "\\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_", "message_", "=_", "message_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "points", " ", "left_", "\\u\\u\\uNL\\u\\u\\u_", "late", "st", "\\u", "date_", "=_", "r_", "._", "get_", "(_", "DATE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "now_", "=_", "datetime_", "._", "utcnow_", "(_", ")_", "._", "date_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "late", "st", "\\u", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "late", "st", "\\u", "date_", "=_", "utc", "\\u", "str_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "set_", "(_", "DATE_", ",_", "late", "st", "\\u", "date_", ")_", "\\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 ", " _", "delta_", "=_", "now_", "-_", "from", "\\u", "utc", "\\u", "str_", "(_", "late", "st", "\\u", "date_", ")_", "._", "date_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "delta_", "._", "days_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "person_", "in_", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "r_", "._", "hse", "t_", "(_", "person_", ",_", "'", "left", "'_", ",_", "DAI", "LY", "\\u", "ALLOW", "ANCE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "._", "set_", "(_", "DATE_", ",_", "utc", "\\u", "str_", "(_", ")_", ")_", "\\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_", "message_", "._", "startswith_", "(_", "(_", "'", "leader", "board", "'_", ",_", "'", "score", "board", "'_", ",_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "map_", "(_", "self_", "._", "get", "\\u", "points_", ",_", "people_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "=_", "filter_", "(_", "None_", ",_", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "values_", ":_", "\\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_", "values_", "._", "sort_", "(_", "key_", "=_", "lambda_", "x_", ":_", "x_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "values_", "._", "reverse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "speak", "_", "(_", "\",", " ", "\"_", "._", "join_", "(_", "[_", "\"%", "s", ":", " ", "%", "s", "\"_", "%_", "v_", "for_", "v_", "in_", "values_", "]_", ")_", ")_", "\\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_", "message_", "._", "startswith_", "(_", "'", "quot", "a", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "r_", "._", "hge", "t_", "(_", "user_", ",_", "'", "left", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "speak", "_", "(_", "user_", "+_", "':", " ", "you", " ", "have", " ", "%", "s", " ", "left", "'_", "%_", "value_", ")_", "\\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_", "res_", "=_", "re_", "._", "findall_", "(_", "pattern_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "res_", ":_", "\\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_", "u_", ",_", "op_", ",_", "value_", "=_", "res_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "int_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "user_", "==_", "u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "speak", "_", "(_", "user_", "+_", "':", " ", "lol", ",", " ", "did", " ", "you", " ", "reall", "y", " ", "just", " ", "try", " ", "to", " ", "give", " ", "points", " ", "to", " ", "your", "self", "?'_", ")_", "\\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_", "u_", "not_", "in_", "names_", ":_", "\\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_", "source", "\\u", "user", "\\u", "hash_", "=_", "r_", "._", "hge", "tall", "_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest", "\\u", "user", "\\u", "hash_", "=_", "r_", "._", "hge", "tall", "_", "(_", "u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "source", "\\u", "user", "\\u", "hash_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "source", "\\u", "user", "\\u", "hash_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "score", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "left", "'_", ":_", "DAI", "LY", "\\u", "ALLOW", "ANCE", "_", "\\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_", "dest", "\\u", "user", "\\u", "hash_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dest", "\\u", "user", "\\u", "hash_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "score", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "left", "'_", ":_", "DAI", "LY", "\\u", "ALLOW", "ANCE", "_", "\\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_", "op_", "==_", "'+'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "int_", "(_", "source", "\\u", "user", "\\u", "hash_", "._", "get_", "(_", "'", "left", "'_", ",_", "0_", ")_", ")_", "<_", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", " ", "eno", "ugh", " ", "points", " ", "left", " ", "for", " ", "the", " ", "day_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "speak", "_", "(_", "user_", "+_", "':", " ", "not", " ", "eno", "ugh", " ", "points", " ", "left", ",", " ", "lol", "'_", ")_", "\\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_", "if_", "op_", "==_", "'+'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "._", "hin", "cr", "by_", "(_", "u_", ",_", "'", "score", "'_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "hin", "cr", "by_", "(_", "user_", ",_", "'", "left", "'_", ",_", "value_", "*_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "op_", "==_", "'-'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "int_", "(_", "source", "\\u", "user", "\\u", "hash_", "._", "get_", "(_", "'", "score", "'_", ",_", "0_", ")_", ")_", "<_", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", " ", "eno", "ugh", " ", "of", " ", "own", " ", "points_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "speak", "_", "(_", "user_", "+_", "':", " ", "not", " ", "eno", "ugh", " ", "score", ",", " ", "lol", "'_", ")_", "\\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 ", " _", "r_", "._", "hin", "cr", "by_", "(_", "u_", ",_", "'", "score", "'_", ",_", "value_", "*_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "hin", "cr", "by_", "(_", "user_", ",_", "'", "score", "'_", ",_", "value_", "*_", "-_", "1_", ")_" ]
[ 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, 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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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
toastdriven/restless/tests/test_serializers.py
[ { "content": " def test_serialize(self):\n body = self.serializer.serialize(self.dict_data)\n self.assertTrue('\"hello\": \"world\"' in body)\n self.assertTrue('\"abc\": 123' in body)\n self.assertTrue('\"nested\": \"2014-03-30T12:55:15\"' in body)\n self.assertTrue('\"again\": \"18.9\"' in body)", "metadata": "root.JSONSerializerTestCase.test_serialize", "header": "['class', 'JSONSerializerTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 24 } ]
[ { "span": "self.assertTrue('\"hello\": \"world\"' in body)", "start_line": 26, "start_column": 8, "end_line": 26, "end_column": 51 }, { "span": "self.assertTrue('\"abc\": 123' in body)", "start_line": 27, "start_column": 8, "end_line": 27, "end_column": 45 }, { "span": "self.assertTrue('\"nested\": \"2014-03-30T12:55:15\"' in body)", "start_line": 28, "start_column": 8, "end_line": 28, "end_column": 66 }, { "span": "self.assertTrue('\"again\": \"18.9\"' in body)", "start_line": 29, "start_column": 8, "end_line": 29, "end_column": 50 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "JSO", "NS", "eria", "lize", "r", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "serialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "self_", "._", "serializer_", "._", "serialize_", "(_", "self_", "._", "dict", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'\"", "hell", "o", "\":", " ", "\"", "world", "\"'_", "in_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'\"", "abc", "\":", " ", "123", "'_", "in_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'\"", "nest", "ed", "\":", " ", "\"", "2014", "-0", "3", "-", "30", "T1", "2", ":", "5", "5", ":", "15", "\"'_", "in_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'\"", "again", "\":", " ", "\"", "18.", "9", "\"'_", "in_", "body_", ")_", "\\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, 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, 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, 2 ]
Unnecessary delete statement in function
evennia/evennia/evennia/server/portal/portalsessionhandler.py
[ { "content": " def server_disconnect(self, session, reason=\"\"):\n \"\"\"\n Called by server to force a disconnect by sessid.\n\n Args:\n sessid (int): Session id to disconnect.\n reason (str, optional): Motivation for disconect.\n\n \"\"\"\n if session:\n session.disconnect(reason)\n if session.sessid in self:\n # in case sess.disconnect doesn't delete it\n del self[session.sessid]\n del session", "metadata": "root.PortalSessionHandler.server_disconnect", "header": "['class', 'PortalSessionHandler', '(', 'SessionHandler', ')', ':', '___EOS___']", "index": 196 } ]
[ { "span": "del session", "start_line": 210, "start_column": 12, "end_line": 210, "end_column": 23 } ]
[ { "span": "def server_disconnect(self, session, reason=\"\"):", "start_line": 196, "start_column": 4, "end_line": 196, "end_column": 52 } ]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "delete_", "statement_", "in_", "function_", "[SEP]_", "class_", "Porta", "l", "Sess", "ion", "Handler_", "(_", "Sess", "ion", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "disconnect_", "(_", "self_", ",_", "session_", ",_", "reason_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", "ed", " ", "by", " ", "server", " ", "to", " ", "force", " ", "a", " ", "discon", "nect", " ", "by", " ", "sess", "id", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "sess", "id", " ", "(", "int", "):", " ", "Sess", "ion", " ", "id", " ", "to", " ", "discon", "nect", ".", "\\", "10", ";", " ", " ", " ", " ", "reason", " ", "(", "str", ",", " ", "option", "al", "):", " ", "Moti", "vati", "on", " ", "for", " ", "discon", "ect", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "session_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "disconnect_", "(_", "reason_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "session_", "._", "sess", "id_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "in", " ", "case", " ", "sess", ".", "discon", "nect", " ", "doe", "sn", "'", "t", " ", "delete", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "[_", "session_", "._", "sess", "id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "session_", "\\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, 3, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
dotskapes/dotSkapes/modules/savage/graph/__init__.py
[ { "content": " def createXAxis (self):\n ax = Group ()\n x = self.canvas.x - self.canvas.height\n y = self.canvas.y + self.canvas.height\n \n if self.settings.horizontal:\n ax.appendTransform (Rotate (-90, self.canvas.x, y))\n UnifiedGraph.createXAxis (self)\n else:\n ax.appendTransform (Rotate (-90, self.canvas.x, self.canvas.y))\n textProperties = {'textHeight': self.settings.xAxisTextHeight,\n 'verticalAnchor': 'middle',\n 'horizontalAnchor': 'right',\n 'maxLines': 1,\n }\n xaxis = YAxis (id = 'x-axis',\n #inf = self.canvas.y + self.canvas.height,\n #sup = self.canvas.y + self.canvas.height - self.canvas.width,\n inf = self.canvas.y,\n sup = self.canvas.y - self.canvas.width,\n #x = self.canvas.x - self.canvas.height - self.settings.xAxisSpace,\n x = self.canvas.x - self.settings.xAxisSpace,\n lower = self.xbounds[0],\n upper = self.xbounds[1],\n textProperties = textProperties)\n sizes = []\n ticks = []\n labels = []\n for child in self.canvas.data:\n if child.xml.has_key ('data'):\n #sizes (child.height)\n ticks.append (child.x + child.width / 2.0)\n labels.append (child.xml['data'])\n xaxis.createTicks (ticks)\n xaxis.setText (map (str, labels))\n xaxis.drawTicks ()\n ax.draw (xaxis)\n self.dataGroup.drawAt (ax, 0)", "metadata": "root.BarGraph.createXAxis", "header": "['class', 'BarGraph', '(', 'UnifiedGraph', ')', ':', '___EOS___']", "index": 219 } ]
[ { "span": "x ", "start_line": 221, "start_column": 8, "end_line": 221, "end_column": 9 }, { "span": "sizes ", "start_line": 244, "start_column": 12, "end_line": 244, "end_column": 17 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Bar", "Graph_", "(_", "Uni", "fied", "Graph_", ")_", ":_", "\\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_", "create", "XA", "xis_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ax_", "=_", "Group_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "self_", "._", "canvas_", "._", "x_", "-_", "self_", "._", "canvas_", "._", "height_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "self_", "._", "canvas_", "._", "y_", "+_", "self_", "._", "canvas_", "._", "height_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "settings_", "._", "horizontal_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ax_", "._", "append", "Transform_", "(_", "Rotate", "_", "(_", "-_", "90_", ",_", "self_", "._", "canvas_", "._", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Uni", "fied", "Graph_", "._", "create", "XA", "xis_", "(_", "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 ", " _", "ax_", "._", "append", "Transform_", "(_", "Rotate", "_", "(_", "-_", "90_", ",_", "self_", "._", "canvas_", "._", "x_", ",_", "self_", "._", "canvas_", "._", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "Properties_", "=_", "{_", "'", "text", "Hei", "ght", "'_", ":_", "self_", "._", "settings_", "._", "x", "Axi", "s", "Text", "Height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "vertical", "Anc", "hor", "'_", ":_", "'", "middle", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "horizon", "tal", "Anc", "hor", "'_", ":_", "'", "right", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "Line", "s", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xaxis_", "=_", "YA", "xis_", "(_", "id_", "=_", "'", "x", "-", "axis", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "inf", " ", "=", " ", "self", ".", "canv", "as", ".", "y", " ", "+", " ", "self", ".", "canv", "as", ".", "height", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "sup", " ", "=", " ", "self", ".", "canv", "as", ".", "y", " ", "+", " ", "self", ".", "canv", "as", ".", "height", " ", "-", " ", "self", ".", "canv", "as", ".", "widt", "h", ",_", "\\u\\u\\uNL\\u\\u\\u_", "inf_", "=_", "self_", "._", "canvas_", "._", "y_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sup_", "=_", "self_", "._", "canvas_", "._", "y_", "-_", "self_", "._", "canvas_", "._", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "x", " ", "=", " ", "self", ".", "canv", "as", ".", "x", " ", "-", " ", "self", ".", "canv", "as", ".", "height", " ", "-", " ", "self", ".", "settings", ".", "x", "Axi", "s", "Spac", "e", ",_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "self_", "._", "canvas_", "._", "x_", "-_", "self_", "._", "settings_", "._", "x", "Axi", "s", "Space_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lower_", "=_", "self_", "._", "xb", "ound", "s_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "upper_", "=_", "self_", "._", "xb", "ound", "s_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "text", "Properties_", "=_", "text", "Properties_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sizes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ticks_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labels_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "canvas_", "._", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "child_", "._", "xml_", "._", "has", "\\u", "key_", "(_", "'", "data", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "size", "s", " ", "(", "child", ".", "height", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ticks_", "._", "append_", "(_", "child_", "._", "x_", "+_", "child_", "._", "width_", "/_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labels_", "._", "append_", "(_", "child_", "._", "xml_", "[_", "'", "data", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "xaxis_", "._", "create", "Ticks", "_", "(_", "ticks_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xaxis_", "._", "set", "Text_", "(_", "map_", "(_", "str_", ",_", "labels_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xaxis_", "._", "draw", "Ticks", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "draw_", "(_", "xaxis_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data", "Group_", "._", "draw", "At_", "(_", "ax_", ",_", "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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
mozilla/inventory/vendor-local/src/django-tastypie/tests/core/tests/resources.py
[ { "content": " def test_get_via_uri(self):\n resource = NoteResource(api_name='v1')\n note_1 = resource.get_via_uri('/api/v1/notes/1/')\n self.assertEqual(note_1.pk, 1)\n\n try:\n should_fail = resource.get_via_uri('http://example.com/')\n self.fail(\"'get_via_uri' should fail miserably with something that isn't an object URI.\")\n except NotFound:\n pass\n\n try:\n should_also_fail = resource.get_via_uri('/api/v1/notes/')\n self.fail(\"'get_via_uri' should fail miserably with something that isn't an object URI.\")\n except MultipleObjectsReturned:\n pass\n\n # Check with the request.\n request = HttpRequest()\n note_1 = resource.get_via_uri('/api/v1/notes/1/', request=request)\n self.assertEqual(note_1.pk, 1)", "metadata": "root.ModelResourceTestCase.test_get_via_uri", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1242 }, { "content": " def test_obj_delete_list_custom_qs(self):\n self.assertEqual(len(Note.objects.all()), 6)\n notes = NoteResource().obj_delete_list()\n self.assertEqual(len(Note.objects.all()), 2)", "metadata": "root.ModelResourceTestCase.test_obj_delete_list_custom_qs", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2345 }, { "content": " def test_obj_delete_list_basic_qs(self):\n self.assertEqual(len(Note.objects.all()), 6)\n customs = VeryCustomNoteResource().obj_delete_list()\n self.assertEqual(len(Note.objects.all()), 0)", "metadata": "root.ModelResourceTestCase.test_obj_delete_list_basic_qs", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2350 }, { "content": " def test_obj_delete_list_non_queryset(self):\n class NonQuerysetNoteResource(ModelResource):\n class Meta:\n queryset = Note.objects.all()\n\n def apply_authorization_limits(self, request, obj_list):\n return tuple(obj_list[:2])\n\n self.assertEqual(len(Note.objects.all()), 6)\n # This is a regression. Used to fail miserably.\n notes = NonQuerysetNoteResource().obj_delete_list()\n self.assertEqual(len(Note.objects.all()), 4)", "metadata": "root.ModelResourceTestCase.test_obj_delete_list_non_queryset", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2355 }, { "content": " def test_obj_update(self):\n self.assertEqual(Note.objects.all().count(), 6)\n note = NoteResource()\n note_obj = note.obj_get(pk=1)\n note_bundle = note.build_bundle(obj=note_obj)\n note_bundle = note.full_dehydrate(note_bundle)\n note_bundle.data['title'] = 'Whee!'\n note.obj_update(note_bundle, pk=1)\n self.assertEqual(Note.objects.all().count(), 6)\n numero_uno = Note.objects.get(pk=1)\n self.assertEqual(numero_uno.title, u'Whee!')\n self.assertEqual(numero_uno.slug, u'first-post')\n self.assertEqual(numero_uno.content, u'This is my very first post using my shiny new API. Pretty sweet, huh?')\n self.assertEqual(numero_uno.is_active, True)\n\n self.assertEqual(Note.objects.all().count(), 6)\n note = RelatedNoteResource()\n related_obj = note.obj_get(pk=1)\n related_bundle = Bundle(obj=related_obj, data={\n 'title': \"Yet another new post!\",\n 'slug': \"yet-another-new-post\",\n 'content': \"WHEEEEEE!\",\n 'is_active': True,\n 'author': '/api/v1/users/2/',\n 'subjects': ['/api/v1/subjects/2/', '/api/v1/subjects/1/'],\n })\n note.obj_update(related_bundle, pk=1)\n self.assertEqual(Note.objects.all().count(), 6)\n latest = Note.objects.get(slug='yet-another-new-post')\n self.assertEqual(latest.title, u\"Yet another new post!\")\n self.assertEqual(latest.slug, u'yet-another-new-post')\n self.assertEqual(latest.content, u'WHEEEEEE!')\n self.assertEqual(latest.is_active, True)\n self.assertEqual(latest.author.username, u'janedoe')\n self.assertEqual(latest.subjects.all().count(), 2)\n self.assertEqual([sub.id for sub in latest.subjects.all()], [1, 2])\n\n self.assertEqual(Note.objects.all().count(), 6)\n note = AnotherRelatedNoteResource()\n related_obj = note.obj_get(pk=1)\n related_bundle = Bundle(data={\n 'title': \"Yet another another new post!\",\n 'slug': \"yet-another-another-new-post\",\n 'content': \"WHEEEEEE!\",\n 'is_active': True,\n 'author': '/api/v1/users/1/',\n 'subjects': [{\n 'name': 'helloworld',\n 'url': 'http://example.com',\n 'created': '2010-05-20 14:22:00',\n }],\n })\n note.obj_update(related_bundle, pk=1)\n self.assertEqual(Note.objects.all().count(), 6)\n latest = Note.objects.get(slug='yet-another-another-new-post')\n self.assertEqual(latest.title, u\"Yet another another new post!\")\n self.assertEqual(latest.slug, u'yet-another-another-new-post')\n self.assertEqual(latest.content, u'WHEEEEEE!')\n self.assertEqual(latest.is_active, True)\n self.assertEqual(latest.author.username, u'johndoe')\n self.assertEqual(latest.subjects.all().count(), 1)\n self.assertEqual([sub.id for sub in latest.subjects.all()], [3])\n\n # Fix non-native types (like datetimes) during attempted hydration.\n # This ensures that handing the wrong type should get coerced to the\n # right thing.\n self.assertEqual(Note.objects.all().count(), 6)\n note = NoteResource()\n note_obj = note.obj_get(pk=1)\n self.assertEqual(note_obj.title, u'Yet another another new post!')\n self.assertEqual(note_obj.created, aware_datetime(2010, 3, 30, 20, 5))\n note_bundle = note.build_bundle(obj=note_obj)\n note_bundle = note.full_dehydrate(note_bundle)\n note_bundle.data['title'] = 'OMGOMGOMGOMG!'\n note_bundle.data['created'] = aware_datetime(2011, 11, 23, 1, 0, 0)\n note.obj_update(note_bundle, pk=1, created='2010-03-30T20:05:00')\n self.assertEqual(Note.objects.all().count(), 6)\n numero_uno = Note.objects.get(pk=1)\n self.assertEqual(numero_uno.title, u'OMGOMGOMGOMG!')\n self.assertEqual(numero_uno.slug, u'yet-another-another-new-post')\n self.assertEqual(numero_uno.content, u'WHEEEEEE!')\n self.assertEqual(numero_uno.created, aware_datetime(2011, 11, 23, 1, 0))\n\n # Now try a lookup that should fail.\n note = NoteResource()\n note_bundle = note.build_bundle(data={\n \"author\": \"/api/v1/users/1/\",\n \"title\": \"Something something Post!\",\n \"slug\": \"something-something-post\",\n \"content\": \"Stock post content.\",\n \"is_active\": True,\n \"created\": \"2011-03-30 20:05:00\",\n \"updated\": \"2011-03-30 20:05:00\"\n })\n self.assertRaises(NotFound, note.obj_update, note_bundle, pk=1, created='2010-03-31T20:05:00')\n self.assertEqual(Note.objects.all().count(), 6)\n\n # Assign based on the ``request.user``, which helps ensure that\n # the correct ``request`` is being passed along.\n request = HttpRequest()\n request.user = User.objects.get(username='johndoe')\n self.assertEqual(AlwaysUserNoteResource().get_object_list(request).count(), 2)\n note = AlwaysUserNoteResource()\n note_obj = note.obj_get(request, pk=1)\n note_bundle = note.build_bundle(obj=note_obj)\n note_bundle = note.full_dehydrate(note_bundle)\n note_bundle.data['title'] = 'Whee!'\n note_bundle.request = request\n note.obj_update(note_bundle, pk=1)\n self.assertEqual(Note.objects.all().count(), 6)\n numero_uno = Note.objects.get(pk=1)\n self.assertEqual(numero_uno.title, u'Whee!')\n self.assertEqual(numero_uno.slug, u'yet-another-another-new-post')\n self.assertEqual(numero_uno.content, u'WHEEEEEE!')\n self.assertEqual(numero_uno.is_active, True)\n self.assertEqual(numero_uno.author.pk, request.user.pk)", "metadata": "root.ModelResourceTestCase.test_obj_update", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2467 }, { "content": " def test_is_valid(self):\n # Using the plug.\n note = NoteResource()\n bundle = Bundle(data={})\n\n try:\n note.is_valid(bundle)\n except:\n self.fail(\"Stock 'is_valid' should pass without exception.\")\n\n # An actual form.\n class NoteForm(forms.Form):\n title = forms.CharField(max_length=100)\n slug = forms.CharField(max_length=50)\n content = forms.CharField(required=False, widget=forms.Textarea)\n is_active = forms.BooleanField()\n\n # Define a custom clean to make sure non-field errors are making it\n # through.\n def clean(self):\n if not self.cleaned_data.get('content', ''):\n raise forms.ValidationError('Having no content makes for a very boring note.')\n\n return self.cleaned_data\n\n class ValidatedNoteResource(ModelResource):\n class Meta:\n queryset = Note.objects.all()\n resource_name = 'validated'\n validation = FormValidation(form_class=NoteForm)\n\n class ValidatedXMLNoteResource(ModelResource):\n class Meta:\n queryset = Note.objects.all()\n resource_name = 'validated'\n validation = FormValidation(form_class=NoteForm)\n default_format = 'application/xml'\n\n validated = ValidatedNoteResource()\n validated_xml = ValidatedXMLNoteResource()\n\n # Test empty data.\n bundle = Bundle(data={})\n self.assertFalse(validated.is_valid(bundle))\n self.assertEqual(bundle.errors, {'validated': {'is_active': [u'This field is required.'], 'slug': [u'This field is required.'], '__all__': [u'Having no content makes for a very boring note.'], 'title': [u'This field is required.']}})\n\n # Test something that fails validation.\n bundle = Bundle(data={\n 'title': 123,\n 'slug': '123456789012345678901234567890123456789012345678901234567890',\n 'content': '',\n 'is_active': True,\n })\n self.assertFalse(validated.is_valid(bundle))\n self.assertEqual(bundle.errors, {'validated': {'slug': [u'Ensure this value has at most 50 characters (it has 60).'], '__all__': [u'Having no content makes for a very boring note.']}})\n\n # Test something that passes validation.\n bundle = Bundle(data={\n 'title': 'Test Content',\n 'slug': 'test-content',\n 'content': \"It doesn't get any more awesome than this.\",\n 'is_active': True,\n })\n\n self.assertTrue(validated.is_valid(bundle))", "metadata": "root.ModelResourceTestCase.test_is_valid", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2609 }, { "content": " def test_nullable_tomany_full_hydrate(self):\n nrrnr = NullableRelatedNoteResource()\n bundle_1 = Bundle(data={\n 'author': '/api/v1/users/1/',\n 'subjects': [],\n })\n\n # Now load up the data.\n hydrated = nrrnr.full_hydrate(bundle_1)\n hydrated = nrrnr.hydrate_m2m(hydrated)\n\n self.assertEqual(hydrated.data['author'], '/api/v1/users/1/')\n self.assertEqual(hydrated.data['subjects'], [])\n\n # Regression: not specifying the tomany field should still work if\n # it is nullable.\n bundle_2 = Bundle(data={\n 'author': '/api/v1/users/1/',\n })\n\n hydrated2 = nrrnr.full_hydrate(bundle_2)\n hydrated2 = nrrnr.hydrate_m2m(hydrated2)\n\n self.assertEqual(hydrated2.data['author'], '/api/v1/users/1/')\n self.assertEqual(hydrated2.data['subjects'], [])\n\n # Regression pt. II - Make sure saving the objects works.\n bundle_3 = Bundle(data={\n 'author': '/api/v1/users/1/',\n })\n hydrated3 = nrrnr.obj_create(bundle_2)\n self.assertEqual(hydrated2.obj.author.username, u'johndoe')\n self.assertEqual(hydrated2.obj.subjects.count(), 0)", "metadata": "root.ModelResourceTestCase.test_nullable_tomany_full_hydrate", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2780 }, { "content": " def regression_test_per_object_detail(self):\n ponr = PerObjectNoteResource()\n empty_request = type('MockRequest', (object,), {'GET': {}})\n\n self.assertEqual(ponr._meta.queryset.count(), 6)\n\n # Regression: Make sure that simple ``get_detail`` requests work.\n self.assertTrue(isinstance(ponr.obj_get(request=empty_request, pk=1), Note))\n self.assertEqual(ponr.obj_get(request=empty_request, pk=1).pk, 1)\n self.assertEqual(ponr._pre_limits, 0)\n self.assertEqual(ponr._post_limits, 1)\n\n try:\n too_many = ponr.obj_get(request=empty_request, is_active=True, pk__gte=1)\n self.fail()\n except MultipleObjectsReturned, e:\n self.assertEqual(str(e), \"More than 'Note' matched 'is_active=True, pk__gte=1'.\")\n\n try:\n too_many = ponr.obj_get(request=empty_request, pk=1000000)\n self.fail()\n except Note.DoesNotExist, e:\n self.assertEqual(str(e), \"Couldn't find an instance of 'Note' which matched 'pk=1000000'.\")", "metadata": "root.ModelResourceTestCase.regression_test_per_object_detail", "header": "['class', 'ModelResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 2871 }, { "content": " def test_debug_on_with_full(self):\n settings.DEBUG = True\n settings.TASTYPIE_FULL_DEBUG = True\n\n try:\n resp = self.resource.wrap_view('get_list')(self.request, pk=1)\n self.fail()\n except YouFail:\n pass", "metadata": "root.BustedResourceTestCase.test_debug_on_with_full", "header": "['class', 'BustedResourceTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 3041 } ]
[ { "span": "should_fail ", "start_line": 1248, "start_column": 12, "end_line": 1248, "end_column": 23 }, { "span": "should_also_fail ", "start_line": 1254, "start_column": 12, "end_line": 1254, "end_column": 28 }, { "span": "notes ", "start_line": 2347, "start_column": 8, "end_line": 2347, "end_column": 13 }, { "span": "customs ", "start_line": 2352, "start_column": 8, "end_line": 2352, "end_column": 15 }, { "span": "notes ", "start_line": 2365, "start_column": 8, "end_line": 2365, "end_column": 13 }, { "span": "related_obj ", "start_line": 2506, "start_column": 8, "end_line": 2506, "end_column": 19 }, { "span": "validated_xml ", "start_line": 2648, "start_column": 8, "end_line": 2648, "end_column": 21 }, { "span": "bundle_3 ", "start_line": 2807, "start_column": 8, "end_line": 2807, "end_column": 16 }, { "span": "hydrated3 ", "start_line": 2810, "start_column": 8, "end_line": 2810, "end_column": 17 }, { "span": "too_many ", "start_line": 2890, "start_column": 12, "end_line": 2890, "end_column": 20 }, { "span": "resp ", "start_line": 3046, "start_column": 12, "end_line": 3046, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "get", "\\u", "via", "\\u", "uri_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resource_", "=_", "Not", "e", "Resource_", "(_", "api", "\\u", "name_", "=_", "'", "v1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "1_", "=_", "resource_", "._", "get", "\\u", "via", "\\u", "uri_", "(_", "'/", "api", "/", "v1", "/", "note", "s", "/", "1", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "note", "\\u", "1_", "._", "pk_", ",_", "1_", ")_", "\\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 ", " _", "shou", "ld", "\\u", "fail_", "=_", "resource_", "._", "get", "\\u", "via", "\\u", "uri_", "(_", "'", "http", "://", "example", ".", "com", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"'", "get", "\\u", "via", "\\u", "uri", "'", " ", "shou", "ld", " ", "fail", " ", "mis", "era", "bly", " ", "with", " ", "somet", "hing", " ", "tha", "t", " ", "isn", "'", "t", " ", "an", " ", "object", " ", "URI", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Found_", ":_", "\\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 ", " _", "shou", "ld", "\\u", "als", "o", "\\u", "fail_", "=_", "resource_", "._", "get", "\\u", "via", "\\u", "uri_", "(_", "'/", "api", "/", "v1", "/", "note", "s", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", "\"'", "get", "\\u", "via", "\\u", "uri", "'", " ", "shou", "ld", " ", "fail", " ", "mis", "era", "bly", " ", "with", " ", "somet", "hing", " ", "tha", "t", " ", "isn", "'", "t", " ", "an", " ", "object", " ", "URI", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Multipl", "e", "Object", "s", "Return", "ed_", ":_", "\\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_", "#", " ", "Check", " ", "with", " ", "the", " ", "request", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "request_", "=_", "Http", "Request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "1_", "=_", "resource_", "._", "get", "\\u", "via", "\\u", "uri_", "(_", "'/", "api", "/", "v1", "/", "note", "s", "/", "1", "/'_", ",_", "request_", "=_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "note", "\\u", "1_", "._", "pk_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "obj", "\\u", "delete", "\\u", "list", "\\u", "custom", "\\u", "qs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "notes_", "=_", "Not", "e", "Resource_", "(_", ")_", "._", "obj", "\\u", "delete", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "obj", "\\u", "delete", "\\u", "list", "\\u", "basic", "\\u", "qs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "s_", "=_", "Ver", "y", "Custom", "Not", "e", "Resource_", "(_", ")_", "._", "obj", "\\u", "delete", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "obj", "\\u", "delete", "\\u", "list", "\\u", "non", "\\u", "queryset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Non", "Query", "set", "Not", "e", "Resource_", "(_", "Model", "Resource_", ")_", ":_", "\\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 ", " _", "queryset_", "=_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "appl", "y", "\\u", "authoriz", "ation", "\\u", "limits_", "(_", "self_", ",_", "request_", ",_", "obj", "\\u", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "tuple_", "(_", "obj", "\\u", "list_", "[_", ":_", "2_", "]_", ")_", "\\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_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "a", " ", "regress", "ion", ".", " ", "Us", "ed", " ", "to", " ", "fail", " ", "mis", "era", "bly", "._", "\\u\\u\\uNL\\u\\u\\u_", "notes_", "=_", "Non", "Query", "set", "Not", "e", "Resource_", "(_", ")_", "._", "obj", "\\u", "delete", "\\u", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", ")_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "obj", "\\u", "update_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "obj_", "=_", "note_", "._", "obj", "\\u", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "build", "\\u", "bundle_", "(_", "obj_", "=_", "note", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "full", "\\u", "de", "hydra", "te_", "(_", "note", "\\u", "bundle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "._", "data_", "[_", "'", "title", "'_", "]_", "=_", "'", "Whe", "e", "!'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "._", "obj", "\\u", "update_", "(_", "note", "\\u", "bundle_", ",_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "numero", "\\u", "uno", "_", "=_", "Note_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "title_", ",_", "u", "'", "Whe", "e", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "slug_", ",_", "u", "'", "first", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "content_", ",_", "u", "'", "Thi", "s", " ", "is", " ", "my", " ", "very", " ", "first", " ", "post", " ", "usi", "ng", " ", "my", " ", "shin", "y", " ", "new", " ", "API", ".", " ", "Pret", "ty", " ", "swe", "et", ",", " ", "hu", "h", "?'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "is", "\\u", "active_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "Rela", "ted", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relate", "d\\u", "obj_", "=_", "note_", "._", "obj", "\\u", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relate", "d\\u", "bundle_", "=_", "Bundle_", "(_", "obj_", "=_", "relate", "d\\u", "obj_", ",_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "\"", "Ye", "t", " ", "anot", "her", " ", "new", " ", "post", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "\"", "ye", "t", "-", "anot", "her", "-", "new", "-", "post", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "'_", ":_", "\"", "WHE", "EEE", "EE", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "'/", "api", "/", "v1", "/", "users", "/", "2", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "subject", "s", "'_", ":_", "[_", "'/", "api", "/", "v1", "/", "subject", "s", "/", "2", "/'_", ",_", "'/", "api", "/", "v1", "/", "subject", "s", "/", "1", "/'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "._", "obj", "\\u", "update_", "(_", "relate", "d\\u", "bundle_", ",_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "latest_", "=_", "Note_", "._", "objects_", "._", "get_", "(_", "slug_", "=_", "'", "ye", "t", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "title_", ",_", "u", "\"", "Ye", "t", " ", "anot", "her", " ", "new", " ", "post", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "slug_", ",_", "u", "'", "ye", "t", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "content_", ",_", "u", "'", "WHE", "EEE", "EE", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "is", "\\u", "active_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "author_", "._", "username_", ",_", "u", "'", "jane", "doe", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "subjects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "sub_", "._", "id_", "for_", "sub_", "in_", "latest_", "._", "subjects_", "._", "all_", "(_", ")_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "Ano", "ther", "Rela", "ted", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relate", "d\\u", "obj_", "=_", "note_", "._", "obj", "\\u", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relate", "d\\u", "bundle_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "\"", "Ye", "t", " ", "anot", "her", " ", "anot", "her", " ", "new", " ", "post", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "\"", "ye", "t", "-", "anot", "her", "-", "anot", "her", "-", "new", "-", "post", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "'_", ":_", "\"", "WHE", "EEE", "EE", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "subject", "s", "'_", ":_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "hellow", "orl", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "http", "://", "example", ".", "com", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "created", "'_", ":_", "'", "2010", "-0", "5", "-", "20", " ", "14", ":", "2", "2", ":", "00", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "._", "obj", "\\u", "update_", "(_", "relate", "d\\u", "bundle_", ",_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "latest_", "=_", "Note_", "._", "objects_", "._", "get_", "(_", "slug_", "=_", "'", "ye", "t", "-", "anot", "her", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "title_", ",_", "u", "\"", "Ye", "t", " ", "anot", "her", " ", "anot", "her", " ", "new", " ", "post", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "slug_", ",_", "u", "'", "ye", "t", "-", "anot", "her", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "content_", ",_", "u", "'", "WHE", "EEE", "EE", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "is", "\\u", "active_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "author_", "._", "username_", ",_", "u", "'", "john", "doe", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "latest_", "._", "subjects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "sub_", "._", "id_", "for_", "sub_", "in_", "latest_", "._", "subjects_", "._", "all_", "(_", ")_", "]_", ",_", "[_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fix", " ", "non", "-", "nativ", "e", " ", "types", " ", "(", "like", " ", "datetimes", ")", " ", "dur", "ing", " ", "atte", "mpte", "d", " ", "hydra", "tion", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "ensure", "s", " ", "tha", "t", " ", "hand", "ing", " ", "the", " ", "wrong", " ", "type", " ", "shou", "ld", " ", "get", " ", "coerce", "d", " ", "to", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "right", " ", "thing", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "obj_", "=_", "note_", "._", "obj", "\\u", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "note", "\\u", "obj_", "._", "title_", ",_", "u", "'", "Ye", "t", " ", "anot", "her", " ", "anot", "her", " ", "new", " ", "post", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "note", "\\u", "obj_", "._", "created_", ",_", "awa", "re", "\\u", "datetime_", "(_", "2010_", ",_", "3_", ",_", "30_", ",_", "20_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "build", "\\u", "bundle_", "(_", "obj_", "=_", "note", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "full", "\\u", "de", "hydra", "te_", "(_", "note", "\\u", "bundle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "._", "data_", "[_", "'", "title", "'_", "]_", "=_", "'", "OM", "GO", "MG", "OM", "GO", "MG", "!'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "._", "data_", "[_", "'", "created", "'_", "]_", "=_", "awa", "re", "\\u", "datetime_", "(_", "2011_", ",_", "11_", ",_", "23_", ",_", "1_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "._", "obj", "\\u", "update_", "(_", "note", "\\u", "bundle_", ",_", "pk_", "=_", "1_", ",_", "created_", "=_", "'", "2010", "-0", "3", "-", "30", "T2", "0", ":", "05", ":", "00", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "numero", "\\u", "uno", "_", "=_", "Note_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "title_", ",_", "u", "'", "OM", "GO", "MG", "OM", "GO", "MG", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "slug_", ",_", "u", "'", "ye", "t", "-", "anot", "her", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "content_", ",_", "u", "'", "WHE", "EEE", "EE", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "created_", ",_", "awa", "re", "\\u", "datetime_", "(_", "2011_", ",_", "11_", ",_", "23_", ",_", "1_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", " ", "try", " ", "a", " ", "look", "up", " ", "tha", "t", " ", "shou", "ld", " ", "fail", "._", "\\u\\u\\uNL\\u\\u\\u_", "note_", "=_", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "build", "\\u", "bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "author", "\"_", ":_", "\"/", "api", "/", "v1", "/", "users", "/", "1", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "title", "\"_", ":_", "\"", "Some", "thing", " ", "somet", "hing", " ", "Post", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "slug", "\"_", ":_", "\"", "somet", "hing", "-", "somet", "hing", "-", "post", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "content", "\"_", ":_", "\"", "Stock", " ", "post", " ", "content", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "is", "\\u", "active", "\"_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "created", "\"_", ":_", "\"", "2011", "-0", "3", "-", "30", " ", "20", ":", "05", ":", "00", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "update", "d", "\"_", ":_", "\"", "2011", "-0", "3", "-", "30", " ", "20", ":", "05", ":", "00", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Not", "Found_", ",_", "note_", "._", "obj", "\\u", "update_", ",_", "note", "\\u", "bundle_", ",_", "pk_", "=_", "1_", ",_", "created_", "=_", "'", "2010", "-0", "3", "-", "3", "1", "T2", "0", ":", "05", ":", "00", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Assign", " ", "based", " ", "on", " ", "the", " ", "``", "request", ".", "user", "``", ",", " ", "whi", "ch", " ", "helps", " ", "ensure", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "correct", " ", "``", "request", "``", " ", "is", " ", "bei", "ng", " ", "pass", "ed", " ", "along", "._", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "Http", "Request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "._", "user_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "username_", "=_", "'", "john", "doe", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Al", "way", "s", "User", "Not", "e", "Resource_", "(_", ")_", "._", "get", "\\u", "object\\u", "list_", "(_", "request_", ")_", "._", "count_", "(_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "=_", "Al", "way", "s", "User", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "obj_", "=_", "note_", "._", "obj", "\\u", "get_", "(_", "request_", ",_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "build", "\\u", "bundle_", "(_", "obj_", "=_", "note", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "=_", "note_", "._", "full", "\\u", "de", "hydra", "te_", "(_", "note", "\\u", "bundle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "._", "data_", "[_", "'", "title", "'_", "]_", "=_", "'", "Whe", "e", "!'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "bundle_", "._", "request_", "=_", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note_", "._", "obj", "\\u", "update_", "(_", "note", "\\u", "bundle_", ",_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "numero", "\\u", "uno", "_", "=_", "Note_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "title_", ",_", "u", "'", "Whe", "e", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "slug_", ",_", "u", "'", "ye", "t", "-", "anot", "her", "-", "anot", "her", "-", "new", "-", "post", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "content_", ",_", "u", "'", "WHE", "EEE", "EE", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "is", "\\u", "active_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "numero", "\\u", "uno", "_", "._", "author_", "._", "pk_", ",_", "request_", "._", "user_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "is", "\\u", "valid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Us", "ing", " ", "the", " ", "plug", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "note_", "=_", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bundle_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "}_", ")_", "\\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 ", " _", "note_", "._", "is", "\\u", "valid_", "(_", "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 ", " _", "self_", "._", "fail_", "(_", "\"", "Stock", " ", "'", "is", "\\u", "valid", "'", " ", "shou", "ld", " ", "pass", " ", "with", "out", " ", "exception", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "An", " ", "actual", " ", "form", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Not", "e", "Form_", "(_", "forms_", "._", "Form_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "title_", "=_", "forms_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slug_", "=_", "forms_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "50_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "forms_", "._", "Char", "Field_", "(_", "required_", "=_", "False_", ",_", "widget_", "=_", "forms_", "._", "Textarea_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "\\u", "active_", "=_", "forms_", "._", "Boo", "lean", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Define", " ", "a", " ", "custom", " ", "clean", " ", "to", " ", "make", " ", "sure", " ", "non", "-", "field", " ", "error", "s", " ", "are", " ", "mak", "ing", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "through", "._", "\\u\\u\\uNL\\u\\u\\u_", "def_", "clean_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "clean", "ed", "\\u", "data_", "._", "get_", "(_", "'", "content", "'_", ",_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "forms_", "._", "Validat", "ion", "Error_", "(_", "'", "Ha", "ving", " ", "no", " ", "content", " ", "make", "s", " ", "for", " ", "a", " ", "very", " ", "bor", "ing", " ", "note", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "clean", "ed", "\\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_", "class_", "Validate", "d", "Not", "e", "Resource_", "(_", "Model", "Resource_", ")_", ":_", "\\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 ", " _", "queryset_", "=_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "name_", "=_", "'", "validat", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation_", "=_", "Form", "Validation_", "(_", "form", "\\u", "class_", "=_", "Not", "e", "Form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Validate", "d", "XML", "Not", "e", "Resource_", "(_", "Model", "Resource_", ")_", ":_", "\\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 ", " _", "queryset_", "=_", "Note_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "name_", "=_", "'", "validat", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validation_", "=_", "Form", "Validation_", "(_", "form", "\\u", "class_", "=_", "Not", "e", "Form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "format_", "=_", "'", "applica", "tion", "/", "xml", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "validated_", "=_", "Validate", "d", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "validat", "ed", "\\u", "xml_", "=_", "Validate", "d", "XML", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "empty", " ", "data", "._", "\\u\\u\\uNL\\u\\u\\u_", "bundle_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "validated_", "._", "is", "\\u", "valid_", "(_", "bundle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bundle_", "._", "errors_", ",_", "{_", "'", "validat", "ed", "'_", ":_", "{_", "'", "is", "\\u", "active", "'_", ":_", "[_", "u", "'", "Thi", "s", " ", "field", " ", "is", " ", "require", "d", ".'_", "]_", ",_", "'", "slug", "'_", ":_", "[_", "u", "'", "Thi", "s", " ", "field", " ", "is", " ", "require", "d", ".'_", "]_", ",_", "'\\u", "\\u", "all", "\\u\\u'_", ":_", "[_", "u", "'", "Ha", "ving", " ", "no", " ", "content", " ", "make", "s", " ", "for", " ", "a", " ", "very", " ", "bor", "ing", " ", "note", ".'_", "]_", ",_", "'", "title", "'_", ":_", "[_", "u", "'", "Thi", "s", " ", "field", " ", "is", " ", "require", "d", ".'_", "]_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "somet", "hing", " ", "tha", "t", " ", "fail", "s", " ", "validation", "._", "\\u\\u\\uNL\\u\\u\\u_", "bundle_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "123_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "'", "123456789012", "3456", "7890", "123456789012", "3456", "7890", "123456789012", "3456", "7890", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "validated_", "._", "is", "\\u", "valid_", "(_", "bundle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bundle_", "._", "errors_", ",_", "{_", "'", "validat", "ed", "'_", ":_", "{_", "'", "slug", "'_", ":_", "[_", "u", "'", "Ensur", "e", " ", "this", " ", "value", " ", "has", " ", "at", " ", "most", " ", "50", " ", "character", "s", " ", "(", "it", " ", "has", " ", "60", ").'_", "]_", ",_", "'\\u", "\\u", "all", "\\u\\u'_", ":_", "[_", "u", "'", "Ha", "ving", " ", "no", " ", "content", " ", "make", "s", " ", "for", " ", "a", " ", "very", " ", "bor", "ing", " ", "note", ".'_", "]_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "somet", "hing", " ", "tha", "t", " ", "pass", "es", " ", "validation", "._", "\\u\\u\\uNL\\u\\u\\u_", "bundle_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "'", "Test", " ", "Conten", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "'", "test", "-", "content", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "'_", ":_", "\"", "It", " ", "doe", "sn", "'", "t", " ", "get", " ", "any", " ", "more", " ", "aw", "eso", "me", " ", "than", " ", "this", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "validated_", "._", "is", "\\u", "valid_", "(_", "bundle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "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", "null", "able", "\\u", "toma", "ny", "\\u", "full", "\\u", "hydra", "te_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nr", "rn", "r_", "=_", "Null", "able", "Rela", "ted", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bundle", "\\u", "1_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "subject", "s", "'_", ":_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", " ", "load", " ", "up", " ", "the", " ", "data", "._", "\\u\\u\\uNL\\u\\u\\u_", "hydra", "ted_", "=_", "nr", "rn", "r_", "._", "full", "\\u", "hydra", "te_", "(_", "bundle", "\\u", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hydra", "ted_", "=_", "nr", "rn", "r_", "._", "hydra", "te", "\\u", "m2", "m_", "(_", "hydra", "ted_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted_", "._", "data_", "[_", "'", "author", "'_", "]_", ",_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted_", "._", "data_", "[_", "'", "subject", "s", "'_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", ":", " ", "not", " ", "speci", "fy", "ing", " ", "the", " ", "toma", "ny", " ", "field", " ", "shou", "ld", " ", "still", " ", "work", " ", "if_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "it", " ", "is", " ", "null", "able", "._", "\\u\\u\\uNL\\u\\u\\u_", "bundle", "\\u", "2_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "hydra", "ted", "2_", "=_", "nr", "rn", "r_", "._", "full", "\\u", "hydra", "te_", "(_", "bundle", "\\u", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hydra", "ted", "2_", "=_", "nr", "rn", "r_", "._", "hydra", "te", "\\u", "m2", "m_", "(_", "hydra", "ted", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted", "2_", "._", "data_", "[_", "'", "author", "'_", "]_", ",_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted", "2_", "._", "data_", "[_", "'", "subject", "s", "'_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", " ", "pt", ".", " ", "II", " ", "-", " ", "Make", " ", "sure", " ", "saving", " ", "the", " ", "object", "s", " ", "works", "._", "\\u\\u\\uNL\\u\\u\\u_", "bundle", "\\u", "3_", "=_", "Bundle_", "(_", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "author", "'_", ":_", "'/", "api", "/", "v1", "/", "users", "/", "1", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hydra", "ted", "3_", "=_", "nr", "rn", "r_", "._", "obj", "\\u", "create_", "(_", "bundle", "\\u", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted", "2_", "._", "obj_", "._", "author_", "._", "username_", ",_", "u", "'", "john", "doe", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "hydra", "ted", "2_", "._", "obj_", "._", "subjects_", "._", "count_", "(_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model", "Reso", "urc", "e", "Test", "Case_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "regress", "ion", "\\u", "test\\u", "per", "\\u", "object\\u", "detail_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pon", "r_", "=_", "Per", "Object", "Not", "e", "Resource_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "empty", "\\u", "request_", "=_", "type_", "(_", "'", "Moc", "k", "Request", "'_", ",_", "(_", "object_", ",_", ")_", ",_", "{_", "'", "GET", "'_", ":_", "{_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "pon", "r_", "._", "\\u", "meta_", "._", "queryset_", "._", "count_", "(_", ")_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Regr", "ession", ":", " ", "Make", " ", "sure", " ", "tha", "t", " ", "simple", " ", "``", "get", "\\u", "deta", "il", "``", " ", "request", "s", " ", "work", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "pon", "r_", "._", "obj", "\\u", "get_", "(_", "request_", "=_", "empty", "\\u", "request_", ",_", "pk_", "=_", "1_", ")_", ",_", "Note_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "pon", "r_", "._", "obj", "\\u", "get_", "(_", "request_", "=_", "empty", "\\u", "request_", ",_", "pk_", "=_", "1_", ")_", "._", "pk_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "pon", "r_", "._", "\\u", "pre", "\\u", "limits_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "pon", "r_", "._", "\\u", "post", "\\u", "limits_", ",_", "1_", ")_", "\\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 ", " _", "too", "\\u", "many_", "=_", "pon", "r_", "._", "obj", "\\u", "get_", "(_", "request_", "=_", "empty", "\\u", "request_", ",_", "is", "\\u", "active_", "=_", "True_", ",_", "pk", "\\u\\u", "gte_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Multipl", "e", "Object", "s", "Return", "ed_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "e_", ")_", ",_", "\"", "Mor", "e", " ", "than", " ", "'", "Not", "e", "'", " ", "matche", "d", " ", "'", "is", "\\u", "active", "=", "Tru", "e", ",", " ", "pk", "\\u\\u", "gte", "=", "1", "'.\"_", ")_", "\\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 ", " _", "too", "\\u", "many_", "=_", "pon", "r_", "._", "obj", "\\u", "get_", "(_", "request_", "=_", "empty", "\\u", "request_", ",_", "pk_", "=_", "1000000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fail_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Note_", "._", "Do", "es", "Not", "Exist_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "str_", "(_", "e_", ")_", ",_", "\"", "Cou", "ld", "n", "'", "t", " ", "find", " ", "an", " ", "instance", " ", "of", " ", "'", "Not", "e", "'", " ", "whi", "ch", " ", "matche", "d", " ", "'", "pk", "=", "1000000", "'.\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bus", "ted", "Reso", "urc", "e", "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", "debug", "\\u", "on", "\\u", "with", "\\u", "full_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "settings_", "._", "DEBUG_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "settings_", "._", "TA", "ST", "YP", "IE", "\\u", "FULL", "\\u", "DEBUG_", "=_", "True_", "\\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 ", " _", "resp_", "=_", "self_", "._", "resource_", "._", "wrap", "\\u", "view_", "(_", "'", "get", "\\u", "list", "'_", ")_", "(_", "self_", "._", "request_", ",_", "pk_", "=_", "1_", ")_", "\\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, 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 ]
Except block handles 'BaseException'
sahana/eden/modules/s3/sync_adapter/eden.py
[ { "content": "# -*- coding: utf-8 -*-\n\n\"\"\" S3 Synchronization: Peer Repository Adapter\n\n @copyright: 2011-2016 (c) Sahana Software Foundation\n @license: MIT\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\n\nimport sys\nimport urllib2\nimport traceback\n\ntry:\n from lxml import etree\nexcept ImportError:\n print >> sys.stderr, \"ERROR: lxml module needed for XML handling\"\n raise\n\ntry:\n import json # try stdlib (Python 2.6)\nexcept ImportError:\n try:\n import simplejson as json # try external module\n except:\n import gluon.contrib.simplejson as json # fallback to pure-Python module\n\nfrom gluon import *\n\nfrom ..s3datetime import s3_encode_iso_datetime\nfrom ..s3sync import S3SyncBaseAdapter\nfrom ..s3utils import S3ModuleDebug\n\nDEBUG = False\nif DEBUG:\n print >> sys.stderr, \"S3SYNC: DEBUG MODE\"\n _debug = S3ModuleDebug.on\nelse:\n _debug = S3ModuleDebug.off\n\n# =============================================================================\n\n# End =========================================================================\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def register(self):\n \"\"\"\n Register this site at the peer repository\n\n @return: True to indicate success, otherwise False\n \"\"\"\n\n repository = self.repository\n\n if not repository.url:\n return True\n\n current.log.debug(\"S3Sync: register at %s\" % (repository.url))\n\n # Construct the URL\n config = repository.config\n url = \"%s/sync/repository/register.xml?repository=%s\" % \\\n (repository.url, config.uuid)\n\n current.log.debug(\"S3Sync: send registration to URL %s\" % url)\n\n # Generate the request\n req = urllib2.Request(url=url)\n handlers = []\n\n # Proxy handling\n proxy = repository.proxy or config.proxy or None\n if proxy:\n proxy_handler = urllib2.ProxyHandler({\"http\": proxy})\n handlers.append(proxy_handler)\n\n # Authentication\n username = repository.username\n password = repository.password\n if username and password:\n import base64\n base64string = base64.encodestring('%s:%s' %\n (username, password))[:-1]\n req.add_header(\"Authorization\", \"Basic %s\" % base64string)\n passwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()\n passwd_manager.add_password(realm=None,\n uri=url,\n user=username,\n passwd=password,\n )\n auth_handler = urllib2.HTTPBasicAuthHandler(passwd_manager)\n handlers.append(auth_handler)\n\n # Install all handlers\n if handlers:\n opener = urllib2.build_opener(*handlers)\n urllib2.install_opener(opener)\n\n # Execute the request\n log = repository.log\n success = True\n remote = False\n try:\n f = urllib2.urlopen(req)\n except urllib2.HTTPError, e:\n result = log.FATAL\n remote = True # Peer error\n code = e.code\n message = e.read()\n success = False\n try:\n message_json = json.loads(message)\n message = message_json.get(\"message\", message)\n except:\n pass\n except:\n result = log.FATAL\n code = 400\n message = sys.exc_info()[1]\n success = False\n else:\n ruid = None\n message = f.read()\n try:\n message_json = json.loads(message)\n message = message_json.get(\"message\", message)\n ruid = message_json.get(\"sender\", None)\n except:\n message = \"Registration successful\"\n result = log.SUCCESS\n if ruid is not None:\n db = current.db\n rtable = current.s3db.sync_repository\n try:\n db(rtable.id == repository.id).update(uuid=ruid)\n except:\n pass\n\n # Log the operation\n log.write(repository_id=repository.id,\n transmission=log.OUT,\n mode=log.PUSH,\n action=\"request registration\",\n remote=remote,\n result=result,\n message=message,\n )\n\n return success", "metadata": "root.S3SyncAdapter.register", "header": "['class', 'S3SyncAdapter', '(', 'S3SyncBaseAdapter', ')', ':', '___EOS___']", "index": 69 }, { "content": " def pull(self, task, onconflict=None):\n \"\"\"\n Fetch updates from the peer repository and import them\n into the local database (active pull)\n\n @param task: the synchronization task (sync_task Row)\n @param onconflict: callback for automatic conflict resolution\n\n @return: tuple (error, mtime), with error=None if successful,\n else error=message, and mtime=modification timestamp\n of the youngest record sent\n \"\"\"\n\n repository = self.repository\n xml = current.xml\n config = repository.config\n resource_name = task.resource_name\n\n current.log.debug(\"S3Sync: pull %s from %s\" % (resource_name,\n repository.url))\n\n # Construct the URL\n url = \"%s/sync/sync.xml?resource=%s&repository=%s\" % \\\n (repository.url, resource_name, config.uuid)\n last_pull = task.last_pull\n if last_pull and task.update_policy not in (\"THIS\", \"OTHER\"):\n url += \"&msince=%s\" % s3_encode_iso_datetime(last_pull)\n url += \"&include_deleted=True\"\n\n # Send sync filters to peer\n filters = current.sync.get_filters(task.id)\n filter_string = None\n resource_name = task.resource_name\n for tablename in filters:\n prefix = \"~\" if not tablename or tablename == resource_name \\\n else tablename\n for k, v in filters[tablename].items():\n urlfilter = \"[%s]%s=%s\" % (prefix, k, v)\n url += \"&%s\" % urlfilter\n\n # Figure out the protocol from the URL\n url_split = url.split(\"://\", 1)\n if len(url_split) == 2:\n protocol, path = url_split\n else:\n protocol, path = \"http\", None\n\n # Create the request\n req = urllib2.Request(url=url)\n handlers = []\n\n # Proxy handling\n proxy = repository.proxy or config.proxy or None\n if proxy:\n current.log.debug(\"S3Sync: pull, using proxy=%s\" % proxy)\n proxy_handler = urllib2.ProxyHandler({protocol: proxy})\n handlers.append(proxy_handler)\n\n # Authentication handling\n username = repository.username\n password = repository.password\n if username and password:\n # Send auth data unsolicitedly (the only way with Eden instances):\n import base64\n base64string = base64.encodestring('%s:%s' %\n (username, password))[:-1]\n req.add_header(\"Authorization\", \"Basic %s\" % base64string)\n # Just in case the peer does not accept that, add a 401 handler:\n passwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()\n passwd_manager.add_password(realm=None,\n uri=url,\n user=username,\n passwd=password)\n auth_handler = urllib2.HTTPBasicAuthHandler(passwd_manager)\n handlers.append(auth_handler)\n\n # Install all handlers\n if handlers:\n opener = urllib2.build_opener(*handlers)\n urllib2.install_opener(opener)\n\n # Execute the request\n remote = False\n action = \"fetch\"\n response = None\n output = None\n\n log = repository.log\n try:\n f = urllib2.urlopen(req)\n except urllib2.HTTPError, e:\n result = log.ERROR\n remote = True # Peer error\n code = e.code\n message = e.read()\n try:\n # Sahana-Eden would send a JSON message,\n # try to extract the actual error message:\n message_json = json.loads(message)\n message = message_json.get(\"message\", message)\n except:\n pass\n # Prefix as peer error and strip XML markup from the message\n # @todo: better method to do this?\n message = \"<message>%s</message>\" % message\n try:\n markup = etree.XML(message)\n message = markup.xpath(\".//text()\")\n if message:\n message = \" \".join(message)\n else:\n message = \"\"\n except etree.XMLSyntaxError:\n pass\n output = xml.json_message(False, code, message, tree=None)\n except:\n result = log.FATAL\n code = 400\n message = sys.exc_info()[1]\n output = xml.json_message(False, code, message)\n else:\n result = log.SUCCESS\n response = f\n\n # Process the response\n mtime = None\n if response:\n\n # Get import strategy and update policy\n strategy = task.strategy\n update_policy = task.update_policy\n conflict_policy = task.conflict_policy\n\n success = True\n message = \"\"\n action = \"import\"\n\n # Import the data\n resource = current.s3db.resource(resource_name)\n if onconflict:\n onconflict_callback = lambda item: onconflict(item,\n repository,\n resource)\n else:\n onconflict_callback = None\n count = 0\n try:\n success = resource.import_xml(\n response,\n ignore_errors=True,\n strategy=strategy,\n update_policy=update_policy,\n conflict_policy=conflict_policy,\n last_sync=last_pull,\n onconflict=onconflict_callback,\n )\n count = resource.import_count\n except IOError, e:\n result = log.FATAL\n message = \"%s\" % e\n output = xml.json_message(False, 400, message)\n except Exception, e:\n # If we end up here, an uncaught error during import\n # has occured which indicates a code defect! We log it\n # and continue here, however - in order to maintain a\n # valid sync status, so that developers can restart\n # the process more easily after fixing the defect.\n result = log.FATAL\n message = \"Uncaught Exception During Import: %s\" % \\\n traceback.format_exc()\n output = xml.json_message(False, 500, sys.exc_info()[1])\n\n mtime = resource.mtime\n\n # Log all validation errors\n if resource.error_tree is not None:\n result = log.WARNING\n message = \"%s\" % resource.error\n for element in resource.error_tree.findall(\"resource\"):\n for field in element.findall(\"data[@error]\"):\n error_msg = field.get(\"error\", None)\n if error_msg:\n msg = \"(UID: %s) %s.%s=%s: %s\" % \\\n (element.get(\"uuid\", None),\n element.get(\"name\", None),\n field.get(\"field\", None),\n field.get(\"value\", field.text),\n field.get(\"error\", None))\n message = \"%s, %s\" % (message, msg)\n\n # Check for failure\n if not success:\n result = log.FATAL\n if not message:\n message = \"%s\" % resource.error\n output = xml.json_message(False, 400, message)\n mtime = None\n\n # ...or report success\n elif not message:\n message = \"Data imported successfully (%s records)\" % count\n\n elif result == log.SUCCESS:\n # No data received from peer\n result = log.ERROR\n remote = True\n message = \"No data received from peer\"\n\n # Log the operation\n log.write(repository_id=repository.id,\n resource_name=task.resource_name,\n transmission=log.OUT,\n mode=log.PULL,\n action=action,\n remote=remote,\n result=result,\n message=message)\n\n current.log.debug(\"S3Sync: import %s: %s\" % (result, message))\n return (output, mtime)", "metadata": "root.S3SyncAdapter.pull", "header": "['class', 'S3SyncAdapter', '(', 'S3SyncBaseAdapter', ')', ':', '___EOS___']", "index": 186 }, { "content": " def push(self, task):\n \"\"\"\n Extract new updates from the local database and send\n them to the peer repository (active push)\n\n @param task: the synchronization task (sync_task Row)\n\n @return: tuple (error, mtime), with error=None if successful,\n else error=message, and mtime=modification timestamp\n of the youngest record sent\n \"\"\"\n\n xml = current.xml\n repository = self.repository\n config = repository.config\n resource_name = task.resource_name\n\n _debug(\"S3SyncRepository.push(%s, %s)\", repository.url, resource_name)\n\n # Construct the URL\n url = \"%s/sync/sync.xml?resource=%s&repository=%s\" % \\\n (repository.url, resource_name, config.uuid)\n strategy = task.strategy\n if strategy:\n url += \"&strategy=%s\" % \",\".join(strategy)\n update_policy = task.update_policy\n if update_policy:\n url += \"&update_policy=%s\" % update_policy\n conflict_policy = task.conflict_policy\n if conflict_policy:\n url += \"&conflict_policy=%s\" % conflict_policy\n last_push = task.last_push\n if last_push and update_policy not in (\"THIS\", \"OTHER\"):\n url += \"&msince=%s\" % s3_encode_iso_datetime(last_push)\n else:\n last_push = None\n _debug(\"...push to URL %s\", url)\n\n # Define the resource\n resource = current.s3db.resource(resource_name,\n include_deleted=True)\n\n # Apply sync filters for this task\n filters = current.sync.get_filters(task.id)\n\n # Export the resource as S3XML\n data = resource.export_xml(filters=filters,\n msince=last_push)\n count = resource.results or 0\n mtime = resource.muntil\n\n # Transmit the data via HTTP\n remote = False\n output = None\n log = repository.log\n if data and count:\n\n # Find the protocol\n url_split = url.split(\"://\", 1)\n if len(url_split) == 2:\n protocol, path = url_split\n else:\n protocol, path = \"http\", None\n\n # Generate the request\n import urllib2\n req = urllib2.Request(url=url, data=data)\n req.add_header('Content-Type', \"text/xml\")\n handlers = []\n\n # Proxy handling\n proxy = repository.proxy or config.proxy or None\n if proxy:\n _debug(\"using proxy=%s\", proxy)\n proxy_handler = urllib2.ProxyHandler({protocol: proxy})\n handlers.append(proxy_handler)\n\n # Authentication\n username = repository.username\n password = repository.password\n if username and password:\n # send auth credentials unsolicitedly\n import base64\n base64string = base64.encodestring('%s:%s' %\n (username, password))[:-1]\n req.add_header(\"Authorization\", \"Basic %s\" % base64string)\n # Just in case the peer does not accept that\n # => add a 401 handler:\n passwd_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()\n passwd_manager.add_password(realm=None,\n uri=url,\n user=username,\n passwd=password)\n auth_handler = urllib2.HTTPBasicAuthHandler(passwd_manager)\n handlers.append(auth_handler)\n\n # Install all handlers\n if handlers:\n opener = urllib2.build_opener(*handlers)\n urllib2.install_opener(opener)\n\n # Execute the request\n try:\n f = urllib2.urlopen(req)\n except urllib2.HTTPError, e:\n result = log.FATAL\n remote = True # Peer error\n code = e.code\n message = e.read()\n try:\n # Sahana-Eden sends a JSON message,\n # try to extract the actual error message:\n message_json = json.loads(message)\n message = message_json.get(\"message\", message)\n except:\n pass\n output = xml.json_message(False, code, message)\n except:\n result = log.FATAL\n code = 400\n message = sys.exc_info()[1]\n output = xml.json_message(False, code, message)\n else:\n result = log.SUCCESS\n message = \"data sent successfully (%s records)\" % count\n\n else:\n # No data to send\n result = log.WARNING\n message = \"No data to send\"\n\n # Log the operation\n log.write(repository_id=repository.id,\n resource_name=task.resource_name,\n transmission=log.OUT,\n mode=log.PUSH,\n action=\"send\",\n remote=remote,\n result=result,\n message=message)\n\n if output is not None:\n mtime = None\n return (output, mtime)", "metadata": "root.S3SyncAdapter.push", "header": "['class', 'S3SyncAdapter', '(', 'S3SyncBaseAdapter', ')', ':', '___EOS___']", "index": 408 } ]
[ { "span": "except:", "start_line": 44, "start_column": 4, "end_line": 44, "end_column": 11 }, { "span": "except:", "start_line": 137, "start_column": 12, "end_line": 137, "end_column": 19 }, { "span": "except:", "start_line": 139, "start_column": 8, "end_line": 139, "end_column": 15 }, { "span": "except:", "start_line": 151, "start_column": 12, "end_line": 151, "end_column": 19 }, { "span": "except:", "start_line": 159, "start_column": 16, "end_line": 159, "end_column": 23 }, { "span": "except:", "start_line": 286, "start_column": 12, "end_line": 286, "end_column": 19 }, { "span": "except:", "start_line": 301, "start_column": 8, "end_line": 301, "end_column": 15 }, { "span": "except:", "start_line": 522, "start_column": 16, "end_line": 522, "end_column": 23 }, { "span": "except:", "start_line": 525, "start_column": 12, "end_line": 525, "end_column": 19 } ]
[]
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_", "\"\"\"", " ", "S", "3", " ", "Synchronization", ":", " ", "Peer", " ", "Repos", "itor", "y", " ", "Adapt", "er", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "copyr", "ight", ":", " ", "2011", "-", "2016", " ", "(", "c", ")", " ", "Sa", "han", "a", " ", "Sof", "twa", "re", " ", "Foun", "dati", "on", "\\", "10", ";", " ", " ", " ", " ", "@", "license", ":", " ", "MIT", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Permi", "ssion", " ", "is", " ", "here", "by", " ", "grant", "ed", ",", " ", "free", " ", "of", " ", "charge", ",", " ", "to", " ", "any", " ", "person", "\\", "10", ";", " ", " ", " ", " ", "obtain", "ing", " ", "a", " ", "copy", " ", "of", " ", "this", " ", "software", " ", "and", " ", "associate", "d", " ", "documentation", "\\", "10", ";", " ", " ", " ", " ", "files", " ", "(", "the", " ", "\"", "Sof", "twa", "re", "\")", ",", " ", "to", " ", "deal", " ", "in", " ", "the", " ", "Sof", "twa", "re", " ", "with", "out", "\\", "10", ";", " ", " ", " ", " ", "restriction", ",", " ", "inclu", "ding", " ", "with", "out", " ", "limit", "ation", " ", "the", " ", "rights", " ", "to", " ", "use", ",", "\\", "10", ";", " ", " ", " ", " ", "copy", ",", " ", "modif", "y", ",", " ", "merge", ",", " ", "publi", "sh", ",", " ", "distribute", ",", " ", "subli", "cens", "e", ",", " ", "and", "/", "or", " ", "sell", "\\", "10", ";", " ", " ", " ", " ", "copie", "s", " ", "of", " ", "the", " ", "Sof", "twa", "re", ",", " ", "and", " ", "to", " ", "permit", " ", "person", "s", " ", "to", " ", "who", "m", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "Sof", "twa", "re", " ", "is", " ", "fur", "nish", "ed", " ", "to", " ", "do", " ", "so", ",", " ", "subject", " ", "to", " ", "the", " ", "follow", "ing", "\\", "10", ";", " ", " ", " ", " ", "condition", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "above", " ", "copyr", "ight", " ", "notice", " ", "and", " ", "this", " ", "permissi", "on", " ", "notice", " ", "sha", "ll", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "include", "d", " ", "in", " ", "all", " ", "copie", "s", " ", "or", " ", "substa", "nti", "al", " ", "porti", "ons", " ", "of", " ", "the", " ", "Sof", "twa", "re", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "THE", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "\"", "AS", " ", "IS", "\",", " ", "WITH", "OUT", " ", "WAR", "RAN", "TY", " ", "OF", " ", "ANY", " ", "KIND", ",", "\\", "10", ";", " ", " ", " ", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", ",", " ", "INC", "LU", "DING", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", " ", "THE", " ", "WAR", "RAN", "TIES", "\\", "10", ";", " ", " ", " ", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", ",", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "AND", "\\", "10", ";", " ", " ", " ", " ", "NON", "INF", "RING", "EME", "NT", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", " ", "AUTHOR", "S", " ", "OR", " ", "COPY", "RIG", "HT", "\\", "10", ";", " ", " ", " ", " ", "HOLD", "ERS", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "CLA", "IM", ",", " ", "DA", "MAGE", "S", " ", "OR", " ", "OTHER", " ", "LI", "ABI", "LIT", "Y", ",", "\\", "10", ";", " ", " ", " ", " ", "WHE", "THER", " ", "IN", " ", "AN", " ", "ACTI", "ON", " ", "OF", " ", "CONTR", "ACT", ",", " ", "TOR", "T", " ", "OR", " ", "OTHER", "WI", "SE", ",", " ", "ARI", "SIN", "G", "\\", "10", ";", " ", " ", " ", " ", "FROM", ",", " ", "OUT", " ", "OF", " ", "OR", " ", "IN", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "SOFT", "WARE", " ", "OR", " ", "THE", " ", "USE", " ", "OR", "\\", "10", ";", " ", " ", " ", " ", "OTHER", " ", "DEA", "LING", "S", " ", "IN", " ", "THE", " ", "SOFT", "WARE", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\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_", "lxml_", "import_", "etree_", "\\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 ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "ERROR", ":", " ", "lx", "ml", " ", "module", " ", "need", "ed", " ", "for", " ", "XML", " ", "handling", "\"_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "json_", "#", " ", "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_", "json_", "#", " ", "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_", "json_", "#", " ", "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_", "from_", "gluon_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "._", "._", "s3", "datetime_", "import_", "s3", "\\u", "encode", "\\u", "iso", "\\u", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "s3", "sync_", "import_", "S", "3", "Sync", "Base", "Adapter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "s3", "utils_", "import_", "S", "3", "Modul", "e", "Debug_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEBUG_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "S", "3", "SYNC", ":", " ", "DEBU", "G", " ", "MODE", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "debug_", "=_", "S", "3", "Modul", "e", "Debug_", "._", "on_", "\\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", "debug_", "=_", "S", "3", "Modul", "e", "Debug_", "._", "off_", "\\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_", "#", " ", "End", " ", "==============", "==============", "==============", "==============", "==============", "===", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "S", "3", "Sync", "Adapter_", "(_", "S", "3", "Sync", "Base", "Adapter_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "register_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Register", " ", "this", " ", "site", " ", "at", " ", "the", " ", "peer", " ", "repos", "itor", "y", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "Tru", "e", " ", "to", " ", "indicat", "e", " ", "success", ",", " ", "other", "wis", "e", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "repository_", "=_", "self_", "._", "repository_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "repository_", "._", "url_", ":_", "\\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_", "current_", "._", "log_", "._", "debug_", "(_", "\"", "S", "3", "Sync", ":", " ", "register", " ", "at", " ", "%", "s", "\"_", "%_", "(_", "repository_", "._", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Construct", " ", "the", " ", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "config_", "=_", "repository_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "\"%", "s", "/", "sync", "/", "repos", "itor", "y", "/", "register", ".", "xml", "?", "repos", "itor", "y", "=", "%", "s", "\"_", "%_", "(_", "repository_", "._", "url_", ",_", "config_", "._", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current_", "._", "log_", "._", "debug_", "(_", "\"", "S", "3", "Sync", ":", " ", "send", " ", "registration", " ", "to", " ", "URL", " ", "%", "s", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "req_", "=_", "urllib2_", "._", "Request_", "(_", "url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pro", "xy", " ", "handling", "_", "\\u\\u\\uNL\\u\\u\\u_", "proxy_", "=_", "repository_", "._", "proxy_", "or_", "config_", "._", "proxy_", "or_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "proxy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy", "\\u", "handler_", "=_", "urllib2_", "._", "Pro", "xy", "Handler_", "(_", "{_", "\"", "http", "\"_", ":_", "proxy_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "proxy", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Authentication_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "username_", "=_", "repository_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "repository_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "username_", "and_", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base64", "string_", "=_", "base64_", "._", "encodes", "tring_", "(_", "'%", "s", ":", "%", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "username_", ",_", "password_", ")_", ")_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "add", "\\u", "header_", "(_", "\"", "Authoriz", "ation", "\"_", ",_", "\"", "Basic", " ", "%", "s", "\"_", "%_", "base64", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passw", "d\\u", "manager_", "=_", "urllib2_", "._", "HTTP", "Passw", "ord", "Mgr", "With", "Default", "Realm", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passw", "d\\u", "manager_", "._", "add", "\\u", "password_", "(_", "realm_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "uri_", "=_", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "passwd_", "=_", "password_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth", "\\u", "handler_", "=_", "urllib2_", "._", "HTTP", "Basic", "Auth", "Handler_", "(_", "passw", "d\\u", "manager_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "auth", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Install", " ", "all", " ", "handlers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "handlers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opener_", "=_", "urllib2_", "._", "build", "\\u", "opener_", "(_", "*_", "handlers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "urllib2_", "._", "install", "\\u", "opener_", "(_", "opener_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "=_", "repository_", "._", "log_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "urllib2_", "._", "urlopen_", "(_", "req_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "urllib2_", "._", "HTTP", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote_", "=_", "True_", "#", " ", "Peer", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "e_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "e_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "message", "\\u", "json_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "message_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "400_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "False_", "\\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 ", " _", "rui", "d_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "message", "\\u", "json_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rui", "d_", "=_", "message", "\\u", "json_", "._", "get_", "(_", "\"", "sender", "\"_", ",_", "None_", ")_", "\\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 ", " _", "message_", "=_", "\"", "Registration", " ", "success", "ful", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "log_", "._", "SUCCESS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rui", "d_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "=_", "current_", "._", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rta", "ble_", "=_", "current_", "._", "s3db_", "._", "sync", "\\u", "repository_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "db_", "(_", "rta", "ble_", "._", "id_", "==_", "repository_", "._", "id_", ")_", "._", "update_", "(_", "uuid_", "=_", "rui", "d_", ")_", "\\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\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "the", " ", "operation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "write_", "(_", "repos", "itor", "y", "\\u", "id_", "=_", "repository_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transmission", "_", "=_", "log_", "._", "OUT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mode_", "=_", "log_", "._", "PUSH", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "\"", "request", " ", "registration", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "remote_", "=_", "remote_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "result_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "message_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "success_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "S", "3", "Sync", "Adapter_", "(_", "S", "3", "Sync", "Base", "Adapter_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "pull_", "(_", "self_", ",_", "task_", ",_", "onc", "onf", "lic", "t_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fe", "tch", " ", "update", "s", " ", "from", " ", "the", " ", "peer", " ", "repos", "itor", "y", " ", "and", " ", "import", " ", "them", "\\", "10", ";", " ", " ", " ", " ", "int", "o", " ", "the", " ", "local", " ", "databa", "se", " ", "(", "active", " ", "pull", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "task", ":", " ", "the", " ", "synchron", "izatio", "n", " ", "task", " ", "(", "sync", "\\u", "task", " ", "Row", ")", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "onc", "onf", "lic", "t", ":", " ", "callback", " ", "for", " ", "automati", "c", " ", "confl", "ict", " ", "resolu", "tion", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "tuple", " ", "(", "error", ",", " ", "mti", "me", "),", " ", "with", " ", "error", "=", "Non", "e", " ", "if", " ", "success", "ful", ",", "\\", "10", ";", " ", " ", " ", "else", " ", "error", "=", "message", ",", " ", "and", " ", "mti", "me", "=", "modification", " ", "timestamp", "\\", "10", ";", " ", " ", " ", "of", " ", "the", " ", "young", "est", " ", "record", " ", "sent", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "repository_", "=_", "self_", "._", "repository_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xml_", "=_", "current_", "._", "xml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "repository_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "name_", "=_", "task_", "._", "resource", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current_", "._", "log_", "._", "debug_", "(_", "\"", "S", "3", "Sync", ":", " ", "pull", " ", "%", "s", " ", "from", " ", "%", "s", "\"_", "%_", "(_", "resource", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "repository_", "._", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Construct", " ", "the", " ", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "\"%", "s", "/", "sync", "/", "sync", ".", "xml", "?", "resource", "=", "%", "s", "&", "repos", "itor", "y", "=", "%", "s", "\"_", "%_", "(_", "repository_", "._", "url_", ",_", "resource", "\\u", "name_", ",_", "config_", "._", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "pull_", "=_", "task_", "._", "last", "\\u", "pull_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "last", "\\u", "pull_", "and_", "task_", "._", "update", "\\u", "policy_", "not_", "in_", "(_", "\"", "THIS", "\"_", ",_", "\"", "OTHER", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "+=_", "\"&", "msi", "nce", "=", "%", "s", "\"_", "%_", "s3", "\\u", "encode", "\\u", "iso", "\\u", "datetime_", "(_", "last", "\\u", "pull_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "url_", "+=_", "\"&", "include", "\\u", "delete", "d", "=", "Tru", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "sync", " ", "filter", "s", " ", "to", " ", "peer_", "\\u\\u\\uNL\\u\\u\\u_", "filters_", "=_", "current_", "._", "sync_", "._", "get", "\\u", "filters_", "(_", "task_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "\\u", "string_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "name_", "=_", "task_", "._", "resource", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "tablename_", "in_", "filters_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prefix_", "=_", "\"~\"_", "if_", "not_", "tablename_", "or_", "tablename_", "==_", "resource", "\\u", "name_", "else_", "tablename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "filters_", "[_", "tablename_", "]_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urlf", "ilter_", "=_", "\"[", "%", "s", "]%", "s", "=", "%", "s", "\"_", "%_", "(_", "prefix_", ",_", "k_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "+=_", "\"&", "%", "s", "\"_", "%_", "urlf", "ilter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fig", "ure", " ", "out", " ", "the", " ", "protoc", "ol", " ", "from", " ", "the", " ", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "url", "\\u", "split_", "=_", "url_", "._", "split_", "(_", "\":", "//", "\"_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "url", "\\u", "split_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "protocol_", ",_", "path_", "=_", "url", "\\u", "split_", "\\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 ", " _", "protocol_", ",_", "path_", "=_", "\"", "http", "\"_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "req_", "=_", "urllib2_", "._", "Request_", "(_", "url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pro", "xy", " ", "handling", "_", "\\u\\u\\uNL\\u\\u\\u_", "proxy_", "=_", "repository_", "._", "proxy_", "or_", "config_", "._", "proxy_", "or_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "proxy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current_", "._", "log_", "._", "debug_", "(_", "\"", "S", "3", "Sync", ":", " ", "pull", ",", " ", "usi", "ng", " ", "proxy", "=", "%", "s", "\"_", "%_", "proxy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "proxy", "\\u", "handler_", "=_", "urllib2_", "._", "Pro", "xy", "Handler_", "(_", "{_", "protocol_", ":_", "proxy_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "proxy", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Auth", "entica", "tion", " ", "handling", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "username_", "=_", "repository_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "repository_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "username_", "and_", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sen", "d", " ", "auth", " ", "data", " ", "uns", "olic", "ited", "ly", " ", "(", "the", " ", "only", " ", "way", " ", "with", " ", "Ed", "en", " ", "instance", "s", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base64", "string_", "=_", "base64_", "._", "encodes", "tring_", "(_", "'%", "s", ":", "%", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "username_", ",_", "password_", ")_", ")_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "add", "\\u", "header_", "(_", "\"", "Authoriz", "ation", "\"_", ",_", "\"", "Basic", " ", "%", "s", "\"_", "%_", "base64", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ju", "st", " ", "in", " ", "case", " ", "the", " ", "peer", " ", "doe", "s", " ", "not", " ", "accept", " ", "tha", "t", ",", " ", "add", " ", "a", " ", "401", " ", "handler", ":_", "\\u\\u\\uNL\\u\\u\\u_", "passw", "d\\u", "manager_", "=_", "urllib2_", "._", "HTTP", "Passw", "ord", "Mgr", "With", "Default", "Realm", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passw", "d\\u", "manager_", "._", "add", "\\u", "password_", "(_", "realm_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "uri_", "=_", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "passwd_", "=_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth", "\\u", "handler_", "=_", "urllib2_", "._", "HTTP", "Basic", "Auth", "Handler_", "(_", "passw", "d\\u", "manager_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "auth", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Install", " ", "all", " ", "handlers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "handlers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opener_", "=_", "urllib2_", "._", "build", "\\u", "opener_", "(_", "*_", "handlers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "urllib2_", "._", "install", "\\u", "opener_", "(_", "opener_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "remote_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "action_", "=_", "\"", "fetch", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "repository_", "._", "log_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "urllib2_", "._", "urlopen_", "(_", "req_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "urllib2_", "._", "HTTP", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote_", "=_", "True_", "#", " ", "Peer", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "e_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "e_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sa", "han", "a", "-", "Ed", "en", " ", "wou", "ld", " ", "send", " ", "a", " ", "JSO", "N", " ", "message", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "to", " ", "extract", " ", "the", " ", "actual", " ", "error", " ", "message", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "message", "\\u", "json_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "message_", ")_", "\\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_", "#", " ", "Pref", "ix", " ", "as", " ", "peer", " ", "error", " ", "and", " ", "strip", " ", "XML", " ", "markup", " ", "from", " ", "the", " ", "message_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "todo", ":", " ", "bett", "er", " ", "method", " ", "to", " ", "do", " ", "this", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message_", "=_", "\"<", "message", ">", "%", "s", "</", "message", ">\"_", "%_", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "markup_", "=_", "etree_", "._", "XML_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "markup_", "._", "xpath_", "(_", "\"./", "/", "text", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "message_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "message_", "=_", "\"", " ", "\"_", "._", "join_", "(_", "message_", ")_", "\\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 ", " ", "_", "message_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "etree_", "._", "XML", "Syntax", "Error_", ":_", "\\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_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "code_", ",_", "message_", ",_", "tree_", "=_", "None_", ")_", "\\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 ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "400_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "code_", ",_", "message_", ")_", "\\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_", "=_", "log_", "._", "SUCCESS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "f_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "the", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mtime_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "response_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "import", " ", "strat", "eg", "y", " ", "and", " ", "update", " ", "policy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "strategy_", "=_", "task_", "._", "strategy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "\\u", "policy_", "=_", "task_", "._", "update", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "confl", "ict", "\\u", "policy_", "=_", "task_", "._", "confl", "ict", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "success_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "action_", "=_", "\"", "import", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "the", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "resource_", "=_", "current_", "._", "s3db_", "._", "resource_", "(_", "resource", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "onc", "onf", "lic", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "onc", "onf", "lic", "t", "\\u", "callback_", "=_", "lambda_", "item_", ":_", "onc", "onf", "lic", "t_", "(_", "item_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "repository_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resource_", ")_", "\\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 ", " _", "onc", "onf", "lic", "t", "\\u", "callback_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success_", "=_", "resource_", "._", "import", "\\u", "xml_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "response_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ignore", "\\u", "errors_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "strategy_", "=_", "strategy_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "policy_", "=_", "update", "\\u", "policy_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "confl", "ict", "\\u", "policy_", "=_", "confl", "ict", "\\u", "policy_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "last", "\\u", "sync_", "=_", "last", "\\u", "pull_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "onc", "onf", "lic", "t_", "=_", "onc", "onf", "lic", "t", "\\u", "callback_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "resource_", "._", "import", "\\u", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"%", "s", "\"_", "%_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "400_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "end", " ", "up", " ", "here", ",", " ", "an", " ", "unca", "ugh", "t", " ", "error", " ", "dur", "ing", " ", "import_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "has", " ", "occure", "d", " ", "whi", "ch", " ", "indicat", "es", " ", "a", " ", "code", " ", "defect", "!", " ", "We", " ", "log", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "continue", " ", "here", ",", " ", "how", "ever", " ", "-", " ", "in", " ", "order", " ", "to", " ", "maintain", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "valid", " ", "sync", " ", "status", ",", " ", "so", " ", "tha", "t", " ", "developer", "s", " ", "can", " ", "restart_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "process", " ", "more", " ", "easi", "ly", " ", "after", " ", "fix", "ing", " ", "the", " ", "defect", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"", "Unc", "aug", "ht", " ", "Except", "ion", " ", "Dur", "ing", " ", "Import", ":", " ", "%", "s", "\"_", "%_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "500_", ",_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mtime_", "=_", "resource_", "._", "mtime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "all", " ", "validation", " ", "errors_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "resource_", "._", "error", "\\u", "tree_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "WARNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"%", "s", "\"_", "%_", "resource_", "._", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "element_", "in_", "resource_", "._", "error", "\\u", "tree_", "._", "findall_", "(_", "\"", "resource", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "field_", "in_", "element_", "._", "findall_", "(_", "\"", "data", "[", "@", "error", "]\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "error", "\\u", "msg_", "=_", "field_", "._", "get_", "(_", "\"", "error", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "error", "\\u", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "msg_", "=_", "\"(", "UI", "D", ":", " ", "%", "s", ")", " ", "%", "s", ".", "%", "s", "=", "%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "element_", "._", "get_", "(_", "\"", "uuid", "\"_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "element_", "._", "get_", "(_", "\"", "name", "\"_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "field_", "._", "get_", "(_", "\"", "field", "\"_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "field_", "._", "get_", "(_", "\"", "value", "\"_", ",_", "field_", "._", "text_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "field_", "._", "get_", "(_", "\"", "error", "\"_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"%", "s", ",", " ", "%", "s", "\"_", "%_", "(_", "message_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "failure_", "\\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_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "message_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "message_", "=_", "\"%", "s", "\"_", "%_", "resource_", "._", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "400_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mtime_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "...", "or", " ", "report", " ", "success_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "message_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "\"", "Data", " ", "import", "ed", " ", "success", "full", "y", " ", "(%", "s", " ", "record", "s", ")\"_", "%_", "count_", "\\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_", "result_", "==_", "log_", "._", "SUCCESS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "data", " ", "receive", "d", " ", "from", " ", "peer_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "ERROR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"", "No", " ", "data", " ", "receive", "d", " ", "from", " ", "peer", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "the", " ", "operation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "write_", "(_", "repos", "itor", "y", "\\u", "id_", "=_", "repository_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resource", "\\u", "name_", "=_", "task_", "._", "resource", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transmission", "_", "=_", "log_", "._", "OUT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mode_", "=_", "log_", "._", "PUL", "L_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "remote_", "=_", "remote_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "result_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current_", "._", "log_", "._", "debug_", "(_", "\"", "S", "3", "Sync", ":", " ", "import", " ", "%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "result_", ",_", "message_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "output_", ",_", "mtime_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "S", "3", "Sync", "Adapter_", "(_", "S", "3", "Sync", "Base", "Adapter_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "push_", "(_", "self_", ",_", "task_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Extract", " ", "new", " ", "update", "s", " ", "from", " ", "the", " ", "local", " ", "databa", "se", " ", "and", " ", "send", "\\", "10", ";", " ", " ", " ", " ", "them", " ", "to", " ", "the", " ", "peer", " ", "repos", "itor", "y", " ", "(", "active", " ", "push", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "task", ":", " ", "the", " ", "synchron", "izatio", "n", " ", "task", " ", "(", "sync", "\\u", "task", " ", "Row", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "return", ":", " ", "tuple", " ", "(", "error", ",", " ", "mti", "me", "),", " ", "with", " ", "error", "=", "Non", "e", " ", "if", " ", "success", "ful", ",", "\\", "10", ";", " ", " ", " ", "else", " ", "error", "=", "message", ",", " ", "and", " ", "mti", "me", "=", "modification", " ", "timestamp", "\\", "10", ";", " ", " ", " ", "of", " ", "the", " ", "young", "est", " ", "record", " ", "sent", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xml_", "=_", "current_", "._", "xml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repository_", "=_", "self_", "._", "repository_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "repository_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "name_", "=_", "task_", "._", "resource", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "debug_", "(_", "\"", "S", "3", "Sync", "Repos", "itor", "y", ".", "push", "(%", "s", ",", " ", "%", "s", ")\"_", ",_", "repository_", "._", "url_", ",_", "resource", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Construct", " ", "the", " ", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "\"%", "s", "/", "sync", "/", "sync", ".", "xml", "?", "resource", "=", "%", "s", "&", "repos", "itor", "y", "=", "%", "s", "\"_", "%_", "(_", "repository_", "._", "url_", ",_", "resource", "\\u", "name_", ",_", "config_", "._", "uuid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "strategy_", "=_", "task_", "._", "strategy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "strategy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "+=_", "\"&", "strat", "eg", "y", "=", "%", "s", "\"_", "%_", "\",\"_", "._", "join_", "(_", "strategy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "update", "\\u", "policy_", "=_", "task_", "._", "update", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "update", "\\u", "policy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "+=_", "\"&", "update", "\\u", "policy", "=", "%", "s", "\"_", "%_", "update", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "confl", "ict", "\\u", "policy_", "=_", "task_", "._", "confl", "ict", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "confl", "ict", "\\u", "policy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "+=_", "\"&", "confl", "ict", "\\u", "policy", "=", "%", "s", "\"_", "%_", "confl", "ict", "\\u", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "last", "\\u", "push_", "=_", "task_", "._", "last", "\\u", "push_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "last", "\\u", "push_", "and_", "update", "\\u", "policy_", "not_", "in_", "(_", "\"", "THIS", "\"_", ",_", "\"", "OTHER", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "+=_", "\"&", "msi", "nce", "=", "%", "s", "\"_", "%_", "s3", "\\u", "encode", "\\u", "iso", "\\u", "datetime_", "(_", "last", "\\u", "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 ", " _", "last", "\\u", "push_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "debug_", "(_", "\"...", "push", " ", "to", " ", "URL", " ", "%", "s", "\"_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Define", " ", "the", " ", "resource_", "\\u\\u\\uNL\\u\\u\\u_", "resource_", "=_", "current_", "._", "s3db_", "._", "resource_", "(_", "resource", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "include", "\\u", "deleted_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Apply", " ", "sync", " ", "filter", "s", " ", "for", " ", "this", " ", "task_", "\\u\\u\\uNL\\u\\u\\u_", "filters_", "=_", "current_", "._", "sync_", "._", "get", "\\u", "filters_", "(_", "task_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Export", " ", "the", " ", "resource", " ", "as", " ", "S", "3", "XML_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "resource_", "._", "export", "\\u", "xml_", "(_", "filters_", "=_", "filters_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "msi", "nce_", "=_", "last", "\\u", "push_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "resource_", "._", "results_", "or_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mtime_", "=_", "resource_", "._", "mun", "til_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Transmit", " ", "the", " ", "data", " ", "via", " ", "HTTP_", "\\u\\u\\uNL\\u\\u\\u_", "remote_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "=_", "repository_", "._", "log_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "data_", "and_", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "protocol_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "split_", "=_", "url_", "._", "split_", "(_", "\":", "//", "\"_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "url", "\\u", "split_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "protocol_", ",_", "path_", "=_", "url", "\\u", "split_", "\\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 ", " _", "protocol_", ",_", "path_", "=_", "\"", "http", "\"_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "urllib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "=_", "urllib2_", "._", "Request_", "(_", "url_", "=_", "url_", ",_", "data_", "=_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "add", "\\u", "header_", "(_", "'", "Conten", "t", "-", "Type", "'_", ",_", "\"", "text", "/", "xml", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pro", "xy", " ", "handling", "_", "\\u\\u\\uNL\\u\\u\\u_", "proxy_", "=_", "repository_", "._", "proxy_", "or_", "config_", "._", "proxy_", "or_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "proxy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "debug_", "(_", "\"", "usi", "ng", " ", "proxy", "=", "%", "s", "\"_", ",_", "proxy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "proxy", "\\u", "handler_", "=_", "urllib2_", "._", "Pro", "xy", "Handler_", "(_", "{_", "protocol_", ":_", "proxy_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "proxy", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Authentication_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "username_", "=_", "repository_", "._", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "repository_", "._", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "username_", "and_", "password_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "auth", " ", "cred", "ential", "s", " ", "uns", "olic", "ited", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base64", "string_", "=_", "base64_", "._", "encodes", "tring_", "(_", "'%", "s", ":", "%", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "username_", ",_", "password_", ")_", ")_", "[_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "add", "\\u", "header_", "(_", "\"", "Authoriz", "ation", "\"_", ",_", "\"", "Basic", " ", "%", "s", "\"_", "%_", "base64", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ju", "st", " ", "in", " ", "case", " ", "the", " ", "peer", " ", "doe", "s", " ", "not", " ", "accept", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "=>", " ", "add", " ", "a", " ", "401", " ", "handler", ":_", "\\u\\u\\uNL\\u\\u\\u_", "passw", "d\\u", "manager_", "=_", "urllib2_", "._", "HTTP", "Passw", "ord", "Mgr", "With", "Default", "Realm", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passw", "d\\u", "manager_", "._", "add", "\\u", "password_", "(_", "realm_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "uri_", "=_", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "passwd_", "=_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auth", "\\u", "handler_", "=_", "urllib2_", "._", "HTTP", "Basic", "Auth", "Handler_", "(_", "passw", "d\\u", "manager_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handlers_", "._", "append_", "(_", "auth", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Install", " ", "all", " ", "handlers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "handlers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opener_", "=_", "urllib2_", "._", "build", "\\u", "opener_", "(_", "*_", "handlers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "urllib2_", "._", "install", "\\u", "opener_", "(_", "opener_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "request_", "\\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 ", " _", "f_", "=_", "urllib2_", "._", "urlopen_", "(_", "req_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "urllib2_", "._", "HTTP", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote_", "=_", "True_", "#", " ", "Peer", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "e_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "e_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sa", "han", "a", "-", "Ed", "en", " ", "send", "s", " ", "a", " ", "JSO", "N", " ", "message", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "to", " ", "extract", " ", "the", " ", "actual", " ", "error", " ", "message", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "message", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "message", "\\u", "json_", "._", "get_", "(_", "\"", "message", "\"_", ",_", "message_", ")_", "\\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_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "code_", ",_", "message_", ")_", "\\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 ", " _", "result_", "=_", "log_", "._", "FATAL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "400_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "xml_", "._", "json", "\\u", "message_", "(_", "False_", ",_", "code_", ",_", "message_", ")_", "\\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_", "=_", "log_", "._", "SUCCESS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"", "data", " ", "sent", " ", "success", "full", "y", " ", "(%", "s", " ", "record", "s", ")\"_", "%_", "count_", "\\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_", "#", " ", "No", " ", "data", " ", "to", " ", "send_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "log_", "._", "WARNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "\"", "No", " ", "data", " ", "to", " ", "send", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "the", " ", "operation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "write_", "(_", "repos", "itor", "y", "\\u", "id_", "=_", "repository_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "resource", "\\u", "name_", "=_", "task_", "._", "resource", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transmission", "_", "=_", "log_", "._", "OUT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mode_", "=_", "log_", "._", "PUSH", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "\"", "send", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "remote_", "=_", "remote_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "result_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "output_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mtime_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "output_", ",_", "mtime_", ")_", "\\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, 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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 ]
Except block handles 'BaseException'
gkno/gkno_launcher/src/gkno/toolConfiguration.py
[ { "content": " def checkConfigurationFile(self, filename):\n\n # Get the configuration file data.\n data = fileHandling.fileHandling.readConfigurationFile(filename, True)\n\n # Check that the configuration file is for a pipeline.\n try: configurationType = data['configuration type']\n except: return False\n if configurationType != 'tool': return False\n return True", "metadata": "root.toolConfiguration.checkConfigurationFile", "header": "['class', 'toolConfiguration', ':', '___EOS___']", "index": 188 }, { "content": " def checkIsTool(self, data):\n\n # Get the configuration type field. If this is not present, terminate, since this is the field that\n # defines if the configuration file is for a tool or for a pipeline.\n try: configurationType = data['configuration type']\n except:\n if self.allowTermination: self.errors.noConfigurationType(self.name)\n else: return False\n\n if configurationType != 'tool':\n if self.allowTermination: self.errors.invalidConfigurationType(self.name, configurationType)\n else: return False\n\n # Return true if this was completed succesfully.\n return True", "metadata": "root.toolConfiguration.checkIsTool", "header": "['class', 'toolConfiguration', ':', '___EOS___']", "index": 267 }, { "content": " def getArgumentAttribute(self, argument, attribute):\n try: return getattr(self.arguments[argument], attribute)\n except: return None", "metadata": "root.toolConfiguration.getArgumentAttribute", "header": "['class', 'toolConfiguration', ':', '___EOS___']", "index": 718 }, { "content": " def getArgumentData(self, argument):\n try: return self.arguments[argument]\n except: return None", "metadata": "root.toolConfiguration.getArgumentData", "header": "['class', 'toolConfiguration', ':', '___EOS___']", "index": 742 }, { "content": " def getArgumentAttributeFromSupplied(attributes, attribute):\n try: return getattr(attributes.arguments[argument], attribute)\n except: return False", "metadata": "root.toolConfiguration.getArgumentAttributeFromSupplied", "header": "['class', 'toolConfiguration', ':', '___EOS___']", "index": 751 } ]
[ { "span": "except: ", "start_line": 195, "start_column": 4, "end_line": 195, "end_column": 11 }, { "span": "except:", "start_line": 272, "start_column": 4, "end_line": 272, "end_column": 11 }, { "span": "except: ", "start_line": 720, "start_column": 4, "end_line": 720, "end_column": 11 }, { "span": "except: ", "start_line": 744, "start_column": 4, "end_line": 744, "end_column": 11 }, { "span": "except: ", "start_line": 753, "start_column": 4, "end_line": 753, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "tool", "Configuration_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Configura", "tion", "File_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "configura", "tion", " ", "file", " ", "data", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "file", "Hand", "ling_", "._", "file", "Hand", "ling_", "._", "read", "Configura", "tion", "File_", "(_", "filename_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "the", " ", "configura", "tion", " ", "file", " ", "is", " ", "for", " ", "a", " ", "pipeline", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "configura", "tion", "Type_", "=_", "data_", "[_", "'", "configura", "tion", " ", "type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "configura", "tion", "Type_", "!=_", "'", "tool", "'_", ":_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "tool", "Configuration_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Is", "Tool_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "configura", "tion", " ", "type", " ", "field", ".", " ", "If", " ", "this", " ", "is", " ", "not", " ", "presen", "t", ",", " ", "terminate", ",", " ", "sinc", "e", " ", "this", " ", "is", " ", "the", " ", "field", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "defin", "es", " ", "if", " ", "the", " ", "configura", "tion", " ", "file", " ", "is", " ", "for", " ", "a", " ", "tool", " ", "or", " ", "for", " ", "a", " ", "pipeline", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "configura", "tion", "Type_", "=_", "data_", "[_", "'", "configura", "tion", " ", "type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "allow", "Terminati", "on_", ":_", "self_", "._", "errors_", "._", "no", "Configura", "tion", "Type_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "configura", "tion", "Type_", "!=_", "'", "tool", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "allow", "Terminati", "on_", ":_", "self_", "._", "errors_", "._", "invalid", "Configura", "tion", "Type_", "(_", "self_", "._", "name_", ",_", "configura", "tion", "Type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "true", " ", "if", " ", "this", " ", "was", " ", "complete", "d", " ", "succe", "sfu", "ll", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "tool", "Configuration_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Arg", "ument", "Attribute_", "(_", "self_", ",_", "argument_", ",_", "attribute_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "return_", "getattr_", "(_", "self_", "._", "arguments_", "[_", "argument_", "]_", ",_", "attribute_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "tool", "Configuration_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Arg", "ument", "Data_", "(_", "self_", ",_", "argument_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "return_", "self_", "._", "arguments_", "[_", "argument_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "tool", "Configuration_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Arg", "ument", "Attribute", "Fro", "m", "Suppl", "ied_", "(_", "attributes_", ",_", "attribute_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "return_", "getattr_", "(_", "attributes_", "._", "arguments_", "[_", "argument_", "]_", ",_", "attribute_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "return_", "False_" ]
[ 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, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 0, 1, 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, 0, 1, 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, 0, 1, 2, 2 ]
Should use a 'with' statement
cournape/Bento/bento/commands/egg_utils.py
[ { "content": "def extract_egg(egg, extract_dir):\n # Given a bento-produced egg, extract its content in the given directory,\n # and returned the corresponding build_manifest info instance\n build_manifest = BuildManifest.from_egg(egg)\n # egg scheme\n build_manifest.update_paths({\"prefix\": \".\", \"eprefix\": \".\", \"sitedir\": \".\"})\n\n zid = zipfile.ZipFile(egg)\n try:\n for type, sections in build_manifest.files.items():\n for name, section in sections.items():\n target_dir = build_manifest.resolve_path(section.target_dir)\n section.source_dir = os.path.join(extract_dir, target_dir)\n for source, target in section.files:\n g = os.path.join(target_dir, target)\n g = os.path.normpath(g)\n zid.extract(g, extract_dir)\n finally:\n zid.close()\n\n return build_manifest", "metadata": "root.extract_egg", "header": "['module', '___EOS___']", "index": 119 } ]
[ { "span": "zid.close()", "start_line": 137, "start_column": 8, "end_line": 137, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Sho", "ul", "d_", "use_", "a_", "'", "with", "'_", "statement_", "[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_", "extract", "\\u", "egg", "_", "(_", "egg", "_", ",_", "extract", "\\u", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Give", "n", " ", "a", " ", "ben", "to", "-", "produce", "d", " ", "egg", ",", " ", "extract", " ", "its", " ", "content", " ", "in", " ", "the", " ", "give", "n", " ", "director", "y", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "return", "ed", " ", "the", " ", "correspond", "ing", " ", "build", "\\u", "manifest", " ", "info", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "\\u", "manifest_", "=_", "Build", "Manifest", "_", "._", "from", "\\u", "egg", "_", "(_", "egg", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "egg", " ", "scheme_", "\\u\\u\\uNL\\u\\u\\u_", "build", "\\u", "manifest_", "._", "update", "\\u", "paths_", "(_", "{_", "\"", "prefix", "\"_", ":_", "\".\"_", ",_", "\"", "epr", "efi", "x", "\"_", ":_", "\".\"_", ",_", "\"", "site", "dir", "\"_", ":_", "\".\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "zi", "d_", "=_", "zipfile_", "._", "Zip", "File_", "(_", "egg", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "type_", ",_", "sections_", "in_", "build", "\\u", "manifest_", "._", "files_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "name_", ",_", "section_", "in_", "sections_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "dir_", "=_", "build", "\\u", "manifest_", "._", "resolve", "\\u", "path_", "(_", "section_", "._", "target", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "section_", "._", "source", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "extract", "\\u", "dir_", ",_", "target", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "source_", ",_", "target_", "in_", "section_", "._", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "g_", "=_", "os_", "._", "path_", "._", "join_", "(_", "target", "\\u", "dir_", ",_", "target_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g_", "=_", "os_", "._", "path_", "._", "normpath_", "(_", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "zi", "d_", "._", "extract_", "(_", "g_", ",_", "extract", "\\u", "dir_", ")_", "\\u\\u\\uNE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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, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
datastax/python-driver/tests/integration/cqlengine/model/test_class_construction.py
[ { "content": " def test_attempting_to_make_duplicate_column_names_fails(self):\n \"\"\"\n Tests that trying to create conflicting db column names will fail\n \"\"\"\n\n with self.assertRaisesRegexp(ModelException, r\".*more than once$\"):\n class BadNames(Model):\n words = columns.Text(primary_key=True)\n content = columns.Text(db_field='words')", "metadata": "root.TestModelClassFunction.test_attempting_to_make_duplicate_column_names_fails", "header": "['class', 'TestModelClassFunction', '(', 'BaseCassEngTestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def test_exception_raised_when_creating_class_without_pk(self):\n with self.assertRaises(ModelDefinitionException):\n class TestModel(Model):\n\n count = columns.Integer()\n text = columns.Text(required=False)", "metadata": "root.TestModelClassFunction.test_exception_raised_when_creating_class_without_pk", "header": "['class', 'TestModelClassFunction', '(', 'BaseCassEngTestCase', ')', ':', '___EOS___']", "index": 91 }, { "content": " def test_abstract_model_keyspace_warning_is_skipped(self):\n with warnings.catch_warnings(record=True) as warn:\n class NoKeyspace(Model):\n __abstract__ = True\n key = columns.UUID(primary_key=True)\n\n self.assertEqual(len(warn), 0)", "metadata": "root.TestModelClassFunction.test_abstract_model_keyspace_warning_is_skipped", "header": "['class', 'TestModelClassFunction', '(', 'BaseCassEngTestCase', ')', ':', '___EOS___']", "index": 211 } ]
[ { "span": "BadNames(", "start_line": 73, "start_column": 18, "end_line": 73, "end_column": 26 }, { "span": "TestModel(", "start_line": 93, "start_column": 18, "end_line": 93, "end_column": 27 }, { "span": "NoKeyspace(", "start_line": 213, "start_column": 18, "end_line": 213, "end_column": 28 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Model", "Class", "Function_", "(_", "Base", "Cass", "Eng", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "atte", "mpt", "ing", "\\u", "to", "\\u", "make", "\\u", "duplicat", "e\\u", "column", "\\u", "names", "\\u", "fails_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "try", "ing", " ", "to", " ", "create", " ", "conflicting", " ", "db", " ", "column", " ", "names", " ", "will", " ", "fail", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Model", "Exception_", ",_", "r", "\".*", "more", " ", "than", " ", "onc", "e", "$\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Ba", "d", "Names_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "words_", "=_", "columns_", "._", "Text_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "columns_", "._", "Text_", "(_", "db", "\\u", "field_", "=_", "'", "words", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Model", "Class", "Function_", "(_", "Base", "Cass", "Eng", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exception", "\\u", "raise", "d\\u", "whe", "n", "\\u", "creati", "ng", "\\u", "class", "\\u", "with", "out", "\\u", "pk_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "assert", "Raises_", "(_", "Model", "Definit", "ion", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "Test", "Model_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "=_", "columns_", "._", "Integer_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "columns_", "._", "Text_", "(_", "required_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Model", "Class", "Function_", "(_", "Base", "Cass", "Eng", "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", "abstract", "\\u", "model", "\\u", "keyspace", "\\u", "warn", "ing", "\\u", "is", "\\u", "skipped_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "warnings_", "._", "catch", "\\u", "warnings_", "(_", "record_", "=_", "True_", ")_", "as_", "warn_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "class_", "No", "Keys", "pace_", "(_", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "abstract", "\\u\\u_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "columns_", "._", "UUID_", "(_", "primary", "\\u", "key_", "=_", "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_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "warn_", ")_", ",_", "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, 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, 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, 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, 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 ]
Unused local variable
funkybob/formulation/tests/tests/test_tags.py
[ { "content": " def test_default_template(self):\n \"\"\"\n Testing default.form template.\n\n \"\"\"\n template = self.template.format('formulation/default.form')\n try:\n render = self._render_string(template)\n except TemplateSyntaxError:\n self.fail('Default template throws syntax error.')", "metadata": "root.DefaultTemplateTest.test_default_template", "header": "['class', 'DefaultTemplateTest', '(', 'SimpleTestCase', ')', ':', '___EOS___']", "index": 309 } ]
[ { "span": "render ", "start_line": 316, "start_column": 12, "end_line": 316, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Default", "Templa", "te", "Test_", "(_", "Simple", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "default", "\\u", "template_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "ing", " ", "default", ".", "form", " ", "template", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "self_", "._", "template_", "._", "format_", "(_", "'", "formula", "tion", "/", "default", ".", "form", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "render_", "=_", "self_", "._", "\\u", "render", "\\u", "string_", "(_", "template_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Templa", "te", "Syntax", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "'", "Default", " ", "template", " ", "throw", "s", " ", "synta", "x", " ", "error", ".'_", ")_", "\\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, 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 ]
Imprecise assert
Infinidat/gitpy/tests/test_workflow.py
[ { "content": " def testCloneModifyPushToBranch(self):\n new_repo = clone(self.repo, utils.get_temporary_location())\n prev_branch = self.repo.getCurrentBranch()\n self.repo.checkout(self.repo.createBranch('temp'))\n branch = new_repo.createBranch('work')\n new_repo.checkout(branch)\n utils.commit_change(new_repo)\n new_repo.push(self.repo, fromBranch=branch, toBranch='work')\n self.repo.checkout(prev_branch)\n self.assertTrue(self.repo.getBranchByName('work').getHead() == new_repo.getHead())", "metadata": "root.TestWorkflows.testCloneModifyPushToBranch", "header": "['class', 'TestWorkflows', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 43 } ]
[ { "span": "self.assertTrue(self.repo.getBranchByName('work').getHead() == new_repo.getHead())", "start_line": 52, "start_column": 8, "end_line": 52, "end_column": 90 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Work", "flows_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Clone", "Modif", "y", "Push", "To", "Branch_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "repo_", "=_", "clone_", "(_", "self_", "._", "repo_", ",_", "utils_", "._", "get", "\\u", "temporar", "y", "\\u", "location_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "\\u", "branch_", "=_", "self_", "._", "repo_", "._", "get", "Curr", "ent", "Branch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "repo_", "._", "checkout_", "(_", "self_", "._", "repo_", "._", "create", "Branch_", "(_", "'", "temp", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "branch_", "=_", "new", "\\u", "repo_", "._", "create", "Branch_", "(_", "'", "work", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "repo_", "._", "checkout_", "(_", "branch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "utils_", "._", "commit", "\\u", "change_", "(_", "new", "\\u", "repo_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "repo_", "._", "push_", "(_", "self_", "._", "repo_", ",_", "from", "Branch_", "=_", "branch_", ",_", "to", "Branch_", "=_", "'", "work", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "repo_", "._", "checkout_", "(_", "prev", "\\u", "branch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "repo_", "._", "get", "Branc", "h", "By", "Name_", "(_", "'", "work", "'_", ")_", "._", "get", "Head_", "(_", ")_", "==_", "new", "\\u", "repo_", "._", "get", "Head_", "(_", ")_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 import
ericholscher/pony_barn/pony_barn/client.py
[ { "content": "\"\"\"\nClient library for pony-build.\n\nSee http://github.com/ericholscher/pony_barn/.\n\"\"\"\n\nimport datetime\nimport sys\nimport subprocess\nimport xmlrpclib\nimport tempfile\nimport shutil\nimport os, os.path\nimport time\nimport traceback\nfrom optparse import OptionParser\n\nimport pip\n\nDEFAULT_CACHE_DIR='~/.pony-build'\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 guess_cache_dir(dirname):\n parent = os.environ.get('PONY_BUILD_CACHE', DEFAULT_CACHE_DIR)\n parent = os.path.expanduser(parent)\n result = os.path.join(parent, dirname)\n return result", "metadata": "root.guess_cache_dir", "header": "['module', '___EOS___']", "index": 21 }, { "content": "def _run_command(command_list, cwd=None, variables=None):\n print command_list\n environment = os.environ.copy()\n environment['PIP_DOWNLOAD_CACHE'] = '/tmp/pip/download'\n environment['PYTHONPATH'] = \"%s:%s\" % (os.getcwd(), environment['PYTHONPATH'])\n if variables:\n x = []\n for cmd in command_list:\n x.append(cmd)\n command_list = x\n\n try:\n p = subprocess.Popen(command_list, shell=False, cwd=cwd,\n stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n env=environment)\n\n out, err = p.communicate()\n ret = p.returncode\n except:\n out = ''\n err = traceback.format_exc()\n ret = -1\n\n return (ret, out, err)", "metadata": "root._run_command", "header": "['module', '___EOS___']", "index": 27 }, { "content": "class Context(object):\n\n\n\n\n", "metadata": "root.Context", "header": "['module', '___EOS___']", "index": 52 }, { "content": " def __init__(self):\n self.history = []\n self.start_time = self.end_time = None\n self.build_dir = None", "metadata": "root.Context.__init__", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 53 }, { "content": " def initialize(self):\n self.start_time = time.time()", "metadata": "root.Context.initialize", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 58 }, { "content": " def finish(self):\n self.end_time = time.time()", "metadata": "root.Context.finish", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 61 }, { "content": " def start_command(self, command):\n if self.build_dir:\n os.chdir(self.build_dir)", "metadata": "root.Context.start_command", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 64 }, { "content": " def end_command(self, command):\n self.history.append(command)", "metadata": "root.Context.end_command", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 68 }, { "content": " def update_client_info(self, info):\n info['duration'] = self.end_time - self.start_time", "metadata": "root.Context.update_client_info", "header": "['class', 'Context', '(', 'object', ')', ':', '___EOS___']", "index": 71 }, { "content": "class CurrentDirectoryContext(Context):\n", "metadata": "root.CurrentDirectoryContext", "header": "['module', '___EOS___']", "index": 74 }, { "content": " def __init__(self, cleanup=True):\n Context.__init__(self)\n self.cleanup = cleanup", "metadata": "root.CurrentDirectoryContext.__init__", "header": "['class', 'CurrentDirectoryContext', '(', 'Context', ')', ':', '___EOS___']", "index": 75 }, { "content": " def initialize(self):\n Context.initialize(self)\n print \"Using the current directory (%s) as my working dir\" % os.getcwd()", "metadata": "root.CurrentDirectoryContext.initialize", "header": "['class', 'CurrentDirectoryContext', '(', 'Context', ')', ':', '___EOS___']", "index": 79 }, { "content": "class TempDirectoryContext(Context):\n", "metadata": "root.TempDirectoryContext", "header": "['module', '___EOS___']", "index": 83 }, { "content": " def __init__(self, cleanup=True):\n Context.__init__(self)\n self.cleanup = cleanup", "metadata": "root.TempDirectoryContext.__init__", "header": "['class', 'TempDirectoryContext', '(', 'Context', ')', ':', '___EOS___']", "index": 84 }, { "content": " def initialize(self):\n Context.initialize(self)\n self.tempdir = tempfile.mkdtemp()\n self.cwd = os.getcwd()\n\n print 'changing to temp directory:', self.tempdir\n os.chdir(self.tempdir)", "metadata": "root.TempDirectoryContext.initialize", "header": "['class', 'TempDirectoryContext', '(', 'Context', ')', ':', '___EOS___']", "index": 88 }, { "content": "class VirtualenvContext(Context):\n\n\n", "metadata": "root.VirtualenvContext", "header": "['module', '___EOS___']", "index": 96 }, { "content": " def __init__(self, always_cleanup=True, use_site_packages=False, dependencies=[], **kwargs):\n Context.__init__(self)\n self.cleanup = always_cleanup\n self.dependencies = dependencies\n base_build = kwargs['base_build']\n\n # Create the virtualenv. Have to do this here so that commands can use\n # VirtualenvContext.python (etc) to get at the right python.\n import virtualenv\n\n self.tempdir = tempfile.mkdtemp()\n\n print 'creating virtualenv'\n if use_site_packages:\n _run_command([base_build.py_name, '-m', 'virtualenv', self.tempdir])\n else:\n _run_command([base_build.py_name, '-m', 'virtualenv', '--no-site-packages', self.tempdir])\n\n # calculate where a few things live so we can easily shell out to 'em\n self.python = os.path.join(self.tempdir, 'bin', 'python')\n self.djangoadmin = os.path.join(self.tempdir, 'bin', 'django-admin.py')\n self.easy_install = os.path.join(self.tempdir, 'bin', 'easy_install')\n self.pip = os.path.join(self.tempdir, 'bin', 'pip')", "metadata": "root.VirtualenvContext.__init__", "header": "['class', 'VirtualenvContext', '(', 'Context', ')', ':', '___EOS___']", "index": 97 }, { "content": " def initialize(self):\n self.start_time = datetime.datetime.now()\n print 'changing to temp directory:', self.tempdir\n self.cwd = os.getcwd()\n os.chdir(self.tempdir)\n\n # install pip, then use it to install any packages desired\n print 'installing pip'\n _run_command([self.easy_install, '-U', 'pip==dev'])\n for dep in self.dependencies:\n print \"installing\", dep\n _run_command([self.pip, 'install', '-U', '-I'] + dep.split())", "metadata": "root.VirtualenvContext.initialize", "header": "['class', 'VirtualenvContext', '(', 'Context', ')', ':', '___EOS___']", "index": 121 }, { "content": " def finish(self):\n os.chdir(self.cwd)\n try:\n self.end_time = datetime.datetime.now()\n finally:\n if self.cleanup:\n print 'removing', self.tempdir\n shutil.rmtree(self.tempdir, ignore_errors=True)", "metadata": "root.VirtualenvContext.finish", "header": "['class', 'VirtualenvContext', '(', 'Context', ')', ':', '___EOS___']", "index": 134 }, { "content": " def update_client_info(self, info):\n #Context.update_client_info(self, info)\n info['start_time'] = str(self.start_time)\n info['end_time'] = str(self.end_time)\n info['tempdir'] = self.tempdir\n info['virtualenv'] = True", "metadata": "root.VirtualenvContext.update_client_info", "header": "['class', 'VirtualenvContext', '(', 'Context', ')', ':', '___EOS___']", "index": 143 }, { "content": "class BaseCommand(object):\n\n\n\n", "metadata": "root.BaseCommand", "header": "['module', '___EOS___']", "index": 150 }, { "content": " def __init__(self, command_list, name='', run_cwd=None):\n self.command_list = command_list\n if name:\n self.command_name = name\n self.run_cwd = run_cwd\n\n self.status = None\n self.output = None\n self.errout = None\n self.duration = None\n\n self.variables = None", "metadata": "root.BaseCommand.__init__", "header": "['class', 'BaseCommand', '(', 'object', ')', ':', '___EOS___']", "index": 151 }, { "content": " def set_variables(self, v):\n self.variables = dict(v)", "metadata": "root.BaseCommand.set_variables", "header": "['class', 'BaseCommand', '(', 'object', ')', ':', '___EOS___']", "index": 164 }, { "content": " def run(self, context):\n start = time.time()\n\n (ret, out, err) = _run_command(self.command_list, cwd=self.run_cwd,\n variables=self.variables)\n\n self.status = ret\n self.output = out\n self.errout = err\n end = time.time()\n\n self.duration = end - start", "metadata": "root.BaseCommand.run", "header": "['class', 'BaseCommand', '(', 'object', ')', ':', '___EOS___']", "index": 167 }, { "content": " def success(self):\n return self.status == 0", "metadata": "root.BaseCommand.success", "header": "['class', 'BaseCommand', '(', 'object', ')', ':', '___EOS___']", "index": 180 }, { "content": " def get_results(self):\n results = dict(status=self.status,\n output=self.output,\n errout=self.errout,\n command=str(self.command_list),\n type=self.command_type,\n name=self.command_name,\n duration=self.duration)\n return results", "metadata": "root.BaseCommand.get_results", "header": "['class', 'BaseCommand', '(', 'object', ')', ':', '___EOS___']", "index": 183 }, { "content": "class SetupCommand(BaseCommand):\n command_type = 'setup'\n command_name = 'setup'", "metadata": "root.SetupCommand", "header": "['module', '___EOS___']", "index": 193 }, { "content": "class BuildCommand(BaseCommand):\n command_type = 'build'\n command_name = 'build'", "metadata": "root.BuildCommand", "header": "['module', '___EOS___']", "index": 197 }, { "content": "class TestCommand(BaseCommand):\n command_type = 'test'\n command_name = 'test'", "metadata": "root.TestCommand", "header": "['module', '___EOS___']", "index": 201 }, { "content": "class VCSClone(SetupCommand):\n command_name = 'checkout'\n\n\n", "metadata": "root.VCSClone", "header": "['module', '___EOS___']", "index": 206 }, { "content": " def __init__(self, repository, branch='master', cache_dir=None,\n use_cache=True, egg=None, **kwargs):\n SetupCommand.__init__(self, [], **kwargs)\n self.repository = repository\n self.branch = branch\n self.egg = egg\n\n self.use_cache = use_cache\n self.cache_dir = cache_dir\n\n self.duration = -1\n self.version_info = ''\n\n self.results_dict = {}", "metadata": "root.VCSClone.__init__", "header": "['class', 'VCSClone', '(', 'SetupCommand', ')', ':', '___EOS___']", "index": 209 }, { "content": " def run(self, context):\n if self.use_cache:\n cache_dir = self.cache_dir\n if not cache_dir:\n cache_dir = guess_cache_dir(self.egg)\n vcs = pip.vcs.get_backend(self.vcs)\n vcs_repo = vcs(\"%s+%s#egg=%s\" % (self.vcs, self.repository, self.egg))\n try:\n if os.path.exists(cache_dir):\n try:\n if vcs.name is 'git':\n _run_command(['git', 'clean', '-f', self.cache_dir])\n vcs_repo.update(cache_dir, ['origin/master'])\n else:\n #pip doesn't use the second arg.\n vcs_repo.update(cache_dir, [])\n except Exception, e:\n #If an update failed, still run.\n #This allows for running tests offline\n print \"Updating Repo Failed: %s\" % e\n else:\n vcs_repo.obtain(cache_dir)\n self.status = 0\n except Exception, e:\n print \"Exception on checkout: %s\" % e\n self.status = 1\n\n context.build_dir = cache_dir", "metadata": "root.VCSClone.run", "header": "['class', 'VCSClone', '(', 'SetupCommand', ')', ':', '___EOS___']", "index": 224 }, { "content": " def get_results(self):\n self.results_dict['out'] = self.results_dict['errout'] = ''\n self.results_dict['command'] = 'Clone(%s, %s)' % (self.repository,\n self.branch)\n self.results_dict['status'] = self.status\n self.results_dict['type'] = self.command_type\n self.results_dict['name'] = self.command_name\n\n self.results_dict['version_type'] = self.vcs\n if self.version_info:\n self.results_dict['version_info'] = self.version_info\n\n return self.results_dict", "metadata": "root.VCSClone.get_results", "header": "['class', 'VCSClone', '(', 'SetupCommand', ')', ':', '___EOS___']", "index": 253 }, { "content": "class GitClone(VCSClone):\n vcs = \"git\"", "metadata": "root.GitClone", "header": "['module', '___EOS___']", "index": 267 }, { "content": "class HgClone(VCSClone):\n vcs = \"hg\"", "metadata": "root.HgClone", "header": "['module', '___EOS___']", "index": 270 }, { "content": "class SvnUpdate(VCSClone):\n vcs = \"svn\"", "metadata": "root.SvnUpdate", "header": "['module', '___EOS___']", "index": 273 }, { "content": "def get_hostname():\n import socket\n return socket.gethostname()", "metadata": "root.get_hostname", "header": "['module', '___EOS___']", "index": 277 }, { "content": "def get_arch():\n import distutils.util\n return distutils.util.get_platform()", "metadata": "root.get_arch", "header": "['module', '___EOS___']", "index": 281 }, { "content": "def _send(server, info, results):\n print 'connecting to', server\n s = xmlrpclib.ServerProxy(server, allow_none=True)\n s.add_results(info, results)", "metadata": "root._send", "header": "['module', '___EOS___']", "index": 287 }, { "content": "def do(name, commands, context=None, arch=None, stop_if_failure=True):\n reslist = []\n\n if context:\n context.initialize()\n\n for c in commands:\n print 'running: %s (%s)' % (c.command_name, c.command_type)\n if context:\n context.start_command(c)\n c.run(context)\n if context:\n context.end_command(c)\n\n reslist.append(c.get_results())\n\n if stop_if_failure and not c.success():\n break\n\n if context:\n context.finish()\n\n if arch is None:\n arch = get_arch()\n\n success = all([ c.success() for c in commands ])\n\n client_info = dict(package=name, arch=arch, success=success)\n if context:\n context.update_client_info(client_info)\n\n return (client_info, reslist)", "metadata": "root.do", "header": "['module', '___EOS___']", "index": 292 }, { "content": "def send(server_url, x, hostname=None, tags=()):\n client_info, reslist = x\n if hostname is None:\n import socket\n hostname = socket.gethostname()\n\n client_info['host'] = hostname\n client_info['tags'] = tags\n\n print 'using server URL:', server_url\n _send(server_url, client_info, reslist)", "metadata": "root.send", "header": "['module', '___EOS___']", "index": 325 }, { "content": "def check(name, server_url, tags=(), hostname=None, arch=None, reserve_time=0):\n if hostname is None:\n hostname = get_hostname()\n\n if arch is None:\n arch = get_arch()\n\n client_info = dict(package=name, host=hostname, arch=arch, tags=tags)\n s = xmlrpclib.ServerProxy(server_url, allow_none=True)\n (flag, reason) = s.check_should_build(client_info, True, reserve_time)\n return flag", "metadata": "root.check", "header": "['module', '___EOS___']", "index": 337 } ]
[ { "span": "import sys", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 10 }, { "span": "from optparse import OptionParser", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 33 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Client", " ", "librar", "y", " ", "for", " ", "pon", "y", "-", "build", ".", "\\", "10", ";", "\\", "10", ";", "See", " ", "http", "://", "git", "hub", ".", "com", "/", "eric", "hol", "sche", "r", "/", "pon", "y", "\\u", "bar", "n", "/.", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "xmlrpclib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "optparse_", "import_", "Optio", "n", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEF", "AUL", "T", "\\u", "CACHE", "\\u", "DIR_", "=_", "'", "~", "/.", "pon", "y", "-", "build", "'_", "\\u\\u\\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\\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\\uNL\\u\\u\\u_", "\\u\\u\\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_", "guess", "\\u", "cache", "\\u", "dir_", "(_", "dirname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "'", "PON", "Y", "\\u", "BUILD", "\\u", "CACHE", "'_", ",_", "DEF", "AUL", "T", "\\u", "CACHE", "\\u", "DIR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "=_", "os_", "._", "path_", "._", "expanduser_", "(_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "os_", "._", "path_", "._", "join_", "(_", "parent_", ",_", "dirname_", ")_", "\\u\\u\\uNEWLINE\\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_", "\\u", "run", "\\u", "command_", "(_", "command", "\\u", "list_", ",_", "cwd_", "=_", "None_", ",_", "variables_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "command", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "environment_", "=_", "os_", "._", "environ_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "environment_", "[_", "'", "PI", "P", "\\u", "DOWNLOAD", "\\u", "CACHE", "'_", "]_", "=_", "'/", "tmp", "/", "pip", "/", "download", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "environment_", "[_", "'", "PYTHON", "PATH", "'_", "]_", "=_", "\"%", "s", ":", "%", "s", "\"_", "%_", "(_", "os_", "._", "getcwd_", "(_", ")_", ",_", "environment_", "[_", "'", "PYTHON", "PATH", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "variables_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cmd_", "in_", "command", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "._", "append_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "command", "\\u", "list_", "=_", "x_", "\\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 ", " _", "p_", "=_", "subprocess_", "._", "Popen_", "(_", "command", "\\u", "list_", ",_", "shell_", "=_", "False_", ",_", "cwd_", "=_", "cwd_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ",_", "stderr_", "=_", "subprocess_", "._", "PIPE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "env_", "=_", "environment_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "out_", ",_", "err_", "=_", "p_", "._", "communicate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "p_", "._", "returncode_", "\\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 ", " _", "out_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "ret_", ",_", "out_", ",_", "err_", ")_", "\\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_", "Context_", "(_", "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\\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_", "Context_", "(_", "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_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "time_", "=_", "self_", "._", "end", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "build", "\\u", "dir_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Context_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "initialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Context_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "finish_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "end", "\\u", "time_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Context_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start", "\\u", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "build", "\\u", "dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "chdir_", "(_", "self_", "._", "build", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Context_", "(_", "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_", "end", "\\u", "command_", "(_", "self_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "history_", "._", "append_", "(_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Context_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "client", "\\u", "info_", "(_", "self_", ",_", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "info_", "[_", "'", "duration", "'_", "]_", "=_", "self_", "._", "end", "\\u", "time_", "-_", "self_", "._", "start", "\\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_", "Curr", "ent", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Curr", "ent", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\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_", ",_", "cleanup_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Context_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "=_", "cleanup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curr", "ent", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "initialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Context_", "._", "initialize_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Us", "ing", " ", "the", " ", "current", " ", "director", "y", " ", "(%", "s", ")", " ", "as", " ", "my", " ", "working", " ", "dir", "\"_", "%_", "os_", "._", "getcwd_", "(_", ")_", "\\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_", "Temp", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Temp", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\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_", ",_", "cleanup_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Context_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "=_", "cleanup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Temp", "Director", "y", "Context_", "(_", "Context_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "initialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Context_", "._", "initialize_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "tempdir_", "=_", "tempfile_", "._", "mkdtemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cwd_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "chang", "ing", " ", "to", " ", "temp", " ", "director", "y", ":'_", ",_", "self_", "._", "tempdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "tempdir_", ")_", "\\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_", "Virt", "ual", "env", "Context_", "(_", "Context_", ")_", ":_", "\\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_", "Virt", "ual", "env", "Context_", "(_", "Context_", ")_", ":_", "\\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_", ",_", "alw", "ay", "s", "\\u", "cleanup_", "=_", "True_", ",_", "use", "\\u", "site", "\\u", "packages_", "=_", "False_", ",_", "dependencies_", "=_", "[_", "]_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Context_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "=_", "alw", "ay", "s", "\\u", "cleanup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dependencies_", "=_", "dependencies_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base", "\\u", "build_", "=_", "kwargs_", "[_", "'", "base", "\\u", "build", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "virtualenv", ".", " ", "Ha", "ve", " ", "to", " ", "do", " ", "this", " ", "here", " ", "so", " ", "tha", "t", " ", "command", "s", " ", "can", " ", "use_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Virt", "ual", "env", "Context", ".", "python", " ", "(", "etc", ")", " ", "to", " ", "get", " ", "at", " ", "the", " ", "right", " ", "python", "._", "\\u\\u\\uNL\\u\\u\\u_", "import_", "virtualenv", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "tempdir_", "=_", "tempfile_", "._", "mkdtemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "creati", "ng", " ", "virtualenv", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "use", "\\u", "site", "\\u", "packages_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "run", "\\u", "command_", "(_", "[_", "base", "\\u", "build_", "._", "py", "\\u", "name_", ",_", "'-", "m", "'_", ",_", "'", "virtualenv", "'_", ",_", "self_", "._", "tempdir_", "]_", ")_", "\\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", "run", "\\u", "command_", "(_", "[_", "base", "\\u", "build_", "._", "py", "\\u", "name_", ",_", "'-", "m", "'_", ",_", "'", "virtualenv", "'_", ",_", "'--", "no", "-", "site", "-", "package", "s", "'_", ",_", "self_", "._", "tempdir_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "calcul", "ate", " ", "where", " ", "a", " ", "few", " ", "thing", "s", " ", "live", " ", "so", " ", "we", " ", "can", " ", "easi", "ly", " ", "shell", " ", "out", " ", "to", " ", "'", "em_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "python_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "tempdir_", ",_", "'", "bin", "'_", ",_", "'", "python", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "django", "admin_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "tempdir_", ",_", "'", "bin", "'_", ",_", "'", "django", "-", "admin", ".", "py", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "easy", "\\u", "install_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "tempdir_", ",_", "'", "bin", "'_", ",_", "'", "easy", "\\u", "install", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pip_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "tempdir_", ",_", "'", "bin", "'_", ",_", "'", "pip", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Virt", "ual", "env", "Context_", "(_", "Context_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "initialize_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "\\u", "time_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "chang", "ing", " ", "to", " ", "temp", " ", "director", "y", ":'_", ",_", "self_", "._", "tempdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cwd_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "self_", "._", "tempdir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "install", " ", "pip", ",", " ", "then", " ", "use", " ", "it", " ", "to", " ", "install", " ", "any", " ", "package", "s", " ", "desired_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "install", "ing", " ", "pip", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "run", "\\u", "command_", "(_", "[_", "self_", "._", "easy", "\\u", "install_", ",_", "'-", "U", "'_", ",_", "'", "pip", "==", "dev", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dep_", "in_", "self_", "._", "dependencies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "install", "ing", "\"_", ",_", "dep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "run", "\\u", "command_", "(_", "[_", "self_", "._", "pip_", ",_", "'", "install", "'_", ",_", "'-", "U", "'_", ",_", "'-", "I", "'_", "]_", "+_", "dep_", "._", "split_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Virt", "ual", "env", "Context_", "(_", "Context_", ")_", ":_", "\\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_", "finish_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "chdir_", "(_", "self_", "._", "cwd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "end", "\\u", "time_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\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_", "._", "cleanup_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "remo", "ving", "'_", ",_", "self_", "._", "tempdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shutil_", "._", "rmtree_", "(_", "self_", "._", "tempdir_", ",_", "ignore", "\\u", "errors_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Virt", "ual", "env", "Context_", "(_", "Context_", ")_", ":_", "\\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", "\\u", "client", "\\u", "info_", "(_", "self_", ",_", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Context", ".", "update", "\\u", "client", "\\u", "info", "(", "self", ",", " ", "info", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "info_", "[_", "'", "start", "\\u", "time", "'_", "]_", "=_", "str_", "(_", "self_", "._", "start", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "[_", "'", "end", "\\u", "time", "'_", "]_", "=_", "str_", "(_", "self_", "._", "end", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "[_", "'", "tempdi", "r", "'_", "]_", "=_", "self_", "._", "tempdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "[_", "'", "virtualenv", "'_", "]_", "=_", "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_", "Base", "Command_", "(_", "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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "Command_", "(_", "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_", ",_", "command", "\\u", "list_", ",_", "name_", "=_", "''_", ",_", "run", "\\u", "cwd_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "command", "\\u", "list_", "=_", "command", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "command", "\\u", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "run", "\\u", "cwd_", "=_", "run", "\\u", "cwd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "status_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "erro", "ut_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "duration_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "variables_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Command_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "variables_", "(_", "self_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "variables_", "=_", "dict_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Command_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "ret_", ",_", "out_", ",_", "err_", ")_", "=_", "\\u", "run", "\\u", "command_", "(_", "self_", "._", "command", "\\u", "list_", ",_", "cwd_", "=_", "self_", "._", "run", "\\u", "cwd_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "variables_", "=_", "self_", "._", "variables_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "status_", "=_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output_", "=_", "out_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "erro", "ut_", "=_", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "duration_", "=_", "end_", "-_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Command_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "success_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "status_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Command_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "results_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "dict_", "(_", "status_", "=_", "self_", "._", "status_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "output_", "=_", "self_", "._", "output_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "erro", "ut_", "=_", "self_", "._", "erro", "ut_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "command_", "=_", "str_", "(_", "self_", "._", "command", "\\u", "list_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type_", "=_", "self_", "._", "command", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "self_", "._", "command", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "duration_", "=_", "self_", "._", "duration_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "results_", "\\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_", "Set", "up", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "\\u", "type_", "=_", "'", "setup", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "name_", "=_", "'", "setup", "'_", "\\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_", "Build", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "\\u", "type_", "=_", "'", "build", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "name_", "=_", "'", "build", "'_", "\\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_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "\\u", "type_", "=_", "'", "test", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "name_", "=_", "'", "test", "'_", "\\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_", "VCS", "Clone", "_", "(_", "Set", "up", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "\\u", "name_", "=_", "'", "check", "out", "'_", "\\u\\u\\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_", "VCS", "Clone", "_", "(_", "Set", "up", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "repository_", ",_", "branch_", "=_", "'", "master", "'_", ",_", "cache", "\\u", "dir_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "use", "\\u", "cache_", "=_", "True_", ",_", "egg", "_", "=_", "None_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Set", "up", "Command_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "[_", "]_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "repository_", "=_", "repository_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "branch_", "=_", "branch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "egg", "_", "=_", "egg", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "use", "\\u", "cache_", "=_", "use", "\\u", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cache", "\\u", "dir_", "=_", "cache", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "duration_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "version", "\\u", "info_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VCS", "Clone", "_", "(_", "Set", "up", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "use", "\\u", "cache_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache", "\\u", "dir_", "=_", "self_", "._", "cache", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cache", "\\u", "dir_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache", "\\u", "dir_", "=_", "guess", "\\u", "cache", "\\u", "dir_", "(_", "self_", "._", "egg", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vcs_", "=_", "pip_", "._", "vcs_", "._", "get", "\\u", "backend_", "(_", "self_", "._", "vcs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vcs", "\\u", "repo_", "=_", "vcs_", "(_", "\"%", "s", "+", "%", "s", "#", "egg", "=", "%", "s", "\"_", "%_", "(_", "self_", "._", "vcs_", ",_", "self_", "._", "repository_", ",_", "self_", "._", "egg", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "exists_", "(_", "cache", "\\u", "dir_", ")_", ":_", "\\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 ", " ", "_", "if_", "vcs_", "._", "name_", "is_", "'", "git", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "\\u", "run", "\\u", "command_", "(_", "[_", "'", "git", "'_", ",_", "'", "clean", "'_", ",_", "'-", "f", "'_", ",_", "self_", "._", "cache", "\\u", "dir_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vcs", "\\u", "repo_", "._", "update_", "(_", "cache", "\\u", "dir_", ",_", "[_", "'", "orig", "in", "/", "master", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "pip", " ", "doe", "sn", "'", "t", " ", "use", " ", "the", " ", "second", " ", "arg", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "vcs", "\\u", "repo_", "._", "update_", "(_", "cache", "\\u", "dir_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "If", " ", "an", " ", "update", " ", "fail", "ed", ",", " ", "still", " ", "run", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "Thi", "s", " ", "allow", "s", " ", "for", " ", "runn", "ing", " ", "tests", " ", "offline_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "\"", "Up", "dati", "ng", " ", "Rep", "o", " ", "Fail", "ed", ":", " ", "%", "s", "\"_", "%_", "e_", "\\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 ", " _", "vcs", "\\u", "repo_", "._", "obtain", "_", "(_", "cache", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "status_", "=_", "0_", "\\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 ", " _", "print_", "\"", "Except", "ion", " ", "on", " ", "check", "out", ":", " ", "%", "s", "\"_", "%_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "status_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "._", "build", "\\u", "dir_", "=_", "cache", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VCS", "Clone", "_", "(_", "Set", "up", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "results_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "results", "\\u", "dict_", "[_", "'", "out", "'_", "]_", "=_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "erro", "ut", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "command", "'_", "]_", "=_", "'", "Clone", "(%", "s", ",", " ", "%", "s", ")'_", "%_", "(_", "self_", "._", "repository_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "branch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "status", "'_", "]_", "=_", "self_", "._", "status_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "type", "'_", "]_", "=_", "self_", "._", "command", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "name", "'_", "]_", "=_", "self_", "._", "command", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "results", "\\u", "dict_", "[_", "'", "version", "\\u", "type", "'_", "]_", "=_", "self_", "._", "vcs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "version", "\\u", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "results", "\\u", "dict_", "[_", "'", "version", "\\u", "info", "'_", "]_", "=_", "self_", "._", "version", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "results", "\\u", "dict_", "\\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_", "Git", "Clone", "_", "(_", "VCS", "Clone", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vcs_", "=_", "\"", "git", "\"_", "\\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_", "Hg", "Clone", "_", "(_", "VCS", "Clone", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vcs_", "=_", "\"", "hg", "\"_", "\\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_", "Sv", "n", "Update_", "(_", "VCS", "Clone", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vcs_", "=_", "\"", "svn", "\"_", "\\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", "\\u", "hostname_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "socket_", "._", "gethostname_", "(_", ")_", "\\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", "\\u", "arch_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "distutils_", "._", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "distutils_", "._", "util_", "._", "get", "\\u", "platform_", "(_", ")_", "\\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", "send_", "(_", "server_", ",_", "info_", ",_", "results_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "connecti", "ng", " ", "to", "'_", ",_", "server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "xmlrpclib_", "._", "Server", "Proxy_", "(_", "server_", ",_", "allow", "\\u", "none_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "._", "add", "\\u", "results_", "(_", "info_", ",_", "results_", ")_", "\\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_", "do_", "(_", "name_", ",_", "commands_", ",_", "context_", "=_", "None_", ",_", "arch_", "=_", "None_", ",_", "stop", "\\u", "if", "\\u", "failure_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "initialize_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "c_", "in_", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "runn", "ing", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "c_", "._", "command", "\\u", "name_", ",_", "c_", "._", "command", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "start", "\\u", "command_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "c_", "._", "run_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "end", "\\u", "command_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "res", "list_", "._", "append_", "(_", "c_", "._", "get", "\\u", "results_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "stop", "\\u", "if", "\\u", "failure_", "and_", "not_", "c_", "._", "success_", "(_", ")_", ":_", "\\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_", "if_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "finish_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "arch_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arch_", "=_", "get", "\\u", "arch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "success_", "=_", "all_", "(_", "[_", "c_", "._", "success_", "(_", ")_", "for_", "c_", "in_", "commands_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "client", "\\u", "info_", "=_", "dict_", "(_", "package_", "=_", "name_", ",_", "arch_", "=_", "arch_", ",_", "success_", "=_", "success_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "._", "update", "\\u", "client", "\\u", "info_", "(_", "client", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "client", "\\u", "info_", ",_", "res", "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_", "def_", "send_", "(_", "server", "\\u", "url_", ",_", "x_", ",_", "hostname_", "=_", "None_", ",_", "tags_", "=_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client", "\\u", "info_", ",_", "res", "list_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hostname_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hostname_", "=_", "socket_", "._", "gethostname_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "\\u", "info_", "[_", "'", "host", "'_", "]_", "=_", "hostname_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "\\u", "info_", "[_", "'", "tags", "'_", "]_", "=_", "tags_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "usi", "ng", " ", "server", " ", "URL", ":'_", ",_", "server", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "send_", "(_", "server", "\\u", "url_", ",_", "client", "\\u", "info_", ",_", "res", "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_", "def_", "check_", "(_", "name_", ",_", "server", "\\u", "url_", ",_", "tags_", "=_", "(_", ")_", ",_", "hostname_", "=_", "None_", ",_", "arch_", "=_", "None_", ",_", "reserve", "\\u", "time_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hostname_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hostname_", "=_", "get", "\\u", "hostname_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "arch_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "arch_", "=_", "get", "\\u", "arch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "\\u", "info_", "=_", "dict_", "(_", "package_", "=_", "name_", ",_", "host_", "=_", "hostname_", ",_", "arch_", "=_", "arch_", ",_", "tags_", "=_", "tags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "xmlrpclib_", "._", "Server", "Proxy_", "(_", "server", "\\u", "url_", ",_", "allow", "\\u", "none_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "flag_", ",_", "reason_", ")_", "=_", "s_", "._", "check", "\\u", "shou", "ld", "\\u", "build_", "(_", "client", "\\u", "info_", ",_", "True_", ",_", "reserve", "\\u", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "flag_" ]
[ 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, 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, 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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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 ]
Unused import
RobotLocomotion/director/src/python/tests/testContinuousWalking_staircase.py
[ { "content": "import os\nimport math\nfrom director import robotsystem\nfrom director.consoleapp import ConsoleApp\nfrom director import ioUtils\nfrom director import segmentation\nfrom director import applogic\nfrom director import visualization as vis\nfrom director import continuouswalkingdemo\nfrom director import objectmodel as om\nfrom director import ikplanner\nfrom director import navigationpanel\nfrom director import cameraview\nfrom director import playbackpanel\nfrom director import drcargs\n\nimport drc as lcmdrc\n\napp = ConsoleApp()\ndataDir = app.getTestingDataDirectory()\n# create a view\nview = app.createView()\nsegmentation._defaultSegmentationView = view\n\n#footstepsPanel = footstepsdriverpanel.init(footstepsDriver, robotStateModel, robotStateJointController, mapServerSource)\nfootstepsPanel = None\nrobotsystem.create(view, globals())\n\n\n\n \n\n\n\n#navigationPanel = navigationpanel.init(robotStateJointController, footstepsDriver)\nnavigationPanel = None\ncontinuouswalkingDemo = continuouswalkingdemo.ContinousWalkingDemo(robotStateModel, footstepsPanel, footstepsDriver, playbackpanel, robotStateJointController, ikPlanner,\n teleopJointController, navigationPanel, cameraview, jointLimitChecker=None)\n\ncwdemo = continuouswalkingDemo\n\n# test 1 - Simple:\n#processSingleBlock(robotStateModel, 0)\n# test 2 - Staircase:\nprocessSingleBlock(robotStateModel, 1)\n\n'''\n# test 3\nprocessSnippet()\n\n# test 4\ncontinuouswalkingDemo.processContinuousStereo = True\nprocessSnippet()\n'''\n\nif app.getTestingInteractiveEnabled():\n view.show()\n app.showObjectModel()\n app.start()\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def processSingleBlock(robotStateModel, whichFile=0):\n\n if (whichFile == 0):\n polyData = ioUtils.readPolyData(os.path.join(dataDir, 'terrain/terrain_simple_ihmc.vtp'))\n vis.updatePolyData( polyData, 'terrain_simple_ihmc.vtp', parent='continuous')\n else:\n polyData = ioUtils.readPolyData(os.path.join(dataDir, 'terrain/terrain_stairs_ihmc.vtp'))\n cwdemo.chosenTerrain = 'stairs'\n cwdemo.supportContact = lcmdrc.footstep_params_t.SUPPORT_GROUPS_MIDFOOT_TOE\n vis.updatePolyData( polyData, 'terrain_stairs_ihmc.vtp', parent='continuous')\n \n if drcargs.args().directorConfigFile.find('atlas') != -1:\n \tstandingFootName = 'l_foot'\n else:\n standingFootName = 'leftFoot'\n\n standingFootFrame = robotStateModel.getLinkFrame(standingFootName)\n vis.updateFrame(standingFootFrame, standingFootName, parent='continuous', visible=False)\n \n # Step 1: filter the data down to a box in front of the robot:\n polyData = cwdemo.getRecedingTerrainRegion(polyData, footstepsDriver.getFeetMidPoint(robotStateModel))\n\n # Step 2: find all the surfaces in front of the robot (about 0.75sec)\n clusters = segmentation.findHorizontalSurfaces(polyData)\n if (clusters is None):\n print \"No cluster found, stop walking now!\"\n return\n \n # Step 3: find the corners of the minimum bounding rectangles\n blocks,match_idx,groundPlane = cwdemo.extractBlocksFromSurfaces(clusters, standingFootFrame)\n\n footsteps = cwdemo.placeStepsOnBlocks(blocks, groundPlane, standingFootName, standingFootFrame)\n\n cwdemo.drawFittedSteps(footsteps)", "metadata": "root.processSingleBlock", "header": "['module', '___EOS___']", "index": 30 }, { "content": "def processSnippet():\n\n obj = om.getOrCreateContainer('continuous')\n om.getOrCreateContainer('cont debug', obj)\n\n if (continuouswalkingDemo.processContinuousStereo):\n polyData = ioUtils.readPolyData(os.path.join(dataDir, 'terrain/block_snippet_stereo.vtp'))\n polyData = segmentation.applyVoxelGrid(polyData, leafSize=0.01)\n else:\n polyData = ioUtils.readPolyData(os.path.join(dataDir, 'terrain/block_snippet.vtp'))\n\n\n vis.updatePolyData( polyData, 'walking snapshot trimmed', parent='continuous')\n if drcargs.args().directorConfigFile.find('atlas') != -1:\n \tstandingFootName = 'l_foot'\n else:\n standingFootName = 'leftFoot'\n\n standingFootFrame = robotStateModel.getLinkFrame(standingFootName)\n vis.updateFrame(standingFootFrame, standingFootName, parent='continuous', visible=False)\n\n # Step 2: find all the surfaces in front of the robot (about 0.75sec)\n clusters = segmentation.findHorizontalSurfaces(polyData)\n if (clusters is None):\n print \"No cluster found, stop walking now!\"\n return\n\n # Step 3: find the corners of the minimum bounding rectangles\n blocks,match_idx,groundPlane = cwdemo.extractBlocksFromSurfaces(clusters, standingFootFrame)\n\n footsteps = cwdemo.placeStepsOnBlocks(blocks, groundPlane, standingFootName, standingFootFrame)\n\n cwdemo.drawFittedSteps(footsteps)\n # cwdemo.sendPlanningRequest(footsteps)", "metadata": "root.processSnippet", "header": "['module', '___EOS___']", "index": 66 } ]
[ { "span": "import math", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 11 }, { "span": "from director import applogic", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 29 }, { "span": "from director import ikplanner", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 30 }, { "span": "from director import navigationpanel", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 36 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "robots", "ystem_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "._", "console", "app_", "import_", "Cons", "ole", "App_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "io", "Utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "segmentation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "appl", "ogi", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "visualization", "_", "as_", "vis_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "continuous", "walking", "demo_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "object", "model_", "as_", "om_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "ik", "planner", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "navigation", "panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "came", "rav", "iew_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "playback", "panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "director_", "import_", "dr", "car", "gs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "dr", "c_", "as_", "lcm", "dr", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "Cons", "ole", "App_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data", "Dir_", "=_", "app_", "._", "get", "Test", "ing", "Data", "Directory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "app_", "._", "create", "View_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "segmentation_", "._", "\\u", "default", "Segmentation", "View_", "=_", "view_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "foot", "step", "s", "Pane", "l", " ", "=", " ", "foot", "step", "sdr", "iver", "panel", ".", "init", "(", "foot", "step", "s", "Drive", "r", ",", " ", "robot", "State", "Model", ",", " ", "robot", "State", "Joint", "Controlle", "r", ",", " ", "map", "Server", "Sou", "rce", ")_", "\\u\\u\\uNL\\u\\u\\u_", "foot", "step", "s", "Panel_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "robots", "ystem_", "._", "create_", "(_", "view_", ",_", "globals_", "(_", ")_", ")_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "navigation", "Pane", "l", " ", "=", " ", "navigation", "panel", ".", "init", "(", "robot", "State", "Joint", "Controlle", "r", ",", " ", "foot", "step", "s", "Drive", "r", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "navigation", "Panel_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continuous", "walking", "Demo", "_", "=_", "continuous", "walking", "demo_", "._", "Conti", "nous", "Walk", "ing", "Demo", "_", "(_", "robot", "State", "Model_", ",_", "foot", "step", "s", "Panel_", ",_", "foot", "step", "s", "Driver_", ",_", "playback", "panel_", ",_", "robot", "State", "Joint", "Controller_", ",_", "ik", "Plann", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tele", "op", "Joint", "Controller_", ",_", "navigation", "Panel_", ",_", "came", "rav", "iew_", ",_", "joint", "Limit", "Checker_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cw", "demo_", "=_", "continuous", "walking", "Demo", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "1", " ", "-", " ", "Simple", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "process", "Sing", "le", "Block", "(", "robot", "State", "Model", ",", " ", "0", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "2", " ", "-", " ", "Sta", "irc", "ase", ":_", "\\u\\u\\uNL\\u\\u\\u_", "process", "Sing", "le", "Block_", "(_", "robot", "State", "Model_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "#", " ", "test", " ", "3", "\\", "10", ";", "process", "Snippet", "()", "\\", "10", ";", "\\", "10", ";", "#", " ", "test", " ", "4", "\\", "10", ";", "continuous", "walking", "Demo", ".", "process", "Continu", "ous", "Ster", "eo", " ", "=", " ", "Tru", "e", "\\", "10", ";", "process", "Snippet", "()", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "app_", "._", "get", "Test", "ing", "Interact", "ive", "Enabled_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "view_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "show", "Object", "Model_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "start_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "process", "Sing", "le", "Block_", "(_", "robot", "State", "Model_", ",_", "whi", "ch", "File_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "whi", "ch", "File_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "poly", "Data_", "=_", "io", "Utils_", "._", "read", "Poly", "Data_", "(_", "os_", "._", "path_", "._", "join_", "(_", "data", "Dir_", ",_", "'", "terrain", "/", "terrain", "\\u", "simple", "\\u", "ih", "mc", ".", "vt", "p", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vis_", "._", "update", "Poly", "Data_", "(_", "poly", "Data_", ",_", "'", "terrain", "\\u", "simple", "\\u", "ih", "mc", ".", "vt", "p", "'_", ",_", "parent_", "=_", "'", "continuous", "'_", ")_", "\\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 ", " _", "poly", "Data_", "=_", "io", "Utils_", "._", "read", "Poly", "Data_", "(_", "os_", "._", "path_", "._", "join_", "(_", "data", "Dir_", ",_", "'", "terrain", "/", "terrain", "\\u", "stair", "s", "\\u", "ih", "mc", ".", "vt", "p", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cw", "demo_", "._", "chosen", "Terra", "in_", "=_", "'", "stair", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cw", "demo_", "._", "support", "Contact_", "=_", "lcm", "dr", "c_", "._", "foot", "step", "\\u", "params", "\\u", "t_", "._", "SUPPORT", "\\u", "GROUPS", "\\u", "MID", "FOO", "T", "\\u", "TO", "E_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vis_", "._", "update", "Poly", "Data_", "(_", "poly", "Data_", ",_", "'", "terrain", "\\u", "stair", "s", "\\u", "ih", "mc", ".", "vt", "p", "'_", ",_", "parent_", "=_", "'", "continuous", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dr", "car", "gs_", "._", "args_", "(_", ")_", "._", "director", "Config", "File_", "._", "find_", "(_", "'", "atlas", "'_", ")_", "!=_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t_", "standing", "Foot", "Name_", "=_", "'", "l\\u", "foot", "'_", "\\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 ", " _", "standing", "Foot", "Name_", "=_", "'", "left", "Foot", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "standing", "Foot", "Frame_", "=_", "robot", "State", "Model_", "._", "get", "Link", "Frame_", "(_", "standing", "Foot", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vis_", "._", "update", "Frame_", "(_", "standing", "Foot", "Frame_", ",_", "standing", "Foot", "Name_", ",_", "parent_", "=_", "'", "continuous", "'_", ",_", "visible_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Step", " ", "1", ":", " ", "filter", " ", "the", " ", "data", " ", "down", " ", "to", " ", "a", " ", "box", " ", "in", " ", "front", " ", "of", " ", "the", " ", "robot", ":_", "\\u\\u\\uNL\\u\\u\\u_", "poly", "Data_", "=_", "cw", "demo_", "._", "get", "Rece", "ding", "Terra", "in", "Region_", "(_", "poly", "Data_", ",_", "foot", "step", "s", "Driver_", "._", "get", "Fee", "t", "Mid", "Point_", "(_", "robot", "State", "Model_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Step", " ", "2", ":", " ", "find", " ", "all", " ", "the", " ", "surfaces", " ", "in", " ", "front", " ", "of", " ", "the", " ", "robot", " ", "(", "abo", "ut", " ", "0.75", "sec", ")_", "\\u\\u\\uNL\\u\\u\\u_", "clusters_", "=_", "segmentation_", "._", "find", "Horiz", "onta", "l", "Surf", "aces", "_", "(_", "poly", "Data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "clusters_", "is_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "cluster", " ", "found", ",", " ", "stop", " ", "walking", " ", "now", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Step", " ", "3", ":", " ", "find", " ", "the", " ", "corners", " ", "of", " ", "the", " ", "minim", "um", " ", "bound", "ing", " ", "rectangle", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "blocks_", ",_", "match", "\\u", "idx_", ",_", "ground", "Plane_", "=_", "cw", "demo_", "._", "extract", "Block", "s", "Fro", "m", "Surf", "aces", "_", "(_", "clusters_", ",_", "standing", "Foot", "Frame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "foot", "steps_", "=_", "cw", "demo_", "._", "place", "Step", "s", "On", "Blocks_", "(_", "blocks_", ",_", "ground", "Plane_", ",_", "standing", "Foot", "Name_", ",_", "standing", "Foot", "Frame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cw", "demo_", "._", "draw", "Fitt", "ed", "Steps_", "(_", "foot", "steps_", ")_", "\\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_", "process", "Snippet", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj_", "=_", "om_", "._", "get", "Or", "Creat", "e", "Container_", "(_", "'", "continuous", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "om_", "._", "get", "Or", "Creat", "e", "Container_", "(_", "'", "cont", " ", "debug", "'_", ",_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "continuous", "walking", "Demo", "_", "._", "process", "Continu", "ous", "Ster", "eo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "poly", "Data_", "=_", "io", "Utils_", "._", "read", "Poly", "Data_", "(_", "os_", "._", "path_", "._", "join_", "(_", "data", "Dir_", ",_", "'", "terrain", "/", "block", "\\u", "snippet", "\\u", "stereo", ".", "vt", "p", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly", "Data_", "=_", "segmentation_", "._", "appl", "y", "Vo", "xel", "Grid_", "(_", "poly", "Data_", ",_", "leaf", "Size_", "=_", "0.01_", ")_", "\\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 ", " _", "poly", "Data_", "=_", "io", "Utils_", "._", "read", "Poly", "Data_", "(_", "os_", "._", "path_", "._", "join_", "(_", "data", "Dir_", ",_", "'", "terrain", "/", "block", "\\u", "snippet", ".", "vt", "p", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vis_", "._", "update", "Poly", "Data_", "(_", "poly", "Data_", ",_", "'", "walking", " ", "snapshot", " ", "trimmed", "'_", ",_", "parent_", "=_", "'", "continuous", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "dr", "car", "gs_", "._", "args_", "(_", ")_", "._", "director", "Config", "File_", "._", "find_", "(_", "'", "atlas", "'_", ")_", "!=_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t_", "standing", "Foot", "Name_", "=_", "'", "l\\u", "foot", "'_", "\\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 ", " _", "standing", "Foot", "Name_", "=_", "'", "left", "Foot", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "standing", "Foot", "Frame_", "=_", "robot", "State", "Model_", "._", "get", "Link", "Frame_", "(_", "standing", "Foot", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vis_", "._", "update", "Frame_", "(_", "standing", "Foot", "Frame_", ",_", "standing", "Foot", "Name_", ",_", "parent_", "=_", "'", "continuous", "'_", ",_", "visible_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Step", " ", "2", ":", " ", "find", " ", "all", " ", "the", " ", "surfaces", " ", "in", " ", "front", " ", "of", " ", "the", " ", "robot", " ", "(", "abo", "ut", " ", "0.75", "sec", ")_", "\\u\\u\\uNL\\u\\u\\u_", "clusters_", "=_", "segmentation_", "._", "find", "Horiz", "onta", "l", "Surf", "aces", "_", "(_", "poly", "Data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "clusters_", "is_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "No", " ", "cluster", " ", "found", ",", " ", "stop", " ", "walking", " ", "now", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Step", " ", "3", ":", " ", "find", " ", "the", " ", "corners", " ", "of", " ", "the", " ", "minim", "um", " ", "bound", "ing", " ", "rectangle", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "blocks_", ",_", "match", "\\u", "idx_", ",_", "ground", "Plane_", "=_", "cw", "demo_", "._", "extract", "Block", "s", "Fro", "m", "Surf", "aces", "_", "(_", "clusters_", ",_", "standing", "Foot", "Frame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "foot", "steps_", "=_", "cw", "demo_", "._", "place", "Step", "s", "On", "Blocks_", "(_", "blocks_", ",_", "ground", "Plane_", ",_", "standing", "Foot", "Name_", ",_", "standing", "Foot", "Frame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cw", "demo_", "._", "draw", "Fitt", "ed", "Steps_", "(_", "foot", "steps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "cw", "demo", ".", "send", "Plann", "ing", "Request", "(", "foot", "step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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, 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, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 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 ]
Except block handles 'BaseException'
bitxbay/BitXBay/electrumfirst/__init__.py
[ { "content": "try:\n import locale\nexcept:\n pass\n\nwithMessagingMenu = False\ntry:\n from gi.repository import MessagingMenu\n from gi.repository import Notify\n withMessagingMenu = True\nexcept ImportError:\n MessagingMenu = None\nimport bitcoin\nfrom addresses import *\nimport shared\nfrom electrumfirst import *\nimport sys\nfrom time import strftime, localtime, gmtime\nimport time\nimport os\nimport hashlib\nfrom pyelliptic.openssl import OpenSSL\nimport pickle\nimport platform\nimport debug\nfrom debug import logger\nimport subprocess\nimport datetime\nimport random\nimport shelve\nimport threading\nimport multiprocessing\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "locale_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with", "Messag", "ing", "Menu_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gi_", "._", "repository_", "import_", "Messag", "ing", "Menu_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gi_", "._", "repository_", "import_", "Notify_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with", "Messag", "ing", "Menu_", "=_", "True_", "\\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 ", " _", "Messag", "ing", "Menu_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "bitcoin", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "addresses_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shared_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "electr", "um", "first_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "strftime_", ",_", "localtime_", ",_", "gmtime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "hashlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pye", "lli", "pti", "c_", "._", "openss", "l_", "import_", "Open", "SSL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "debug_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "debug_", "import_", "logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shelve", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "threading_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "multiprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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 ]
Redundant comparison
pimusicbox/pimusicbox/filechangesxbmc/.xbmc/addons/weather.wunderground/resources/lib/utilities.py
[ { "content": "def KPHTOBFT(spd):\n if (spd < 1.0):\n bft = '0'\n elif (spd >= 1.0) and (spd < 5.6):\n bft = '1'\n elif (spd >= 5.6) and (spd < 12.0):\n bft = '2'\n elif (spd >= 12.0) and (spd < 20.0):\n bft = '3'\n elif (spd >= 20.0) and (spd < 29.0):\n bft = '4'\n elif (spd >= 29.0) and (spd < 39.0):\n bft = '5'\n elif (spd >= 39.0) and (spd < 50.0):\n bft = '6'\n elif (spd >= 50.0) and (spd < 62.0):\n bft = '7'\n elif (spd >= 62.0) and (spd < 75.0):\n bft = '8'\n elif (spd >= 75.0) and (spd < 89.0):\n bft = '9'\n elif (spd >= 89.0) and (spd < 103.0):\n bft = '10'\n elif (spd >= 103.0) and (spd < 118.0):\n bft = '11'\n elif (spd >= 118.0):\n bft = '12'\n else:\n bft = ''\n return bft", "metadata": "root.KPHTOBFT", "header": "['module', '___EOS___']", "index": 171 } ]
[ { "span": "spd >= 1.0)", "start_line": 174, "start_column": 10, "end_line": 174, "end_column": 20 } ]
[ { "span": "spd < 1.0)", "start_line": 172, "start_column": 8, "end_line": 172, "end_column": 17 } ]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "comparison_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "KP", "HT", "OB", "FT_", "(_", "spd", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "spd", "_", "<_", "1.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "1.0_", ")_", "and_", "(_", "spd", "_", "<_", "5.6", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "5.6", "_", ")_", "and_", "(_", "spd", "_", "<_", "12.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "12.0_", ")_", "and_", "(_", "spd", "_", "<_", "20.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "20.0_", ")_", "and_", "(_", "spd", "_", "<_", "29.", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "4", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "29.", "0_", ")_", "and_", "(_", "spd", "_", "<_", "39.", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "5", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "39.", "0_", ")_", "and_", "(_", "spd", "_", "<_", "50.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "6", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "50.0_", ")_", "and_", "(_", "spd", "_", "<_", "62.", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "7", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "62.", "0_", ")_", "and_", "(_", "spd", "_", "<_", "75.", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "8", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "75.", "0_", ")_", "and_", "(_", "spd", "_", "<_", "89.0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "9", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "89.0_", ")_", "and_", "(_", "spd", "_", "<_", "103", ".0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "10", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "103", ".0_", ")_", "and_", "(_", "spd", "_", "<_", "118", ".0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "11", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "spd", "_", ">=_", "118", ".0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bf", "t_", "=_", "'", "1", "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 ", " _", "bf", "t_", "=_", "''_", "\\u\\u\\uNEWLINE\\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 ]
Unused local variable
statsmodels/statsmodels/statsmodels/discrete/tests/test_constrained.py
[ { "content": " @classmethod\n def setup_class(cls):\n\n cls.res2 = results.results_noexposure_constraint\n cls.idx = [7, 3, 4, 5, 6, 0, 1] # 2 is dropped baseline for categorical\n\n # example without offset\n formula = 'deaths ~ logpyears + smokes + C(agecat)'\n mod = Poisson.from_formula(formula, data=data)\n #res1a = mod1a.fit()\n # get start_params, example fails to converge on one py TravisCI\n k_vars = len(mod.exog_names)\n start_params = np.zeros(k_vars)\n start_params[0] = np.log(mod.endog.mean())\n # if we need it, this is desired params\n p = np.array([-3.93478643, 1.37276214, 2.33077032, 2.71338891,\n 2.71338891, 0.57966535, 0.97254074])\n\n constr = 'C(agecat)[T.4] = C(agecat)[T.5]'\n lc = patsy.DesignInfo(mod.exog_names).linear_constraint(constr)\n cls.res1 = fit_constrained(mod, lc.coefs, lc.constants,\n start_params=start_params,\n fit_kwds={'method': 'bfgs',\n 'disp': 0})\n # TODO: Newton fails\n\n # test method of Poisson, not monkey patched\n cls.res1m = mod.fit_constrained(constr, start_params=start_params,\n method='bfgs', disp=0)", "metadata": "root.TestPoissonConstrained1a.setup_class", "header": "['class', 'TestPoissonConstrained1a', '(', 'CheckPoissonConstrainedMixin', ')', ':', '___EOS___']", "index": 125 }, { "content": " @classmethod\n def setup_class(cls):\n\n cls.res2 = results.results_noexposure_constraint2\n cls.idx = [7, 3, 4, 5, 6, 0, 1] # 2 is dropped baseline for categorical\n\n # example without offset\n formula = 'deaths ~ logpyears + smokes + C(agecat)'\n mod = Poisson.from_formula(formula, data=data)\n\n # get start_params, example fails to converge on one py TravisCI\n k_vars = len(mod.exog_names)\n start_params = np.zeros(k_vars)\n start_params[0] = np.log(mod.endog.mean())\n # if we need it, this is desired params\n p = np.array([-9.43762015, 1.52762442, 2.74155711, 3.58730007,\n 4.08730007, 1.15987869, 0.12111539])\n\n constr = 'C(agecat)[T.5] - C(agecat)[T.4] = 0.5'\n lc = patsy.DesignInfo(mod.exog_names).linear_constraint(constr)\n cls.res1 = fit_constrained(mod, lc.coefs, lc.constants,\n start_params=start_params,\n fit_kwds={'method': 'bfgs', 'disp': 0})\n # TODO: Newton fails\n\n # test method of Poisson, not monkey patched\n cls.res1m = mod.fit_constrained(constr, start_params=start_params,\n method='bfgs', disp=0)", "metadata": "root.TestPoissonConstrained2a.setup_class", "header": "['class', 'TestPoissonConstrained2a', '(', 'CheckPoissonConstrainedMixin', ')', ':', '___EOS___']", "index": 238 }, { "content": "def junk():\n # Singular Matrix in mod1a.fit()\n\n formula1 = 'deaths ~ smokes + C(agecat)'\n\n formula2 = 'deaths ~ C(agecat) + C(smokes) : C(agecat)' # same as Stata default\n\n mod = Poisson.from_formula(formula2, data=data, exposure=data['pyears'].values)\n\n res0 = mod.fit()\n\n constraints = 'C(smokes)[T.1]:C(agecat)[3] = C(smokes)[T.1]:C(agecat)[4]'\n\n import patsy\n lc = patsy.DesignInfo(mod.exog_names).linear_constraint(constraints)\n R, q = lc.coefs, lc.constants\n\n resc = mod.fit_constrained(R,q, fit_kwds={'method':'bfgs'})\n\n # example without offset\n formula1a = 'deaths ~ logpyears + smokes + C(agecat)'\n mod1a = Poisson.from_formula(formula1a, data=data)\n print(mod1a.exog.shape)\n\n res1a = mod1a.fit()\n lc_1a = patsy.DesignInfo(mod1a.exog_names).linear_constraint('C(agecat)[T.4] = C(agecat)[T.5]')\n resc1a = mod1a.fit_constrained(lc_1a.coefs, lc_1a.constants, fit_kwds={'method':'newton'})\n print(resc1a[0])\n print(resc1a[1])", "metadata": "root.junk", "header": "['module', '___EOS___']", "index": 488 } ]
[ { "span": "p ", "start_line": 140, "start_column": 8, "end_line": 140, "end_column": 9 }, { "span": "p ", "start_line": 253, "start_column": 8, "end_line": 253, "end_column": 9 }, { "span": "formula1 ", "start_line": 491, "start_column": 4, "end_line": 491, "end_column": 12 }, { "span": "res0 ", "start_line": 497, "start_column": 4, "end_line": 497, "end_column": 8 }, { "span": "resc ", "start_line": 505, "start_column": 4, "end_line": 505, "end_column": 8 }, { "span": "res1a ", "start_line": 512, "start_column": 4, "end_line": 512, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Pois", "son", "Constr", "aine", "d1", "a_", "(_", "Check", "Pois", "son", "Constr", "aine", "d", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup", "\\u", "class_", "(_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cls_", "._", "res2_", "=_", "results_", "._", "results", "\\u", "noe", "xpo", "sure", "\\u", "constraint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "idx_", "=_", "[_", "7_", ",_", "3_", ",_", "4_", ",_", "5_", ",_", "6_", ",_", "0_", ",_", "1_", "]_", "#", " ", "2", " ", "is", " ", "dropped", " ", "baseline", " ", "for", " ", "categorical_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "example", " ", "with", "out", " ", "offset_", "\\u\\u\\uNL\\u\\u\\u_", "formula_", "=_", "'", "death", "s", " ", "~", " ", "logp", "year", "s", " ", "+", " ", "smoke", "s", " ", "+", " ", "C", "(", "age", "cat", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mod_", "=_", "Pois", "son_", "._", "from", "\\u", "formula_", "(_", "formula_", ",_", "data_", "=_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "res", "1a", " ", "=", " ", "mod", "1a", ".", "fit", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "start", "\\u", "params", ",", " ", "example", " ", "fail", "s", " ", "to", " ", "converg", "e", " ", "on", " ", "one", " ", "py", " ", "Tra", "vis", "CI", "_", "\\u\\u\\uNL\\u\\u\\u_", "k", "\\u", "vars_", "=_", "len_", "(_", "mod_", "._", "exo", "g", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "params_", "=_", "np_", "._", "zeros_", "(_", "k", "\\u", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "params_", "[_", "0_", "]_", "=_", "np_", "._", "log_", "(_", "mod_", "._", "endo", "g_", "._", "mean_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "need", " ", "it", ",", " ", "this", " ", "is", " ", "desi", "red", " ", "params_", "\\u\\u\\uNL\\u\\u\\u_", "p_", "=_", "np_", "._", "array_", "(_", "[_", "-_", "3.9", "347", "864", "3_", ",_", "1.3", "727", "621", "4_", ",_", "2.3", "307", "703", "2_", ",_", "2.7", "133", "889", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2.7", "133", "889", "1_", ",_", "0.57", "966", "535", "_", ",_", "0.97", "254", "074", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "constr", "_", "=_", "'", "C", "(", "age", "cat", ")[", "T", ".4", "]", " ", "=", " ", "C", "(", "age", "cat", ")[", "T", ".5", "]'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lc_", "=_", "pat", "sy_", "._", "Desig", "n", "Info_", "(_", "mod_", "._", "exo", "g", "\\u", "names_", ")_", "._", "linear", "\\u", "constraint_", "(_", "constr", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "res1_", "=_", "fit", "\\u", "constrained", "_", "(_", "mod_", ",_", "lc_", "._", "coefs_", ",_", "lc_", "._", "constants_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "params_", "=_", "start", "\\u", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fit", "\\u", "kwds_", "=_", "{_", "'", "method", "'_", ":_", "'", "bf", "gs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "disp", "'_", ":_", "0_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "New", "ton", " ", "fails_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "method", " ", "of", " ", "Pois", "son", ",", " ", "not", " ", "monkey", " ", "patched_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", "._", "res", "1", "m_", "=_", "mod_", "._", "fit", "\\u", "constrained", "_", "(_", "constr", "_", ",_", "start", "\\u", "params_", "=_", "start", "\\u", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "method_", "=_", "'", "bf", "gs", "'_", ",_", "disp_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Pois", "son", "Constr", "aine", "d2", "a_", "(_", "Check", "Pois", "son", "Constr", "aine", "d", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "setup", "\\u", "class_", "(_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cls_", "._", "res2_", "=_", "results_", "._", "results", "\\u", "noe", "xpo", "sure", "\\u", "constraint", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "idx_", "=_", "[_", "7_", ",_", "3_", ",_", "4_", ",_", "5_", ",_", "6_", ",_", "0_", ",_", "1_", "]_", "#", " ", "2", " ", "is", " ", "dropped", " ", "baseline", " ", "for", " ", "categorical_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "example", " ", "with", "out", " ", "offset_", "\\u\\u\\uNL\\u\\u\\u_", "formula_", "=_", "'", "death", "s", " ", "~", " ", "logp", "year", "s", " ", "+", " ", "smoke", "s", " ", "+", " ", "C", "(", "age", "cat", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mod_", "=_", "Pois", "son_", "._", "from", "\\u", "formula_", "(_", "formula_", ",_", "data_", "=_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "start", "\\u", "params", ",", " ", "example", " ", "fail", "s", " ", "to", " ", "converg", "e", " ", "on", " ", "one", " ", "py", " ", "Tra", "vis", "CI", "_", "\\u\\u\\uNL\\u\\u\\u_", "k", "\\u", "vars_", "=_", "len_", "(_", "mod_", "._", "exo", "g", "\\u", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "params_", "=_", "np_", "._", "zeros_", "(_", "k", "\\u", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "params_", "[_", "0_", "]_", "=_", "np_", "._", "log_", "(_", "mod_", "._", "endo", "g_", "._", "mean_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "we", " ", "need", " ", "it", ",", " ", "this", " ", "is", " ", "desi", "red", " ", "params_", "\\u\\u\\uNL\\u\\u\\u_", "p_", "=_", "np_", "._", "array_", "(_", "[_", "-_", "9.4", "376", "2015_", ",_", "1.5", "276", "244", "2_", ",_", "2.7", "415", "571", "1_", ",_", "3.5", "873", "0007", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "4.0", "873", "0007", "_", ",_", "1.1", "598", "786", "9_", ",_", "0.12", "111", "539", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "constr", "_", "=_", "'", "C", "(", "age", "cat", ")[", "T", ".5", "]", " ", "-", " ", "C", "(", "age", "cat", ")[", "T", ".4", "]", " ", "=", " ", "0.", "5", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lc_", "=_", "pat", "sy_", "._", "Desig", "n", "Info_", "(_", "mod_", "._", "exo", "g", "\\u", "names_", ")_", "._", "linear", "\\u", "constraint_", "(_", "constr", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "res1_", "=_", "fit", "\\u", "constrained", "_", "(_", "mod_", ",_", "lc_", "._", "coefs_", ",_", "lc_", "._", "constants_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "params_", "=_", "start", "\\u", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fit", "\\u", "kwds_", "=_", "{_", "'", "method", "'_", ":_", "'", "bf", "gs", "'_", ",_", "'", "disp", "'_", ":_", "0_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "New", "ton", " ", "fails_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "method", " ", "of", " ", "Pois", "son", ",", " ", "not", " ", "monkey", " ", "patched_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", "._", "res", "1", "m_", "=_", "mod_", "._", "fit", "\\u", "constrained", "_", "(_", "constr", "_", ",_", "start", "\\u", "params_", "=_", "start", "\\u", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "method_", "=_", "'", "bf", "gs", "'_", ",_", "disp_", "=_", "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_", "junk", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sing", "ular", " ", "Matrix", " ", "in", " ", "mod", "1a", ".", "fit", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "formula", "1_", "=_", "'", "death", "s", " ", "~", " ", "smoke", "s", " ", "+", " ", "C", "(", "age", "cat", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "formula", "2_", "=_", "'", "death", "s", " ", "~", " ", "C", "(", "age", "cat", ")", " ", "+", " ", "C", "(", "smoke", "s", ")", " ", ":", " ", "C", "(", "age", "cat", ")'_", "#", " ", "same", " ", "as", " ", "Stat", "a", " ", "default_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mod_", "=_", "Pois", "son_", "._", "from", "\\u", "formula_", "(_", "formula", "2_", ",_", "data_", "=_", "data_", ",_", "exposure", "_", "=_", "data_", "[_", "'", "pye", "ars", "'_", "]_", "._", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res", "0_", "=_", "mod_", "._", "fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "constraints_", "=_", "'", "C", "(", "smoke", "s", ")[", "T", ".1", "]:", "C", "(", "age", "cat", ")[", "3", "]", " ", "=", " ", "C", "(", "smoke", "s", ")[", "T", ".1", "]:", "C", "(", "age", "cat", ")[", "4", "]'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pat", "sy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lc_", "=_", "pat", "sy_", "._", "Desig", "n", "Info_", "(_", "mod_", "._", "exo", "g", "\\u", "names_", ")_", "._", "linear", "\\u", "constraint_", "(_", "constraints_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", ",_", "q_", "=_", "lc_", "._", "coefs_", ",_", "lc_", "._", "constants_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resc", "_", "=_", "mod_", "._", "fit", "\\u", "constrained", "_", "(_", "R_", ",_", "q_", ",_", "fit", "\\u", "kwds_", "=_", "{_", "'", "method", "'_", ":_", "'", "bf", "gs", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "example", " ", "with", "out", " ", "offset_", "\\u\\u\\uNL\\u\\u\\u_", "formula", "1a_", "=_", "'", "death", "s", " ", "~", " ", "logp", "year", "s", " ", "+", " ", "smoke", "s", " ", "+", " ", "C", "(", "age", "cat", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mod", "1a_", "=_", "Pois", "son_", "._", "from", "\\u", "formula_", "(_", "formula", "1a_", ",_", "data_", "=_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "mod", "1a_", "._", "exo", "g_", "._", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res", "1a_", "=_", "mod", "1a_", "._", "fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lc", "\\u", "1a_", "=_", "pat", "sy_", "._", "Desig", "n", "Info_", "(_", "mod", "1a_", "._", "exo", "g", "\\u", "names_", ")_", "._", "linear", "\\u", "constraint_", "(_", "'", "C", "(", "age", "cat", ")[", "T", ".4", "]", " ", "=", " ", "C", "(", "age", "cat", ")[", "T", ".5", "]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resc", "1a_", "=_", "mod", "1a_", "._", "fit", "\\u", "constrained", "_", "(_", "lc", "\\u", "1a_", "._", "coefs_", ",_", "lc", "\\u", "1a_", "._", "constants_", ",_", "fit", "\\u", "kwds_", "=_", "{_", "'", "method", "'_", ":_", "'", "newton", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "resc", "1a_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "resc", "1a_", "[_", "1_", "]_", ")_" ]
[ 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, 0, 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 ]
Except block handles 'BaseException'
rsms/smisk/lib/smisk/mvc/filters.py
[ { "content": "@leaf_filter\ndef confirm(leaf, *va, **params):\n\t'''Requires the client to resend the request, passing a one-time\n\tvalid token as confirmation.\n\t'''\n\treq = App.current.request\n\t\n\t# Validate confirmation if available\n\tparams['confirmed'] = False\n\ttry:\n\t\tif params['confirm_token'] == req.session['confirm_token']:\n\t\t\tparams['confirmed'] = True\n\texcept (KeyError, TypeError):\n\t\tpass\n\t\n\t# Make sure we don't keep confirm_token in params\n\ttry: del params['confirm_token']\n\texcept: pass\n\t\n\t# Call leaf\n\trsp = leaf(*va, **params)\n\t\n\t# Add confirmation token if still unconfirmed\n\tif not params['confirmed']:\n\t\tif not isinstance(req.session, dict):\n\t\t\treq.session = {}\n\t\tconfirm_token = smisk.core.uid()\n\t\treq.session['confirm_token'] = confirm_token\n\t\tif not isinstance(rsp, dict):\n\t\t\trsp = {}\n\t\trsp['confirm_token'] = confirm_token\n\telse:\n\t\t# Remove confirmation tokens\n\t\ttry: del req.session['confirm_token']\n\t\texcept: pass\n\t\ttry: del rsp['confirm_token']\n\t\texcept: pass\n\t\n\t# Return response\n\treturn rsp", "metadata": "root.confirm", "header": "['module', '___EOS___']", "index": 18 } ]
[ { "span": "except: ", "start_line": 35, "start_column": 1, "end_line": 35, "end_column": 8 }, { "span": "except: ", "start_line": 52, "start_column": 2, "end_line": 52, "end_column": 9 }, { "span": "except: ", "start_line": 54, "start_column": 2, "end_line": 54, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "leaf", "\\u", "filter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "confirm_", "(_", "leaf_", ",_", "*_", "va_", ",_", "**_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "'''", "Requ", "ires", " ", "the", " ", "client", " ", "to", " ", "resen", "d", " ", "the", " ", "request", ",", " ", "passi", "ng", " ", "a", " ", "one", "-", "time", "\\", "10", ";", "\t", "valid", " ", "token", " ", "as", " ", "confirmation", ".", "\\", "10", ";", "\t", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "=_", "App_", "._", "current_", "._", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Validate", " ", "confirmation", " ", "if", " ", "available_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "[_", "'", "confirm", "ed", "'_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "params_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "==_", "req_", "._", "session_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "params_", "[_", "'", "confirm", "ed", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "Error_", ",_", "Type", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "we", " ", "don", "'", "t", " ", "keep", " ", "confirm", "\\u", "token", " ", "in", " ", "params_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "del_", "params_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Call", " ", "leaf_", "\\u\\u\\uNL\\u\\u\\u_", "rsp_", "=_", "leaf_", "(_", "*_", "va_", ",_", "**_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "confirmation", " ", "token", " ", "if", " ", "still", " ", "unconfi", "rmed", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "params_", "[_", "'", "confirm", "ed", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "not_", "isinstance_", "(_", "req_", "._", "session_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "req_", "._", "session_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "confirm", "\\u", "token_", "=_", "smi", "sk_", "._", "core_", "._", "uid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "req_", "._", "session_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "=_", "confirm", "\\u", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "rsp_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "rsp_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rsp_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "=_", "confirm", "\\u", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", "confirmation", " ", "tokens_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "try_", ":_", "del_", "req_", "._", "session_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "del_", "rsp_", "[_", "'", "confirm", "\\u", "token", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rsp_", "\\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, 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, 0, 1, 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 ]
Unused import
google/grr/grr/config/contexts.py
[ { "content": "#!/usr/bin/env python\n\"\"\"This file defines valid configuration contexts.\"\"\"\n\n# Also import the contexts needed for client building.\n# pylint: disable=unused-import\nfrom grr.config import build_contexts\n# pylint: enable=unused-import\nfrom grr.lib import config_lib\n\n# Different client platforms.\nconfig_lib.CONFIG.DEFINE_context(\"Platform:Darwin\")\nconfig_lib.CONFIG.DEFINE_context(\"Platform:Linux\")\nconfig_lib.CONFIG.DEFINE_context(\"Platform:Windows\")\n\n# Client architectures.\nconfig_lib.CONFIG.DEFINE_context(\"Arch:amd64\")\nconfig_lib.CONFIG.DEFINE_context(\"Arch:i386\")\n\n# Global system install context - set when GRR is installed globally on the\n# system.\nconfig_lib.CONFIG.DEFINE_context(\"Global Install Context\")\n\n# Different components.\nconfig_lib.CONFIG.DEFINE_context(\"AdminUI Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Client Context\")\nconfig_lib.CONFIG.DEFINE_context(\"ConfigUpdater Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Console Context\")\nconfig_lib.CONFIG.DEFINE_context(\"DataServer Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Demo Context\")\nconfig_lib.CONFIG.DEFINE_context(\"EntryPoint Context\")\nconfig_lib.CONFIG.DEFINE_context(\"ExportTool Context\")\nconfig_lib.CONFIG.DEFINE_context(\"HTTPServer Context\")\nconfig_lib.CONFIG.DEFINE_context(\"PoolClient Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Worker Context\")\n\n# Client building contexts.\nconfig_lib.CONFIG.DEFINE_context(\"ClientBuilder Context\")\nconfig_lib.CONFIG.DEFINE_context(\"DebugClientBuild Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Target:Darwin\")\nconfig_lib.CONFIG.DEFINE_context(\"Target:Linux\")\nconfig_lib.CONFIG.DEFINE_context(\"Target:LinuxDeb\")\nconfig_lib.CONFIG.DEFINE_context(\"Target:LinuxRpm\")\nconfig_lib.CONFIG.DEFINE_context(\"Target:Windows\")\n\n# Running from the command line.\nconfig_lib.CONFIG.DEFINE_context(\"Commandline Context\")\n\n# For debugging.\nconfig_lib.CONFIG.DEFINE_context(\"Debug Context\")\nconfig_lib.CONFIG.DEFINE_context(\"Test Context\")\n\n# Datastores.\nconfig_lib.CONFIG.DEFINE_context(\"MySQLDataStore\")\n\n# Client installer context.\nconfig_lib.CONFIG.DEFINE_context(\"Installer Context\")\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from grr.config import build_contexts", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Thi", "s", " ", "file", " ", "defin", "es", " ", "valid", " ", "configura", "tion", " ", "context", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Al", "so", " ", "import", " ", "the", " ", "context", "s", " ", "need", "ed", " ", "for", " ", "client", " ", "buildi", "ng", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pylint", ":", " ", "disable", "=", "unu", "sed", "-", "import_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "grr_", "._", "config_", "import_", "build", "\\u", "contexts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pylint", ":", " ", "enable", "=", "unu", "sed", "-", "import_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "grr_", "._", "lib_", "import_", "config", "\\u", "lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Different", " ", "client", " ", "platform", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Plat", "form", ":", "Dar", "win", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Plat", "form", ":", "Lin", "ux", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Plat", "form", ":", "Window", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Client", " ", "architecture", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Arch", ":", "am", "d6", "4", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Arch", ":", "i3", "86", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Global", " ", "system", " ", "install", " ", "context", " ", "-", " ", "set", " ", "whe", "n", " ", "GR", "R", " ", "is", " ", "install", "ed", " ", "global", "ly", " ", "on", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "system", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Global", " ", "Install", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Different", " ", "component", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Admi", "n", "UI", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Client", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Config", "Update", "r", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Cons", "ole", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Data", "Server", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Demo", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Entr", "y", "Point", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Export", "Tool", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "HTTP", "Server", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Poo", "l", "Client", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Worke", "r", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Client", " ", "buildi", "ng", " ", "context", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Client", "Build", "er", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Deb", "ug", "Client", "Build", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Target", ":", "Dar", "win", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Target", ":", "Lin", "ux", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Target", ":", "Lin", "ux", "Deb", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Target", ":", "Lin", "ux", "Rp", "m", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Target", ":", "Window", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Run", "ning", " ", "from", " ", "the", " ", "command", " ", "line", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Command", "line", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "debugg", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Deb", "ug", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Test", " ", "Context", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Datas", "tore", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "My", "SQL", "Data", "Stor", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Client", " ", "installer", " ", "context", "._", "\\u\\u\\uNL\\u\\u\\u_", "config", "\\u", "lib_", "._", "CONFIG_", "._", "DEFINE", "\\u", "context_", "(_", "\"", "Installer", " ", "Context", "\"_", ")_" ]
[ 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, 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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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
acil-bwh/SlicerCIP/Scripted/LungRegistration/LungRegistration.py
[ { "content": "import os\nimport unittest\nfrom __main__ import vtk, qt, ctk, slicer\n#import slicer.modules.ChestImagingPlatform\n#\n# LungRegistration\n#\n\n\n#\n# qLungRegistrationWidget\n#\n\n\n\n#\n# LungRegistrationLogic\n#\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class LungRegistration:\n", "metadata": "root.LungRegistration", "header": "['module', '___EOS___']", "index": 8 }, { "content": " def __init__(self, parent):\n parent.title = \"LungRegistration\" # TODO make this more human readable by adding spaces\n parent.categories = [\"Chest Imaging Platform\"]\n parent.dependencies = []\n parent.contributors = [\"Applied Chest Imaging Laboratory, Brigham and Women's Hopsital\"] # replace with \"Firstname Lastname (Org)\"\n parent.helpText = \"\"\"\n Simple Lung registration module\n \"\"\"\n parent.acknowledgementText = \"\"\"\n This work is funded by the National Heart, Lung, And Blood Institute of the National Institutes of Health under Award Number R01HL116931. The content is solely the responsibility of the authors and does not necessarily represent the official views of the National Institutes of Health.\n\"\"\" # replace with organization, grant and thanks.\n self.parent = parent\n\n # Add this test to the SelfTest module's list for discovery when the module\n # is created. Since this module may be discovered before SelfTests itself,\n # create the list if it doesn't already exist.\n try:\n slicer.selfTests\n except AttributeError:\n slicer.selfTests = {}\n slicer.selfTests['LungRegistration'] = self.runTest", "metadata": "root.LungRegistration.__init__", "header": "['class', 'LungRegistration', ':', '___EOS___']", "index": 9 }, { "content": " def runTest(self):\n tester = LungRegistrationTest()\n tester.runTest()", "metadata": "root.LungRegistration.runTest", "header": "['class', 'LungRegistration', ':', '___EOS___']", "index": 31 }, { "content": "class LungRegistrationWidget:\n\n\n\n\n\n####need to specify output type for resample\n\n", "metadata": "root.LungRegistrationWidget", "header": "['module', '___EOS___']", "index": 39 }, { "content": " def __init__(self, parent = None):\n if not parent:\n self.parent = slicer.qMRMLWidget()\n self.parent.setLayout(qt.QVBoxLayout())\n self.parent.setMRMLScene(slicer.mrmlScene)\n else:\n self.parent = parent\n self.layout = self.parent.layout()\n if not parent:\n self.setup()\n self.parent.show()", "metadata": "root.LungRegistrationWidget.__init__", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 40 }, { "content": " def setup(self):\n # Instantiate and connect widgets ...\n\n #\n # Reload and Test area\n #\n reloadCollapsibleButton = ctk.ctkCollapsibleButton()\n reloadCollapsibleButton.text = \"Reload && Test\"\n self.layout.addWidget(reloadCollapsibleButton)\n reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton)\n\n # reload button\n # (use this during development, but remove it when delivering\n # your module to users)\n self.reloadButton = qt.QPushButton(\"Reload\")\n self.reloadButton.toolTip = \"Reload this module.\"\n self.reloadButton.name = \"LungRegistration Reload\"\n reloadFormLayout.addWidget(self.reloadButton)\n self.reloadButton.connect('clicked()', self.onReload)\n\n # reload and test button\n # (use this during development, but remove it when delivering\n # your module to users)\n self.reloadAndTestButton = qt.QPushButton(\"Reload and Test\")\n self.reloadAndTestButton.toolTip = \"Reload this module and then run the self tests.\"\n reloadFormLayout.addWidget(self.reloadAndTestButton)\n self.reloadAndTestButton.connect('clicked()', self.onReloadAndTest)\n\n #\n # Parameters Area\n #\n parametersCollapsibleButton = ctk.ctkCollapsibleButton()\n parametersCollapsibleButton.text = \"Parameters\"\n self.layout.addWidget(parametersCollapsibleButton)\n\n # Layout within the dummy collapsible button\n parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)\n\n #\n # input .vtk selector\n #\n self.inputVTKSelector = slicer.qMRMLNodeComboBox()\n self.inputVTKSelector.nodeTypes = ( (\"vtkMRMLModelNode\"), \"\" )\n self.inputVTKSelector.selectNodeUponCreation = True\n self.inputVTKSelector.addEnabled = False\n self.inputVTKSelector.removeEnabled = False\n self.inputVTKSelector.noneEnabled = False\n self.inputVTKSelector.showHidden = False\n self.inputVTKSelector.showChildNodeTypes = False\n self.inputVTKSelector.setMRMLScene( slicer.mrmlScene )\n self.inputVTKSelector.setToolTip( \"Pick the input convex hull to the algorithm.\" )\n parametersFormLayout.addRow(\"Input .vtk atlas convex hull: \", self.inputVTKSelector) \n \n #input CT image selector\n self.inputSelector = slicer.qMRMLNodeComboBox()\n self.inputSelector.nodeTypes = ( (\"vtkMRMLScalarVolumeNode\"), \"\" )\n #self.inputSelector.addAttribute( \"vtkMRMLScalarVolumeNode\", \"LabelMap\", 0 )\n self.inputSelector.selectNodeUponCreation = True\n self.inputSelector.addEnabled = False\n self.inputSelector.removeEnabled = False\n self.inputSelector.noneEnabled = False\n self.inputSelector.showHidden = False\n self.inputSelector.showChildNodeTypes = False\n self.inputSelector.setMRMLScene( slicer.mrmlScene )\n self.inputSelector.setToolTip( \"Pick the input to the algorithm.\" )\n parametersFormLayout.addRow(\"Input volume: \", self.inputSelector)\n \n \n ##\n ## atlas volume selector\n ##\n self.atlasSelector = slicer.qMRMLNodeComboBox()\n self.atlasSelector.nodeTypes = ( (\"vtkMRMLScalarVolumeNode\"), \"\" )\n #self.leftAtlasSelector.addAttribute( \"vtkMRMLScalarVolumeNode\", \"LabelMap\", 1 )\n self.atlasSelector.selectNodeUponCreation = True\n self.atlasSelector.addEnabled = False\n self.atlasSelector.removeEnabled = False\n self.atlasSelector.noneEnabled = False\n self.atlasSelector.showHidden = False\n self.atlasSelector.showChildNodeTypes = False\n self.atlasSelector.setMRMLScene( slicer.mrmlScene )\n self.atlasSelector.setToolTip( \"Pick the atlas volume.\" )\n parametersFormLayout.addRow(\"Atlas Volume: \", self.atlasSelector)\n #\n ##\n ## right atlas volume selector\n ##\n #self.rightAtlasSelector = slicer.qMRMLNodeComboBox()\n #self.rightAtlasSelector.nodeTypes = ( (\"vtkMRMLScalarVolumeNode\"), \"\" )\n ##self.rightAtlasSelector.addAttribute( \"vtkMRMLScalarVolumeNode\", \"LabelMap\", 2 )\n #self.rightAtlasSelector.selectNodeUponCreation = True\n #self.rightAtlasSelector.addEnabled = False\n #self.rightAtlasSelector.removeEnabled = False\n #self.rightAtlasSelector.noneEnabled = False\n #self.rightAtlasSelector.showHidden = False\n #self.rightAtlasSelector.showChildNodeTypes = False\n #self.rightAtlasSelector.setMRMLScene( slicer.mrmlScene )\n #self.rightAtlasSelector.setToolTip( \"Pick the atlas volume.\" )\n #parametersFormLayout.addRow(\"right Atlas Volume: \", self.rightAtlasSelector)\n \n\n \n \n #\n # output volume selector\n #\n self.outputSelector = slicer.qMRMLNodeComboBox()\n self.outputSelector.nodeTypes = ( (\"vtkMRMLScalarVolumeNode\"), \"\" )\n self.outputSelector.addAttribute( \"vtkMRMLScalarVolumeNode\", \"LabelMap\", 0 )\n self.outputSelector.selectNodeUponCreation = False\n self.outputSelector.addEnabled = True\n self.outputSelector.removeEnabled = True\n self.outputSelector.noneEnabled = False\n self.outputSelector.showHidden = False\n self.outputSelector.showChildNodeTypes = False\n self.outputSelector.setMRMLScene( slicer.mrmlScene )\n self.outputSelector.setToolTip( \"Pick the output to the algorithm.\" )\n parametersFormLayout.addRow(\"Output Volume: \", self.outputSelector)\n \n \n #Add parameters:\n self.numberOfIterations = qt.QSpinBox() \n self.numberOfIterations.setRange(1,1000000) \n self.numberOfIterations.setValue(200)\n self.numberOfIterations.setToolTip( \"Specify the number of iterations to find the transformation.\" )\n parametersFormLayout.addRow(\"Number of iterations (Registration part): \", self.numberOfIterations)\n \n self.boneThreshold = qt.QSpinBox() \n self.boneThreshold.setRange(1,1000000) \n self.boneThreshold.setValue(600)\n self.boneThreshold.setToolTip( \"Threshold value for bone. Any voxel having HU intensity greater than or equal to this value will be considered bone and will be added to the fixed point set..\" )\n parametersFormLayout.addRow(\"Threshold value for bone (Registration part): \", self.boneThreshold) \n \n #\n # Apply Button\n #\n self.applyButton = qt.QPushButton(\"Register\")\n self.applyButton.toolTip = \"Run the registration algorithm.\"\n self.applyButton.enabled = False\n parametersFormLayout.addRow(self.applyButton)\n\n\n # connections\n self.applyButton.connect('clicked(bool)', self.onApplyButton)\n self.inputSelector.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect)\n self.outputSelector.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect)\n self.inputVTKSelector.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect)\n self.atlasSelector.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect)\n self.boneThreshold.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect)\n #self.rightAtlasSelector.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect) \n #self.outModel.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect) \n #self.numberOfIterations.connect(\"currentNodeChanged(vtkMRMLNode*)\", self.onSelect) \n \n # Add vertical spacer\n self.layout.addStretch(1)", "metadata": "root.LungRegistrationWidget.setup", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 52 }, { "content": " def cleanup(self):\n pass", "metadata": "root.LungRegistrationWidget.cleanup", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 208 }, { "content": " def onSelect(self):\n self.applyButton.enabled = self.outputSelector.currentNode() ", "metadata": "root.LungRegistrationWidget.onSelect", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 211 }, { "content": " def onApplyButton(self):\n logic = LungRegistrationLogic()\n print(\"Run the algorithm\")\n #logic.run(self.inputSelector.currentNode(), self.leftAtlasSelector.currentNode(), self.rightAtlasSelector.currentNode(),\"~/TestConvexHull.vtk\", self.numberOfIterations, self.outModel)\n logic.run(self.inputSelector.currentNode(), self.atlasSelector.currentNode(),self.inputVTKSelector.currentNode(), self.numberOfIterations, self.boneThreshold,self.outputSelector.currentNode())", "metadata": "root.LungRegistrationWidget.onApplyButton", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 214 }, { "content": " def onReload(self,moduleName=\"LungRegistration\"):\n \"\"\"Generic reload method for any scripted module.\n ModuleWizard will subsitute correct default moduleName.\n \"\"\"\n import imp, sys, os, slicer\n\n widgetName = moduleName + \"Widget\"\n\n # reload the source code\n # - set source file path\n # - load the module to the global space\n filePath = eval('slicer.modules.%s.path' % moduleName.lower())\n p = os.path.dirname(filePath)\n if not sys.path.__contains__(p):\n sys.path.insert(0,p)\n fp = open(filePath, \"r\")\n globals()[moduleName] = imp.load_module(\n moduleName, fp, filePath, ('.py', 'r', imp.PY_SOURCE))\n fp.close()\n\n # rebuild the widget\n # - find and hide the existing widget\n # - create a new widget in the existing parent\n parent = slicer.util.findChildren(name='%s Reload' % moduleName)[0].parent().parent()\n for child in parent.children():\n try:\n child.hide()\n except AttributeError:\n pass\n # Remove spacer items\n item = parent.layout().itemAt(0)\n while item:\n parent.layout().removeItem(item)\n item = parent.layout().itemAt(0)\n\n # delete the old widget instance\n if hasattr(globals()['slicer'].modules, widgetName):\n getattr(globals()['slicer'].modules, widgetName).cleanup()\n\n # create new widget inside existing parent\n globals()[widgetName.lower()] = eval(\n 'globals()[\"%s\"].%s(parent)' % (moduleName, widgetName))\n globals()[widgetName.lower()].setup()\n setattr(globals()['slicer'].modules, widgetName, globals()[widgetName.lower()])", "metadata": "root.LungRegistrationWidget.onReload", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 222 }, { "content": " def onReloadAndTest(self,moduleName=\"LungRegistration\"):\n try:\n self.onReload()\n evalString = 'globals()[\"%s\"].%sTest()' % (moduleName, moduleName)\n tester = eval(evalString)\n tester.runTest()\n except Exception, e:\n import traceback\n traceback.print_exc()\n qt.QMessageBox.warning(slicer.util.mainWindow(), \n \"Reload and Test\", 'Exception!\\n\\n' + str(e) + \"\\n\\nSee Python Console for Stack Trace\")", "metadata": "root.LungRegistrationWidget.onReloadAndTest", "header": "['class', 'LungRegistrationWidget', ':', '___EOS___']", "index": 267 }, { "content": "class LungRegistrationLogic:\n \"\"\"This class should implement all the actual \n computation done by your module. The interface \n should be such that other python code can import\n this class and make use of the functionality without\n requiring an instance of the Widget\n \"\"\"\n\n\n\n", "metadata": "root.LungRegistrationLogic", "header": "['module', '___EOS___']", "index": 284 }, { "content": " def __init__(self):\n pass", "metadata": "root.LungRegistrationLogic.__init__", "header": "['class', 'LungRegistrationLogic', ':', '___EOS___']", "index": 291 }, { "content": " def hasImageData(self,volumeNode):\n \"\"\"This is a dummy logic method that \n returns true if the passed in volume\n node has valid image data\n \"\"\"\n if not volumeNode:\n print('no volume node')\n return False\n if volumeNode.GetImageData() == None:\n print('no image data')\n return False\n return True", "metadata": "root.LungRegistrationLogic.hasImageData", "header": "['class', 'LungRegistrationLogic', ':', '___EOS___']", "index": 294 }, { "content": " def run(self,inputVolume,atlasVolume, convexHullVolume, numIterations, boneThreshold, outVolume):\n \"\"\"\n Run the actual algorithm\n \"\"\"\n print('In Run method')\n \n \"\"\"\n Generate Atlas convex Hull\n \"\"\"\n \n #convexHullVolume = \"~/TestConvexHull.vtk\"\n #cliparameters = {\n #\"leftAtlasFileName\" : leftAtlasVolume.GetID(),\n #\"rightAtlasFileName\" : rightAtlasVolume.GetID(),\n #\"downsampleFactor\" : 4, \n #\"outputFileName\" : outModel.GetID(), #\"~/TestConvexHull.vtk\", *** should be a vtk file \n #}\n #GenerateAtlasConvexHull = slicer.modules.generateatlasconvexhull\n #slicer.cli.run(GenerateAtlasConvexHull,None, cliparameters, wait_for_completion=True)\n \n \n \n #C:\\ChestImagingPlatformPrivate\\Build\\bin\\Debug>RegisterLungAtlas -i 200 -m D:/Po\n # stdoc/Data/LungAtlases/atlasConvexHull.vtk -c D:/Postdoc/Data/10360K/10360Kinsp\n # .nhdr -o d:/Postdoc/Data/10360K/AtlasTo10360Kinsp.tfm\n\n #\"\"\"\n #Call RegisterLungAtlas cli, tfm intermediate file ?\n #\"\"\"\n \n #Define temporary .tfm file\n f = qt.QTemporaryFile( slicer.app.temporaryPath+ \"/RegisterLungAtlas-XXXXXX.tfm\") #slicer.app.temporaryPath\n f.open() # Create the file\n \n # Get model node by ID\n modelNode = slicer.mrmlScene.GetNodeByID(convexHullVolume.GetID())\n polyData = modelNode.GetPolyData()\n \n cliparameters = {}\n cliparameters['convexHullMeshFileName'] = convexHullVolume.GetID() #modelNode.GetID() #\"\"/Users/rolaharmouche/Documents/Data/LungAtlases/atlasConvexHull.vtk\" #\n cliparameters['numberOfIterations'] = numIterations.value\n cliparameters['boneThreshold'] = boneThreshold.value\n cliparameters['outputTransformFileName'] = f.fileName()#\"/Users/rolaharmouche/Documents/Data/tempdata/Test6.tfm\" #outputTransform, slicer.app.temporarypath\n cliparameters['ctFileName'] = inputVolume.GetID() \n\n #cliparameters['ctFileName'] = \"/Users/rolaharmouche/Documents/Data/COPDGene/14988Y/14988Y_INSP_STD_UAB_COPD/14988Y_INSP_STD_UAB_COPD_downsampled.nrrd\"\n\n #destructor delete stuff\n \n RegisterLungAtlas = slicer.modules.registerlungatlas\n cliNode = slicer.cli.run(RegisterLungAtlas,None, cliparameters, wait_for_completion=True)\n\n #\"\"\"\n #Call ResampleLabelMap cli, save the output volume directly\n #\"\"\"\n ##ResampleLabelMap.exe -d D:/Postdoc/Data/10360K/10360Kinsp.nhdr -r D:/Postdoc/Data/10360K/10360KleftAtlas.nrrd -t \n ##D:/Postdoc/Data/10360K/AtlasTo10360Kinsp.tfm -l D:/Postdoc/Data/LungAtlases/leftLungAtlas.nhdr\n #\n \n cliparameters = {}\n cliparameters['labelMapFileName'] = atlasVolume.GetID() # \"/Users/rolaharmouche/Documents/Data/LungAtlases/leftLungAtlas.nhdr\"\n cliparameters['transformFileName'] = f.fileName()#\"/Users/rolaharmouche/Documents/Data/tempdata/Test6.tfm\"\n cliparameters['resampledFileName'] = outVolume.GetID() #\"~/Test.nrrd\" # \n cliparameters['destinationFileName'] = inputVolume.GetID() #\"/Users/rolaharmouche/Documents/Data/COPDGene/14988Y/14988Y_INSP_STD_UAB_COPD/14988Y_INSP_STD_UAB_COPD_downsampled.nrrd\"\n cliparameters['isInvertTransformation'] =True\n ResampleLabelMap = slicer.modules.resamplelabelmap\n cliNode = slicer.cli.run(ResampleLabelMap,None, cliparameters, wait_for_completion=True), #use qt assistant\n \n return True", "metadata": "root.LungRegistrationLogic.run", "header": "['class', 'LungRegistrationLogic', ':', '___EOS___']", "index": 309 }, { "content": "class LungRegistrationTest(unittest.TestCase):\n \"\"\"\n This is the test case for your scripted module.\n \"\"\"\n\n\n\n", "metadata": "root.LungRegistrationTest", "header": "['module', '___EOS___']", "index": 380 }, { "content": " def delayDisplay(self,message,msec=1000):\n \"\"\"This utility method displays a small dialog and waits.\n This does two things: 1) it lets the event loop catch up\n to the state of the test so that rendering and widget updates\n have all taken place before the test continues and 2) it\n shows the user/developer/tester the state of the test\n so that we'll know when it breaks.\n \"\"\"\n print(message)\n self.info = qt.QDialog()\n self.infoLayout = qt.QVBoxLayout()\n self.info.setLayout(self.infoLayout)\n self.label = qt.QLabel(message,self.info)\n self.infoLayout.addWidget(self.label)\n qt.QTimer.singleShot(msec, self.info.close)\n self.info.exec_()", "metadata": "root.LungRegistrationTest.delayDisplay", "header": "['class', 'LungRegistrationTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 385 }, { "content": " def setUp(self):\n \"\"\" Do whatever is needed to reset the state - typically a scene clear will be enough.\n \"\"\"\n slicer.mrmlScene.Clear(0)", "metadata": "root.LungRegistrationTest.setUp", "header": "['class', 'LungRegistrationTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 402 }, { "content": " def runTest(self):\n \"\"\"Run as few or as many tests as needed here.\n \"\"\"\n self.setUp()\n self.test_LungRegistration1()", "metadata": "root.LungRegistrationTest.runTest", "header": "['class', 'LungRegistrationTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 407 }, { "content": " def test_LungRegistration1(self):\n \"\"\" Ideally you should have several levels of tests. At the lowest level\n tests sould exercise the functionality of the logic with different inputs\n (both valid and invalid). At higher levels your tests should emulate the\n way the user would interact with your code and confirm that it still works\n the way you intended.\n One of the most important features of the tests is that it should alert other\n developers when their changes will have an impact on the behavior of your\n module. For example, if a developer removes a feature that you depend on,\n your test should break so they know that the feature is needed.\n \"\"\"\n\n self.delayDisplay(\"Starting the test\")\n #\n # first, get some data\n #\n import urllib\n downloads = (\n ('http://slicer.kitware.com/midas3/download?items=5767', 'FA.nrrd', slicer.util.loadVolume),\n )\n\n for url,name,loader in downloads:\n filePath = slicer.app.temporaryPath + '/' + name\n if not os.path.exists(filePath) or os.stat(filePath).st_size == 0:\n print('Requesting download %s from %s...\\n' % (name, url))\n urllib.urlretrieve(url, filePath)\n if loader:\n print('Loading %s...\\n' % (name,))\n loader(filePath)\n self.delayDisplay('Finished with download and loading\\n')\n\n volumeNode = slicer.util.getNode(pattern=\"FA\")\n logic = LungRegistrationLogic()\n self.assertTrue( logic.hasImageData(volumeNode) )\n self.delayDisplay('Test passed!')", "metadata": "root.LungRegistrationTest.test_LungRegistration1", "header": "['class', 'LungRegistrationTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 413 } ]
[ { "span": "from __main__ import vtk, qt, ctk, slicer", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 41 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "main\\u\\u_", "import_", "vtk_", ",_", "qt_", ",_", "ct", "k_", ",_", "slicer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "import", " ", "slicer", ".", "module", "s", ".", "Ches", "t", "Imagin", "g", "Platform_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Lun", "g", "Registration", "_", "\\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_", "#", " ", "q", "Lun", "g", "Registration", "Widget_", "\\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_", "#", " ", "Lun", "g", "Registration", "Logic_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Lun", "g", "Registration", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "_", ":_", "\\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_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "._", "title_", "=_", "\"", "Lun", "g", "Registration", "\"_", "#", " ", "TOD", "O", " ", "make", " ", "this", " ", "more", " ", "human", " ", "reada", "ble", " ", "by", " ", "addin", "g", " ", "spaces_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "._", "categories_", "=_", "[_", "\"", "Ches", "t", " ", "Imagin", "g", " ", "Plat", "form", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "._", "dependencies_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "._", "contributor", "s_", "=_", "[_", "\"", "Appl", "ied", " ", "Ches", "t", " ", "Imagin", "g", " ", "Labo", "rator", "y", ",", " ", "Bri", "gha", "m", " ", "and", " ", "Wo", "men", "'", "s", " ", "Hop", "sit", "al", "\"_", "]_", "#", " ", "replace", " ", "with", " ", "\"", "Fi", "rst", "name", " ", "Las", "tname", " ", "(", "Org", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "._", "help", "Text_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Simple", " ", "Lun", "g", " ", "registration", " ", "module", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent_", "._", "acknowledge", "ment", "Text_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "work", " ", "is", " ", "fund", "ed", " ", "by", " ", "the", " ", "Nat", "ional", " ", "Heart", ",", " ", "Lun", "g", ",", " ", "And", " ", "Bloo", "d", " ", "Institut", "e", " ", "of", " ", "the", " ", "Nat", "ional", " ", "Institut", "es", " ", "of", " ", "Health", " ", "under", " ", "Award", " ", "Number", " ", "R0", "1", "HL", "116", "931", ".", " ", "The", " ", "content", " ", "is", " ", "sole", "ly", " ", "the", " ", "responsib", "ilit", "y", " ", "of", " ", "the", " ", "author", "s", " ", "and", " ", "doe", "s", " ", "not", " ", "necessar", "il", "y", " ", "represent", " ", "the", " ", "official", " ", "views", " ", "of", " ", "the", " ", "Nat", "ional", " ", "Institut", "es", " ", "of", " ", "Health", ".", "\\", "10", ";\"\"\"_", "#", " ", "replace", " ", "with", " ", "organization", ",", " ", "grant", " ", "and", " ", "thanks", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "=_", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "this", " ", "test", " ", "to", " ", "the", " ", "Self", "Test", " ", "module", "'", "s", " ", "list", " ", "for", " ", "discove", "ry", " ", "whe", "n", " ", "the", " ", "module_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "created", ".", " ", " ", "Sin", "ce", " ", "this", " ", "module", " ", "may", " ", "be", " ", "discovere", "d", " ", "bef", "ore", " ", "Self", "Test", "s", " ", "its", "elf", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "the", " ", "list", " ", "if", " ", "it", " ", "doe", "sn", "'", "t", " ", "alr", "ead", "y", " ", "exist", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "slicer", "_", "._", "self", "Tests_", "\\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 ", " _", "slicer", "_", "._", "self", "Tests_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "slicer", "_", "._", "self", "Tests_", "[_", "'", "Lun", "g", "Registration", "'_", "]_", "=_", "self_", "._", "run", "Test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "Test_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tester_", "=_", "Lun", "g", "Registration", "Test_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tester_", "._", "run", "Test_", "(_", ")_", "\\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_", "Lun", "g", "Registration", "Widget_", ":_", "\\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_", "###", "#", "need", " ", "to", " ", "speci", "fy", " ", "output", " ", "type", " ", "for", " ", "resample_", "\\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_", "Lun", "g", "Registration", "Widget_", ":_", "\\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_", ",_", "parent_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parent_", "=_", "slicer", "_", "._", "q", "MR", "ML", "Widget_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "._", "set", "Layout_", "(_", "qt_", "._", "QV", "Box", "Layout_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "._", "set", "MR", "ML", "Scene_", "(_", "slicer", "_", "._", "mr", "ml", "Scene_", ")_", "\\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_", "._", "parent_", "=_", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "layout_", "=_", "self_", "._", "parent_", "._", "layout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "setup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\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_", "setup_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Instantiate", " ", "and", " ", "connect", " ", "widget", "s", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Relo", "ad", " ", "and", " ", "Test", " ", "area_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "relo", "ad", "Collaps", "ibl", "e", "Button_", "=_", "ct", "k_", "._", "ct", "k", "Collaps", "ibl", "e", "Button_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relo", "ad", "Collaps", "ibl", "e", "Button_", "._", "text_", "=_", "\"", "Relo", "ad", " ", "&&", " ", "Test", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "layout_", "._", "add", "Widget_", "(_", "relo", "ad", "Collaps", "ibl", "e", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relo", "ad", "Form", "Layout_", "=_", "qt_", "._", "QF", "orm", "Layout_", "(_", "relo", "ad", "Collaps", "ibl", "e", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "relo", "ad", " ", "button_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "use", " ", "this", " ", "dur", "ing", " ", "develop", "ment", ",", " ", "but", " ", "remove", " ", "it", " ", "whe", "n", " ", "deliver", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "your", " ", "module", " ", "to", " ", "users", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "relo", "ad", "Button_", "=_", "qt_", "._", "QP", "ush", "Button_", "(_", "\"", "Relo", "ad", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "relo", "ad", "Button_", "._", "tool", "Tip_", "=_", "\"", "Relo", "ad", " ", "this", " ", "module", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "relo", "ad", "Button_", "._", "name_", "=_", "\"", "Lun", "g", "Registration", " ", "Relo", "ad", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relo", "ad", "Form", "Layout_", "._", "add", "Widget_", "(_", "self_", "._", "relo", "ad", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "relo", "ad", "Button_", "._", "connect_", "(_", "'", "click", "ed", "()'_", ",_", "self_", "._", "on", "Relo", "ad_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "relo", "ad", " ", "and", " ", "test", " ", "button_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "use", " ", "this", " ", "dur", "ing", " ", "develop", "ment", ",", " ", "but", " ", "remove", " ", "it", " ", "whe", "n", " ", "deliver", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "your", " ", "module", " ", "to", " ", "users", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "relo", "ad", "And", "Test", "Button_", "=_", "qt_", "._", "QP", "ush", "Button_", "(_", "\"", "Relo", "ad", " ", "and", " ", "Test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "relo", "ad", "And", "Test", "Button_", "._", "tool", "Tip_", "=_", "\"", "Relo", "ad", " ", "this", " ", "module", " ", "and", " ", "then", " ", "run", " ", "the", " ", "self", " ", "tests", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "relo", "ad", "Form", "Layout_", "._", "add", "Widget_", "(_", "self_", "._", "relo", "ad", "And", "Test", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "relo", "ad", "And", "Test", "Button_", "._", "connect_", "(_", "'", "click", "ed", "()'_", ",_", "self_", "._", "on", "Relo", "ad", "And", "Test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter", "s", " ", "Area_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "parameter", "s", "Collaps", "ibl", "e", "Button_", "=_", "ct", "k_", "._", "ct", "k", "Collaps", "ibl", "e", "Button_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Collaps", "ibl", "e", "Button_", "._", "text_", "=_", "\"", "Parameter", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "layout_", "._", "add", "Widget_", "(_", "parameter", "s", "Collaps", "ibl", "e", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Lay", "out", " ", "within", " ", "the", " ", "dummy", " ", "colla", "psi", "ble", " ", "button_", "\\u\\u\\uNL\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "=_", "qt_", "._", "QF", "orm", "Layout_", "(_", "parameter", "s", "Collaps", "ibl", "e", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "input", " ", ".", "vtk", " ", "selector_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "=_", "slicer", "_", "._", "q", "MR", "ML", "Node", "Comb", "o", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "node", "Types_", "=_", "(_", "(_", "\"", "vtk", "MR", "ML", "Model", "Node", "\"_", ")_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "select", "Node", "Up", "on", "Creat", "ion_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "add", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "remove", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "none", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "show", "Hidden_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "show", "Chil", "d", "Node", "Types_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "set", "MR", "ML", "Scene_", "(_", "slicer", "_", "._", "mr", "ml", "Scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "set", "Tool", "Tip_", "(_", "\"", "Pick", " ", "the", " ", "input", " ", "convex", " ", "hull", " ", "to", " ", "the", " ", "algo", "rit", "hm", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Inp", "ut", " ", ".", "vtk", " ", "atlas", " ", "convex", " ", "hull", ":", " ", "\"_", ",_", "self_", "._", "input", "VT", "KS", "elect", "or_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "input", " ", "CT", " ", "image", " ", "selector_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input", "Selector_", "=_", "slicer", "_", "._", "q", "MR", "ML", "Node", "Comb", "o", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "node", "Types_", "=_", "(_", "(_", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\"_", ")_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "input", "Select", "or", ".", "add", "Attribute", "(", " ", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\",", " ", "\"", "Label", "Map", "\",", " ", "0", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "select", "Node", "Up", "on", "Creat", "ion_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "add", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "remove", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "none", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "show", "Hidden_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "show", "Chil", "d", "Node", "Types_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "set", "MR", "ML", "Scene_", "(_", "slicer", "_", "._", "mr", "ml", "Scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "set", "Tool", "Tip_", "(_", "\"", "Pick", " ", "the", " ", "input", " ", "to", " ", "the", " ", "algo", "rit", "hm", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Inp", "ut", " ", "volume", ":", " ", "\"_", ",_", "self_", "._", "input", "Selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "atlas", " ", "volume", " ", "selector_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "=_", "slicer", "_", "._", "q", "MR", "ML", "Node", "Comb", "o", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "node", "Types_", "=_", "(_", "(_", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\"_", ")_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "left", "Atla", "s", "Select", "or", ".", "add", "Attribute", "(", " ", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\",", " ", "\"", "Label", "Map", "\",", " ", "1", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "select", "Node", "Up", "on", "Creat", "ion_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "add", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "remove", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "none", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "show", "Hidden_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "show", "Chil", "d", "Node", "Types_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "set", "MR", "ML", "Scene_", "(_", "slicer", "_", "._", "mr", "ml", "Scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "set", "Tool", "Tip_", "(_", "\"", "Pick", " ", "the", " ", "atlas", " ", "volume", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Atla", "s", " ", "Volume", ":", " ", "\"_", ",_", "self_", "._", "atlas", "Selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "right", " ", "atlas", " ", "volume", " ", "selector_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", " ", "=", " ", "slicer", ".", "q", "MR", "ML", "Node", "Comb", "o", "Box", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "node", "Type", "s", " ", "=", " ", "(", " ", "(\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\")", ",", " ", "\"\"", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", "self", ".", "right", "Atla", "s", "Select", "or", ".", "add", "Attribute", "(", " ", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\",", " ", "\"", "Label", "Map", "\",", " ", "2", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "select", "Node", "Up", "on", "Creat", "ion", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "add", "Enable", "d", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "remove", "Enable", "d", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "none", "Enable", "d", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "show", "Hi", "dde", "n", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "show", "Chil", "d", "Node", "Type", "s", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "set", "MR", "ML", "Scen", "e", "(", " ", "slicer", ".", "mr", "ml", "Scen", "e", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "set", "Tool", "Tip", "(", " ", "\"", "Pick", " ", "the", " ", "atlas", " ", "volume", ".\"", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "parameter", "s", "Form", "Lay", "out", ".", "add", "Row", "(\"", "right", " ", "Atla", "s", " ", "Volume", ":", " ", "\",", " ", "self", ".", "right", "Atla", "s", "Select", "or", ")_", "\\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\\uNL\\u\\u\\u_", "#", " ", "output", " ", "volume", " ", "selector_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "output", "Selector_", "=_", "slicer", "_", "._", "q", "MR", "ML", "Node", "Comb", "o", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "node", "Types_", "=_", "(_", "(_", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\"_", ")_", ",_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "add", "Attribute_", "(_", "\"", "vtk", "MR", "ML", "Scala", "r", "Volume", "Node", "\"_", ",_", "\"", "Label", "Map", "\"_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "select", "Node", "Up", "on", "Creat", "ion_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "add", "Enabled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "remove", "Enabled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "none", "Enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "show", "Hidden_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "show", "Chil", "d", "Node", "Types_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "set", "MR", "ML", "Scene_", "(_", "slicer", "_", "._", "mr", "ml", "Scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "set", "Tool", "Tip_", "(_", "\"", "Pick", " ", "the", " ", "output", " ", "to", " ", "the", " ", "algo", "rit", "hm", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Output", " ", "Volume", ":", " ", "\"_", ",_", "self_", "._", "output", "Selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Add", " ", "parameter", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "number", "Of", "Iterations", "_", "=_", "qt_", "._", "QS", "pin", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "number", "Of", "Iterations", "_", "._", "set", "Range_", "(_", "1_", ",_", "1000000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "number", "Of", "Iterations", "_", "._", "set", "Value_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "number", "Of", "Iterations", "_", "._", "set", "Tool", "Tip_", "(_", "\"", "Speci", "fy", " ", "the", " ", "number", " ", "of", " ", "iterati", "ons", " ", "to", " ", "find", " ", "the", " ", "transformation", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Number", " ", "of", " ", "iterati", "ons", " ", "(", "Registration", " ", "part", "):", " ", "\"_", ",_", "self_", "._", "number", "Of", "Iterations", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "bone", "Threshold_", "=_", "qt_", "._", "QS", "pin", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bone", "Threshold_", "._", "set", "Range_", "(_", "1_", ",_", "1000000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bone", "Threshold_", "._", "set", "Value_", "(_", "600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bone", "Threshold_", "._", "set", "Tool", "Tip_", "(_", "\"", "Thresh", "old", " ", "value", " ", "for", " ", "bone", ".", " ", "Any", " ", "voxel", " ", "hav", "ing", " ", "HU", " ", "intensity", " ", "great", "er", " ", "than", " ", "or", " ", "equal", " ", "to", " ", "this", " ", "value", " ", "will", " ", "be", " ", "consider", "ed", " ", "bone", " ", "and", " ", "will", " ", "be", " ", "adde", "d", " ", "to", " ", "the", " ", "fixed", " ", "point", " ", "set", "..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "\"", "Thresh", "old", " ", "value", " ", "for", " ", "bone", " ", "(", "Registration", " ", "part", "):", " ", "\"_", ",_", "self_", "._", "bone", "Threshold_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Apply", " ", "Button_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "appl", "y", "Button_", "=_", "qt_", "._", "QP", "ush", "Button_", "(_", "\"", "Register", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "appl", "y", "Button_", "._", "tool", "Tip_", "=_", "\"", "Run", " ", "the", " ", "registration", " ", "algo", "rit", "hm", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "appl", "y", "Button_", "._", "enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parameter", "s", "Form", "Layout_", "._", "add", "Row_", "(_", "self_", "._", "appl", "y", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "connections_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "appl", "y", "Button_", "._", "connect_", "(_", "'", "click", "ed", "(", "bool", ")'_", ",_", "self_", "._", "on", "Apply", "Button_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "Selector_", "._", "connect_", "(_", "\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", "_", ",_", "self_", "._", "on", "Select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "output", "Selector_", "._", "connect_", "(_", "\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", "_", ",_", "self_", "._", "on", "Select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "connect_", "(_", "\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", "_", ",_", "self_", "._", "on", "Select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "atlas", "Selector_", "._", "connect_", "(_", "\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", "_", ",_", "self_", "._", "on", "Select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bone", "Threshold_", "._", "connect_", "(_", "\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", "_", ",_", "self_", "._", "on", "Select_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "right", "Atla", "s", "Select", "or", ".", "connect", "(\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", ",", " ", "self", ".", "on", "Select", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "out", "Model", ".", "connect", "(\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", ",", " ", "self", ".", "on", "Select", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "number", "Of", "Iterations", ".", "connect", "(\"", "current", "Node", "Change", "d", "(", "vtk", "MR", "ML", "Node", "*)\"", ",", " ", "self", ".", "on", "Select", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "vertical", " ", "spacer", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "layout_", "._", "add", "Stretch_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cleanup_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Select_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "appl", "y", "Button_", "._", "enabled_", "=_", "self_", "._", "output", "Selector_", "._", "current", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Apply", "Button_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logic_", "=_", "Lun", "g", "Registration", "Logic_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Run", " ", "the", " ", "algo", "rit", "hm", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "logic", ".", "run", "(", "self", ".", "input", "Select", "or", ".", "current", "Node", "()", ",", " ", "self", ".", "left", "Atla", "s", "Select", "or", ".", "current", "Node", "()", ",", " ", "self", ".", "right", "Atla", "s", "Select", "or", ".", "current", "Node", "()", ",\"", "~", "/", "Test", "Conve", "x", "Hul", "l", ".", "vtk", "\",", " ", "self", ".", "number", "Of", "Iterations", ",", " ", "self", ".", "out", "Model", ")_", "\\u\\u\\uNL\\u\\u\\u_", "logic_", "._", "run_", "(_", "self_", "._", "input", "Selector_", "._", "current", "Node_", "(_", ")_", ",_", "self_", "._", "atlas", "Selector_", "._", "current", "Node_", "(_", ")_", ",_", "self_", "._", "input", "VT", "KS", "elect", "or_", "._", "current", "Node_", "(_", ")_", ",_", "self_", "._", "number", "Of", "Iterations", "_", ",_", "self_", "._", "bone", "Threshold_", ",_", "self_", "._", "output", "Selector_", "._", "current", "Node_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Relo", "ad_", "(_", "self_", ",_", "module", "Name_", "=_", "\"", "Lun", "g", "Registration", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Gene", "ric", " ", "relo", "ad", " ", "method", " ", "for", " ", "any", " ", "script", "ed", " ", "module", ".", "\\", "10", ";", " ", " ", " ", " ", "Modul", "e", "Wiz", "ard", " ", "will", " ", "subs", "itut", "e", " ", "correct", " ", "default", " ", "module", "Name", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "imp_", ",_", "sys_", ",_", "os_", ",_", "slicer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "widget", "Name_", "=_", "module", "Name_", "+_", "\"", "Wid", "get", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "relo", "ad", " ", "the", " ", "source", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "set", " ", "source", " ", "file", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "load", " ", "the", " ", "module", " ", "to", " ", "the", " ", "global", " ", "space_", "\\u\\u\\uNL\\u\\u\\u_", "file", "Path_", "=_", "eval_", "(_", "'", "slicer", ".", "module", "s", ".", "%", "s", ".", "path", "'_", "%_", "module", "Name_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "file", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "sys_", "._", "path_", "._", "\\u\\u", "contains\\u\\u_", "(_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fp_", "=_", "open_", "(_", "file", "Path_", ",_", "\"", "r", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "globals_", "(_", ")_", "[_", "module", "Name_", "]_", "=_", "imp_", "._", "load", "\\u", "module_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "module", "Name_", ",_", "fp_", ",_", "file", "Path_", ",_", "(_", "'.", "py", "'_", ",_", "'", "r", "'_", ",_", "imp_", "._", "PY", "\\u", "SOURCE_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rebu", "ild", " ", "the", " ", "widget_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "find", " ", "and", " ", "hide", " ", "the", " ", "exist", "ing", " ", "widget_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "create", " ", "a", " ", "new", " ", "widget", " ", "in", " ", "the", " ", "exist", "ing", " ", "parent_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "=_", "slicer", "_", "._", "util_", "._", "find", "Children_", "(_", "name_", "=_", "'%", "s", " ", "Relo", "ad", "'_", "%_", "module", "Name_", ")_", "[_", "0_", "]_", "._", "parent_", "(_", ")_", "._", "parent_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "parent_", "._", "children_", "(_", ")_", ":_", "\\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 ", " _", "child_", "._", "hide_", "(_", ")_", "\\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_", "#", " ", "Remove", " ", "spacer", " ", "items_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "item_", "=_", "parent_", "._", "layout_", "(_", ")_", "._", "item", "At_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "._", "layout_", "(_", ")_", "._", "remove", "Item_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "parent_", "._", "layout_", "(_", ")_", "._", "item", "At_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "delete", " ", "the", " ", "old", " ", "widget", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "globals_", "(_", ")_", "[_", "'", "slicer", "'_", "]_", "._", "modules_", ",_", "widget", "Name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "getattr_", "(_", "globals_", "(_", ")_", "[_", "'", "slicer", "'_", "]_", "._", "modules_", ",_", "widget", "Name_", ")_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "new", " ", "widget", " ", "insi", "de", " ", "exist", "ing", " ", "parent_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "globals_", "(_", ")_", "[_", "widget", "Name_", "._", "lower_", "(_", ")_", "]_", "=_", "eval_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "globals", "()[", "\"%", "s", "\"]", ".", "%", "s", "(", "parent", ")'_", "%_", "(_", "module", "Name_", ",_", "widget", "Name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "globals_", "(_", ")_", "[_", "widget", "Name_", "._", "lower_", "(_", ")_", "]_", "._", "setup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "setattr_", "(_", "globals_", "(_", ")_", "[_", "'", "slicer", "'_", "]_", "._", "modules_", ",_", "widget", "Name_", ",_", "globals_", "(_", ")_", "[_", "widget", "Name_", "._", "lower_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Widget_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Relo", "ad", "And", "Test_", "(_", "self_", ",_", "module", "Name_", "=_", "\"", "Lun", "g", "Registration", "\"_", ")_", ":_", "\\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_", "._", "on", "Relo", "ad_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "eval", "String_", "=_", "'", "globals", "()[", "\"%", "s", "\"]", ".", "%", "s", "Test", "()'_", "%_", "(_", "module", "Name_", ",_", "module", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tester_", "=_", "eval_", "(_", "eval", "String_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tester_", "._", "run", "Test_", "(_", ")_", "\\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 ", " _", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qt_", "._", "QM", "essage", "Box_", "._", "warning_", "(_", "slicer", "_", "._", "util_", "._", "main", "Window_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Relo", "ad", " ", "and", " ", "Test", "\"_", ",_", "'", "Except", "ion", "!\\\\", "n", "\\\\", "n", "'_", "+_", "str_", "(_", "e_", ")_", "+_", "\"\\\\", "n", "\\\\", "n", "See", " ", "Pyth", "on", " ", "Cons", "ole", " ", "for", " ", "Stack", " ", "Trace", "\"_", ")_", "\\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_", "Lun", "g", "Registration", "Logic_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Thi", "s", " ", "class", " ", "shou", "ld", " ", "implement", " ", "all", " ", "the", " ", "actual", " ", "\\", "10", ";", " ", " ", "computation", " ", "don", "e", " ", "by", " ", "your", " ", "module", ".", " ", " ", "The", " ", "interface", " ", "\\", "10", ";", " ", " ", "shou", "ld", " ", "be", " ", "suc", "h", " ", "tha", "t", " ", "other", " ", "python", " ", "code", " ", "can", " ", "import", "\\", "10", ";", " ", " ", "this", " ", "class", " ", "and", " ", "make", " ", "use", " ", "of", " ", "the", " ", "functional", "it", "y", " ", "with", "out", "\\", "10", ";", " ", " ", "requi", "ring", " ", "an", " ", "instance", " ", "of", " ", "the", " ", "Wid", "get", "\\", "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\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Logic_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Logic_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "has", "Image", "Data_", "(_", "self_", ",_", "volume", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Thi", "s", " ", "is", " ", "a", " ", "dummy", " ", "logic", " ", "method", " ", "tha", "t", " ", "\\", "10", ";", " ", " ", " ", " ", "return", "s", " ", "true", " ", "if", " ", "the", " ", "pass", "ed", " ", "in", " ", "volume", "\\", "10", ";", " ", " ", " ", " ", "node", " ", "has", " ", "valid", " ", "image", " ", "data", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "volume", "Node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "no", " ", "volume", " ", "node", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "volume", "Node_", "._", "Get", "Image", "Data_", "(_", ")_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "no", " ", "image", " ", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Logic_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "input", "Volume_", ",_", "atlas", "Volume_", ",_", "convex", "Hul", "l", "Volume_", ",_", "num", "Iterations", "_", ",_", "bone", "Threshold_", ",_", "out", "Volume_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "the", " ", "actual", " ", "algo", "rit", "hm", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "In", " ", "Run", " ", "method", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Generate", " ", "Atla", "s", " ", "convex", " ", "Hul", "l", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "convex", "Hul", "l", "Volume", " ", "=", " ", "\"~/", "Test", "Conve", "x", "Hul", "l", ".", "vtk", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "clip", "aram", "eter", "s", " ", "=", " ", "{_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "left", "Atla", "s", "File", "Name", "\"", " ", ":", " ", "left", "Atla", "s", "Volume", ".", "Get", "ID", "()", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "right", "Atla", "s", "File", "Name", "\"", " ", ":", " ", "right", "Atla", "s", "Volume", ".", "Get", "ID", "()", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "downsample", "Factor", "\"", " ", ":", " ", "4", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "output", "File", "Name", "\"", " ", ":", " ", "out", "Model", ".", "Get", "ID", "()", ",", " ", "#\"", "~", "/", "Test", "Conve", "x", "Hul", "l", ".", "vtk", "\",", " ", " ", " ", "***", " ", "shou", "ld", " ", "be", " ", "a", " ", "vtk", " ", "file", " _", "\\u\\u\\uNL\\u\\u\\u_", "#}", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Generate", "Atla", "s", "Conve", "x", "Hul", "l", " ", "=", " ", "slicer", ".", "module", "s", ".", "generat", "eat", "las", "convex", "hull", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "slicer", ".", "cli", ".", "run", "(", "Generate", "Atla", "s", "Conve", "x", "Hul", "l", ",", "Non", "e", ",", " ", "clip", "aram", "eter", "s", ",", " ", "wait", "\\u", "for", "\\u", "completion", "=", "Tru", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "C", ":\\\\", "Ches", "t", "Imagin", "g", "Plat", "form", "Priva", "te", "\\\\", "Build", "\\\\", "bin", "\\\\", "Deb", "ug", ">", "Register", "Lun", "g", "Atla", "s", " ", "-", "i", " ", "200", " ", "-", "m", " ", "D", ":/", "Po", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "std", "oc", "/", "Data", "/", "Lun", "g", "Atla", "ses", "/", "atlas", "Conve", "x", "Hul", "l", ".", "vtk", " ", "-", "c", " ", " ", "D", ":/", "Post", "doc", "/", "Data", "/", "103", "60", "K", "/", "103", "60", "Kin", "sp_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", ".", "nh", "dr", " ", "-", "o", " ", "d", ":/", "Post", "doc", "/", "Data", "/", "103", "60", "K", "/", "Atla", "s", "To", "103", "60", "Kin", "sp", ".", "tf", "m_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Call", " ", "Register", "Lun", "g", "Atla", "s", " ", "cli", ",", " ", "tf", "m", " ", "intermediate", " ", "file", " ", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Define", " ", "temporar", "y", " ", ".", "tf", "m", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "qt_", "._", "QT", "emp", "ora", "ry", "File_", "(_", "slicer", "_", "._", "app_", "._", "temporar", "y", "Path_", "+_", "\"/", "Register", "Lun", "g", "Atla", "s", "-", "XXXXXX", ".", "tf", "m", "\"_", ")_", "#", "slicer", ".", "app", ".", "temporar", "y", "Path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "open_", "(_", ")_", "#", " ", "Creat", "e", " ", "the", " ", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "model", " ", "node", " ", "by", " ", "ID_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Node_", "=_", "slicer", "_", "._", "mr", "ml", "Scene_", "._", "Get", "Node", "By", "ID_", "(_", "convex", "Hul", "l", "Volume_", "._", "Get", "ID_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly", "Data_", "=_", "model", "Node_", "._", "Get", "Poly", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "clip", "aram", "eter", "s_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "convex", "Hul", "l", "Mesh", "File", "Name", "'_", "]_", "=_", "convex", "Hul", "l", "Volume_", "._", "Get", "ID_", "(_", ")_", "#", "model", "Node", ".", "Get", "ID", "()", " ", "#\"", "\"/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "Lun", "g", "Atla", "ses", "/", "atlas", "Conve", "x", "Hul", "l", ".", "vtk", "\"", " ", "#", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "number", "Of", "Iterations", "'_", "]_", "=_", "num", "Iterations", "_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "bone", "Thresh", "old", "'_", "]_", "=_", "bone", "Threshold_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "output", "Transform", "File", "Name", "'_", "]_", "=_", "f_", "._", "file", "Name_", "(_", ")_", "#\"", "/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "temp", "data", "/", "Test", "6", ".", "tf", "m", "\"", " ", "#", "output", "Transform", ",", " ", "slicer", ".", "app", ".", "temporar", "ypa", "th_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "ct", "File", "Name", "'_", "]_", "=_", "input", "Volume_", "._", "Get", "ID_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "clip", "aram", "eter", "s", "['", "ct", "File", "Name", "']", " ", "=", " ", "\"/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "COP", "DG", "ene", "/", "149", "88", "Y", "/", "149", "88", "Y", "\\u", "INS", "P", "\\u", "STD", "\\u", "UA", "B", "\\u", "COP", "D", "/", "149", "88", "Y", "\\u", "INS", "P", "\\u", "STD", "\\u", "UA", "B", "\\u", "COP", "D", "\\u", "downsample", "d", ".", "nr", "rd", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "destruct", "or", " ", "delete", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Register", "Lun", "g", "Atla", "s_", "=_", "slicer", "_", "._", "modules_", "._", "register", "lun", "gat", "las", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cli", "Node_", "=_", "slicer", "_", "._", "cli_", "._", "run_", "(_", "Register", "Lun", "g", "Atla", "s_", ",_", "None_", ",_", "clip", "aram", "eter", "s_", ",_", "wait", "\\u", "for", "\\u", "completion_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Call", " ", "Res", "ample", "Label", "Map", " ", "cli", ",", " ", "save", " ", "the", " ", "output", " ", "volume", " ", "direct", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "#\"", "\"\"_", "\\u\\u\\uNL\\u\\u\\u_", "##", "Res", "ample", "Label", "Map", ".", "exe", " ", "-", "d", " ", "D", ":/", "Post", "doc", "/", "Data", "/", "103", "60", "K", "/", "103", "60", "Kin", "sp", ".", "nh", "dr", " ", "-", "r", " ", "D", ":/", "Post", "doc", "/", "Data", "/", "103", "60", "K", "/", "103", "60", "Kl", "eft", "Atla", "s", ".", "nr", "rd", " ", "-", "t", " _", "\\u\\u\\uNL\\u\\u\\u_", "##", "D", ":/", "Post", "doc", "/", "Data", "/", "103", "60", "K", "/", "Atla", "s", "To", "103", "60", "Kin", "sp", ".", "tf", "m", " ", "-", "l", " ", "D", ":/", "Post", "doc", "/", "Data", "/", "Lun", "g", "Atla", "ses", "/", "left", "Lun", "g", "Atla", "s", ".", "nh", "dr_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "clip", "aram", "eter", "s_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "label", "Map", "File", "Name", "'_", "]_", "=_", "atlas", "Volume_", "._", "Get", "ID_", "(_", ")_", "#", " ", "\"/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "Lun", "g", "Atla", "ses", "/", "left", "Lun", "g", "Atla", "s", ".", "nh", "dr", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "transform", "File", "Name", "'_", "]_", "=_", "f_", "._", "file", "Name_", "(_", ")_", "#\"", "/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "temp", "data", "/", "Test", "6", ".", "tf", "m", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "resample", "d", "File", "Name", "'_", "]_", "=_", "out", "Volume_", "._", "Get", "ID_", "(_", ")_", "#\"", "~", "/", "Test", ".", "nr", "rd", "\"", " ", " ", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "destinat", "ion", "File", "Name", "'_", "]_", "=_", "input", "Volume_", "._", "Get", "ID_", "(_", ")_", "#\"", "/", "User", "s", "/", "rol", "aha", "rmo", "uche", "/", "Document", "s", "/", "Data", "/", "COP", "DG", "ene", "/", "149", "88", "Y", "/", "149", "88", "Y", "\\u", "INS", "P", "\\u", "STD", "\\u", "UA", "B", "\\u", "COP", "D", "/", "149", "88", "Y", "\\u", "INS", "P", "\\u", "STD", "\\u", "UA", "B", "\\u", "COP", "D", "\\u", "downsample", "d", ".", "nr", "rd", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clip", "aram", "eter", "s_", "[_", "'", "is", "Invert", "Transformation", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Res", "ample", "Label", "Map_", "=_", "slicer", "_", "._", "modules_", "._", "resample", "label", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cli", "Node_", "=_", "slicer", "_", "._", "cli_", "._", "run_", "(_", "Res", "ample", "Label", "Map_", ",_", "None_", ",_", "clip", "aram", "eter", "s_", ",_", "wait", "\\u", "for", "\\u", "completion_", "=_", "True_", ")_", ",_", "#", "use", " ", "qt", " ", "assistan", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Lun", "g", "Registration", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", "Thi", "s", " ", "is", " ", "the", " ", "test", " ", "case", " ", "for", " ", "your", " ", "script", "ed", " ", "module", ".", "\\", "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_", "[SEP]_", "class_", "Lun", "g", "Registration", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "dela", "y", "Display_", "(_", "self_", ",_", "message_", ",_", "msec", "_", "=_", "1000_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Thi", "s", " ", "utility", " ", "method", " ", "display", "s", " ", "a", " ", "small", " ", "dialog", " ", "and", " ", "waits", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "doe", "s", " ", "two", " ", "thing", "s", ":", " ", "1", ")", " ", "it", " ", "lets", " ", "the", " ", "event", " ", "loop", " ", "catch", " ", "up", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "state", " ", "of", " ", "the", " ", "test", " ", "so", " ", "tha", "t", " ", "render", "ing", " ", "and", " ", "widget", " ", "update", "s", "\\", "10", ";", " ", " ", " ", " ", "have", " ", "all", " ", "take", "n", " ", "place", " ", "bef", "ore", " ", "the", " ", "test", " ", "continue", "s", " ", "and", " ", "2", ")", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "show", "s", " ", "the", " ", "user", "/", "developer", "/", "teste", "r", " ", "the", " ", "state", " ", "of", " ", "the", " ", "test", "\\", "10", ";", " ", " ", " ", " ", "so", " ", "tha", "t", " ", "we", "'", "ll", " ", "know", " ", "whe", "n", " ", "it", " ", "breaks", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info_", "=_", "qt_", "._", "QD", "ial", "og_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info", "Layout_", "=_", "qt_", "._", "QV", "Box", "Layout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info_", "._", "set", "Layout_", "(_", "self_", "._", "info", "Layout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "qt_", "._", "QL", "abel_", "(_", "message_", ",_", "self_", "._", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info", "Layout_", "._", "add", "Widget_", "(_", "self_", "._", "label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qt_", "._", "QT", "ime", "r_", "._", "single", "Shot", "_", "(_", "msec", "_", ",_", "self_", "._", "info_", "._", "close_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "info_", "._", "exec\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Test_", "(_", "unittest_", "._", "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_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Do", " ", "what", "ever", " ", "is", " ", "need", "ed", " ", "to", " ", "reset", " ", "the", " ", "state", " ", "-", " ", "typical", "ly", " ", "a", " ", "scen", "e", " ", "clear", " ", "will", " ", "be", " ", "eno", "ugh", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slicer", "_", "._", "mr", "ml", "Scene_", "._", "Clear_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "Test_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Run", " ", "as", " ", "few", " ", "or", " ", "as", " ", "many", " ", "tests", " ", "as", " ", "need", "ed", " ", "here", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Up_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "test\\u", "Lun", "g", "Registration", "1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Lun", "g", "Registration", "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", "Lun", "g", "Registration", "1_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Ideal", "ly", " ", "you", " ", "shou", "ld", " ", "have", " ", "sever", "al", " ", "level", "s", " ", "of", " ", "tests", ".", " ", " ", "At", " ", "the", " ", "lowe", "st", " ", "level", "\\", "10", ";", " ", " ", " ", " ", "tests", " ", "sou", "ld", " ", "exercise", " ", "the", " ", "functional", "it", "y", " ", "of", " ", "the", " ", "logic", " ", "with", " ", "different", " ", "inputs", "\\", "10", ";", " ", " ", " ", " ", "(", "bot", "h", " ", "valid", " ", "and", " ", "invalid", ").", " ", " ", "At", " ", "higher", " ", "level", "s", " ", "your", " ", "tests", " ", "shou", "ld", " ", "emulate", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "way", " ", "the", " ", "user", " ", "wou", "ld", " ", "interact", " ", "with", " ", "your", " ", "code", " ", "and", " ", "confirm", " ", "tha", "t", " ", "it", " ", "still", " ", "works", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "way", " ", "you", " ", "inten", "ded", ".", "\\", "10", ";", " ", " ", " ", " ", "One", " ", "of", " ", "the", " ", "most", " ", "importa", "nt", " ", "features", " ", "of", " ", "the", " ", "tests", " ", "is", " ", "tha", "t", " ", "it", " ", "shou", "ld", " ", "alert", " ", "other", "\\", "10", ";", " ", " ", " ", " ", "developer", "s", " ", "whe", "n", " ", "thei", "r", " ", "change", "s", " ", "will", " ", "have", " ", "an", " ", "impact", " ", "on", " ", "the", " ", "behavior", " ", "of", " ", "your", "\\", "10", ";", " ", " ", " ", " ", "module", ".", " ", " ", "For", " ", "example", ",", " ", "if", " ", "a", " ", "developer", " ", "remove", "s", " ", "a", " ", "feature", " ", "tha", "t", " ", "you", " ", "depend", " ", "on", ",", "\\", "10", ";", " ", " ", " ", " ", "your", " ", "test", " ", "shou", "ld", " ", "break", " ", "so", " ", "the", "y", " ", "know", " ", "tha", "t", " ", "the", " ", "feature", " ", "is", " ", "need", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "dela", "y", "Display_", "(_", "\"", "Start", "ing", " ", "the", " ", "test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "first", ",", " ", "get", " ", "some", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "downloads_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "http", "://", "slicer", ".", "kit", "ware", ".", "com", "/", "mid", "as", "3", "/", "download", "?", "items", "=", "576", "7", "'_", ",_", "'", "FA", ".", "nr", "rd", "'_", ",_", "slicer", "_", "._", "util_", "._", "load", "Volume_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "url_", ",_", "name_", ",_", "loader_", "in_", "downloads_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file", "Path_", "=_", "slicer", "_", "._", "app_", "._", "temporar", "y", "Path_", "+_", "'/'_", "+_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "file", "Path_", ")_", "or_", "os_", "._", "stat_", "(_", "file", "Path_", ")_", "._", "st", "\\u", "size_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Request", "ing", " ", "download", " ", "%", "s", " ", "from", " ", "%", "s", "...", "\\\\", "n", "'_", "%_", "(_", "name_", ",_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "urllib_", "._", "urlretrieve_", "(_", "url_", ",_", "file", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "loader_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Load", "ing", " ", "%", "s", "...", "\\\\", "n", "'_", "%_", "(_", "name_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loader_", "(_", "file", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "dela", "y", "Display_", "(_", "'", "Finish", "ed", " ", "with", " ", "download", " ", "and", " ", "load", "ing", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "volume", "Node_", "=_", "slicer", "_", "._", "util_", "._", "get", "Node_", "(_", "pattern_", "=_", "\"", "FA", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logic_", "=_", "Lun", "g", "Registration", "Logic_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "logic_", "._", "has", "Image", "Data_", "(_", "volume", "Node_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dela", "y", "Display_", "(_", "'", "Test", " ", "pass", "ed", "!'_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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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 ]
Unused import
catap/namebench/tools/alexa-subdomains.py
[ { "content": "#!/usr/bin/env python\n# Copyright 2009 Google Inc. All Rights Reserved.\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\"\"\"Subdomain data parser for Alexa.\"\"\"\n\n__author__ = '[email protected] (Thomas Stromberg)'\n\nimport glob\nimport operator\nimport os\nimport os.path\nimport re\nimport sys\nimport time\n\nif __name__ == '__main__':\n sys.path.append('..')\n \n# See if a third_party library exists -- use it if so.\ntry:\n import third_party\nexcept ImportError:\n pass\n\n\nimport httplib2\n\nCACHE_DIR = os.getenv('HOME') + '/.alexa_cache'\nCACHE_EXPIRATION = 86400 * 90\nSLEEPY_TIME = 15\nMAX_ATTEMPTS = 5\n\nNAKED_DOMAINS = ['twitter.com', 'rapidshare.com', 'perezhilton.com', 'posterous.com']\n\n \n \n \n \nif __name__ == '__main__':\n index = 0\n results = {}\n \n for domain in sys.stdin:\n index += 1\n domain = domain.rstrip()\n for host, percentage in GetHostsForDomain(domain):\n if host == domain and domain not in NAKED_DOMAINS:\n host = '.'.join(('www', domain))\n if percentage == '0.0':\n continue\n score = index / (float(percentage) / 100)\n if host not in results:\n results[host] = score\n print >> sys.stderr, \"%s: %s (%s)\" % (score, host, percentage)\n\n for host, score in sorted(results.items(), key=operator.itemgetter(1)):\n print \"A %s.\" % host\n\n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def FetchUrl(url, attempts=0):\n attempts += 1\n print >> sys.stderr, \"Fetching %s (attempt %s)\" % (url, attempts)\n h = httplib2.Http(CACHE_DIR, timeout=10)\n try:\n resp, content = h.request(url, 'GET', headers={'cache_control': 'max-age=%s' % CACHE_EXPIRATION})\n except:\n if attempts < MAX_ATTEMPTS:\n print >> sys.stderr, \"Will try again...\"\n time.sleep(SLEEPY_TIME)\n return FetchUrl(url, attempts=attempts)\n \n time.sleep(SLEEPY_TIME)\n return content", "metadata": "root.FetchUrl", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def FetchCachedAlexaPage(domain):\n url_path = 'www.alexa.com/siteinfo/%s' % domain\n cache_path = '%s/%s' % (CACHE_DIR, url_path.replace('/', ','))\n for file in glob.glob(\"%s,*\" % cache_path):\n f = open(file)\n return f.read()\n \n # If we haven't returned already...\n return FetchUrl(\"http://%s\" % url_path)", "metadata": "root.FetchCachedAlexaPage", "header": "['module', '___EOS___']", "index": 61 }, { "content": "def ParseAlexaSubdomains(content):\n return re.findall('\\<p class=\\\"tc1.*?>([\\w\\.-]+\\.[\\w]{2,})\\<\\/p>.*?tc1.*?(\\d+\\.\\d+)%', content, re.M | re.S)", "metadata": "root.ParseAlexaSubdomains", "header": "['module', '___EOS___']", "index": 71 }, { "content": "def GetHostsForDomain(domain):\n content = FetchCachedAlexaPage(domain)\n return ParseAlexaSubdomains(content)", "metadata": "root.GetHostsForDomain", "header": "['module', '___EOS___']", "index": 74 } ]
[ { "span": "import third_party", "start_line": 32, "start_column": 2, "end_line": 32, "end_column": 20 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "200", "9", " ", "Goo", "gle", " ", "Inc", ".", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d", "._", "\\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_", "\"\"\"", "Subd", "omain", " ", "data", " ", "parser", " ", "for", " ", "Alexa", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "'", "tstr", "omb", "erg", "@", "google", ".", "com", " ", "(", "Tho", "mas", " ", "Str", "omb", "erg", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "glob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "operator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\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 ", " _", "sys_", "._", "path_", "._", "append_", "(_", "'..'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "if", " ", "a", " ", "third", "\\u", "part", "y", " ", "librar", "y", " ", "exist", "s", " ", "--", " ", "use", " ", "it", " ", "if", " ", "so", "._", "\\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_", "third", "\\u", "party_", "\\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\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "httplib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "CACHE", "\\u", "DIR_", "=_", "os_", "._", "getenv_", "(_", "'", "HOM", "E", "'_", ")_", "+_", "'/.", "alex", "a", "\\u", "cache", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CACHE", "\\u", "EXP", "IRA", "TION_", "=_", "86400_", "*_", "90_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SLEEP", "Y", "\\u", "TIME_", "=_", "15_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "MAX", "\\u", "ATTE", "MPT", "S_", "=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "NA", "KE", "D", "\\u", "DOM", "AINS", "_", "=_", "[_", "'", "twit", "ter", ".", "com", "'_", ",_", "'", "rapid", "share", ".", "com", "'_", ",_", "'", "per", "ez", "hil", "ton", ".", "com", "'_", ",_", "'", "poster", "ous", ".", "com", "'_", "]_", "\\u\\u\\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_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "domain_", "in_", "sys_", "._", "stdin_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain_", "=_", "domain_", "._", "rstrip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "host_", ",_", "percentage_", "in_", "Get", "Host", "s", "For", "Domain_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "host_", "==_", "domain_", "and_", "domain_", "not_", "in_", "NA", "KE", "D", "\\u", "DOM", "AINS", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "host_", "=_", "'.'_", "._", "join_", "(_", "(_", "'", "www", "'_", ",_", "domain_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "percentage_", "==_", "'", "0.", "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_", "score_", "=_", "index_", "/_", "(_", "float_", "(_", "percentage_", ")_", "/_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "host_", "not_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "[_", "host_", "]_", "=_", "score_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"%", "s", ":", " ", "%", "s", " ", "(%", "s", ")\"_", "%_", "(_", "score_", ",_", "host_", ",_", "percentage_", ")_", "\\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_", "host_", ",_", "score_", "in_", "sorted_", "(_", "results_", "._", "items_", "(_", ")_", ",_", "key_", "=_", "operator_", "._", "itemgetter_", "(_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "A", " ", "%", "s", ".\"_", "%_", "host_", "\\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_", "Fe", "tch", "Url_", "(_", "url_", ",_", "attempts_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attempts_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "Fe", "tch", "ing", " ", "%", "s", " ", "(", "atte", "mpt", " ", "%", "s", ")\"_", "%_", "(_", "url_", ",_", "attempts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "=_", "httplib2_", "._", "Http_", "(_", "CACHE", "\\u", "DIR_", ",_", "timeout_", "=_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resp_", ",_", "content_", "=_", "h_", "._", "request_", "(_", "url_", ",_", "'", "GET", "'_", ",_", "headers_", "=_", "{_", "'", "cache", "\\u", "control", "'_", ":_", "'", "max", "-", "age", "=", "%", "s", "'_", "%_", "CACHE", "\\u", "EXP", "IRA", "TION_", "}_", ")_", "\\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_", "attempts_", "<_", "MAX", "\\u", "ATTE", "MPT", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "Wil", "l", " ", "try", " ", "again", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "SLEEP", "Y", "\\u", "TIME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Fe", "tch", "Url_", "(_", "url_", ",_", "attempts_", "=_", "attempts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "SLEEP", "Y", "\\u", "TIME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "content_", "\\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_", "Fe", "tch", "Cache", "d", "Alexa", "Page_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "path_", "=_", "'", "www", ".", "alex", "a", ".", "com", "/", "site", "info", "/", "%", "s", "'_", "%_", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "\\u", "path_", "=_", "'%", "s", "/", "%", "s", "'_", "%_", "(_", "CACHE", "\\u", "DIR_", ",_", "url", "\\u", "path_", "._", "replace_", "(_", "'/'_", ",_", "','_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "file_", "in_", "glob_", "._", "glob_", "(_", "\"%", "s", ",*", "\"_", "%_", "cache", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f_", "=_", "open_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "have", "n", "'", "t", " ", "return", "ed", " ", "alr", "ead", "y", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Fe", "tch", "Url_", "(_", "\"", "http", "://", "%", "s", "\"_", "%_", "url", "\\u", "path_", ")_", "\\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_", "Pars", "e", "Alexa", "Subd", "omain", "s_", "(_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "re_", "._", "findall_", "(_", "'\\\\", "<", "p", " ", "class", "=\\\\\"", "tc", "1", ".*?", ">([", "\\\\", "w", "\\\\.", "-]+", "\\\\.", "[\\\\", "w", "]{", "2", ",}", ")\\\\", "<\\\\", "/", "p", ">.*?", "tc", "1", ".*?", "(\\\\", "d", "+\\\\.", "\\\\", "d", "+)", "%'_", ",_", "content_", ",_", "re_", "._", "M_", "|_", "re_", "._", "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_", "Get", "Host", "s", "For", "Domain_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "content_", "=_", "Fe", "tch", "Cache", "d", "Alexa", "Page_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Pars", "e", "Alexa", "Subd", "omain", "s_", "(_", "content_", ")_", "\\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,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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 ]
Unused local variable
aigamedev/scikit-neuralnetwork/sknn/tests/test_conv.py
[ { "content": " def _run(self, activation):\n a_in, a_out = numpy.zeros((8,32,16,1)), numpy.zeros((8,4))\n nn = MLPR(\n layers=[\n C(activation, channels=4, kernel_shape=(3,3),\n pool_shape=(2,2), pool_type='mean'),\n L(\"Linear\")],\n n_iter=1)\n nn.fit(a_in, a_out)\n a_test = nn.predict(a_in)\n assert_equal(type(a_out), type(a_in))", "metadata": "root.TestActivationTypes._run", "header": "['class', 'TestActivationTypes', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 222 }, { "content": " def _run(self, nn, a_in=None):\n if a_in is None:\n a_in = numpy.zeros((8,32,16,1))\n a_out = numpy.zeros((8,4))\n\n nn.fit(a_in, a_out)\n a_test = nn.predict(a_in)\n assert_equal(type(a_out), type(a_in))", "metadata": "root.TestConvolutionRGB._run", "header": "['class', 'TestConvolutionRGB', '(', 'TestConvolution', ')', ':', '___EOS___']", "index": 255 } ]
[ { "span": "a_test ", "start_line": 231, "start_column": 8, "end_line": 231, "end_column": 14 }, { "span": "a_test ", "start_line": 261, "start_column": 8, "end_line": 261, "end_column": 14 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Activat", "ion", "Types_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "run_", "(_", "self_", ",_", "activation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a", "\\u", "in_", ",_", "a", "\\u", "out_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "8_", ",_", "32_", ",_", "16_", ",_", "1_", ")_", ")_", ",_", "numpy_", "._", "zeros_", "(_", "(_", "8_", ",_", "4_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nn_", "=_", "MLP", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "layers_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "C_", "(_", "activation_", ",_", "channels_", "=_", "4_", ",_", "kernel", "\\u", "shape_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pool", "\\u", "shape_", "=_", "(_", "2_", ",_", "2_", ")_", ",_", "pool", "\\u", "type_", "=_", "'", "mean", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "L_", "(_", "\"", "Linea", "r", "\"_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "n", "\\u", "iter_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nn_", "._", "fit_", "(_", "a", "\\u", "in_", ",_", "a", "\\u", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a", "\\u", "test_", "=_", "nn_", "._", "predict_", "(_", "a", "\\u", "in_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "equal_", "(_", "type_", "(_", "a", "\\u", "out_", ")_", ",_", "type_", "(_", "a", "\\u", "in_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Convolution", "RGB_", "(_", "Test", "Convolution", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u", "run_", "(_", "self_", ",_", "nn_", ",_", "a", "\\u", "in_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "a", "\\u", "in_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a", "\\u", "in_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "8_", ",_", "32_", ",_", "16_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a", "\\u", "out_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "8_", ",_", "4_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nn_", "._", "fit_", "(_", "a", "\\u", "in_", ",_", "a", "\\u", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a", "\\u", "test_", "=_", "nn_", "._", "predict_", "(_", "a", "\\u", "in_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "equal_", "(_", "type_", "(_", "a", "\\u", "out_", ")_", ",_", "type_", "(_", "a", "\\u", "in_", ")_", ")_", "\\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, 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, 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, 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 ]
Unused import
itdxer/neupy/tests/plots/test_hinton.py
[ { "content": "import os\n\nimport six\nimport numpy as np\nimport theano\nimport matplotlib.pyplot as plt\n\nfrom neupy import plots\n\nfrom base import BaseTestCase\nfrom utils import (skip_image_comparison_if_specified, image_comparison,\n format_image_name)\n\n\nIMGDIR = os.path.join(\"plots\", \"images\", \"hinton\")\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class HintonDiagramTestCase(BaseTestCase):\n\n\n\n\n\n", "metadata": "root.HintonDiagramTestCase", "header": "['module', '___EOS___']", "index": 17 }, { "content": " def setUp(self):\n super(HintonDiagramTestCase, self).setUp()\n theano.config.floatX = 'float64'", "metadata": "root.HintonDiagramTestCase.setUp", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 18 }, { "content": " @skip_image_comparison_if_specified\n def test_simple_hinton(self):\n original_image_name = format_image_name(\"simple_hinton.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 6)) as fig:\n weight = np.random.randn(20, 20)\n ax = fig.add_subplot(1, 1, 1)\n plt.sca(ax) # To test the case when ax=None\n plots.hinton(weight, add_legend=True)", "metadata": "root.HintonDiagramTestCase.test_simple_hinton", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 22 }, { "content": " @skip_image_comparison_if_specified\n def test_max_weight(self):\n original_image_name = format_image_name(\"max_weight_hinton.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 6)) as fig:\n weight = 100 * np.random.randn(20, 20)\n ax = fig.add_subplot(1, 1, 1)\n plots.hinton(weight, ax=ax, max_weight=10, add_legend=True)", "metadata": "root.HintonDiagramTestCase.test_max_weight", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 33 }, { "content": " @skip_image_comparison_if_specified\n def test_hinton_without_legend(self):\n original_image_name = format_image_name(\"hinton_without_legend.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 6)) as fig:\n weight = np.random.randn(20, 20)\n ax = fig.add_subplot(1, 1, 1)\n plots.hinton(weight, ax=ax, add_legend=False)", "metadata": "root.HintonDiagramTestCase.test_hinton_without_legend", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 43 }, { "content": " @skip_image_comparison_if_specified\n def test_hinton_only_positive(self):\n original_image_name = format_image_name(\"hinton_only_positive.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 6)) as fig:\n weight = np.random.random((20, 20))\n ax = fig.add_subplot(1, 1, 1)\n plots.hinton(weight, ax=ax)", "metadata": "root.HintonDiagramTestCase.test_hinton_only_positive", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 53 }, { "content": " @skip_image_comparison_if_specified\n def test_hinton_only_negative(self):\n original_image_name = format_image_name(\"hinton_only_negative.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 6)) as fig:\n weight = -np.random.random((20, 20))\n ax = fig.add_subplot(1, 1, 1)\n plots.hinton(weight, ax=ax)", "metadata": "root.HintonDiagramTestCase.test_hinton_only_negative", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 63 }, { "content": " @skip_image_comparison_if_specified\n def test_hinton_1darray(self):\n original_image_name = format_image_name(\"hinton_1darray.png\")\n original_image = os.path.join(IMGDIR, original_image_name)\n\n with image_comparison(original_image, figsize=(10, 4)) as fig:\n weight = -np.random.randn(20)\n ax = fig.add_subplot(1, 1, 1)\n plots.hinton(weight, ax=ax)", "metadata": "root.HintonDiagramTestCase.test_hinton_1darray", "header": "['class', 'HintonDiagramTestCase', '(', 'BaseTestCase', ')', ':', '___EOS___']", "index": 73 } ]
[ { "span": "import six", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "six_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "neu", "py_", "import_", "plots_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "base_", "import_", "Base", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "utils_", "import_", "(_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", ",_", "image", "\\u", "comparison_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "format\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "IMG", "DIR_", "=_", "os_", "._", "path_", "._", "join_", "(_", "\"", "plots", "\"_", ",_", "\"", "images", "\"_", ",_", "\"", "hin", "ton", "\"_", ")_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\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 ", " _", "super_", "(_", "Hint", "on", "Diagram", "Test", "Case_", ",_", "self_", ")_", "._", "set", "Up_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theano_", "._", "config_", "._", "float", "X_", "=_", "'", "float", "64", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "simple", "\\u", "hin", "ton_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "simple", "\\u", "hin", "ton", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "6_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "np_", "._", "random_", "._", "randn_", "(_", "20_", ",_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "sca", "_", "(_", "ax_", ")_", "#", " ", "To", " ", "test", " ", "the", " ", "case", " ", "whe", "n", " ", "ax", "=", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "add", "\\u", "legend_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "max", "\\u", "weight_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "max", "\\u", "weight", "\\u", "hin", "ton", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "6_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "100_", "*_", "np_", "._", "random_", "._", "randn_", "(_", "20_", ",_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "ax_", "=_", "ax_", ",_", "max", "\\u", "weight_", "=_", "10_", ",_", "add", "\\u", "legend_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "hin", "ton", "\\u", "with", "out", "\\u", "legend_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "hin", "ton", "\\u", "with", "out", "\\u", "legend", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "6_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "np_", "._", "random_", "._", "randn_", "(_", "20_", ",_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "ax_", "=_", "ax_", ",_", "add", "\\u", "legend_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "hin", "ton", "\\u", "only", "\\u", "positive_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "hin", "ton", "\\u", "only", "\\u", "posit", "ive", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "6_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "np_", "._", "random_", "._", "random_", "(_", "(_", "20_", ",_", "20_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "ax_", "=_", "ax_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "hin", "ton", "\\u", "only", "\\u", "negative_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "hin", "ton", "\\u", "only", "\\u", "negati", "ve", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "6_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "-_", "np_", "._", "random_", "._", "random_", "(_", "(_", "20_", ",_", "20_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "ax_", "=_", "ax_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Hint", "on", "Diagram", "Test", "Case_", "(_", "Base", "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_", "@_", "skip", "\\u", "image", "\\u", "compa", "ris", "on", "\\u", "if", "\\u", "specified", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "hin", "ton", "\\u", "1d", "array_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "original", "\\u", "image", "\\u", "name_", "=_", "format\\u", "image", "\\u", "name_", "(_", "\"", "hin", "ton", "\\u", "1d", "array", ".", "png", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "original", "\\u", "image_", "=_", "os_", "._", "path_", "._", "join_", "(_", "IMG", "DIR_", ",_", "original", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "image", "\\u", "comparison_", "(_", "original", "\\u", "image_", ",_", "figsize_", "=_", "(_", "10_", ",_", "4_", ")_", ")_", "as_", "fig_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "weight_", "=_", "-_", "np_", "._", "random_", "._", "randn_", "(_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "=_", "fig_", "._", "add", "\\u", "subplot_", "(_", "1_", ",_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plots_", "._", "hin", "ton_", "(_", "weight_", ",_", "ax_", "=_", "ax_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 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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 ]
Unnecessary pass
zzzeek/sqlalchemy/lib/sqlalchemy/dialects/mysql/base.py
[ { "content": " @reflection.cache\n def get_indexes(self, connection, table_name, schema=None, **kw):\n\n parsed_state = self._parsed_state_or_create(\n connection, table_name, schema, **kw)\n\n indexes = []\n for spec in parsed_state.keys:\n unique = False\n flavor = spec['type']\n if flavor == 'PRIMARY':\n continue\n if flavor == 'UNIQUE':\n unique = True\n elif flavor in (None, 'FULLTEXT', 'SPATIAL'):\n pass\n else:\n self.logger.info(\n \"Converting unknown KEY type %s to a plain KEY\", flavor)\n pass\n index_d = {}\n index_d['name'] = spec['name']\n index_d['column_names'] = [s[0] for s in spec['columns']]\n index_d['unique'] = unique\n if flavor:\n index_d['type'] = flavor\n indexes.append(index_d)\n return indexes", "metadata": "root.MySQLDialect.get_indexes", "header": "['class', 'MySQLDialect', '(', 'default', '.', 'DefaultDialect', ')', ':', '___EOS___']", "index": 1752 } ]
[ { "span": "pass", "start_line": 1771, "start_column": 16, "end_line": 1771, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "class_", "My", "SQL", "Dial", "ect_", "(_", "default_", "._", "Default", "Dial", "ect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "reflection_", "._", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "indexes_", "(_", "self_", ",_", "connection_", ",_", "table", "\\u", "name_", ",_", "schema_", "=_", "None_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parsed", "\\u", "state_", "=_", "self_", "._", "\\u", "parsed", "\\u", "state", "\\u", "or", "\\u", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "connection_", ",_", "table", "\\u", "name_", ",_", "schema_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "indexes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "spec_", "in_", "parsed", "\\u", "state_", "._", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unique_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flavor_", "=_", "spec_", "[_", "'", "type", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "flavor_", "==_", "'", "PRIMA", "RY", "'_", ":_", "\\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_", "if_", "flavor_", "==_", "'", "UNI", "QUE", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "unique_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "flavor_", "in_", "(_", "None_", ",_", "'", "FULL", "TEXT", "'_", ",_", "'", "SPA", "TI", "AL", "'_", ")_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "logger_", "._", "info_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Converti", "ng", " ", "unknown", " ", "KEY", " ", "type", " ", "%", "s", " ", "to", " ", "a", " ", "plain", " ", "KEY", "\"_", ",_", "flavor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index", "\\u", "d_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "d_", "[_", "'", "name", "'_", "]_", "=_", "spec_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "d_", "[_", "'", "column", "\\u", "names", "'_", "]_", "=_", "[_", "s_", "[_", "0_", "]_", "for_", "s_", "in_", "spec_", "[_", "'", "column", "s", "'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "d_", "[_", "'", "unique", "'_", "]_", "=_", "unique_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "flavor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "index", "\\u", "d_", "[_", "'", "type", "'_", "]_", "=_", "flavor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "indexes_", "._", "append_", "(_", "index", "\\u", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "indexes_", "\\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, 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 ]
Except block handles 'BaseException'
dokterbob/satchmo/satchmo/apps/satchmo_store/contact/views.py
[ { "content": "def ajax_get_state(request, **kwargs):\n formdata = request.REQUEST.copy()\n\n try:\n if formdata.has_key(\"country\"):\n country_field = 'country'\n elif formdata.has_key(\"ship_country\"):\n country_field = 'ship_country'\n else:\n raise AjaxGetStateException(\"No country specified\")\n\n form = ContactInfoForm(data=formdata)\n country_data = formdata.get(country_field)\n try:\n country_obj = form.fields[country_field].clean(country_data)\n except:\n raise AjaxGetStateException(\"Invalid country specified\")\n\n areas = area_choices_for_country(country_obj, ugettext)\n\n context = RequestContext(request, {\n 'areas': areas,\n })\n return render_to_response('contact/_state_choices.html',\n context_instance=context)\n except AjaxGetStateException, e:\n log.error(\"ajax_get_state aborting: %s\" % e.message)\n\n return http.HttpResponseServerError()", "metadata": "root.ajax_get_state", "header": "['module', '___EOS___']", "index": 107 } ]
[ { "span": "except:", "start_line": 122, "start_column": 8, "end_line": 122, "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "aja", "x", "\\u", "get", "\\u", "state_", "(_", "request_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form", "data_", "=_", "request_", "._", "REQUEST_", "._", "copy_", "(_", ")_", "\\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 ", " _", "if_", "form", "data_", "._", "has", "\\u", "key_", "(_", "\"", "countr", "y", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "countr", "y", "\\u", "field_", "=_", "'", "countr", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "form", "data_", "._", "has", "\\u", "key_", "(_", "\"", "ship", "\\u", "countr", "y", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "countr", "y", "\\u", "field_", "=_", "'", "ship", "\\u", "countr", "y", "'_", "\\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_", "Ajax", "Get", "State", "Exception_", "(_", "\"", "No", " ", "countr", "y", " ", "specified", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Conta", "ct", "Info", "Form_", "(_", "data_", "=_", "form", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "countr", "y", "\\u", "data_", "=_", "form", "data_", "._", "get_", "(_", "countr", "y", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "countr", "y", "\\u", "obj_", "=_", "form_", "._", "fields_", "[_", "countr", "y", "\\u", "field_", "]_", "._", "clean_", "(_", "countr", "y", "\\u", "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 ", " _", "raise_", "Ajax", "Get", "State", "Exception_", "(_", "\"", "Inva", "lid", " ", "countr", "y", " ", "specified", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "areas_", "=_", "area", "\\u", "choice", "s", "\\u", "for", "\\u", "country_", "(_", "countr", "y", "\\u", "obj_", ",_", "ugettext_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "=_", "Request", "Context_", "(_", "request_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "area", "s", "'_", ":_", "areas_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "contact", "/\\u", "state", "\\u", "choice", "s", ".", "html", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Ajax", "Get", "State", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "\"", "aja", "x", "\\u", "get", "\\u", "state", " ", "abort", "ing", ":", " ", "%", "s", "\"_", "%_", "e_", "._", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "http_", "._", "Http", "Respons", "e", "Server", "Error_", "(_", ")_" ]
[ 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, 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 ]
Unused import
veeresht/CommPy/commpy/channelcoding/algcode.py
[ { "content": "\n\n# Authors: Veeresh Taranalli <[email protected]>\n# License: BSD 3-Clause\n\nfrom fractions import gcd\nfrom numpy import array, arange, concatenate, convolve\n\nfrom gfields import GF, polymultiply, poly_to_string\nfrom commpy.utilities import dec2bitarray, bitarray2dec\n\n__all__ = ['cyclic_code_genpoly']\n\n\n\nif __name__ == \"__main__\":\n genpolys = cyclic_code_genpoly(31, 21)\n for poly in genpolys:\n print poly_to_string(poly)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def cyclic_code_genpoly(n, k):\n \"\"\"\n Generate all possible generator polynomials for a (n, k)-cyclic code.\n\n Parameters\n ----------\n n : int\n Code blocklength of the cyclic code.\n\n k : int\n Information blocklength of the cyclic code.\n\n Returns\n -------\n poly_list : 1D ndarray of ints\n A list of generator polynomials (represented as integers) for the (n, k)-cyclic code.\n\n \"\"\"\n\n\n if n%2 == 0:\n raise ValueError, \"n cannot be an even number\"\n\n for m in arange(1, 18):\n if (2**m-1)%n == 0:\n break\n\n x_gf = GF(arange(1, 2**m), m)\n coset_fields = x_gf.cosets()\n\n coset_leaders = array([])\n minpol_degrees = array([])\n for field in coset_fields:\n coset_leaders = concatenate((coset_leaders, array([field.elements[0]])))\n minpol_degrees = concatenate((minpol_degrees, array([len(field.elements)])))\n\n y_gf = GF(coset_leaders, m)\n minpol_list = y_gf.minpolys()\n idx_list = arange(1, len(minpol_list))\n poly_list = array([])\n\n for i in xrange(1, 2**len(minpol_list)):\n i_array = dec2bitarray(i, len(minpol_list))\n subset_array = minpol_degrees[i_array == 1]\n if int(subset_array.sum()) == (n-k):\n poly_set = minpol_list[i_array == 1]\n gpoly = 1\n for poly in poly_set:\n gpoly_array = dec2bitarray(gpoly, 2**m)\n poly_array = dec2bitarray(poly, 2**m)\n gpoly = bitarray2dec(convolve(gpoly_array, poly_array) % 2)\n poly_list = concatenate((poly_list, array([gpoly])))\n\n return poly_list.astype(int)", "metadata": "root.cyclic_code_genpoly", "header": "['module', '___EOS___']", "index": 13 } ]
[ { "span": "from fractions import gcd", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 25 }, { "span": "from gfields import GF, polymultiply, poly_to_string", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 52 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Author", "s", ":", " ", "Ve", "eres", "h", " ", "Tar", "anal", "li", " ", "<", "ve", "eres", "ht", "@", "gma", "il", ".", "com", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ":", " ", "BS", "D", " ", "3", "-", "Clause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "fractions_", "import_", "gcd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numpy_", "import_", "array_", ",_", "arange_", ",_", "concatenate_", ",_", "convolve", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "gf", "ields", "_", "import_", "GF", "_", ",_", "poly", "multiply_", ",_", "poly", "\\u", "to", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "comm", "py_", "._", "utilities_", "import_", "dec", "2b", "ita", "rray_", ",_", "bita", "rray", "2de", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "'", "cyclic", "\\u", "code", "\\u", "gen", "poly", "'_", "]_", "\\u\\u\\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 ", " _", "gen", "polys", "_", "=_", "cyclic", "\\u", "code", "\\u", "gen", "poly_", "(_", "31_", ",_", "21_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "poly_", "in_", "gen", "polys", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "poly", "\\u", "to", "\\u", "string_", "(_", "poly_", ")_", "\\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_", "cyclic", "\\u", "code", "\\u", "gen", "poly_", "(_", "n_", ",_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Generate", " ", "all", " ", "possib", "le", " ", "generat", "or", " ", "polynomial", "s", " ", "for", " ", "a", " ", "(", "n", ",", " ", "k", ")-", "cyclic", " ", "code", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "n", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Code", " ", "block", "length", " ", "of", " ", "the", " ", "cyclic", " ", "code", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "k", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Information", " ", "block", "length", " ", "of", " ", "the", " ", "cyclic", " ", "code", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "poly", "\\u", "list", " ", ":", " ", "1", "D", " ", "ndar", "ray", " ", "of", " ", "ints", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "list", " ", "of", " ", "generat", "or", " ", "polynomial", "s", " ", "(", "represent", "ed", " ", "as", " ", "integ", "ers", ")", " ", "for", " ", "the", " ", "(", "n", ",", " ", "k", ")-", "cyclic", " ", "code", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "n_", "%_", "2_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", ",_", "\"", "n", " ", "cann", "ot", " ", "be", " ", "an", " ", "even", " ", "number", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "m_", "in_", "arange_", "(_", "1_", ",_", "18_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "2_", "**_", "m_", "-_", "1_", ")_", "%_", "n_", "==_", "0_", ":_", "\\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_", "x", "\\u", "gf_", "=_", "GF", "_", "(_", "arange_", "(_", "1_", ",_", "2_", "**_", "m_", ")_", ",_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cos", "et", "\\u", "fields_", "=_", "x", "\\u", "gf_", "._", "cos", "ets_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cos", "et", "\\u", "leader", "s_", "=_", "array_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "minp", "ol", "\\u", "degrees_", "=_", "array_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field_", "in_", "cos", "et", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cos", "et", "\\u", "leader", "s_", "=_", "concatenate_", "(_", "(_", "cos", "et", "\\u", "leader", "s_", ",_", "array_", "(_", "[_", "field_", "._", "elements_", "[_", "0_", "]_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "minp", "ol", "\\u", "degrees_", "=_", "concatenate_", "(_", "(_", "minp", "ol", "\\u", "degrees_", ",_", "array_", "(_", "[_", "len_", "(_", "field_", "._", "elements_", ")_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "y", "\\u", "gf_", "=_", "GF", "_", "(_", "cos", "et", "\\u", "leader", "s_", ",_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "minp", "ol", "\\u", "list_", "=_", "y", "\\u", "gf_", "._", "minp", "oly", "s_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idx", "\\u", "list_", "=_", "arange_", "(_", "1_", ",_", "len_", "(_", "minp", "ol", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly", "\\u", "list_", "=_", "array_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "1_", ",_", "2_", "**_", "len_", "(_", "minp", "ol", "\\u", "list_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "array_", "=_", "dec", "2b", "ita", "rray_", "(_", "i_", ",_", "len_", "(_", "minp", "ol", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subse", "t", "\\u", "array_", "=_", "minp", "ol", "\\u", "degrees_", "[_", "i", "\\u", "array_", "==_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "int_", "(_", "subse", "t", "\\u", "array_", "._", "sum_", "(_", ")_", ")_", "==_", "(_", "n_", "-_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "poly", "\\u", "set_", "=_", "minp", "ol", "\\u", "list_", "[_", "i", "\\u", "array_", "==_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gpo", "ly_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "poly_", "in_", "poly", "\\u", "set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gpo", "ly", "\\u", "array_", "=_", "dec", "2b", "ita", "rray_", "(_", "gpo", "ly_", ",_", "2_", "**_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly", "\\u", "array_", "=_", "dec", "2b", "ita", "rray_", "(_", "poly_", ",_", "2_", "**_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gpo", "ly_", "=_", "bita", "rray", "2de", "c_", "(_", "convolve", "_", "(_", "gpo", "ly", "\\u", "array_", ",_", "poly", "\\u", "array_", ")_", "%_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "poly", "\\u", "list_", "=_", "concatenate_", "(_", "(_", "poly", "\\u", "list_", ",_", "array_", "(_", "[_", "gpo", "ly_", "]_", ")_", ")_", ")_", "\\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_", "poly", "\\u", "list_", "._", "astype_", "(_", "int_", ")_", "\\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, 0, 1, 1, 1, 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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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 ]
Unused local variable
jyapayne/Web2Executable/png.py
[ { "content": " def undo_filter(self, filter_type, scanline, previous):\n \"\"\"Undo the filter for a scanline. `scanline` is a sequence of\n bytes that does not include the initial filter type byte.\n `previous` is decoded previous scanline (for straightlaced\n images this is the previous pixel row, but for interlaced\n images, it is the previous scanline in the reduced image, which\n in general is not the previous pixel row in the final image).\n When there is no previous scanline (the first row of a\n straightlaced image, or the first row in one of the passes in an\n interlaced image), then this argument should be ``None``.\n\n The scanline will have the effects of filtering removed, and the\n result will be returned as a fresh sequence of bytes.\n \"\"\"\n\n # :todo: Would it be better to update scanline in place?\n # Yes, with the Cython extension making the undo_filter fast,\n # updating scanline inplace makes the code 3 times faster\n # (reading 50 images of 800x800 went from 40s to 16s)\n result = scanline\n\n if filter_type == 0:\n return result\n\n if filter_type not in (1,2,3,4):\n raise FormatError('Invalid PNG Filter Type.'\n ' See http://www.w3.org/TR/2003/REC-PNG-20031110/#9Filters .')\n\n # Filter unit. The stride from one pixel to the corresponding\n # byte from the previous pixel. Normally this is the pixel\n # size in bytes, but when this is smaller than 1, the previous\n # byte is used instead.\n fu = max(1, self.psize)\n\n # For the first line of a pass, synthesize a dummy previous\n # line. An alternative approach would be to observe that on the\n # first line 'up' is the same as 'null', 'paeth' is the same\n # as 'sub', with only 'average' requiring any special case.\n if not previous:\n previous = array('B', [0]*len(scanline))\n\n def sub():\n \"\"\"Undo sub filter.\"\"\"\n\n ai = 0\n # Loop starts at index fu. Observe that the initial part\n # of the result is already filled in correctly with\n # scanline.\n for i in range(fu, len(result)):\n x = scanline[i]\n a = result[ai]\n result[i] = (x + a) & 0xff\n ai += 1\n\n def up():\n \"\"\"Undo up filter.\"\"\"\n\n for i in range(len(result)):\n x = scanline[i]\n b = previous[i]\n result[i] = (x + b) & 0xff\n\n def average():\n \"\"\"Undo average filter.\"\"\"\n\n ai = -fu\n for i in range(len(result)):\n x = scanline[i]\n if ai < 0:\n a = 0\n else:\n a = result[ai]\n b = previous[i]\n result[i] = (x + ((a + b) >> 1)) & 0xff\n ai += 1\n\n def paeth():\n \"\"\"Undo Paeth filter.\"\"\"\n\n # Also used for ci.\n ai = -fu\n for i in range(len(result)):\n x = scanline[i]\n if ai < 0:\n a = c = 0\n else:\n a = result[ai]\n c = previous[ai]\n b = previous[i]\n p = a + b - c\n pa = abs(p - a)\n pb = abs(p - b)\n pc = abs(p - c)\n if pa <= pb and pa <= pc:\n pr = a\n elif pb <= pc:\n pr = b\n else:\n pr = c\n result[i] = (x + pr) & 0xff\n ai += 1\n\n # Call appropriate filter algorithm. Note that 0 has already\n # been dealt with.\n (None,\n pngfilters.undo_filter_sub,\n pngfilters.undo_filter_up,\n pngfilters.undo_filter_average,\n pngfilters.undo_filter_paeth)[filter_type](fu, scanline, previous, result)\n return result", "metadata": "root.Reader.undo_filter", "header": "['class', 'Reader', ':', '___EOS___']", "index": 1434 } ]
[ { "span": "sub(", "start_line": 1475, "start_column": 12, "end_line": 1475, "end_column": 15 }, { "span": "up(", "start_line": 1488, "start_column": 12, "end_line": 1488, "end_column": 14 }, { "span": "average(", "start_line": 1496, "start_column": 12, "end_line": 1496, "end_column": 19 }, { "span": "paeth(", "start_line": 1510, "start_column": 12, "end_line": 1510, "end_column": 17 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Reader_", ":_", "\\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_", "undo", "\\u", "filter_", "(_", "self_", ",_", "filter", "\\u", "type_", ",_", "scan", "line_", ",_", "previous_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Und", "o", " ", "the", " ", "filter", " ", "for", " ", "a", " ", "scan", "line", ".", " ", " ", "`", "scan", "line", "`", " ", "is", " ", "a", " ", "sequence", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "bytes", " ", "tha", "t", " ", "doe", "s", " ", "not", " ", "include", " ", "the", " ", "initial", " ", "filter", " ", "type", " ", "byte", ".", "\\", "10", ";", " ", " ", " ", " ", "`", "previ", "ous", "`", " ", "is", " ", "decode", "d", " ", "previ", "ous", " ", "scan", "line", " ", "(", "for", " ", "straight", "lace", "d", "\\", "10", ";", " ", " ", " ", " ", "images", " ", "this", " ", "is", " ", "the", " ", "previ", "ous", " ", "pixel", " ", "row", ",", " ", "but", " ", "for", " ", "interl", "ace", "d", "\\", "10", ";", " ", " ", " ", " ", "images", ",", " ", "it", " ", "is", " ", "the", " ", "previ", "ous", " ", "scan", "line", " ", "in", " ", "the", " ", "reduce", "d", " ", "image", ",", " ", "whi", "ch", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "genera", "l", " ", "is", " ", "not", " ", "the", " ", "previ", "ous", " ", "pixel", " ", "row", " ", "in", " ", "the", " ", "final", " ", "image", ").", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "there", " ", "is", " ", "no", " ", "previ", "ous", " ", "scan", "line", " ", "(", "the", " ", "first", " ", "row", " ", "of", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "straight", "lace", "d", " ", "image", ",", " ", "or", " ", "the", " ", "first", " ", "row", " ", "in", " ", "one", " ", "of", " ", "the", " ", "pass", "es", " ", "in", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "interl", "ace", "d", " ", "image", "),", " ", "then", " ", "this", " ", "argu", "ment", " ", "shou", "ld", " ", "be", " ", "``", "Non", "e", "``.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "scan", "line", " ", "will", " ", "have", " ", "the", " ", "effect", "s", " ", "of", " ", "filtering", " ", "remove", "d", ",", " ", "and", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "result", " ", "will", " ", "be", " ", "return", "ed", " ", "as", " ", "a", " ", "fresh", " ", "sequence", " ", "of", " ", "bytes", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", ":", "todo", ":", " ", "Wo", "ul", "d", " ", "it", " ", "be", " ", "bett", "er", " ", "to", " ", "update", " ", "scan", "line", " ", "in", " ", "place", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ye", "s", ",", " ", "with", " ", "the", " ", "Cython", " ", "extensi", "on", " ", "mak", "ing", " ", "the", " ", "undo", "\\u", "filter", " ", "fast", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "updat", "ing", " ", "scan", "line", " ", "inpla", "ce", " ", "make", "s", " ", "the", " ", "code", " ", "3", " ", "times", " ", "faste", "r_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "readi", "ng", " ", "50", " ", "images", " ", "of", " ", "800", "x8", "00", " ", "wen", "t", " ", "from", " ", "40", "s", " ", "to", " ", "16", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "scan", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "filter", "\\u", "type_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "filter", "\\u", "type_", "not_", "in_", "(_", "1_", ",_", "2_", ",_", "3_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Format", "Error_", "(_", "'", "Inva", "lid", " ", "PNG", " ", "Filter", " ", "Type", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", "See", " ", "http", "://", "www", ".", "w3", ".", "org", "/", "TR", "/", "2003", "/", "REC", "-", "PNG", "-", "2003", "1110", "/", "#", "9", "Filter", "s", " ", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Filter", " ", "unit", ".", " ", " ", "The", " ", "stride", " ", "from", " ", "one", " ", "pixel", " ", "to", " ", "the", " ", "correspond", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "byte", " ", "from", " ", "the", " ", "previ", "ous", " ", "pixel", ".", " ", " ", "Normal", "ly", " ", "this", " ", "is", " ", "the", " ", "pixel_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "size", " ", "in", " ", "bytes", ",", " ", "but", " ", "whe", "n", " ", "this", " ", "is", " ", "small", "er", " ", "than", " ", "1", ",", " ", "the", " ", "previous_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "byte", " ", "is", " ", "used", " ", "inst", "ead", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fu", "_", "=_", "max_", "(_", "1_", ",_", "self_", "._", "psi", "ze_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "the", " ", "first", " ", "line", " ", "of", " ", "a", " ", "pass", ",", " ", "synthesi", "ze", " ", "a", " ", "dummy", " ", "previous_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "line", ".", " ", " ", "An", " ", "alternative", " ", "appro", "ach", " ", "wou", "ld", " ", "be", " ", "to", " ", "observe", " ", "tha", "t", " ", "on", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "first", " ", "line", " ", "'", "up", "'", " ", "is", " ", "the", " ", "same", " ", "as", " ", "'", "null", "',", " ", "'", "pa", "eth", "'", " ", "is", " ", "the", " ", "same_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "'", "sub", "',", " ", "with", " ", "only", " ", "'", "averag", "e", "'", " ", "requi", "ring", " ", "any", " ", "special", " ", "case", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "previous_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "previous_", "=_", "array_", "(_", "'", "B", "'_", ",_", "[_", "0_", "]_", "*_", "len_", "(_", "scan", "line_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "sub_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Und", "o", " ", "sub", " ", "filter", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ai_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Loop", " ", "starts", " ", "at", " ", "index", " ", "fu", ".", " ", " ", "Observ", "e", " ", "tha", "t", " ", "the", " ", "initial", " ", "part_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "the", " ", "result", " ", "is", " ", "alr", "ead", "y", " ", "filled", " ", "in", " ", "correct", "ly", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "scan", "line", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "fu", "_", ",_", "len_", "(_", "result_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "scan", "line_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "result_", "[_", "ai_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "i_", "]_", "=_", "(_", "x_", "+_", "a_", ")_", "&_", "0xff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ai_", "+=_", "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_", "def_", "up_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Und", "o", " ", "up", " ", "filter", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "result_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "scan", "line_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "previous_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "i_", "]_", "=_", "(_", "x_", "+_", "b_", ")_", "&_", "0xff_", "\\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_", "average_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Und", "o", " ", "averag", "e", " ", "filter", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ai_", "=_", "-_", "fu", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "result_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "scan", "line_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ai_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "a_", "=_", "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 ", " ", "_", "a_", "=_", "result_", "[_", "ai_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "b_", "=_", "previous_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "i_", "]_", "=_", "(_", "x_", "+_", "(_", "(_", "a_", "+_", "b_", ")_", ">>_", "1_", ")_", ")_", "&_", "0xff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ai_", "+=_", "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_", "def_", "pa", "eth_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Und", "o", " ", "Pa", "eth", " ", "filter", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Al", "so", " ", "used", " ", "for", " ", "ci", "._", "\\u\\u\\uNL\\u\\u\\u_", "ai_", "=_", "-_", "fu", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "result_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "scan", "line_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ai_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "a_", "=_", "c_", "=_", "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 ", " ", "_", "a_", "=_", "result_", "[_", "ai_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "previous_", "[_", "ai_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "b_", "=_", "previous_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "a_", "+_", "b_", "-_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pa_", "=_", "abs_", "(_", "p_", "-_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pb_", "=_", "abs_", "(_", "p_", "-_", "b_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pc_", "=_", "abs_", "(_", "p_", "-_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pa_", "<=_", "pb_", "and_", "pa_", "<=_", "pc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pr_", "=_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "pb_", "<=_", "pc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pr_", "=_", "b_", "\\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 ", " ", "_", "pr_", "=_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "[_", "i_", "]_", "=_", "(_", "x_", "+_", "pr_", ")_", "&_", "0xff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ai_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Call", " ", "appropr", "iate", " ", "filter", " ", "algo", "rit", "hm", ".", " ", " ", "Not", "e", " ", "tha", "t", " ", "0", " ", "has", " ", "alr", "ead", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bee", "n", " ", "deal", "t", " ", "with", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "(_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "png", "filters_", "._", "undo", "\\u", "filter", "\\u", "sub_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "png", "filters_", "._", "undo", "\\u", "filter", "\\u", "up_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "png", "filters_", "._", "undo", "\\u", "filter", "\\u", "average_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "png", "filters_", "._", "undo", "\\u", "filter", "\\u", "pa", "eth_", ")_", "[_", "filter", "\\u", "type_", "]_", "(_", "fu", "_", ",_", "scan", "line_", ",_", "previous_", ",_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
banjiewen/bernhard/setup.py
[ { "content": "# -*- coding: utf-8 -\n\nimport codecs\nimport io\nimport os\n\nfrom setuptools import setup\n\nwith io.open(os.path.join(os.path.dirname(__file__), 'README.md'),\n encoding='utf-8') as f:\n long_description = f.read()\n\nsetup(\n name = 'bernhard',\n version = '0.2.4',\n description = 'Python client for Riemann',\n long_description = long_description,\n author = 'Benjamin Anderspn',\n author_email = '[email protected]',\n license = 'ASF2.0',\n url = 'http://github.com/banjiewen/bernhard.git',\n\n classifiers = [\n 'Development Status :: 4 - Beta',\n 'Environment :: Other Environment',\n 'Intended Audience :: Developers',\n 'License :: OSI Approved :: Apache Software License',\n 'Operating System :: MacOS :: MacOS X',\n 'Operating System :: POSIX',\n 'Operating System :: Unix',\n 'Programming Language :: Python',\n 'Programming Language :: Python :: 2',\n 'Programming Language :: Python :: 3',\n 'Topic :: Internet :: Log Analysis',\n 'Topic :: Utilities',\n 'Topic :: System :: Networking :: Monitoring'\n ],\n zip_safe = False,\n packages = ['bernhard'],\n include_package_data = True,\n install_requires=['protobuf >= 2.4']\n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import codecs", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 13 } ]
[]
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_", "import_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "setuptools_", "import_", "setup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "io_", "._", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "'", "READ", "ME", ".", "md", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "encoding_", "=_", "'", "utf", "-", "8", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "long", "\\u", "description_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "bern", "hard", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "0.", "2.4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "Pyth", "on", " ", "client", " ", "for", " ", "Ri", "eman", "n", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "long", "\\u", "description_", "=_", "long", "\\u", "description_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author_", "=_", "'", "Ben", "jam", "in", " ", "And", "ers", "pn", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author", "\\u", "email_", "=_", "'", "b", "@", "ban", "jie", "wen", ".", "net", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "license_", "=_", "'", "AS", "F2", ".0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "'", "http", "://", "git", "hub", ".", "com", "/", "ban", "jie", "wen", "/", "bern", "hard", ".", "git", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "classifiers_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Dev", "elo", "pme", "nt", " ", "Status", " ", "::", " ", "4", " ", "-", " ", "Beta", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Environ", "ment", " ", "::", " ", "Ot", "her", " ", "Environ", "ment", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Inten", "ded", " ", "Audi", "ence", " ", "::", " ", "Dev", "elope", "rs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "License", " ", "::", " ", "OSI", " ", "Appro", "ved", " ", "::", " ", "Ap", "ache", " ", "Sof", "twa", "re", " ", "License", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Opera", "ting", " ", "System", " ", "::", " ", "Mac", "OS", " ", "::", " ", "Mac", "OS", " ", "X", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Opera", "ting", " ", "System", " ", "::", " ", "POSI", "X", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Opera", "ting", " ", "System", " ", "::", " ", "Uni", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Programm", "ing", " ", "Lang", "ua", "ge", " ", "::", " ", "Pyth", "on", " ", "::", " ", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Intern", "et", " ", "::", " ", "Log", " ", "Analy", "sis", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Utili", "ties", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "System", " ", "::", " ", "Network", "ing", " ", "::", " ", "Monitor", "ing", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "zip", "\\u", "safe_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "packages_", "=_", "[_", "'", "bern", "hard", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "include", "\\u", "package", "\\u", "data_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "install", "\\u", "requires_", "=_", "[_", "'", "proto", "buf", " ", ">=", " ", "2.4", "'_", "]_", "\\u\\u\\uNL\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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'
estevaofon/angry-birds-python/pymunk-4.0.0/pymunk/__init__.py
[ { "content": " def __del__(self):\n try:\n cp.cpSpaceFree(self._space)\n except:\n pass", "metadata": "root.Space.__del__", "header": "['class', 'Space', '(', 'object', ')', ':', '___EOS___']", "index": 167 }, { "content": " def __del__(self):\n try:\n cp.cpBodyFree(self._body)\n except: \n pass", "metadata": "root.Body.__del__", "header": "['class', 'Body', '(', 'object', ')', ':', '___EOS___']", "index": 790 }, { "content": " def __del__(self):\n try:\n cp.cpShapeFree(self._shape)\n except:\n pass", "metadata": "root.Shape.__del__", "header": "['class', 'Shape', '(', 'object', ')', ':', '___EOS___']", "index": 1073 } ]
[ { "span": "except:", "start_line": 170, "start_column": 8, "end_line": 170, "end_column": 15 }, { "span": "except: ", "start_line": 793, "start_column": 8, "end_line": 793, "end_column": 15 }, { "span": "except:", "start_line": 1076, "start_column": 8, "end_line": 1076, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Space_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "del\\u\\u_", "(_", "self_", ")_", ":_", "\\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 ", " _", "cp_", "._", "cp", "Spac", "e", "Free", "_", "(_", "self_", "._", "\\u", "space_", ")_", "\\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_", "Body_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "del\\u\\u_", "(_", "self_", ")_", ":_", "\\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 ", " _", "cp_", "._", "cp", "Bod", "y", "Free", "_", "(_", "self_", "._", "\\u", "body_", ")_", "\\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_", "Shape_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "del\\u\\u_", "(_", "self_", ")_", ":_", "\\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 ", " _", "cp_", "._", "cp", "Shape", "Free", "_", "(_", "self_", "._", "\\u", "shape_", ")_", "\\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_" ]
[ 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, 0, 1, 1, 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, 0, 1, 1, 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, 0, 1, 1, 2, 2, 2, 2, 2 ]
Modification of dictionary returned by locals()
kayhayen/Nuitka/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Tool/packaging/rpm.py
[ { "content": "def package(env, target, source, PACKAGEROOT, NAME, VERSION,\n PACKAGEVERSION, DESCRIPTION, SUMMARY, X_RPM_GROUP, LICENSE,\n **kw):\n # initialize the rpm tool\n SCons.Tool.Tool('rpm').generate(env)\n\n bld = env['BUILDERS']['Rpm']\n\n # Generate a UserError whenever the target name has been set explicitly,\n # since rpm does not allow for controlling it. This is detected by\n # checking if the target has been set to the default by the Package()\n # Environment function.\n if str(target[0])!=\"%s-%s\"%(NAME, VERSION):\n raise UserError( \"Setting target is not supported for rpm.\" )\n else:\n # This should be overridable from the construction environment,\n # which it is by using ARCHITECTURE=.\n buildarchitecture = SCons.Tool.rpmutils.defaultMachine()\n\n if 'ARCHITECTURE' in kw:\n buildarchitecture = kw['ARCHITECTURE']\n\n fmt = '%s-%s-%s.%s.rpm'\n srcrpm = fmt % (NAME, VERSION, PACKAGEVERSION, 'src')\n binrpm = fmt % (NAME, VERSION, PACKAGEVERSION, buildarchitecture)\n\n target = [ srcrpm, binrpm ]\n\n # get the correct arguments into the kw hash\n loc=locals()\n del loc['kw']\n kw.update(loc)\n del kw['source'], kw['target'], kw['env']\n\n # if no \"SOURCE_URL\" tag is given add a default one.\n if 'SOURCE_URL' not in kw:\n #kw['SOURCE_URL']=(str(target[0])+\".tar.gz\").replace('.rpm', '')\n kw['SOURCE_URL']=(str(target[0])+\".tar.gz\").replace('.rpm', '')\n\n # mangle the source and target list for the rpmbuild\n env = OverrideEnvironment(env, kw)\n target, source = stripinstallbuilder(target, source, env)\n target, source = addspecfile(target, source, env)\n target, source = collectintargz(target, source, env)\n\n # now call the rpm builder to actually build the packet.\n return bld(env, target, source, **kw)", "metadata": "root.package", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "loc['kw']", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 17 } ]
[]
1
true
[ "[CLS]_", "Modifica", "tion_", "of_", "dictionary_", "returned_", "by_", "locals_", "(_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "package_", "(_", "env_", ",_", "target_", ",_", "source_", ",_", "PACKAG", "ERO", "OT", "_", ",_", "NAME_", ",_", "VERSION_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "PACKAG", "EVE", "RSI", "ON_", ",_", "DESCRIPTION_", ",_", "SUMMARY", "_", ",_", "X", "\\u", "RPM", "\\u", "GROUP_", ",_", "LICENSE", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "initialize", " ", "the", " ", "rpm", " ", "tool_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SC", "ons_", "._", "Tool_", "._", "Tool_", "(_", "'", "rpm", "'_", ")_", "._", "generate_", "(_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bld", "_", "=_", "env_", "[_", "'", "BUILD", "ERS", "'_", "]_", "[_", "'", "Rp", "m", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "a", " ", "User", "Error", " ", "whe", "neve", "r", " ", "the", " ", "target", " ", "name", " ", "has", " ", "bee", "n", " ", "set", " ", "explicit", "ly", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sinc", "e", " ", "rpm", " ", "doe", "s", " ", "not", " ", "allow", " ", "for", " ", "controll", "ing", " ", "it", ".", " ", "Thi", "s", " ", "is", " ", "detect", "ed", " ", "by_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "checking", " ", "if", " ", "the", " ", "target", " ", "has", " ", "bee", "n", " ", "set", " ", "to", " ", "the", " ", "default", " ", "by", " ", "the", " ", "Packa", "ge", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Environ", "ment", " ", "function", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "str_", "(_", "target_", "[_", "0_", "]_", ")_", "!=_", "\"%", "s", "-%", "s", "\"_", "%_", "(_", "NAME_", ",_", "VERSION_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "User", "Error_", "(_", "\"", "Sett", "ing", " ", "target", " ", "is", " ", "not", " ", "support", "ed", " ", "for", " ", "rpm", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "be", " ", "overrid", "able", " ", "from", " ", "the", " ", "constructi", "on", " ", "environ", "ment", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whi", "ch", " ", "it", " ", "is", " ", "by", " ", "usi", "ng", " ", "ARCH", "ITE", "CTU", "RE", "=.", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "architecture_", "=_", "SC", "ons_", "._", "Tool_", "._", "rpm", "utils_", "._", "default", "Machine_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "ARCH", "ITE", "CTU", "RE", "'_", "in_", "kw_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "architecture_", "=_", "kw_", "[_", "'", "ARCH", "ITE", "CTU", "RE", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fmt_", "=_", "'%", "s", "-%", "s", "-%", "s", ".", "%", "s", ".", "rpm", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "src", "rpm_", "=_", "fmt_", "%_", "(_", "NAME_", ",_", "VERSION_", ",_", "PACKAG", "EVE", "RSI", "ON_", ",_", "'", "src", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bin", "rpm_", "=_", "fmt_", "%_", "(_", "NAME_", ",_", "VERSION_", ",_", "PACKAG", "EVE", "RSI", "ON_", ",_", "build", "architecture_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "[_", "src", "rpm_", ",_", "bin", "rpm_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "correct", " ", "argu", "ment", "s", " ", "int", "o", " ", "the", " ", "kw", " ", "hash_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "loc_", "=_", "locals_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "loc_", "[_", "'", "kw", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "kw_", "[_", "'", "source", "'_", "]_", ",_", "kw_", "[_", "'", "target", "'_", "]_", ",_", "kw_", "[_", "'", "env", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "no", " ", "\"", "SOU", "RC", "E", "\\u", "URL", "\"", " ", "tag", " ", "is", " ", "give", "n", " ", "add", " ", "a", " ", "default", " ", "one", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "SOU", "RC", "E", "\\u", "URL", "'_", "not_", "in_", "kw_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "kw", "['", "SOU", "RC", "E", "\\u", "URL", "']", "=(", "str", "(", "target", "[", "0", "])", "+\"", ".", "tar", ".", "gz", "\")", ".", "replace", "('.", "rpm", "',", " ", "''", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kw_", "[_", "'", "SOU", "RC", "E", "\\u", "URL", "'_", "]_", "=_", "(_", "str_", "(_", "target_", "[_", "0_", "]_", ")_", "+_", "\".", "tar", ".", "gz", "\"_", ")_", "._", "replace_", "(_", "'.", "rpm", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mangle", " ", "the", " ", "source", " ", "and", " ", "target", " ", "list", " ", "for", " ", "the", " ", "rpm", "build_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "env_", "=_", "Override", "Environment_", "(_", "env_", ",_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", ",_", "source_", "=_", "strip", "install", "builder_", "(_", "target_", ",_", "source_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", ",_", "source_", "=_", "adds", "pec", "file_", "(_", "target_", ",_", "source_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target_", ",_", "source_", "=_", "collecti", "nta", "rg", "z_", "(_", "target_", ",_", "source_", ",_", "env_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "call", " ", "the", " ", "rpm", " ", "builde", "r", " ", "to", " ", "actual", "ly", " ", "build", " ", "the", " ", "packet", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "bld", "_", "(_", "env_", ",_", "target_", ",_", "source_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 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 ]
Unused local variable
aldebaran/qibuild/python/qibuild/test/test_cmake_builder.py
[ { "content": "def test_sdk_dirs(build_worktree):\n foo_proj = build_worktree.create_project(\"foo\")\n bar_proj = build_worktree.create_project(\"bar\", build_depends=[\"foo\"])\n baz_proj = build_worktree.create_project(\"baz\", build_depends=[\"bar\"])\n cmake_builder = qibuild.cmake_builder.CMakeBuilder(build_worktree, [bar_proj])\n sdk_dirs_when_top_project = cmake_builder.get_sdk_dirs_for_project(bar_proj)\n cmake_builder.projects = [baz_proj]\n sdk_dirs_when_not_top_project = cmake_builder.get_sdk_dirs_for_project(bar_proj)\n assert sdk_dirs_when_top_project == sdk_dirs_when_not_top_project", "metadata": "root.test_sdk_dirs", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def test_host_tools_no_host_config(build_worktree, fake_ctc):\n footool = build_worktree.add_test_project(\"footool\")\n usefootool_proj = build_worktree.add_test_project(\"usefootool\")\n build_worktree.set_active_config(\"fake-ctc\")\n cmake_builder = qibuild.cmake_builder.CMakeBuilder(build_worktree)\n # pylint:disable-msg=E1101\n with pytest.raises(qisys.error.Error) as e:\n cmake_builder.get_host_dirs(usefootool_proj)\n assert \"`qibuild set-host-config`\" in e.value.message", "metadata": "root.test_host_tools_no_host_config", "header": "['module', '___EOS___']", "index": 81 }, { "content": "def test_host_tools_host_tools_not_built(build_worktree, fake_ctc):\n qibuild.config.add_build_config(\"foo\", host=True)\n footool = build_worktree.add_test_project(\"footool\")\n usefootool_proj = build_worktree.add_test_project(\"usefootool\")\n build_worktree.set_active_config(\"fake-ctc\")\n cmake_builder = qibuild.cmake_builder.CMakeBuilder(build_worktree)\n # pylint:disable-msg=E1101\n with pytest.raises(qisys.error.Error) as e:\n cmake_builder.get_host_dirs(usefootool_proj)\n assert \"(Using 'foo' build config)\" in e.value.message", "metadata": "root.test_host_tools_host_tools_not_built", "header": "['module', '___EOS___']", "index": 91 } ]
[ { "span": "foo_proj ", "start_line": 45, "start_column": 4, "end_line": 45, "end_column": 12 }, { "span": "footool ", "start_line": 82, "start_column": 4, "end_line": 82, "end_column": 11 }, { "span": "footool ", "start_line": 93, "start_column": 4, "end_line": 93, "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_", "test\\u", "sd", "k", "\\u", "dirs_", "(_", "build", "\\u", "work", "tree_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "foo", "\\u", "proj_", "=_", "build", "\\u", "work", "tree_", "._", "create", "\\u", "project_", "(_", "\"", "foo", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bar", "\\u", "proj_", "=_", "build", "\\u", "work", "tree_", "._", "create", "\\u", "project_", "(_", "\"", "bar", "\"_", ",_", "build", "\\u", "depends_", "=_", "[_", "\"", "foo", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ba", "z", "\\u", "proj_", "=_", "build", "\\u", "work", "tree_", "._", "create", "\\u", "project_", "(_", "\"", "ba", "z", "\"_", ",_", "build", "\\u", "depends_", "=_", "[_", "\"", "bar", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "ke", "\\u", "builder_", "=_", "qi", "build_", "._", "cma", "ke", "\\u", "builder_", "._", "CM", "ake", "Builder_", "(_", "build", "\\u", "work", "tree_", ",_", "[_", "bar", "\\u", "proj_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sd", "k", "\\u", "dirs", "\\u", "whe", "n", "\\u", "top", "\\u", "project_", "=_", "cma", "ke", "\\u", "builder_", "._", "get", "\\u", "sd", "k", "\\u", "dirs", "\\u", "for", "\\u", "project_", "(_", "bar", "\\u", "proj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "ke", "\\u", "builder_", "._", "projects_", "=_", "[_", "ba", "z", "\\u", "proj_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sd", "k", "\\u", "dirs", "\\u", "whe", "n", "\\u", "not", "\\u", "top", "\\u", "project_", "=_", "cma", "ke", "\\u", "builder_", "._", "get", "\\u", "sd", "k", "\\u", "dirs", "\\u", "for", "\\u", "project_", "(_", "bar", "\\u", "proj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "sd", "k", "\\u", "dirs", "\\u", "whe", "n", "\\u", "top", "\\u", "project_", "==_", "sd", "k", "\\u", "dirs", "\\u", "whe", "n", "\\u", "not", "\\u", "top", "\\u", "project_", "\\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", "host", "\\u", "tool", "s", "\\u", "no", "\\u", "host", "\\u", "config_", "(_", "build", "\\u", "work", "tree_", ",_", "fake", "\\u", "ctc", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "foot", "ool_", "=_", "build", "\\u", "work", "tree_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "foot", "ool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "usef", "oot", "ool", "\\u", "proj_", "=_", "build", "\\u", "work", "tree_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "usef", "oot", "ool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "build", "\\u", "work", "tree_", "._", "set\\u", "active", "\\u", "config_", "(_", "\"", "fake", "-", "ctc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "ke", "\\u", "builder_", "=_", "qi", "build_", "._", "cma", "ke", "\\u", "builder_", "._", "CM", "ake", "Builder_", "(_", "build", "\\u", "work", "tree_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pylint", ":", "disable", "-", "msg", "=", "E1", "101_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "pytest_", "._", "raises_", "(_", "qi", "sys_", "._", "error_", "._", "Error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cma", "ke", "\\u", "builder_", "._", "get", "\\u", "host", "\\u", "dirs_", "(_", "usef", "oot", "ool", "\\u", "proj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "\"`", "qi", "build", " ", "set", "-", "host", "-", "config", "`\"_", "in_", "e_", "._", "value_", "._", "message_", "\\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", "host", "\\u", "tool", "s", "\\u", "host", "\\u", "tool", "s", "\\u", "not", "\\u", "built_", "(_", "build", "\\u", "work", "tree_", ",_", "fake", "\\u", "ctc", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qi", "build_", "._", "config_", "._", "add", "\\u", "build", "\\u", "config_", "(_", "\"", "foo", "\"_", ",_", "host_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "foot", "ool_", "=_", "build", "\\u", "work", "tree_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "foot", "ool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "usef", "oot", "ool", "\\u", "proj_", "=_", "build", "\\u", "work", "tree_", "._", "add", "\\u", "test\\u", "project_", "(_", "\"", "usef", "oot", "ool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "build", "\\u", "work", "tree_", "._", "set\\u", "active", "\\u", "config_", "(_", "\"", "fake", "-", "ctc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "ke", "\\u", "builder_", "=_", "qi", "build_", "._", "cma", "ke", "\\u", "builder_", "._", "CM", "ake", "Builder_", "(_", "build", "\\u", "work", "tree_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pylint", ":", "disable", "-", "msg", "=", "E1", "101_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "pytest_", "._", "raises_", "(_", "qi", "sys_", "._", "error_", "._", "Error_", ")_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cma", "ke", "\\u", "builder_", "._", "get", "\\u", "host", "\\u", "dirs_", "(_", "usef", "oot", "ool", "\\u", "proj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "\"(", "Us", "ing", " ", "'", "foo", "'", " ", "build", " ", "config", ")\"_", "in_", "e_", "._", "value_", "._", "message_", "\\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, 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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 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 ]
Unused import
AcademicsToday/py-academicstoday/academicstoday_project/teacher/tests/test_policy.py
[ { "content": "# Django & Python\nfrom 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\n\n# Modal\nfrom registrar.models import Course\nfrom registrar.models import Teacher\nfrom registrar.models import Policy\n\n\n# View\nfrom teacher.views import policy\n\n# Contants\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# Create your tests here.\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class PolicyTestCase(TestCase):\n\n\n\n\n \n\n\n\n\n ", "metadata": "root.PolicyTestCase", "header": "['module', '___EOS___']", "index": 30 }, { "content": " def tearDown(self):\n policies = Policy.objects.all()\n for policy in policies:\n policy.delete()\n courses = Course.objects.all()\n for course in courses:\n course.delete()\n User.objects.all().delete()", "metadata": "root.PolicyTestCase.tearDown", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 31 }, { "content": " def setUp(self):\n # Create our Trudy user.\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 \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 \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 )", "metadata": "root.PolicyTestCase.setUp", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 40 }, { "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.PolicyTestCase.get_logged_in_client", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 68 }, { "content": " def get_logged_in_trudy_client(self):\n client = Client()\n client.login(\n username=TEST_USER_USERNAME2,\n password=TEST_USER_PASSWORD2\n )\n return client", "metadata": "root.PolicyTestCase.get_logged_in_trudy_client", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 76 }, { "content": " def test_url_resolves_to_policy_page_view(self):\n found = resolve('/teacher/course/1/policy')\n self.assertEqual(found.func, policy.policy_page)", "metadata": "root.PolicyTestCase.test_url_resolves_to_policy_page_view", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 84 }, { "content": " def test_policy_page_without_pdf_file(self):\n client = self.get_logged_in_client()\n response = client.post('/teacher/course/1/policy')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'Comics Book Course',response.content)\n self.assertIn(b'<h1>Upload',response.content)", "metadata": "root.PolicyTestCase.test_policy_page_without_pdf_file", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 88 }, { "content": " def test_policy_modal(self):\n client = self.get_logged_in_client()\n response = client.post('/teacher/course/1/policy_modal')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'policy_modal',response.content)", "metadata": "root.PolicyTestCase.test_policy_modal", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 95 }, { "content": " def test_policy_page_with_pdf_file(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n file_path = settings.MEDIA_ROOT + '/sample.pdf'\n with open(file_path, 'rb') as fp:\n self.assertTrue(fp is not None)\n response = client.post('/teacher/course/1/save_policy',{\n 'file': fp,\n }, **kwargs)\n self.assertEqual(response.status_code, 200)\n response = client.post('/teacher/course/1/policy')\n self.assertEqual(response.status_code, 200)\n self.assertIn(b'Comics Book Course',response.content)\n self.assertIn(b'ajax_delete_policy',response.content)\n self.assertIn(b'PDF RESULT',response.content)\n\n try:\n Policy.objects.get(policy_id=1).delete()\n except Policy.DoesNotExist:\n pass\n try:\n Policy.objects.get(policy_id=2).delete()\n except Policy.DoesNotExist:\n pass\n try:\n Policy.objects.get(policy_id=3).delete()\n except Policy.DoesNotExist:\n pass", "metadata": "root.PolicyTestCase.test_policy_page_with_pdf_file", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 101 }, { "content": " def test_save_policy(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n file_path = settings.MEDIA_ROOT + '/sample.pdf'\n with open(file_path, 'rb') as fp:\n self.assertTrue(fp is not None)\n response = client.post('/teacher/course/1/save_policy',{\n 'file': fp,\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['message'], 'saved')\n self.assertEqual(array['status'], 'success')\n \n try:\n Policy.objects.get(policy_id=1).delete()\n except Policy.DoesNotExist:\n pass\n try:\n Policy.objects.get(policy_id=2).delete()\n except Policy.DoesNotExist:\n pass\n try:\n Policy.objects.get(policy_id=3).delete()\n except Policy.DoesNotExist:\n pass", "metadata": "root.PolicyTestCase.test_save_policy", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 130 }, { "content": " def test_delete_policy_with_submission_and_correct_user(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n file_path = settings.MEDIA_ROOT + '/sample.pdf'\n with open(file_path, 'rb') as fp:\n self.assertTrue(fp is not None)\n response = client.post('/teacher/course/1/save_policy',{\n 'file': fp,\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['message'], 'saved')\n self.assertEqual(array['status'], 'success')\n \n response = client.post('/teacher/course/1/delete_policy',{\n 'policy_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['message'], 'deleted')\n self.assertEqual(array['status'], 'success')", "metadata": "root.PolicyTestCase.test_delete_policy_with_submission_and_correct_user", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 158 }, { "content": " def test_delete_policy_with_submission_and_correct_user(self):\n kwargs = {'HTTP_X_REQUESTED_WITH':'XMLHttpRequest'}\n client = self.get_logged_in_client()\n file_path = settings.MEDIA_ROOT + '/sample.pdf'\n with open(file_path, 'rb') as fp:\n self.assertTrue(fp is not None)\n response = client.post('/teacher/course/1/save_policy',{\n 'file': fp,\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['message'], 'saved')\n self.assertEqual(array['status'], 'success')\n \n client.logout()\n client = self.get_logged_in_trudy_client()\n response = client.post('/teacher/course/1/delete_policy',{\n 'policy_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['message'], 'unauthorized deletion')\n self.assertEqual(array['status'], 'failed')", "metadata": "root.PolicyTestCase.test_delete_policy_with_submission_and_correct_user", "header": "['class', 'PolicyTestCase', '(', 'TestCase', ')', ':', '___EOS___']", "index": 182 } ]
[ { "span": "from django.http import HttpRequest", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 35 }, { "span": "from django.http import QueryDict", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 33 }, { "span": "from django.contrib.auth import authenticate, login, logout", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 59 }, { "span": "from django.contrib.auth.decorators import login_required", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 57 }, { "span": "from django.conf.urls.static import static, settings", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 52 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Dj", "ang", "o", " ", "&", " ", "Python_", "\\u\\u\\uNL\\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_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Modal_", "\\u\\u\\uNL\\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_", "Policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "View_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "teacher_", "._", "views_", "import_", "policy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Conta", "nts_", "\\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_", "#", " ", "Creat", "e", " ", "your", " ", "tests", " ", "here", "._", "\\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_", "Polic", "y", "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_", "[SEP]_", "class_", "Polic", "y", "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 ", " _", "policies_", "=_", "Policy_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "policy_", "in_", "policies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "policy_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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_", "Polic", "y", "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", " ", "user", "._", "\\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_", "\\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_", "\\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_", "[SEP]_", "class_", "Polic", "y", "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_", "Polic", "y", "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", "tru", "dy", "\\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", "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_", "return_", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "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", "policy", "\\u", "page", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "found_", "=_", "resolve_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "policy", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "found_", "._", "func_", ",_", "policy_", "._", "policy", "\\u", "page_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "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", "policy", "\\u", "page", "\\u", "with", "out", "\\u", "pdf", "\\u", "file_", "(_", "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_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "policy", "'_", ")_", "\\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", "'<", "h1", ">", "Upload", "'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "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", "policy", "\\u", "modal_", "(_", "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_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "policy", "\\u", "modal", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "policy", "\\u", "modal", "'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "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", "policy", "\\u", "page", "\\u", "with", "\\u", "pdf", "\\u", "file_", "(_", "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_", "file", "\\u", "path_", "=_", "settings_", "._", "MEDIA", "\\u", "ROOT_", "+_", "'/", "sample", ".", "pdf", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "file", "\\u", "path_", ",_", "'", "rb", "'_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "fp_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "save", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "'_", ":_", "fp_", ",_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "policy", "'_", ")_", "\\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", "'", "aja", "x", "\\u", "delete", "\\u", "policy", "'_", ",_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "b", "'", "PD", "F", " ", "RESU", "LT", "'_", ",_", "response_", "._", "content_", ")_", "\\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 ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "1_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "2_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "3_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "Test", "Case_", "(_", "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", "save", "\\u", "policy_", "(_", "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_", "file", "\\u", "path_", "=_", "settings_", "._", "MEDIA", "\\u", "ROOT_", "+_", "'/", "sample", ".", "pdf", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "file", "\\u", "path_", ",_", "'", "rb", "'_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "fp_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "save", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "'_", ":_", "fp_", ",_", "\\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_", "[_", "'", "message", "'_", "]_", ",_", "'", "saved", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\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 ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "1_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "2_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Policy_", "._", "objects_", "._", "get_", "(_", "policy", "\\u", "id_", "=_", "3_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Policy_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "Test", "Case_", "(_", "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", "delete", "\\u", "policy", "\\u", "with", "\\u", "subm", "ission", "\\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_", "file", "\\u", "path_", "=_", "settings_", "._", "MEDIA", "\\u", "ROOT_", "+_", "'/", "sample", ".", "pdf", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "file", "\\u", "path_", ",_", "'", "rb", "'_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "fp_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "save", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "'_", ":_", "fp_", ",_", "\\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_", "[_", "'", "message", "'_", "]_", ",_", "'", "saved", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "delete", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "policy", "\\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_", "[_", "'", "message", "'_", "]_", ",_", "'", "delete", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Polic", "y", "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", "policy", "\\u", "with", "\\u", "subm", "ission", "\\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_", "file", "\\u", "path_", "=_", "settings_", "._", "MEDIA", "\\u", "ROOT_", "+_", "'/", "sample", ".", "pdf", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "file", "\\u", "path_", ",_", "'", "rb", "'_", ")_", "as_", "fp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "fp_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "save", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "file", "'_", ":_", "fp_", ",_", "\\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_", "[_", "'", "message", "'_", "]_", ",_", "'", "saved", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "success", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client_", "._", "logout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "self_", "._", "get", "\\u", "logged", "\\u", "in", "\\u", "tru", "dy", "\\u", "client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "client_", "._", "post_", "(_", "'/", "teacher", "/", "course", "/", "1", "/", "delete", "\\u", "policy", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "policy", "\\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_", "[_", "'", "message", "'_", "]_", ",_", "'", "unauthorized", " ", "deletion", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "array_", "[_", "'", "status", "'_", "]_", ",_", "'", "fail", "ed", "'_", ")_" ]
[ 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, 0, 1, 1, 1, 1, 1, 1, 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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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
ARTbio/tools-artbio/unstable/local_tools/piRNA_cluster_extracter.py
[ { "content": "#!/usr/bin/python\n# script to extract cluster sequences from brennecke et al table\n# version 1 - 22-03-2013\n# Usage piRNA_cluster_extracter.py <Dmfasta_genome> <coordinate reference table>\n\nimport sys\n\nfasta_dic = {}\n\nF = open (sys.argv[1], \"r\") # F the Dm fasta genome\nfor line in F:\n if line[0] == \">\":\n try:\n fasta_dic[current_item] = \"\".join(stringlist) # to dump the sequence of the previous item - try because of the keyerror of the first item\n except: pass\n current_item = line[1:].rstrip().split()[0] #take the first word before space because bowtie splits headers !\n fasta_dic[current_item] = \"\"\n stringlist=[]\n else:\n stringlist.append(line.rstrip() )\nfasta_dic[current_item] = \"\".join(stringlist) # for the last item\nF.close()\n\nF = open (sys.argv[2], \"r\") # F the cluster reference coordinates\nref_lines = F.readlines()\nfor line in ref_lines[1:]:\n fields = line.split()\n print \">%s_%s\" % (fields[0], fields[3])\n sequence=fasta_dic[fields[0]][int(fields[1]):int(fields[2])+1]\n for i in range(0, len(sequence), 60):\n print \"%s\" % (sequence[i:i+60])\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except: ", "start_line": 14, "start_column": 4, "end_line": 14, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "script", " ", "to", " ", "extract", " ", "cluster", " ", "sequence", "s", " ", "from", " ", "bre", "nne", "cke", " ", "et", " ", "al", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "version", " ", "1", " ", "-", " ", "2", "2", "-0", "3", "-", "2013_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "age", " ", "pi", "RNA", "\\u", "cluster", "\\u", "extract", "er", ".", "py", " ", " ", "<", "Dm", "fasta", "\\u", "geno", "me", ">", " ", "<", "coordinate", " ", "reference", " ", "table", ">_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fasta", "\\u", "dic_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "F_", "=_", "open_", "(_", "sys_", "._", "argv_", "[_", "1_", "]_", ",_", "\"", "r", "\"_", ")_", "#", " ", "F", " ", "the", " ", "Dm", " ", "fasta", " ", "genome_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "F_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "line_", "[_", "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 ", " _", "fasta", "\\u", "dic_", "[_", "current", "\\u", "item_", "]_", "=_", "\"\"_", "._", "join_", "(_", "string", "list_", ")_", "#", " ", "to", " ", "dump", " ", "the", " ", "sequence", " ", "of", " ", "the", " ", "previ", "ous", " ", "item", " ", "-", " ", "try", " ", "bec", "aus", "e", " ", "of", " ", "the", " ", "key", "error", " ", "of", " ", "the", " ", "first", " ", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "\\u", "item_", "=_", "line_", "[_", "1_", ":_", "]_", "._", "rstrip_", "(_", ")_", "._", "split_", "(_", ")_", "[_", "0_", "]_", "#", "take", " ", "the", " ", "first", " ", "word", " ", "bef", "ore", " ", "space", " ", "bec", "aus", "e", " ", "bowtie", " ", "split", "s", " ", "header", "s", " ", "!", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fasta", "\\u", "dic_", "[_", "current", "\\u", "item_", "]_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "string", "list_", "=_", "[_", "]_", "\\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 ", " _", "string", "list_", "._", "append_", "(_", "line_", "._", "rstrip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fasta", "\\u", "dic_", "[_", "current", "\\u", "item_", "]_", "=_", "\"\"_", "._", "join_", "(_", "string", "list_", ")_", "#", " ", "for", " ", "the", " ", "last", " ", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "F_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "F_", "=_", "open_", "(_", "sys_", "._", "argv_", "[_", "2_", "]_", ",_", "\"", "r", "\"_", ")_", "#", " ", "F", " ", "the", " ", "cluster", " ", "reference", " ", "coordinates_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ref", "\\u", "lines_", "=_", "F_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "ref", "\\u", "lines_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fields_", "=_", "line_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\">", "%", "s", "\\u", "%", "s", "\"_", "%_", "(_", "fields_", "[_", "0_", "]_", ",_", "fields_", "[_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sequence_", "=_", "fasta", "\\u", "dic_", "[_", "fields_", "[_", "0_", "]_", "]_", "[_", "int_", "(_", "fields_", "[_", "1_", "]_", ")_", ":_", "int_", "(_", "fields_", "[_", "2_", "]_", ")_", "+_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "0_", ",_", "len_", "(_", "sequence_", ")_", ",_", "60_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"%", "s", "\"_", "%_", "(_", "sequence_", "[_", "i_", ":_", "i_", "+_", "60_", "]_", ")_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
google/transitfeed/transitfeed/schedule.py
[ { "content": " def AddTransferObject(self, transfer, problem_reporter=None):\n assert transfer._schedule is None, \"only add Transfer to a schedule once\"\n if not problem_reporter:\n problem_reporter = self.problem_reporter\n\n transfer_id = transfer._ID()\n\n if transfer_id in self._transfers:\n self.problem_reporter.DuplicateID(self._gtfs_factory.Transfer._ID_COLUMNS,\n transfer_id,\n type=problems_module.TYPE_WARNING)\n # Duplicates are still added, while not prohibited by GTFS.\n\n transfer._schedule = weakref.proxy(self) # See weakref comment at top\n self.AddTableColumns('transfers', transfer._ColumnNames())\n self._transfers[transfer_id].append(transfer)", "metadata": "root.Schedule.AddTransferObject", "header": "['class', 'Schedule', '(', 'object', ')', ':', '___EOS___']", "index": 546 } ]
[ { "span": "problem_reporter ", "start_line": 549, "start_column": 6, "end_line": 549, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Schedule_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Add", "Transfer", "Object_", "(_", "self_", ",_", "transfer_", ",_", "problem", "\\u", "reporter_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "transfer_", "._", "\\u", "schedule_", "is_", "None_", ",_", "\"", "only", " ", "add", " ", "Transfer", " ", "to", " ", "a", " ", "schedule", " ", "onc", "e", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "problem", "\\u", "reporter_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "problem", "\\u", "reporter_", "=_", "self_", "._", "problem", "\\u", "reporter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "transfer", "\\u", "id_", "=_", "transfer_", "._", "\\u", "ID_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "transfer", "\\u", "id_", "in_", "self_", "._", "\\u", "transfers", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "problem", "\\u", "reporter_", "._", "Duplicate", "ID_", "(_", "self_", "._", "\\u", "gtfs", "\\u", "factory_", "._", "Transfer", "_", "._", "\\u", "ID", "\\u", "COLUMNS_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transfer", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type_", "=_", "problem", "s", "\\u", "module_", "._", "TYPE", "\\u", "WARNING_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Duplicate", "s", " ", "are", " ", "still", " ", "adde", "d", ",", " ", "whi", "le", " ", "not", " ", "pro", "hibit", "ed", " ", "by", " ", "GT", "FS", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "transfer_", "._", "\\u", "schedule_", "=_", "weakref_", "._", "proxy_", "(_", "self_", ")_", "#", " ", "See", " ", "weak", "ref", " ", "comment", " ", "at", " ", "top_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Add", "Table", "Columns_", "(_", "'", "transfers", "'_", ",_", "transfer_", "._", "\\u", "Colum", "n", "Names_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "transfers", "_", "[_", "transfer", "\\u", "id_", "]_", "._", "append_", "(_", "transfer_", ")_", "\\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, 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 ]
Except block handles 'BaseException'
twisted/nevow/nevow/flat/flatsax.py
[ { "content": "# Copyright (c) 2004-2009 Divmod.\n# See LICENSE for details.\n\nfrom xml.sax import make_parser, handler\nimport xml as pyxml\n\nfrom nevow.stan import xml, Tag, directive, slot\nimport nevow\n\n## Require PyXML 0.8.2 or later, or, if PyXML isn't installed\n## python2.3 or later, because that includes approximately the\n## same code (but doesn't share a version number *!@#$@!@#)\n\ntry:\n ## pyxml package has a version_info attribute\n bad_version = pyxml.version_info < (0,8,2)\n ## before 0.8.3, startDTD was passed the args in the wrong order\n bad_startdtd_args = pyxml.version_info < (0,8,3)\nexcept:\n ## we're using core python xml library\n import sys\n bad_version = sys.version_info < (2,3)\n # python < 2.4 has the startDTD bug\n bad_startdtd_args = sys.version_info < (2,4)\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2004", "-", "200", "9", " ", "Di", "vmo", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "LICENSE", " ", "for", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "xml_", "._", "sax_", "import_", "make", "\\u", "parser_", ",_", "handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "xml_", "as_", "pyx", "ml_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "nev", "ow_", "._", "stan", "_", "import_", "xml_", ",_", "Tag_", ",_", "directive_", ",_", "slot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "nev", "ow_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Requ", "ire", " ", "Py", "XML", " ", "0.", "8.2", " ", "or", " ", "late", "r", ",", " ", "or", ",", " ", "if", " ", "Py", "XML", " ", "isn", "'", "t", " ", "installed_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "python", "2.3", " ", "or", " ", "late", "r", ",", " ", "bec", "aus", "e", " ", "tha", "t", " ", "include", "s", " ", "approximate", "ly", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "same", " ", "code", " ", "(", "but", " ", "doe", "sn", "'", "t", " ", "share", " ", "a", " ", "version", " ", "number", " ", "*", "!@", "#$", "@", "!@", "#)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "pyx", "ml", " ", "package", " ", "has", " ", "a", " ", "version", "\\u", "info", " ", "attribute_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bad", "\\u", "version_", "=_", "pyx", "ml_", "._", "version", "\\u", "info_", "<_", "(_", "0_", ",_", "8_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "bef", "ore", " ", "0.", "8.3", ",", " ", "start", "DT", "D", " ", "was", " ", "pass", "ed", " ", "the", " ", "args", " ", "in", " ", "the", " ", "wrong", " ", "order_", "\\u\\u\\uNL\\u\\u\\u_", "bad", "\\u", "startd", "td", "\\u", "args_", "=_", "pyx", "ml_", "._", "version", "\\u", "info_", "<_", "(_", "0_", ",_", "8_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "we", "'", "re", " ", "usi", "ng", " ", "core", " ", "python", " ", "xml", " ", "library_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad", "\\u", "version_", "=_", "sys_", "._", "version", "\\u", "info_", "<_", "(_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "python", " ", "<", " ", "2.4", " ", "has", " ", "the", " ", "start", "DT", "D", " ", "bug_", "\\u\\u\\uNL\\u\\u\\u_", "bad", "\\u", "startd", "td", "\\u", "args_", "=_", "sys_", "._", "version", "\\u", "info_", "<_", "(_", "2_", ",_", "4_", ")_", "\\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\\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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 ]
Variable defined multiple times
grantmcconnaughey/django-avatar/tests/settings.py
[ { "content": "import django\n\nDATABASE_ENGINE = 'sqlite3'\n\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3',\n 'NAME': ':memory:',\n }\n}\n\nINSTALLED_APPS = [\n 'django.contrib.sessions',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sites',\n 'avatar',\n]\n\nMIDDLEWARE_CLASSES = (\n \"django.middleware.common.CommonMiddleware\",\n \"django.contrib.sessions.middleware.SessionMiddleware\",\n \"django.middleware.csrf.CsrfViewMiddleware\",\n \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n \"django.contrib.messages.middleware.MessageMiddleware\",\n)\n\n\nROOT_URLCONF = 'tests.urls'\n\nSITE_ID = 1\n\nSECRET_KEY = 'something-something'\n\nif django.VERSION[:2] < (1, 6):\n TEST_RUNNER = 'discover_runner.DiscoverRunner'\n\nROOT_URLCONF = 'tests.urls'\n\nSTATIC_URL = '/site_media/static/'\n\nAVATAR_ALLOWED_FILE_EXTS = ('.jpg', '.png')\nAVATAR_MAX_SIZE = 1024 * 1024\nAVATAR_MAX_AVATARS_PER_USER = 20\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "ROOT_URLCONF ", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 12 } ]
[ { "span": "ROOT_URLCONF ", "start_line": 37, "start_column": 0, "end_line": 37, "end_column": 12 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "django_", "\\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_", "\\u\\u\\uNL\\u\\u\\u_", "DATABASES_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "default", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ENGINE", "'_", ":_", "'", "django", ".", "db", ".", "back", "ends", ".", "sql", "ite", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "NAME", "'_", ":_", "':", "memory", ":'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "INSTALLE", "D", "\\u", "APPS_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "django", ".", "contrib", ".", "session", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "django", ".", "contrib", ".", "auth", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "django", ".", "contrib", ".", "contenttype", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "django", ".", "contrib", ".", "sites", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "avat", "ar", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MIDDLE", "WARE", "\\u", "CLASSES_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "django", ".", "middle", "ware", ".", "common", ".", "Common", "Mid", "dle", "ware", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "django", ".", "contrib", ".", "session", "s", ".", "middle", "ware", ".", "Sess", "ion", "Mid", "dle", "ware", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "django", ".", "middle", "ware", ".", "csr", "f", ".", "Cs", "rf", "View", "Mid", "dle", "ware", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "django", ".", "contrib", ".", "auth", ".", "middle", "ware", ".", "Auth", "entica", "tion", "Mid", "dle", "ware", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "django", ".", "contrib", ".", "message", "s", ".", "middle", "ware", ".", "Messag", "e", "Mid", "dle", "ware", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ROO", "T", "\\u", "URLCONF_", "=_", "'", "tests", ".", "urls", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SITE", "\\u", "ID_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SEC", "RET", "\\u", "KEY_", "=_", "'", "somet", "hing", "-", "somet", "hing", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "django_", "._", "VERSION_", "[_", ":_", "2_", "]_", "<_", "(_", "1_", ",_", "6_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "TEST", "\\u", "RUNN", "ER_", "=_", "'", "discove", "r", "\\u", "runn", "er", ".", "Discover", "Run", "ner", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ROO", "T", "\\u", "URLCONF_", "=_", "'", "tests", ".", "urls", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "STATI", "C", "\\u", "URL_", "=_", "'/", "site", "\\u", "media", "/", "static", "/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "AVA", "TAR", "\\u", "ALLOWED", "\\u", "FILE", "\\u", "EXT", "S_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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, 3, 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 ]
Except block handles 'BaseException'
RoseOu/flasky/venv/lib/python2.7/site-packages/gunicorn/workers/gthread.py
[ { "content": " def finish_request(self, fs):\n if fs.cancelled():\n fs.conn.close()\n return\n\n try:\n (keepalive, conn) = fs.result()\n # if the connection should be kept alived add it\n # to the eventloop and record it\n if keepalive:\n # flag the socket as non blocked\n conn.sock.setblocking(False)\n\n # register the connection\n conn.set_timeout()\n with self._lock:\n self._keep.append(conn)\n\n # add the socket to the event loop\n self.poller.register(conn.sock, selectors.EVENT_READ,\n partial(self.reuse_connection, conn))\n else:\n self.nr_conns -= 1\n conn.close()\n except:\n # an exception happened, make sure to close the\n # socket.\n self.nr_conns -= 1\n fs.conn.close()", "metadata": "root.ThreadWorker.finish_request", "header": "['class', 'ThreadWorker', '(', 'base', '.', 'Worker', ')', ':', '___EOS___']", "index": 234 } ]
[ { "span": "except:", "start_line": 258, "start_column": 8, "end_line": 258, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Thread", "Worker_", "(_", "base_", "._", "Worker_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "finish", "\\u", "request_", "(_", "self_", ",_", "fs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "fs_", "._", "cancelled_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fs_", "._", "conn_", "._", "close_", "(_", ")_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "keepalive", "_", ",_", "conn_", ")_", "=_", "fs_", "._", "result_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "connecti", "on", " ", "shou", "ld", " ", "be", " ", "kep", "t", " ", "alive", "d", " ", "add", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "the", " ", "eventl", "oop", " ", "and", " ", "record", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "keepalive", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "flag", " ", "the", " ", "socket", " ", "as", " ", "non", " ", "blocked_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conn_", "._", "sock_", "._", "setb", "locking_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "register", " ", "the", " ", "connection_", "\\u\\u\\uNL\\u\\u\\u_", "conn_", "._", "set\\u", "timeout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "\\u", "lock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "keep_", "._", "append_", "(_", "conn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "the", " ", "socket", " ", "to", " ", "the", " ", "event", " ", "loop_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "poller_", "._", "register_", "(_", "conn_", "._", "sock_", ",_", "selectors_", "._", "EVENT", "\\u", "READ_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "partial_", "(_", "self_", "._", "reus", "e\\u", "connection_", ",_", "conn_", ")_", ")_", "\\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_", "._", "nr", "\\u", "conns_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "close_", "(_", ")_", "\\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_", "#", " ", "an", " ", "exception", " ", "happ", "ened", ",", " ", "make", " ", "sure", " ", "to", " ", "close", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "socket", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nr", "\\u", "conns_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fs_", "._", "conn_", "._", "close_", "(_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
deanhiller/databus/webapp/play1.3.x/python/Lib/site-packages/pyreadline/modes/basemode.py
[ { "content": "# -*- coding: utf-8 -*-\n#*****************************************************************************\n# Copyright (C) 2003-2006 Gary Bishop.\n# Copyright (C) 2006 Jorgen Stenarson. <[email protected]>\n#\n# Distributed under the terms of the BSD License. The full license is in\n# the file COPYING, distributed as part of this software.\n#*****************************************************************************\nimport os,re,math,glob,sys\nimport pyreadline.logger as logger\nfrom pyreadline.logger import log,log_sock\nfrom pyreadline.keysyms.common import make_KeyPress_from_keydescr\nimport pyreadline.lineeditor.lineobj as lineobj\nimport pyreadline.lineeditor.history as history\nimport pyreadline.clipboard as clipboard\nfrom pyreadline.error import ReadlineError,GetSetError\nfrom pyreadline.unicode_helper import ensure_str, ensure_unicode\nin_ironpython=\"IronPython\" in sys.version\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class BaseMode(object):\n mode=\"base\"\n \n\n \n\n argument_reset=property(_argreset)\n \n ctrl_c_tap_time_interval=property(*_gs(\"ctrl_c_tap_time_interval\"))\n allow_ctrl_c=property(*_gs(\"allow_ctrl_c\"))\n l_buffer=property(*_gs(\"l_buffer\"))\n next_meta=property(*_gs(\"next_meta\"))\n first_prompt=property(*_gs(\"first_prompt\"))\n prompt=property(*_gs(\"prompt\"))\n paste_line_buffer=property(*_gs(\"paste_line_buffer\"))\n completer_delims=property(*_gs(\"completer_delims\"))\n show_all_if_ambiguous=property(*_gs(\"show_all_if_ambiguous\"))\n mark_directories=property(*_gs(\"mark_directories\"))\n completer=property(*_gs(\"completer\"))\n begidx=property(*_gs(\"begidx\"))\n startup_hook=property(*_gs(\"startup_hook\"))\n pre_input_hook=property(*_gs(\"pre_input_hook\"))\n endidx=property(*_gs(\"endidx\"))\n \n console=property(_g(\"console\"))\n insert_text=property(_g(\"insert_text\"))\n _print_prompt=property(_g(\"_print_prompt\"))\n _update_line=property(_g(\"_update_line\"))\n add_history=property(_g(\"add_history\"))\n _bell=property(_g(\"_bell\"))\n _clear_after=property(_g(\"_clear_after\"))\n _set_cursor=property(_g(\"_set_cursor\"))\n _update_prompt_pos=property(_g(\"_update_prompt_pos\"))\n _update_line=property(_g(\"_update_line\"))\n enable_win32_clipboard=property(_g(\"enable_win32_clipboard\"))\n enable_ipython_paste_list_of_lists=property(_g(\"enable_ipython_paste_list_of_lists\"))\n enable_ipython_paste_for_paths=property(_g(\"enable_ipython_paste_for_paths\"))\n _bell=property(_g(\"_bell\"))\n _history=property(_g(\"_history\"))\n prompt_end_pos=property(_g(\"prompt_end_pos\"))\n prompt_begin_pos=property(_g(\"prompt_begin_pos\"))\n\n rl_settings_to_string=property(_g(\"rl_settings_to_string\"))\n\n\n\n #Create key bindings:\n\n\n\n#completion commands \n \n\n \n\n\n\n\n\n ### Methods below here are bindable emacs functions\n\n\n\n\n\n\n\n\n\n### Movement with extend selection\n\n\n\n\n\n\n\n\n\n######## Change case\n\n\n\n\n\n########\n\n\n\n\n\n\n\n\n\n\n\n# Paste from clipboard\n\n\n \n\n\n\n\n\n", "metadata": "root.BaseMode", "header": "['module', '___EOS___']", "index": 19 }, { "content": " def __init__(self,rlobj):\n self.rlobj=rlobj\n self.exit_dispatch = {}\n self.key_dispatch = {}\n self.argument=1\n self.prevargument=None", "metadata": "root.BaseMode.__init__", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 21 }, { "content": " def __repr__(self):\n return \"<BaseMode>\"", "metadata": "root.BaseMode.__repr__", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 28 }, { "content": " def _gs(x):\n def g(self):\n return getattr(self.rlobj,x)\n def s(self,q):\n setattr(self.rlobj,x,q)\n return g,s", "metadata": "root.BaseMode._gs", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 31 }, { "content": " def _g(x):\n def g(self):\n return getattr(self.rlobj,x)\n return g", "metadata": "root.BaseMode._g", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 38 }, { "content": " def _argreset(self):\n val=self.argument\n self.argument=1\n return val", "metadata": "root.BaseMode._argreset", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 43 }, { "content": " def _readline_from_keyboard(self):\n raise NotImplementedError", "metadata": "root.BaseMode._readline_from_keyboard", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 85 }, { "content": " def readline(self, prompt=''):\n raise NotImplementedError", "metadata": "root.BaseMode.readline", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 88 }, { "content": " def _bind_key(self, key, func):\n '''setup the mapping from key to call the function.'''\n if type(func) != type(self._bind_key):\n print \"Trying to bind non method to keystroke:%s,%s\"%(key,func)\n raise PyreadlineError(\"Trying to bind non method to keystroke:%s,%s,%s,%s\"%(key,func,type(func),type(self._bind_key)))\n keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()\n log(\">>>%s -> %s<<<\"%(keyinfo,func.__name__))\n self.key_dispatch[keyinfo] = func", "metadata": "root.BaseMode._bind_key", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 93 }, { "content": " def _bind_exit_key(self, key):\n '''setup the mapping from key to call the function.'''\n keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()\n self.exit_dispatch[keyinfo] = None", "metadata": "root.BaseMode._bind_exit_key", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 102 }, { "content": " def init_editing_mode(self, e): # (C-e)\n '''When in vi command mode, this causes a switch to emacs editing\n mode.'''\n\n raise NotImplementedError", "metadata": "root.BaseMode.init_editing_mode", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 107 }, { "content": " def _get_completions(self):\n \n '''Return a list of possible completions for the string ending at the point.\n\n Also set begidx and endidx in the process.'''\n completions = []\n self.begidx = self.l_buffer.point\n self.endidx = self.l_buffer.point\n buf=self.l_buffer.line_buffer\n if self.completer:\n # get the string to complete\n while self.begidx > 0:\n self.begidx -= 1\n if buf[self.begidx] in self.completer_delims:\n self.begidx += 1\n break\n text = ensure_str(''.join(buf[self.begidx:self.endidx]))\n log('complete text=\"%s\"' % text)\n i = 0\n while 1:\n try:\n r = ensure_unicode(self.completer(text, i))\n except:\n break\n i += 1\n if r and r not in completions:\n completions.append(r)\n else:\n break\n log('text completions=%s' % completions)\n if not completions:\n # get the filename to complete\n while self.begidx > 0:\n self.begidx -= 1\n if buf[self.begidx] in ' \\t\\n':\n self.begidx += 1\n break\n text = ensure_str(''.join(buf[self.begidx:self.endidx]))\n log('file complete text=\"%s\"' % text)\n completions = map(ensure_unicode, glob.glob(os.path.expanduser(text) + '*'))\n if self.mark_directories == 'on':\n mc = []\n for f in completions:\n if os.path.isdir(f):\n mc.append(f + os.sep)\n else:\n mc.append(f)\n completions = mc\n log('fnames=%s' % completions)\n return completions", "metadata": "root.BaseMode._get_completions", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 114 }, { "content": " def _display_completions(self, completions):\n if not completions:\n return\n self.console.write('\\n')\n wmax = max(map(len, completions))\n w, h = self.console.size()\n cols = max(1, int((w-1) / (wmax+1)))\n rows = int(math.ceil(float(len(completions)) / cols))\n for row in range(rows):\n s = ''\n for col in range(cols):\n i = col*rows + row\n if i < len(completions):\n self.console.write(completions[i].ljust(wmax+1))\n self.console.write('\\n')\n if in_ironpython:\n self.prompt=sys.ps1\n self._print_prompt()", "metadata": "root.BaseMode._display_completions", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 166 }, { "content": " def complete(self, e): # (TAB)\n '''Attempt to perform completion on the text before point. The\n actual completion performed is application-specific. The default is\n filename completion.'''\n completions = self._get_completions()\n if completions:\n cprefix = commonprefix(completions)\n rep = [ c for c in cprefix ]\n point=self.l_buffer.point\n self.l_buffer[self.begidx:self.endidx] = rep\n self.l_buffer.point = point + len(rep) - (self.endidx - self.begidx)\n if len(completions) > 1:\n if self.show_all_if_ambiguous == 'on':\n self._display_completions(completions)\n else:\n self._bell()\n else:\n self._bell()", "metadata": "root.BaseMode.complete", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 185 }, { "content": " def possible_completions(self, e): # (M-?)\n '''List the possible completions of the text before point. '''\n completions = self._get_completions()\n self._display_completions(completions)", "metadata": "root.BaseMode.possible_completions", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 204 }, { "content": " def insert_completions(self, e): # (M-*)\n '''Insert all completions of the text before point that would have\n been generated by possible-completions.'''\n completions = self._get_completions()\n b = self.begidx\n e = self.endidx\n for comp in completions:\n rep = [ c for c in comp ]\n rep.append(' ')\n self.l_buffer[b:e] = rep\n b += len(rep)\n e = b\n self.line_cursor = b ", "metadata": "root.BaseMode.insert_completions", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 209 }, { "content": " def menu_complete(self, e): # ()\n '''Similar to complete, but replaces the word to be completed with a\n single match from the list of possible completions. Repeated\n execution of menu-complete steps through the list of possible\n completions, inserting each match in turn. At the end of the list of\n completions, the bell is rung (subject to the setting of bell-style)\n and the original text is restored. An argument of n moves n\n positions forward in the list of matches; a negative argument may be\n used to move backward through the list. This command is intended to\n be bound to TAB, but is unbound by default.'''\n pass", "metadata": "root.BaseMode.menu_complete", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 223 }, { "content": " def beginning_of_line(self, e): # (C-a)\n '''Move to the start of the current line. '''\n self.l_buffer.beginning_of_line()", "metadata": "root.BaseMode.beginning_of_line", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 237 }, { "content": " def end_of_line(self, e): # (C-e)\n '''Move to the end of the line. '''\n self.l_buffer.end_of_line()", "metadata": "root.BaseMode.end_of_line", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 241 }, { "content": " def forward_char(self, e): # (C-f)\n '''Move forward a character. '''\n self.l_buffer.forward_char(self.argument_reset)", "metadata": "root.BaseMode.forward_char", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 245 }, { "content": " def backward_char(self, e): # (C-b)\n '''Move back a character. '''\n self.l_buffer.backward_char(self.argument_reset)", "metadata": "root.BaseMode.backward_char", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 249 }, { "content": " def forward_word(self, e): # (M-f)\n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.forward_word(self.argument_reset)", "metadata": "root.BaseMode.forward_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 253 }, { "content": " def backward_word(self, e): # (M-b)\n '''Move back to the start of the current or previous word. Words are\n composed of letters and digits.'''\n self.l_buffer.backward_word(self.argument_reset)", "metadata": "root.BaseMode.backward_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 258 }, { "content": " def forward_word_end(self, e): # ()\n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.forward_word_end(self.argument_reset)", "metadata": "root.BaseMode.forward_word_end", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 263 }, { "content": " def backward_word_end(self, e): # ()\n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.backward_word_end(self.argument_reset)", "metadata": "root.BaseMode.backward_word_end", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 268 }, { "content": " def beginning_of_line_extend_selection(self, e): # \n '''Move to the start of the current line. '''\n self.l_buffer.beginning_of_line_extend_selection()", "metadata": "root.BaseMode.beginning_of_line_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 274 }, { "content": " def end_of_line_extend_selection(self, e): # \n '''Move to the end of the line. '''\n self.l_buffer.end_of_line_extend_selection()", "metadata": "root.BaseMode.end_of_line_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 278 }, { "content": " def forward_char_extend_selection(self, e): # \n '''Move forward a character. '''\n self.l_buffer.forward_char_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.forward_char_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 282 }, { "content": " def backward_char_extend_selection(self, e): #\n '''Move back a character. '''\n self.l_buffer.backward_char_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.backward_char_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 286 }, { "content": " def forward_word_extend_selection(self, e): # \n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.forward_word_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.forward_word_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 290 }, { "content": " def backward_word_extend_selection(self, e): # \n '''Move back to the start of the current or previous word. Words are\n composed of letters and digits.'''\n self.l_buffer.backward_word_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.backward_word_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 295 }, { "content": " def forward_word_end_extend_selection(self, e): # \n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.forward_word_end_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.forward_word_end_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 300 }, { "content": " def backward_word_end_extend_selection(self, e): # \n '''Move forward to the end of the next word. Words are composed of\n letters and digits.'''\n self.l_buffer.forward_word_end_extend_selection(self.argument_reset)", "metadata": "root.BaseMode.backward_word_end_extend_selection", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 305 }, { "content": " def upcase_word(self, e): # (M-u)\n '''Uppercase the current (or following) word. With a negative\n argument, uppercase the previous word, but do not move the cursor.'''\n self.l_buffer.upcase_word()", "metadata": "root.BaseMode.upcase_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 313 }, { "content": " def downcase_word(self, e): # (M-l)\n '''Lowercase the current (or following) word. With a negative\n argument, lowercase the previous word, but do not move the cursor.'''\n self.l_buffer.downcase_word()", "metadata": "root.BaseMode.downcase_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 318 }, { "content": " def capitalize_word(self, e): # (M-c)\n '''Capitalize the current (or following) word. With a negative\n argument, capitalize the previous word, but do not move the cursor.'''\n self.l_buffer.capitalize_word()", "metadata": "root.BaseMode.capitalize_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 323 }, { "content": " def clear_screen(self, e): # (C-l)\n '''Clear the screen and redraw the current line, leaving the current\n line at the top of the screen.'''\n self.console.page()", "metadata": "root.BaseMode.clear_screen", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 330 }, { "content": " def redraw_current_line(self, e): # ()\n '''Refresh the current line. By default, this is unbound.'''\n pass", "metadata": "root.BaseMode.redraw_current_line", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 335 }, { "content": " def accept_line(self, e): # (Newline or Return)\n '''Accept the line regardless of where the cursor is. If this line\n is non-empty, it may be added to the history list for future recall\n with add_history(). If this line is a modified history line, the\n history line is restored to its original state.'''\n return True", "metadata": "root.BaseMode.accept_line", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 339 }, { "content": " def delete_char(self, e): # (C-d)\n '''Delete the character at point. If point is at the beginning of\n the line, there are no characters in the line, and the last\n character typed was not bound to delete-char, then return EOF.'''\n self.l_buffer.delete_char(self.argument_reset)", "metadata": "root.BaseMode.delete_char", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 347 }, { "content": " def backward_delete_char(self, e): # (Rubout)\n '''Delete the character behind the cursor. A numeric argument means\n to kill the characters instead of deleting them.'''\n self.l_buffer.backward_delete_char(self.argument_reset)", "metadata": "root.BaseMode.backward_delete_char", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 353 }, { "content": " def backward_delete_word(self, e): # (Control-Rubout)\n '''Delete the character behind the cursor. A numeric argument means\n to kill the characters instead of deleting them.'''\n self.l_buffer.backward_delete_word(self.argument_reset)", "metadata": "root.BaseMode.backward_delete_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 358 }, { "content": " def forward_delete_word(self, e): # (Control-Delete)\n '''Delete the character behind the cursor. A numeric argument means\n to kill the characters instead of deleting them.'''\n self.l_buffer.forward_delete_word(self.argument_reset)", "metadata": "root.BaseMode.forward_delete_word", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 363 }, { "content": " def delete_horizontal_space(self, e): # ()\n '''Delete all spaces and tabs around point. By default, this is unbound. '''\n self.l_buffer.delete_horizontal_space()", "metadata": "root.BaseMode.delete_horizontal_space", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 368 }, { "content": " def self_insert(self, e): # (a, b, A, 1, !, ...)\n '''Insert yourself. '''\n \n if e.char and ord(e.char)!=0: #don't insert null character in buffer, can happen with dead keys.\n self.insert_text(e.char)", "metadata": "root.BaseMode.self_insert", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 372 }, { "content": " def paste(self,e):\n '''Paste windows clipboard.\n Assume single line strip other lines and end of line markers and trailing spaces''' #(Control-v)\n if self.enable_win32_clipboard:\n txt=clipboard.get_clipboard_text_and_convert(False)\n txt=txt.split(\"\\n\")[0].strip(\"\\r\").strip(\"\\n\")\n log(\"paste: >%s<\"%map(ord,txt))\n self.insert_text(txt)", "metadata": "root.BaseMode.paste", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 381 }, { "content": " def paste_mulitline_code(self,e):\n '''Paste windows clipboard as multiline code.\n Removes any empty lines in the code'''\n reg=re.compile(\"\\r?\\n\")\n if self.enable_win32_clipboard:\n txt=clipboard.get_clipboard_text_and_convert(False)\n t=reg.split(txt)\n t=[row for row in t if row.strip()!=\"\"] #remove empty lines\n if t!=[\"\"]:\n self.insert_text(t[0])\n self.add_history(self.l_buffer.copy())\n self.paste_line_buffer=t[1:]\n log(\"multi: %s\"%self.paste_line_buffer)\n return True\n else:\n return False", "metadata": "root.BaseMode.paste_mulitline_code", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 390 }, { "content": " def ipython_paste(self,e):\n '''Paste windows clipboard. If enable_ipython_paste_list_of_lists is \n True then try to convert tabseparated data to repr of list of lists or \n repr of array.\n If enable_ipython_paste_for_paths==True then change \\\\ to / and spaces to \\space'''\n if self.enable_win32_clipboard:\n txt=clipboard.get_clipboard_text_and_convert(\n self.enable_ipython_paste_list_of_lists)\n if self.enable_ipython_paste_for_paths:\n if len(txt)<300 and (\"\\t\" not in txt) and (\"\\n\" not in txt):\n txt=txt.replace(\"\\\\\",\"/\").replace(\" \",r\"\\ \")\n self.insert_text(txt)", "metadata": "root.BaseMode.ipython_paste", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 407 }, { "content": " def copy_region_to_clipboard(self, e): # ()\n '''Copy the text in the region to the windows clipboard.'''\n self.l_buffer.copy_region_to_clipboard()", "metadata": "root.BaseMode.copy_region_to_clipboard", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 421 }, { "content": " def copy_selection_to_clipboard(self, e): # ()\n '''Copy the text in the region to the windows clipboard.'''\n self.l_buffer.copy_selection_to_clipboard()", "metadata": "root.BaseMode.copy_selection_to_clipboard", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 425 }, { "content": " def cut_selection_to_clipboard(self, e): # ()\n '''Copy the text in the region to the windows clipboard.'''\n self.l_buffer.cut_selection_to_clipboard()", "metadata": "root.BaseMode.cut_selection_to_clipboard", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 429 }, { "content": " def dump_functions(self, e): # ()\n '''Print all of the functions and their key bindings to the Readline\n output stream. If a numeric argument is supplied, the output is\n formatted in such a way that it can be made part of an inputrc\n file. This command is unbound by default.'''\n print\n txt=\"\\n\".join(self.rl_settings_to_string())\n print txt\n self._print_prompt()", "metadata": "root.BaseMode.dump_functions", "header": "['class', 'BaseMode', '(', 'object', ')', ':', '___EOS___']", "index": 434 }, { "content": "def commonprefix(m):\n \"Given a list of pathnames, returns the longest common leading component\"\n if not m: return ''\n prefix = m[0]\n for item in m:\n for i in range(len(prefix)):\n if prefix[:i+1].lower() != item[:i+1].lower():\n prefix = prefix[:i]\n if i == 0: return ''\n break\n return prefix", "metadata": "root.commonprefix", "header": "['module', '___EOS___']", "index": 447 } ]
[ { "span": "import pyreadline.logger as logger", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 34 }, { "span": "from pyreadline.logger import log,log_sock", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 44 }, { "span": "import pyreadline.lineeditor.lineobj as lineobj", "start_line": 12, "start_column": 0, "end_line": 12, "end_column": 47 }, { "span": "import pyreadline.lineeditor.history as history", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 47 }, { "span": "from pyreadline.error import ReadlineError,GetSetError", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 54 } ]
[]
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_", "#", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "2003", "-", "2006", " ", "Gar", "y", " ", "Bis", "hop", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "2006", " ", " ", "Jo", "rge", "n", " ", "Ste", "nar", "son", ".", " ", "<", "jor", "gen", ".", "sten", "ars", "on", "@", "bos", "tream", ".", "nu", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Distribut", "ed", " ", "under", " ", "the", " ", "term", "s", " ", "of", " ", "the", " ", "BS", "D", " ", "License", ".", " ", " ", "The", " ", "full", " ", "license", " ", "is", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "the", " ", "file", " ", "COPY", "ING", ",", " ", "distributed", " ", "as", " ", "part", " ", "of", " ", "this", " ", "software", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "***********", "***********", "***********", "***********", "***********", "***********", "***********", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", ",_", "re_", ",_", "math_", ",_", "glob_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyre", "adl", "ine_", "._", "logger_", "as_", "logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyre", "adl", "ine_", "._", "logger_", "import_", "log_", ",_", "log", "\\u", "sock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyre", "adl", "ine_", "._", "keysym", "s_", "._", "common_", "import_", "make", "\\u", "Key", "Press", "\\u", "from", "\\u", "keyd", "esc", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyre", "adl", "ine_", "._", "line", "editor_", "._", "line", "obj_", "as_", "line", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyre", "adl", "ine_", "._", "line", "editor_", "._", "history_", "as_", "history_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyre", "adl", "ine_", "._", "clipboard_", "as_", "clipboard_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyre", "adl", "ine_", "._", "error_", "import_", "Read", "line", "Error_", ",_", "Get", "Set", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyre", "adl", "ine_", "._", "unicode", "\\u", "helper_", "import_", "ensure", "\\u", "str_", ",_", "ensure", "\\u", "unicode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "iron", "python_", "=_", "\"", "Iron", "Pyth", "on", "\"_", "in_", "sys_", "._", "version_", "\\u\\u\\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\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mode_", "=_", "\"", "base", "\"_", "\\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\\uDEDENT\\u\\u\\u_", "argu", "ment", "\\u", "reset_", "=_", "property_", "(_", "\\u", "arg", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctrl", "\\u", "c\\u", "tap", "\\u", "time", "\\u", "interval_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "ctrl", "\\u", "c\\u", "tap", "\\u", "time", "\\u", "interval", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "\\u", "ctrl", "\\u", "c_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "allow", "\\u", "ctrl", "\\u", "c", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l\\u", "buffer_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "l\\u", "buffer", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next", "\\u", "meta_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "next", "\\u", "meta", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "\\u", "prompt_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "first", "\\u", "prompt", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prompt_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "prompt", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "paste", "\\u", "line", "\\u", "buffer_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "paste", "\\u", "line", "\\u", "buffer", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completer", "\\u", "delim", "s_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "completer", "\\u", "delim", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "show", "\\u", "all", "\\u", "if", "\\u", "ambiguous", "_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "show", "\\u", "all", "\\u", "if", "\\u", "ambiguous", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mark", "\\u", "directories_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "mark", "\\u", "director", "ies", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completer_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "completer", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beg", "idx_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "beg", "idx", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "up", "\\u", "hook_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "start", "up", "\\u", "hook", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pre", "\\u", "input", "\\u", "hook_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "pre", "\\u", "input", "\\u", "hook", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "endi", "dx_", "=_", "property_", "(_", "*_", "\\u", "gs_", "(_", "\"", "endi", "dx", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "console_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "console", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "insert", "\\u", "text_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "insert", "\\u", "text", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "print", "\\u", "prompt_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "print", "\\u", "prompt", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "update", "\\u", "line_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "update", "\\u", "line", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "\\u", "history_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "add", "\\u", "histo", "ry", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "bell", "_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "bell", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "clear", "\\u", "after_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "clear", "\\u", "after", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "set\\u", "cursor_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "set\\u", "cursor", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "update", "\\u", "prompt", "\\u", "pos_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "update", "\\u", "prompt", "\\u", "pos", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "update", "\\u", "line_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "update", "\\u", "line", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enable", "\\u", "win32", "\\u", "clipboard_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "enable", "\\u", "win32", "\\u", "clip", "board", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "list", "\\u", "of", "\\u", "lists_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "list", "\\u", "of", "\\u", "lists", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "for", "\\u", "paths_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "for", "\\u", "path", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "bell", "_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "bell", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "history_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"\\u", "histo", "ry", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prompt", "\\u", "end", "\\u", "pos_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "prompt", "\\u", "end", "\\u", "pos", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prompt", "\\u", "begin", "\\u", "pos_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "prompt", "\\u", "begin", "\\u", "pos", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rl", "\\u", "settings", "\\u", "to", "\\u", "string_", "=_", "property_", "(_", "\\u", "g_", "(_", "\"", "rl", "\\u", "settings", "\\u", "to", "\\u", "string", "\"_", ")_", ")_", "\\u\\u\\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_", "#", "Creat", "e", " ", "key", " ", "bindi", "ngs", ":_", "\\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_", "#", "completion", " ", "command", "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\\uNL\\u\\u\\u_", "\\u\\u\\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_", "###", " ", "Meth", "ods", " ", "belo", "w", " ", "here", " ", "are", " ", "bind", "able", " ", "ema", "cs", " ", "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_", "###", " ", "Move", "ment", " ", "with", " ", "extend", " ", "selection_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "######", "##", " ", "Change", " ", "case_", "\\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\\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\\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_", "#", " ", " ", " ", "Past", "e", " ", "from", " ", "clipboard_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "rlo", "bj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "rlo", "bj_", "=_", "rlo", "bj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "exit", "\\u", "dispatch_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "\\u", "dispatch_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "argument_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prev", "argument_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "\"<", "Base", "Mode", ">\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gs_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "g_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "getattr_", "(_", "self_", "._", "rlo", "bj_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "s_", "(_", "self_", ",_", "q_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "self_", "._", "rlo", "bj_", ",_", "x_", ",_", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "g_", ",_", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "g_", "(_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "g_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "getattr_", "(_", "self_", "._", "rlo", "bj_", ",_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "arg", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "val_", "=_", "self_", "._", "argument_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "argument_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "readline", "\\u", "from", "\\u", "keyboard_", "(_", "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", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "readline_", "(_", "self_", ",_", "prompt_", "=_", "''_", ")_", ":_", "\\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", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "bind", "\\u", "key_", "(_", "self_", ",_", "key_", ",_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "setup", " ", "the", " ", "mapping", " ", "from", " ", "key", " ", "to", " ", "call", " ", "the", " ", "function", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "func_", ")_", "!=_", "type_", "(_", "self_", "._", "\\u", "bind", "\\u", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Tr", "ying", " ", "to", " ", "bind", " ", "non", " ", "method", " ", "to", " ", "keystr", "oke", ":", "%", "s", ",%", "s", "\"_", "%_", "(_", "key_", ",_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Pyr", "ead", "line", "Error_", "(_", "\"", "Tr", "ying", " ", "to", " ", "bind", " ", "non", " ", "method", " ", "to", " ", "keystr", "oke", ":", "%", "s", ",%", "s", ",%", "s", ",%", "s", "\"_", "%_", "(_", "key_", ",_", "func_", ",_", "type_", "(_", "func_", ")_", ",_", "type_", "(_", "self_", "._", "\\u", "bind", "\\u", "key_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "key", "info_", "=_", "make", "\\u", "Key", "Press", "\\u", "from", "\\u", "keyd", "esc", "r_", "(_", "key_", "._", "lower_", "(_", ")_", ")_", "._", "tuple_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "(_", "\">>>", "%", "s", " ", "->", " ", "%", "s", "<<", "<\"_", "%_", "(_", "key", "info_", ",_", "func_", "._", "\\u\\u", "name\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "key", "\\u", "dispatch_", "[_", "key", "info_", "]_", "=_", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "bind", "\\u", "exit", "\\u", "key_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "setup", " ", "the", " ", "mapping", " ", "from", " ", "key", " ", "to", " ", "call", " ", "the", " ", "function", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key", "info_", "=_", "make", "\\u", "Key", "Press", "\\u", "from", "\\u", "keyd", "esc", "r_", "(_", "key_", "._", "lower_", "(_", ")_", ")_", "._", "tuple_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "exit", "\\u", "dispatch_", "[_", "key", "info_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init", "\\u", "editin", "g", "\\u", "mode_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "e", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Whe", "n", " ", "in", " ", "vi", " ", "command", " ", "mode", ",", " ", "this", " ", "caus", "es", " ", "a", " ", "switch", " ", "to", " ", "ema", "cs", " ", "editin", "g", "\\", "10", ";", " ", " ", " ", " ", "mode", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "completions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Return", " ", "a", " ", "list", " ", "of", " ", "possib", "le", " ", "completion", "s", " ", "for", " ", "the", " ", "string", " ", "ending", " ", "at", " ", "the", " ", "point", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Al", "so", " ", "set", " ", "beg", "idx", " ", "and", " ", "endi", "dx", " ", "in", " ", "the", " ", "process", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completions_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "beg", "idx_", "=_", "self_", "._", "l\\u", "buffer_", "._", "point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "endi", "dx_", "=_", "self_", "._", "l\\u", "buffer_", "._", "point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "buf_", "=_", "self_", "._", "l\\u", "buffer_", "._", "line", "\\u", "buffer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "completer_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "string", " ", "to", " ", "complete_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "self_", "._", "beg", "idx_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "beg", "idx_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "buf_", "[_", "self_", "._", "beg", "idx_", "]_", "in_", "self_", "._", "completer", "\\u", "delim", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "beg", "idx_", "+=_", "1_", "\\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_", "text_", "=_", "ensure", "\\u", "str_", "(_", "''_", "._", "join_", "(_", "buf_", "[_", "self_", "._", "beg", "idx_", ":_", "self_", "._", "endi", "dx_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "(_", "'", "complete", " ", "text", "=\"", "%", "s", "\"'_", "%_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "1_", ":_", "\\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 ", " ", "_", "r_", "=_", "ensure", "\\u", "unicode_", "(_", "self_", "._", "completer_", "(_", "text_", ",_", "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 ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "and_", "r_", "not_", "in_", "completions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "completions_", "._", "append_", "(_", "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 ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "(_", "'", "text", " ", "completion", "s", "=", "%", "s", "'_", "%_", "completions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "completions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "filename", " ", "to", " ", "complete_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "self_", "._", "beg", "idx_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "beg", "idx_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "buf_", "[_", "self_", "._", "beg", "idx_", "]_", "in_", "'", " ", "\\\\", "t", "\\\\", "n", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "beg", "idx_", "+=_", "1_", "\\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_", "text_", "=_", "ensure", "\\u", "str_", "(_", "''_", "._", "join_", "(_", "buf_", "[_", "self_", "._", "beg", "idx_", ":_", "self_", "._", "endi", "dx_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "(_", "'", "file", " ", "complete", " ", "text", "=\"", "%", "s", "\"'_", "%_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completions_", "=_", "map_", "(_", "ensure", "\\u", "unicode_", ",_", "glob_", "._", "glob_", "(_", "os_", "._", "path_", "._", "expanduser_", "(_", "text_", ")_", "+_", "'*'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "mark", "\\u", "directories_", "==_", "'", "on", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mc_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "completions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "os_", "._", "path_", "._", "isdir_", "(_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "mc_", "._", "append_", "(_", "f_", "+_", "os_", "._", "sep_", ")_", "\\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 ", " ", " _", "mc_", "._", "append_", "(_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "completions_", "=_", "mc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "(_", "'", "fname", "s", "=", "%", "s", "'_", "%_", "completions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "completions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "display", "\\u", "completions_", "(_", "self_", ",_", "completions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "completions_", ":_", "\\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_", "._", "console_", "._", "write_", "(_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wma", "x_", "=_", "max_", "(_", "map_", "(_", "len_", ",_", "completions_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", ",_", "h_", "=_", "self_", "._", "console_", "._", "size_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cols_", "=_", "max_", "(_", "1_", ",_", "int_", "(_", "(_", "w_", "-_", "1_", ")_", "/_", "(_", "wma", "x_", "+_", "1_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "int_", "(_", "math_", "._", "ceil_", "(_", "float_", "(_", "len_", "(_", "completions_", ")_", ")_", "/_", "cols_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "range_", "(_", "rows_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "col_", "in_", "range_", "(_", "cols_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "col_", "*_", "rows_", "+_", "row_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i_", "<_", "len_", "(_", "completions_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "console_", "._", "write_", "(_", "completions_", "[_", "i_", "]_", "._", "ljust_", "(_", "wma", "x_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "console_", "._", "write_", "(_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "in", "\\u", "iron", "python_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "prompt_", "=_", "sys_", "._", "ps", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "print", "\\u", "prompt_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "complete_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "TAB", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Atte", "mpt", " ", "to", " ", "perform", " ", "completion", " ", "on", " ", "the", " ", "text", " ", "bef", "ore", " ", "point", ".", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "actual", " ", "completion", " ", "perform", "ed", " ", "is", " ", "applica", "tion", "-", "specific", ".", " ", "The", " ", "default", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "filename", " ", "completion", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completions_", "=_", "self_", "._", "\\u", "get", "\\u", "completions_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "completions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cpr", "efi", "x_", "=_", "common", "prefix_", "(_", "completions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rep_", "=_", "[_", "c_", "for_", "c_", "in_", "cpr", "efi", "x_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "point_", "=_", "self_", "._", "l\\u", "buffer_", "._", "point_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "[_", "self_", "._", "beg", "idx_", ":_", "self_", "._", "endi", "dx_", "]_", "=_", "rep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "point_", "=_", "point_", "+_", "len_", "(_", "rep_", ")_", "-_", "(_", "self_", "._", "endi", "dx_", "-_", "self_", "._", "beg", "idx_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "completions_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "show", "\\u", "all", "\\u", "if", "\\u", "ambiguous", "_", "==_", "'", "on", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "display", "\\u", "completions_", "(_", "completions_", ")_", "\\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", "bell", "_", "(_", ")_", "\\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_", "._", "\\u", "bell", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "possib", "le", "\\u", "completions_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-?", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "List", " ", "the", " ", "possib", "le", " ", "completion", "s", " ", "of", " ", "the", " ", "text", " ", "bef", "ore", " ", "point", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completions_", "=_", "self_", "._", "\\u", "get", "\\u", "completions_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "display", "\\u", "completions_", "(_", "completions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "insert", "\\u", "completions_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-*", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Insert", " ", "all", " ", "completion", "s", " ", "of", " ", "the", " ", "text", " ", "bef", "ore", " ", "point", " ", "tha", "t", " ", "wou", "ld", " ", "have", "\\", "10", ";", " ", " ", " ", " ", "bee", "n", " ", "generat", "ed", " ", "by", " ", "possib", "le", "-", "completion", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "completions_", "=_", "self_", "._", "\\u", "get", "\\u", "completions_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "self_", "._", "beg", "idx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "self_", "._", "endi", "dx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "comp_", "in_", "completions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rep_", "=_", "[_", "c_", "for_", "c_", "in_", "comp_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rep_", "._", "append_", "(_", "'", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "[_", "b_", ":_", "e_", "]_", "=_", "rep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "+=_", "len_", "(_", "rep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "line", "\\u", "cursor_", "=_", "b_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "menu", "\\u", "complete_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Simil", "ar", " ", "to", " ", "complete", ",", " ", "but", " ", "replace", "s", " ", "the", " ", "word", " ", "to", " ", "be", " ", "complete", "d", " ", "with", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "single", " ", "match", " ", "from", " ", "the", " ", "list", " ", "of", " ", "possib", "le", " ", "completion", "s", ".", " ", "Repeat", "ed", "\\", "10", ";", " ", " ", " ", " ", "executi", "on", " ", "of", " ", "menu", "-", "complete", " ", "step", "s", " ", "through", " ", "the", " ", "list", " ", "of", " ", "possib", "le", "\\", "10", ";", " ", " ", " ", " ", "completion", "s", ",", " ", "insert", "ing", " ", "each", " ", "match", " ", "in", " ", "turn", ".", " ", "At", " ", "the", " ", "end", " ", "of", " ", "the", " ", "list", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "completion", "s", ",", " ", "the", " ", "bell", " ", "is", " ", "run", "g", " ", "(", "subject", " ", "to", " ", "the", " ", "setti", "ng", " ", "of", " ", "bell", "-", "style", ")", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "the", " ", "original", " ", "text", " ", "is", " ", "restore", "d", ".", " ", "An", " ", "argu", "ment", " ", "of", " ", "n", " ", "moves", " ", "n", "\\", "10", ";", " ", " ", " ", " ", "position", "s", " ", "forward", " ", "in", " ", "the", " ", "list", " ", "of", " ", "matche", "s", ";", " ", "a", " ", "negati", "ve", " ", "argu", "ment", " ", "may", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "used", " ", "to", " ", "move", " ", "back", "ward", " ", "through", " ", "the", " ", "list", ".", " ", "Thi", "s", " ", "command", " ", "is", " ", "inten", "ded", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "bound", " ", "to", " ", "TAB", ",", " ", "but", " ", "is", " ", "unbound", " ", "by", " ", "default", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "beginn", "ing", "\\u", "of", "\\u", "line_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "a", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "to", " ", "the", " ", "start", " ", "of", " ", "the", " ", "current", " ", "line", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "beginn", "ing", "\\u", "of", "\\u", "line_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "end", "\\u", "of", "\\u", "line_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "e", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "line", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "end", "\\u", "of", "\\u", "line_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "char_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "f", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "a", " ", "character", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "char_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "char_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "b", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "back", " ", "a", " ", "character", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "char_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-", "f", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "word_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-", "b", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "back", " ", "to", " ", "the", " ", "start", " ", "of", " ", "the", " ", "current", " ", "or", " ", "previ", "ous", " ", "word", ".", " ", "Word", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "compose", "d", " ", "of", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "word_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "word", "\\u", "end_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "word", "\\u", "end_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "word", "\\u", "end_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "word", "\\u", "end_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "beginn", "ing", "\\u", "of", "\\u", "line", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "to", " ", "the", " ", "start", " ", "of", " ", "the", " ", "current", " ", "line", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "beginn", "ing", "\\u", "of", "\\u", "line", "\\u", "extend", "\\u", "selection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "end", "\\u", "of", "\\u", "line", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "line", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "end", "\\u", "of", "\\u", "line", "\\u", "extend", "\\u", "selection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "char", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "a", " ", "character", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "char", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "char", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "back", " ", "a", " ", "character", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "char", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "word", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "word", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "word", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "back", " ", "to", " ", "the", " ", "start", " ", "of", " ", "the", " ", "current", " ", "or", " ", "previ", "ous", " ", "word", ".", " ", "Word", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "compose", "d", " ", "of", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "word", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "word", "\\u", "end", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "word", "\\u", "end", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "word", "\\u", "end", "\\u", "extend", "\\u", "selection_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Move", " ", "forward", " ", "to", " ", "the", " ", "end", " ", "of", " ", "the", " ", "next", " ", "word", ".", " ", "Word", "s", " ", "are", " ", "compose", "d", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "letter", "s", " ", "and", " ", "digit", "s", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "word", "\\u", "end", "\\u", "extend", "\\u", "selection_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "upc", "ase", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-", "u", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Upp", "erc", "ase", " ", "the", " ", "current", " ", "(", "or", " ", "follow", "ing", ")", " ", "word", ".", " ", "With", " ", "a", " ", "negati", "ve", "\\", "10", ";", " ", " ", " ", " ", "argu", "ment", ",", " ", "upper", "case", " ", "the", " ", "previ", "ous", " ", "word", ",", " ", "but", " ", "do", " ", "not", " ", "move", " ", "the", " ", "cursor", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "upc", "ase", "\\u", "word_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "down", "case", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-", "l", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Lower", "case", " ", "the", " ", "current", " ", "(", "or", " ", "follow", "ing", ")", " ", "word", ".", " ", "With", " ", "a", " ", "negati", "ve", "\\", "10", ";", " ", " ", " ", " ", "argu", "ment", ",", " ", "lower", "case", " ", "the", " ", "previ", "ous", " ", "word", ",", " ", "but", " ", "do", " ", "not", " ", "move", " ", "the", " ", "cursor", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "down", "case", "\\u", "word_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "capitaliz", "e\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "M", "-", "c", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Capita", "lize", " ", "the", " ", "current", " ", "(", "or", " ", "follow", "ing", ")", " ", "word", ".", " ", "With", " ", "a", " ", "negati", "ve", "\\", "10", ";", " ", " ", " ", " ", "argu", "ment", ",", " ", "capitaliz", "e", " ", "the", " ", "previ", "ous", " ", "word", ",", " ", "but", " ", "do", " ", "not", " ", "move", " ", "the", " ", "cursor", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "capitaliz", "e\\u", "word_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clear", "\\u", "screen_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "l", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Clear", " ", "the", " ", "screen", " ", "and", " ", "redraw", " ", "the", " ", "current", " ", "line", ",", " ", "leaving", " ", "the", " ", "current", "\\", "10", ";", " ", " ", " ", " ", "line", " ", "at", " ", "the", " ", "top", " ", "of", " ", "the", " ", "screen", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "console_", "._", "page_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redraw", "\\u", "current", "\\u", "line_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Refr", "esh", " ", "the", " ", "current", " ", "line", ".", " ", "By", " ", "default", ",", " ", "this", " ", "is", " ", "unbound", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "accept", "\\u", "line_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "New", "line", " ", "or", " ", "Return", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Accept", " ", "the", " ", "line", " ", "rega", "rd", "less", " ", "of", " ", "where", " ", "the", " ", "cursor", " ", "is", ".", " ", "If", " ", "this", " ", "line", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "non", "-", "empty", ",", " ", "it", " ", "may", " ", "be", " ", "adde", "d", " ", "to", " ", "the", " ", "histo", "ry", " ", "list", " ", "for", " ", "future", " ", "reca", "ll", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "add", "\\u", "histo", "ry", "()", ".", " ", "If", " ", "this", " ", "line", " ", "is", " ", "a", " ", "modifi", "ed", " ", "histo", "ry", " ", "line", ",", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "histo", "ry", " ", "line", " ", "is", " ", "restore", "d", " ", "to", " ", "its", " ", "original", " ", "state", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "\\u", "char_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "C", "-", "d", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "the", " ", "character", " ", "at", " ", "point", ".", " ", "If", " ", "point", " ", "is", " ", "at", " ", "the", " ", "beginn", "ing", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "line", ",", " ", "there", " ", "are", " ", "no", " ", "character", "s", " ", "in", " ", "the", " ", "line", ",", " ", "and", " ", "the", " ", "last", "\\", "10", ";", " ", " ", " ", " ", "character", " ", "typed", " ", "was", " ", "not", " ", "bound", " ", "to", " ", "delete", "-", "char", ",", " ", "then", " ", "return", " ", "EO", "F", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "delete", "\\u", "char_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "delete", "\\u", "char_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "Rub", "out", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "the", " ", "character", " ", "beh", "ind", " ", "the", " ", "cursor", ".", " ", "A", " ", "numeri", "c", " ", "argu", "ment", " ", "means", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "kill", " ", "the", " ", "character", "s", " ", "inst", "ead", " ", "of", " ", "delet", "ing", " ", "them", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "delete", "\\u", "char_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "back", "ward", "\\u", "delete", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "Control", "-", "Rub", "out", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "the", " ", "character", " ", "beh", "ind", " ", "the", " ", "cursor", ".", " ", "A", " ", "numeri", "c", " ", "argu", "ment", " ", "means", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "kill", " ", "the", " ", "character", "s", " ", "inst", "ead", " ", "of", " ", "delet", "ing", " ", "them", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "back", "ward", "\\u", "delete", "\\u", "word_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "forward", "\\u", "delete", "\\u", "word_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "Control", "-", "Delete", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "the", " ", "character", " ", "beh", "ind", " ", "the", " ", "cursor", ".", " ", "A", " ", "numeri", "c", " ", "argu", "ment", " ", "means", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "kill", " ", "the", " ", "character", "s", " ", "inst", "ead", " ", "of", " ", "delet", "ing", " ", "them", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "forward", "\\u", "delete", "\\u", "word_", "(_", "self_", "._", "argu", "ment", "\\u", "reset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "\\u", "horizon", "tal", "\\u", "space_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "all", " ", "space", "s", " ", "and", " ", "tabs", " ", "aro", "und", " ", "point", ".", " ", "By", " ", "default", ",", " ", "this", " ", "is", " ", "unbound", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "delete", "\\u", "horizon", "tal", "\\u", "space_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "self", "\\u", "insert_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "(", "a", ",", " ", "b", ",", " ", "A", ",", " ", "1", ",", " ", "!", ",", " ", "...)", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Insert", " ", "your", "self", ".", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "e_", "._", "char_", "and_", "ord_", "(_", "e_", "._", "char_", ")_", "!=_", "0_", ":_", "#", "don", "'", "t", " ", "insert", " ", "null", " ", "character", " ", "in", " ", "buffer", ",", " ", "can", " ", "happ", "en", " ", "with", " ", "dead", " ", "keys", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "insert", "\\u", "text_", "(_", "e_", "._", "char_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "paste_", "(_", "self_", ",_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Past", "e", " ", "windows", " ", "clip", "board", ".", "\\", "10", ";", " ", " ", " ", " ", "Assume", " ", "single", " ", "line", " ", "strip", " ", "other", " ", "lines", " ", "and", " ", "end", " ", "of", " ", "line", " ", "marker", "s", " ", "and", " ", "trail", "ing", " ", "space", "s", "'''_", "#(", "Control", "-", "v", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "enable", "\\u", "win32", "\\u", "clipboard_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "txt_", "=_", "clipboard_", "._", "get", "\\u", "clip", "board", "\\u", "text", "\\u", "and", "\\u", "convert_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "txt_", "=_", "txt_", "._", "split_", "(_", "\"\\\\", "n", "\"_", ")_", "[_", "0_", "]_", "._", "strip_", "(_", "\"\\\\", "r", "\"_", ")_", "._", "strip_", "(_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "(_", "\"", "paste", ":", " ", ">", "%", "s", "<\"_", "%_", "map_", "(_", "ord_", ",_", "txt_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "insert", "\\u", "text_", "(_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "paste", "\\u", "mul", "it", "line", "\\u", "code_", "(_", "self_", ",_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Past", "e", " ", "windows", " ", "clip", "board", " ", "as", " ", "multiline", " ", "code", ".", "\\", "10", ";", " ", " ", " ", " ", "Remove", "s", " ", "any", " ", "empty", " ", "lines", " ", "in", " ", "the", " ", "code", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reg_", "=_", "re_", "._", "compile_", "(_", "\"\\\\", "r", "?\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "enable", "\\u", "win32", "\\u", "clipboard_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "txt_", "=_", "clipboard_", "._", "get", "\\u", "clip", "board", "\\u", "text", "\\u", "and", "\\u", "convert_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "reg_", "._", "split_", "(_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "[_", "row_", "for_", "row_", "in_", "t_", "if_", "row_", "._", "strip_", "(_", ")_", "!=_", "\"\"_", "]_", "#", "remove", " ", "empty", " ", "lines_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "t_", "!=_", "[_", "\"\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "insert", "\\u", "text_", "(_", "t_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "history_", "(_", "self_", "._", "l\\u", "buffer_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "paste", "\\u", "line", "\\u", "buffer_", "=_", "t_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "log_", "(_", "\"", "multi", ":", " ", "%", "s", "\"_", "%_", "self_", "._", "paste", "\\u", "line", "\\u", "buffer_", ")_", "\\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 ", " ", "_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "ipython", "\\u", "paste_", "(_", "self_", ",_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Past", "e", " ", "windows", " ", "clip", "board", ".", " ", "If", " ", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "list", "\\u", "of", "\\u", "lists", " ", "is", " ", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", " ", "then", " ", "try", " ", "to", " ", "convert", " ", "tabs", "epa", "rated", " ", "data", " ", "to", " ", "repr", " ", "of", " ", "list", " ", "of", " ", "lists", " ", "or", " ", "\\", "10", ";", " ", " ", " ", " ", "repr", " ", "of", " ", "array", ".", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "for", "\\u", "path", "s", "==", "Tru", "e", " ", "then", " ", "change", " ", "\\\\\\\\", " ", "to", " ", "/", " ", "and", " ", "space", "s", " ", "to", " ", "\\\\", "space", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "enable", "\\u", "win32", "\\u", "clipboard_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "txt_", "=_", "clipboard_", "._", "get", "\\u", "clip", "board", "\\u", "text", "\\u", "and", "\\u", "convert_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "list", "\\u", "of", "\\u", "lists_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "enable", "\\u", "ipython", "\\u", "paste", "\\u", "for", "\\u", "paths_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "len_", "(_", "txt_", ")_", "<_", "300_", "and_", "(_", "\"\\\\", "t", "\"_", "not_", "in_", "txt_", ")_", "and_", "(_", "\"\\\\", "n", "\"_", "not_", "in_", "txt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "txt_", "=_", "txt_", "._", "replace_", "(_", "\"\\\\\\\\\"_", ",_", "\"/\"_", ")_", "._", "replace_", "(_", "\"", " ", "\"_", ",_", "r", "\"\\\\", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "insert", "\\u", "text_", "(_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "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_", "copy", "\\u", "region", "\\u", "to", "\\u", "clipboard_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "the", " ", "text", " ", "in", " ", "the", " ", "region", " ", "to", " ", "the", " ", "windows", " ", "clip", "board", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "copy", "\\u", "region", "\\u", "to", "\\u", "clipboard_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy", "\\u", "selection", "\\u", "to", "\\u", "clipboard_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "the", " ", "text", " ", "in", " ", "the", " ", "region", " ", "to", " ", "the", " ", "windows", " ", "clip", "board", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "copy", "\\u", "selection", "\\u", "to", "\\u", "clipboard_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cut", "\\u", "selection", "\\u", "to", "\\u", "clipboard_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Copy", " ", "the", " ", "text", " ", "in", " ", "the", " ", "region", " ", "to", " ", "the", " ", "windows", " ", "clip", "board", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "l\\u", "buffer_", "._", "cut", "\\u", "selection", "\\u", "to", "\\u", "clipboard_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Mode_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dump", "\\u", "functions_", "(_", "self_", ",_", "e_", ")_", ":_", "#", " ", "()", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Print", " ", "all", " ", "of", " ", "the", " ", "function", "s", " ", "and", " ", "thei", "r", " ", "key", " ", "bindi", "ngs", " ", "to", " ", "the", " ", "Read", "line", "\\", "10", ";", " ", " ", " ", " ", "output", " ", "stream", ".", " ", "If", " ", "a", " ", "numeri", "c", " ", "argu", "ment", " ", "is", " ", "supplie", "d", ",", " ", "the", " ", "output", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "format", "ted", " ", "in", " ", "suc", "h", " ", "a", " ", "way", " ", "tha", "t", " ", "it", " ", "can", " ", "be", " ", "made", " ", "part", " ", "of", " ", "an", " ", "input", "rc", "\\", "10", ";", " ", " ", " ", " ", "file", ".", " ", "Thi", "s", " ", "command", " ", "is", " ", "unbound", " ", "by", " ", "default", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "txt_", "=_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "self_", "._", "rl", "\\u", "settings", "\\u", "to", "\\u", "string_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "txt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "print", "\\u", "prompt_", "(_", ")_", "\\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_", "common", "prefix_", "(_", "m_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Give", "n", " ", "a", " ", "list", " ", "of", " ", "path", "names", ",", " ", "return", "s", " ", "the", " ", "long", "est", " ", "common", " ", "lead", "ing", " ", "component", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "m_", ":_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prefix_", "=_", "m_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "prefix_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "prefix_", "[_", ":_", "i_", "+_", "1_", "]_", "._", "lower_", "(_", ")_", "!=_", "item_", "[_", ":_", "i_", "+_", "1_", "]_", "._", "lower_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prefix_", "=_", "prefix_", "[_", ":_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i_", "==_", "0_", ":_", "return_", "''_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "prefix_" ]
[ 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,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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, 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 ]
Unused import
pydanny/dj-spam/tests/test_views.py
[ { "content": "from base64 import b16encode, b16decode\n\nfrom django.core.urlresolvers import reverse\nfrom django.http import HttpResponseNotAllowed\nfrom django.test import RequestFactory\n\nfrom spam.views import ReportSpamCreateView\nfrom test_plus.test import TestCase\n\nfrom test_app.models import Data\nfrom test_app.views import DataDetailView\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestReportSpamCreateView(TestCase):\n\n\n", "metadata": "root.TestReportSpamCreateView", "header": "['module', '___EOS___']", "index": 13 }, { "content": " def setUp(self):\n self.data = Data.objects.create(title='test')\n self.factory = RequestFactory()", "metadata": "root.TestReportSpamCreateView.setUp", "header": "['class', 'TestReportSpamCreateView', '(', 'TestCase', ')', ':', '___EOS___']", "index": 15 }, { "content": " def test_data_detail_view(self):\n \"\"\" Just to make certain we have the tests wired up right\"\"\"\n # Get the URL\n # Create a request\n request = self.factory.get('/fake-url')\n # Generate a response\n response = DataDetailView.as_view()(request, pk=self.data.pk)\n\n # Check to see if we had a 404 or not\n self.response_200(response)", "metadata": "root.TestReportSpamCreateView.test_data_detail_view", "header": "['class', 'TestReportSpamCreateView', '(', 'TestCase', ')', ':', '___EOS___']", "index": 19 }, { "content": " def test_slug_to_arguments(self):\n base_url = \"test_app/data/{0}/\".format(self.data.pk)\n b16_slug = b16encode(base_url.encode('utf-8'))\n\n request = self.factory.get('/fake-url')\n\n view = ReportSpamCreateView.as_view()\n response = view(request, slug=b16_slug)\n self.response_200(response)", "metadata": "root.TestReportSpamCreateView.test_slug_to_arguments", "header": "['class', 'TestReportSpamCreateView', '(', 'TestCase', ')', ':', '___EOS___']", "index": 30 } ]
[ { "span": "from base64 import b16encode, b16decode", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 39 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 44 }, { "span": "from django.http import HttpResponseNotAllowed", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 46 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "base64_", "import_", "b1", "6e", "ncode", "_", ",_", "b1", "6d", "ecode", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Respons", "e", "Not", "Allowed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Request", "Factory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "spam_", "._", "views_", "import_", "Report", "Spam", "Creat", "e", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "test\\u", "plus_", "._", "test_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "test\\u", "app_", "._", "models_", "import_", "Data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "test\\u", "app_", "._", "views_", "import_", "Data", "Det", "ail", "View_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Report", "Spam", "Creat", "e", "View_", "(_", "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_", "[SEP]_", "class_", "Test", "Report", "Spam", "Creat", "e", "View_", "(_", "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 ", " _", "self_", "._", "data_", "=_", "Data_", "._", "objects_", "._", "create_", "(_", "title_", "=_", "'", "test", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "factory_", "=_", "Request", "Factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Report", "Spam", "Creat", "e", "View_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "data\\u", "deta", "il", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Ju", "st", " ", "to", " ", "make", " ", "cert", "ain", " ", "we", " ", "have", " ", "the", " ", "tests", " ", "wire", "d", " ", "up", " ", "right", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "self_", "._", "factory_", "._", "get_", "(_", "'/", "fake", "-", "url", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Generate", " ", "a", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "Data", "Det", "ail", "View_", "._", "as", "\\u", "view_", "(_", ")_", "(_", "request_", ",_", "pk_", "=_", "self_", "._", "data_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "we", " ", "had", " ", "a", " ", "404", " ", "or", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "response", "\\u", "200_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Report", "Spam", "Creat", "e", "View_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "slug", "\\u", "to", "\\u", "arguments_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "base", "\\u", "url_", "=_", "\"", "test\\u", "app", "/", "data", "/{", "0", "}/", "\"_", "._", "format_", "(_", "self_", "._", "data_", "._", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b1", "6", "\\u", "slug_", "=_", "b1", "6e", "ncode", "_", "(_", "base", "\\u", "url_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "=_", "self_", "._", "factory_", "._", "get_", "(_", "'/", "fake", "-", "url", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "Report", "Spam", "Creat", "e", "View_", "._", "as", "\\u", "view_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "view_", "(_", "request_", ",_", "slug_", "=_", "b1", "6", "\\u", "slug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "response", "\\u", "200_", "(_", "response_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 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, 4, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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'
BrightcoveOS/Diamond/src/collectors/monit/monit.py
[ { "content": " def collect(self):\n url = 'http://%s:%i/_status?format=xml' % (self.config['host'],\n int(self.config['port']))\n try:\n request = urllib2.Request(url)\n\n #\n # shouldn't need to check this\n base64string = base64.encodestring('%s:%s' % (\n self.config['user'], self.config['passwd'])).replace('\\n', '')\n request.add_header(\"Authorization\", \"Basic %s\" % base64string)\n response = urllib2.urlopen(request)\n except urllib2.HTTPError, err:\n self.log.error(\"%s: %s\", err, url)\n return\n\n metrics = {}\n\n try:\n dom = parseString(\"\".join(response.readlines()))\n except:\n self.log.error(\"Got an empty response from the monit server\")\n return\n\n for service in dom.getElementsByTagName('service'):\n if int(service.getAttribute('type')) == 3:\n name = service.getElementsByTagName('name')[0].firstChild.data\n if (service.getElementsByTagName(\n 'status')[0].firstChild.data == '0'\n and service.getElementsByTagName(\n 'monitor')[0].firstChild.data == '1'):\n try:\n uptime = service.getElementsByTagName(\n 'uptime')[0].firstChild.data\n metrics[\"%s.uptime\" % name] = uptime\n\n cpu = service.getElementsByTagName(\n 'cpu')[0].getElementsByTagName(\n 'percent')[0].firstChild.data\n metrics[\"%s.cpu.percent\" % name] = cpu\n if self.config['send_totals']:\n cpu_total = service.getElementsByTagName(\n 'cpu')[0].getElementsByTagName(\n 'percenttotal')[0].firstChild.data\n metrics[\"%s.cpu.percent_total\" % name] = cpu_total\n\n mem = int(service.getElementsByTagName(\n 'memory')[0].getElementsByTagName(\n 'kilobyte')[0].firstChild.data)\n for unit in self.config['byte_unit']:\n metrics[\"%s.memory.%s_usage\" % (name, unit)] = (\n diamond.convertor.binary.convert(\n value=mem,\n oldUnit='kilobyte',\n newUnit=unit))\n metrics[\"%s.uptime\" % name] = uptime\n if self.config['send_totals']:\n mem_total = int(service.getElementsByTagName(\n 'memory')[0].getElementsByTagName(\n 'kilobytetotal')[0].firstChild.data)\n for unit in self.config['byte_unit']:\n metrics[\"%s.memory_total.%s_usage\" % (\n name, unit)] = (\n diamond.convertor.binary.convert(\n value=mem,\n oldUnit='kilobyte',\n newUnit=unit))\n\n except:\n pass\n\n for key in metrics:\n self.publish(key, metrics[key])", "metadata": "root.MonitCollector.collect", "header": "['class', 'MonitCollector', '(', 'diamond', '.', 'collector', '.', 'Collector', ')', ':', '___EOS___']", "index": 44 } ]
[ { "span": "except:", "start_line": 64, "start_column": 8, "end_line": 64, "end_column": 15 }, { "span": "except:", "start_line": 112, "start_column": 20, "end_line": 112, "end_column": 27 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Mon", "it", "Collector_", "(_", "diamond", "_", "._", "collector_", "._", "Collector_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "collect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "'", "http", "://", "%", "s", ":", "%", "i", "/\\u", "status", "?", "format", "=", "xml", "'_", "%_", "(_", "self_", "._", "config_", "[_", "'", "host", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "int_", "(_", "self_", "._", "config_", "[_", "'", "port", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", "=_", "urllib2_", "._", "Request_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shou", "ld", "n", "'", "t", " ", "need", " ", "to", " ", "check", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "base64", "string_", "=_", "base64_", "._", "encodes", "tring_", "(_", "'%", "s", ":", "%", "s", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "config_", "[_", "'", "user", "'_", "]_", ",_", "self_", "._", "config_", "[_", "'", "passw", "d", "'_", "]_", ")_", ")_", "._", "replace_", "(_", "'\\\\", "n", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "._", "add", "\\u", "header_", "(_", "\"", "Authoriz", "ation", "\"_", ",_", "\"", "Basic", " ", "%", "s", "\"_", "%_", "base64", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "urllib2_", "._", "urlopen_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "urllib2_", "._", "HTTP", "Error_", ",_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "log_", "._", "error_", "(_", "\"%", "s", ":", " ", "%", "s", "\"_", ",_", "err_", ",_", "url_", ")_", "\\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_", "metrics_", "=_", "{_", "}_", "\\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 ", " _", "dom_", "=_", "parse", "String_", "(_", "\"\"_", "._", "join_", "(_", "response_", "._", "readlines_", "(_", ")_", ")_", ")_", "\\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", " ", "an", " ", "empty", " ", "response", " ", "from", " ", "the", " ", "monit", " ", "server", "\"_", ")_", "\\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_", "for_", "service_", "in_", "dom_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "'", "service", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "int_", "(_", "service_", "._", "get", "Attribute_", "(_", "'", "type", "'_", ")_", ")_", "==_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "'", "name", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "==_", "'", "0", "'_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "monit", "or", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "==_", "'", "1", "'_", ")_", ":_", "\\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 ", " ", " _", "uptime_", "=_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "upti", "me", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metrics_", "[_", "\"%", "s", ".", "upti", "me", "\"_", "%_", "name_", "]_", "=_", "uptime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cpu_", "=_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "cpu", "'_", ")_", "[_", "0_", "]_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "percent", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metrics_", "[_", "\"%", "s", ".", "cpu", ".", "percent", "\"_", "%_", "name_", "]_", "=_", "cpu_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "config_", "[_", "'", "send", "\\u", "totals", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "cpu", "\\u", "total_", "=_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "cpu", "'_", ")_", "[_", "0_", "]_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "percent", "total", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "metrics_", "[_", "\"%", "s", ".", "cpu", ".", "percent", "\\u", "total", "\"_", "%_", "name_", "]_", "=_", "cpu", "\\u", "total_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mem_", "=_", "int_", "(_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "memory", "'_", ")_", "[_", "0_", "]_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kilo", "byte", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "unit_", "in_", "self_", "._", "config_", "[_", "'", "byte", "\\u", "unit", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "metrics_", "[_", "\"%", "s", ".", "memory", ".", "%", "s", "\\u", "usage", "\"_", "%_", "(_", "name_", ",_", "unit_", ")_", "]_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "diamond", "_", "._", "convert", "or_", "._", "binary_", "._", "convert_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "value_", "=_", "mem_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "old", "Unit_", "=_", "'", "kilo", "byte", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "Unit_", "=_", "unit_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "metrics_", "[_", "\"%", "s", ".", "upti", "me", "\"_", "%_", "name_", "]_", "=_", "uptime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "config_", "[_", "'", "send", "\\u", "totals", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "mem", "\\u", "total_", "=_", "int_", "(_", "service_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "memory", "'_", ")_", "[_", "0_", "]_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kilo", "byte", "total", "'_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "unit_", "in_", "self_", "._", "config_", "[_", "'", "byte", "\\u", "unit", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "metrics_", "[_", "\"%", "s", ".", "memory", "\\u", "total", ".", "%", "s", "\\u", "usage", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", ",_", "unit_", ")_", "]_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "diamond", "_", "._", "convert", "or_", "._", "binary_", "._", "convert_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "value_", "=_", "mem_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "old", "Unit_", "=_", "'", "kilo", "byte", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "Unit_", "=_", "unit_", ")_", ")_", "\\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_", ":_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "key_", "in_", "metrics_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "publish_", "(_", "key_", ",_", "metrics_", "[_", "key_", "]_", ")_" ]
[ 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, 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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, 0, 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 ]
Unused local variable
sassoftware/conary/conary_test/cvctest/buildtest/groupsettest.py
[ { "content": " @testhelp.context('sysmodel')\n def testDependencies(self):\n self.addComponent('foo:runtime=1.0',\n requires = deps.parseDep('trove: bar:lib'))\n self.addComponent('bar:lib=1.0')\n grp = self._build(\n \"runtime = world.find('foo:runtime')\",\n \"suggestions = runtime.depsNeeded(world)\",\n \"r.Group(runtime + suggestions)\")\n\n self.checkTroves(grp,\n [ (('bar:lib', '/localhost@rpl:linux/1.0-1-1', ''), True, True),\n (('foo:runtime', '/localhost@rpl:linux/1.0-1-1', ''), True, True)\n ])\n\n # resolve against a TroveSet\n grp = self._build(\n \"lib = world.find('bar:lib')\",\n \"runtime = world.find('foo:runtime')\",\n \"suggestions = runtime.depsNeeded(lib)\",\n \"r.Group(runtime + suggestions)\")\n\n self.checkTroves(grp,\n [ (('bar:lib', '/localhost@rpl:linux/1.0-1-1', ''), True, True),\n (('foo:runtime', '/localhost@rpl:linux/1.0-1-1', ''), True, True)\n ])\n\n # test failOnUnresolved\n grp = self._build(\n \"emptyWorld = r.Repository('localhost@foo:bar', r.flavor)\",\n \"runtime = world.find('foo:runtime')\",\n \"suggestions = runtime.depsNeeded(emptyWorld,\",\n \" failOnUnresolved = False)\",\n \"r.Group(runtime + suggestions)\")\n\n self.assertRaises(cook.CookError, self._build,\n \"emptyWorld = r.Repository('localhost@foo:bar', r.flavor)\",\n \"runtime = world.find('foo:runtime')\",\n \"suggestions = runtime.depsNeeded(emptyWorld)\",\n \"r.Group(runtime + suggestions)\")\n\n # test requires in subgroups\n grp = self._build(\n \"runtime = world['foo:runtime']\",\n \"sub = runtime.createGroup('group-sub')\",\n \"suggestions = sub.depsNeeded(world)\",\n \"r.Group(runtime + suggestions)\")\n\n self.checkTroves(grp,\n [ (('bar:lib', '/localhost@rpl:linux/1.0-1-1', ''), True, True),\n (('foo:runtime', '/localhost@rpl:linux/1.0-1-1', ''), True, True)\n ])\n\n # test provides in subgroups\n grp = self._build(\n \"emptyWorld = r.Repository('localhost@foo:bar', r.flavor)\",\n \"lib = world['bar:lib']\",\n \"sub = lib.createGroup('group-sub')\",\n \"outer = world['foo:runtime']\",\n \"suggestions = outer.depsNeeded(sub)\",\n \"r.Group(outer)\")", "metadata": "root.GroupSetTest.testDependencies", "header": "['class', 'GroupSetTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 167 }, { "content": " @testhelp.context('sysmodel')\n def testEmpty(self):\n self.addComponent(\"foo:runtime=1.0\")\n self.addComponent(\"foo:lib=1.0\")\n self.addCollection(\"foo=1.0\", [ \":runtime\", \":lib\" ])\n grp = self._build(\n \"world['foo'].findByName('bar', emptyOkay = True).isEmpty()\",\n \"r.Group(world['foo'])\"\n )\n\n self.assertRaises(cook.CookError,\n self._build,\n \"world['foo'].findByName('foo.*').isEmpty()\")\n\n grp = self._build(\n \"world['foo'].findByName('foo.*').isNotEmpty()\",\n \"r.Group(world['foo'])\"\n )\n\n self.assertRaises(cook.CookError,\n self._build,\n \"world['foo'].findByName('bar').isNotEmpty()\")", "metadata": "root.GroupSetTest.testEmpty", "header": "['class', 'GroupSetTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 308 }, { "content": " @testhelp.context('sysmodel')\n def testPackages(self):\n self.addComponent('foo:runtime=1.0')\n self.addCollection('foo=1.0', [ ':runtime' ])\n self.addCollection('group-foo=1.0', [ 'foo' ])\n\n self.addCollection('group-all=1.0', [ 'group-foo' ])\n\n grp = self._build(\n \"all = world['group-all']\",\n \"return r.Group(all.packages())\")", "metadata": "root.GroupSetTest.testPackages", "header": "['class', 'GroupSetTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 452 }, { "content": " @testhelp.context('sysmodel')\n def testOverrides(self):\n self.addComponent('foo:runtime=1.0')\n self.addComponent('foo:lib=1.0')\n self.addCollection('foo=1.0', [ ':runtime', ':lib' ])\n grp = self._build(\n \"foo = world['foo']\",\n \"runtime = foo['foo:runtime']\",\n \"foo = foo.makeOptional(runtime)\",\n \"r.Group(foo)\" )\n\n return\n\n self.checkTroves(grp,\n [ (('foo', '/localhost@rpl:linux/1.0-1-1', ''), True, True),\n (('foo:lib', '/localhost@rpl:linux/1.0-1-1', ''), True, False),\n (('foo:runtime', '/localhost@rpl:linux/1.0-1-1', ''), False, False)\n ])\n\n grp = self._build(\n \"foo = world['foo']\",\n \"runtime = foo['foo:runtime']\",\n \"sub = foo.makeOptional(runtime).createGroup('group-sub')\",\n \"r.Group(sub)\" )\n\n self.checkTroves(grp,\n [ (('foo', '/localhost@rpl:linux/1.0-1-1', ''), True, False),\n (('foo:lib', '/localhost@rpl:linux/1.0-1-1', ''), True, False),\n (('foo:runtime', '/localhost@rpl:linux/1.0-1-1', ''), False, False),\n (('group-sub', '/localhost@rpl:linux/1.0-1-2', ''), True, True)\n ])", "metadata": "root.GroupSetTest.testOverrides", "header": "['class', 'GroupSetTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 531 }, { "content": " @testhelp.context('sysmodel')\n def testRedirects(self):\n self.addComponent('bar:runtime=1.0')\n self.addCollection('bar=1.0', [ ':runtime'] )\n\n self.addComponent('redirect:runtime=1.0')\n self.addCollection('redirect=1.0', [ ':runtime'] )\n\n self.addComponent('foo:runtime=/localhost@foo:bar/2.0')\n self.addCollection('foo=/localhost@foo:bar/2.0', [ ':runtime' ])\n\n redirectRecipe = \"\\n\".join([\n 'class testRedirect(RedirectRecipe):',\n ' name = \"redirect\"',\n ' version = \"2.0\"',\n ' clearBuildReqs()',\n '',\n ' def setup(r):',\n ' r.addRedirect(\"foo\", \"localhost@foo:bar\")' ])\n\n built, d = self.buildRecipe(redirectRecipe, \"testRedirect\")\n\n self.assertRaisesRegexp(cook.CookError,\n '^' + re.escape('Cannot include redirect '\n 'redirect:runtime=/localhost@rpl:linux/2.0-1-1[] in a group'\n ) + '$',\n\n self._build, 'g = world[\"redirect\"]', 'r.Group(g)')\n\n self.assertRaisesRegexp(cook.CookError,\n '^' + re.escape('Cannot include redirect '\n 'redirect:runtime=/localhost@rpl:linux/2.0-1-1[] in a group'\n ) + '$',\n\n self._build, 'g = world.latestPackages()', 'r.Group(g)')", "metadata": "root.GroupSetTest.testRedirects", "header": "['class', 'GroupSetTest', '(', 'rephelp', '.', 'RepositoryHelper', ')', ':', '___EOS___']", "index": 582 } ]
[ { "span": "grp ", "start_line": 221, "start_column": 8, "end_line": 221, "end_column": 11 }, { "span": "grp ", "start_line": 322, "start_column": 8, "end_line": 322, "end_column": 11 }, { "span": "grp ", "start_line": 460, "start_column": 8, "end_line": 460, "end_column": 11 }, { "span": "grp ", "start_line": 536, "start_column": 8, "end_line": 536, "end_column": 11 }, { "span": "built,", "start_line": 602, "start_column": 8, "end_line": 602, "end_column": 13 }, { "span": "d ", "start_line": 602, "start_column": 15, "end_line": 602, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Group", "Set", "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_", "@_", "testh", "elp", "_", "._", "context_", "(_", "'", "sys", "model", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test", "Dependenc", "ies_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Component_", "(_", "'", "foo", ":", "runt", "ime", "=", "1.0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "requires_", "=_", "deps_", "._", "parse", "Dep", "_", "(_", "'", "trove", ":", " ", "bar", ":", "lib", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Component_", "(_", "'", "bar", ":", "lib", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "world", ".", "find", "('", "foo", ":", "runt", "ime", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "runt", "ime", ".", "dep", "s", "Needed", "(", "world", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "runt", "ime", " ", "+", " ", "suggestions", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "Trove", "s_", "(_", "grp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "(_", "'", "bar", ":", "lib", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "runt", "ime", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "resolve", " ", "against", " ", "a", " ", "Trove", "Set_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "lib", " ", "=", " ", "world", ".", "find", "('", "bar", ":", "lib", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "world", ".", "find", "('", "foo", ":", "runt", "ime", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "runt", "ime", ".", "dep", "s", "Needed", "(", "lib", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "runt", "ime", " ", "+", " ", "suggestions", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "Trove", "s_", "(_", "grp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "(_", "'", "bar", ":", "lib", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "runt", "ime", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "fail", "On", "Unre", "solved", "_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "empty", "Wor", "ld", " ", "=", " ", "r", ".", "Repos", "itor", "y", "('", "local", "host", "@", "foo", ":", "bar", "',", " ", "r", ".", "flavor", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "world", ".", "find", "('", "foo", ":", "runt", "ime", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "runt", "ime", ".", "dep", "s", "Needed", "(", "empty", "Wor", "ld", ",\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", " ", " ", " ", " ", " ", " ", "fail", "On", "Unre", "solved", " ", "=", " ", "Fal", "se", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "runt", "ime", " ", "+", " ", "suggestions", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "cook", "_", "._", "Coo", "k", "Error_", ",_", "self_", "._", "\\u", "build_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "empty", "Wor", "ld", " ", "=", " ", "r", ".", "Repos", "itor", "y", "('", "local", "host", "@", "foo", ":", "bar", "',", " ", "r", ".", "flavor", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "world", ".", "find", "('", "foo", ":", "runt", "ime", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "runt", "ime", ".", "dep", "s", "Needed", "(", "empty", "Wor", "ld", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "runt", "ime", " ", "+", " ", "suggestions", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "require", "s", " ", "in", " ", "subgroup", "s_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "world", "['", "foo", ":", "runt", "ime", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sub", " ", "=", " ", "runt", "ime", ".", "create", "Group", "('", "group", "-", "sub", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "sub", ".", "dep", "s", "Needed", "(", "world", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "runt", "ime", " ", "+", " ", "suggestions", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "Trove", "s_", "(_", "grp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "(_", "'", "bar", ":", "lib", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "runt", "ime", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "provide", "s", " ", "in", " ", "subgroup", "s_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "empty", "Wor", "ld", " ", "=", " ", "r", ".", "Repos", "itor", "y", "('", "local", "host", "@", "foo", ":", "bar", "',", " ", "r", ".", "flavor", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "lib", " ", "=", " ", "world", "['", "bar", ":", "lib", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sub", " ", "=", " ", "lib", ".", "create", "Group", "('", "group", "-", "sub", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "outer", " ", "=", " ", "world", "['", "foo", ":", "runt", "ime", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "suggestions", " ", "=", " ", "outer", ".", "dep", "s", "Needed", "(", "sub", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "outer", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Group", "Set", "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_", "@_", "testh", "elp", "_", "._", "context_", "(_", "'", "sys", "model", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test", "Empty_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Component_", "(_", "\"", "foo", ":", "runt", "ime", "=", "1.0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Component_", "(_", "\"", "foo", ":", "lib", "=", "1.0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "\"", "foo", "=", "1.0", "\"_", ",_", "[_", "\":", "runt", "ime", "\"_", ",_", "\":", "lib", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "world", "['", "foo", "']", ".", "find", "By", "Name", "('", "bar", "',", " ", "empty", "Ok", "ay", " ", "=", " ", "Tru", "e", ").", "is", "Emp", "ty", "()\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "world", "['", "foo", "'])", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "cook", "_", "._", "Coo", "k", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "build_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "world", "['", "foo", "']", ".", "find", "By", "Name", "('", "foo", ".*", "')", ".", "is", "Emp", "ty", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "world", "['", "foo", "']", ".", "find", "By", "Name", "('", "foo", ".*", "')", ".", "is", "Not", "Emp", "ty", "()\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "world", "['", "foo", "'])", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "cook", "_", "._", "Coo", "k", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "build_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "world", "['", "foo", "']", ".", "find", "By", "Name", "('", "bar", "')", ".", "is", "Not", "Emp", "ty", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Group", "Set", "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_", "@_", "testh", "elp", "_", "._", "context_", "(_", "'", "sys", "model", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test", "Packages_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Component_", "(_", "'", "foo", ":", "runt", "ime", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "foo", "=", "1.0", "'_", ",_", "[_", "':", "runt", "ime", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "group", "-", "foo", "=", "1.0", "'_", ",_", "[_", "'", "foo", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "group", "-", "all", "=", "1.0", "'_", ",_", "[_", "'", "group", "-", "foo", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "all", " ", "=", " ", "world", "['", "group", "-", "all", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "return", " ", "r", ".", "Group", "(", "all", ".", "package", "s", "())", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Group", "Set", "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_", "@_", "testh", "elp", "_", "._", "context_", "(_", "'", "sys", "model", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test", "Override", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Component_", "(_", "'", "foo", ":", "runt", "ime", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Component_", "(_", "'", "foo", ":", "lib", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "foo", "=", "1.0", "'_", ",_", "[_", "':", "runt", "ime", "'_", ",_", "':", "lib", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "foo", " ", "=", " ", "world", "['", "foo", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "foo", "['", "foo", ":", "runt", "ime", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "foo", " ", "=", " ", "foo", ".", "make", "Optio", "nal", "(", "runt", "ime", ")\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "foo", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "Trove", "s_", "(_", "grp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "(_", "'", "foo", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "lib", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "runt", "ime", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "False_", ",_", "False_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "grp_", "=_", "self_", "._", "\\u", "build_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "foo", " ", "=", " ", "world", "['", "foo", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "runt", "ime", " ", "=", " ", "foo", "['", "foo", ":", "runt", "ime", "']\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "sub", " ", "=", " ", "foo", ".", "make", "Optio", "nal", "(", "runt", "ime", ").", "create", "Group", "('", "group", "-", "sub", "')\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "r", ".", "Group", "(", "sub", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "Trove", "s_", "(_", "grp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "(_", "(_", "'", "foo", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "lib", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "foo", ":", "runt", "ime", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-1", "'_", ",_", "''_", ")_", ",_", "False_", ",_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "'", "group", "-", "sub", "'_", ",_", "'/", "local", "host", "@", "rpl", ":", "linux", "/", "1.0", "-1", "-", "2", "'_", ",_", "''_", ")_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Group", "Set", "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_", "@_", "testh", "elp", "_", "._", "context_", "(_", "'", "sys", "model", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test", "Redirects_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Component_", "(_", "'", "bar", ":", "runt", "ime", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "bar", "=", "1.0", "'_", ",_", "[_", "':", "runt", "ime", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "add", "Component_", "(_", "'", "redirec", "t", ":", "runt", "ime", "=", "1.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "redirec", "t", "=", "1.0", "'_", ",_", "[_", "':", "runt", "ime", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "add", "Component_", "(_", "'", "foo", ":", "runt", "ime", "=", "/", "local", "host", "@", "foo", ":", "bar", "/", "2.0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Collection_", "(_", "'", "foo", "=", "/", "local", "host", "@", "foo", ":", "bar", "/", "2.0", "'_", ",_", "[_", "':", "runt", "ime", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "redirec", "t", "Recipe_", "=_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", " ", "test", "Redirect", "(", "Redirect", "Recip", "e", "):'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", " ", "name", " ", "=", " ", "\"", "redirec", "t", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", " ", "version", " ", "=", " ", "\"", "2.0", "\"'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", " ", "clear", "Build", "Re", "qs", "()'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", " ", "def", " ", "setup", "(", "r", "):'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", " ", "r", ".", "add", "Redirect", "(\"", "foo", "\",", " ", "\"", "local", "host", "@", "foo", ":", "bar", "\")'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "built_", ",_", "d_", "=_", "self_", "._", "build", "Recipe_", "(_", "redirec", "t", "Recipe_", ",_", "\"", "test", "Redirect", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "cook", "_", "._", "Coo", "k", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "^", "'_", "+_", "re_", "._", "escape_", "(_", "'", "Cann", "ot", " ", "include", " ", "redirec", "t", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "redirec", "t", ":", "runt", "ime", "=", "/", "local", "host", "@", "rpl", ":", "linux", "/", "2.0", "-1", "-1", "[]", " ", "in", " ", "a", " ", "group", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "+_", "'$'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "build_", ",_", "'", "g", " ", "=", " ", "world", "[\"", "redirec", "t", "\"]'_", ",_", "'", "r", ".", "Group", "(", "g", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "cook", "_", "._", "Coo", "k", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "^", "'_", "+_", "re_", "._", "escape_", "(_", "'", "Cann", "ot", " ", "include", " ", "redirec", "t", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "redirec", "t", ":", "runt", "ime", "=", "/", "local", "host", "@", "rpl", ":", "linux", "/", "2.0", "-1", "-1", "[]", " ", "in", " ", "a", " ", "group", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "+_", "'$'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "build_", ",_", "'", "g", " ", "=", " ", "world", ".", "late", "st", "Packa", "ges", "()'_", ",_", "'", "r", ".", "Group", "(", "g", ")'_", ")_", "\\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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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 local variable
tony/tmuxp/tmuxp/server.py
[ { "content": " def _list_sessions(self):\n \"\"\"Return list of sessions in :py:obj:`dict` form.\n\n Retrieved from ``$ tmux(1) list-sessions`` stdout.\n\n The :py:obj:`list` is derived from ``stdout`` in :class:`util.tmux_cmd`\n which wraps :py:class:`subprocess.Popen`.\n\n :rtype: :py:obj:`list` of :py:obj:`dict`\n\n \"\"\"\n\n sformats = formats.SESSION_FORMATS\n tmux_formats = ['#{%s}' % f for f in sformats]\n\n tmux_args = (\n '-F%s' % '\\t'.join(tmux_formats), # output\n )\n\n proc = self.cmd(\n 'list-sessions',\n *tmux_args\n )\n\n if proc.stderr:\n raise exc.TmuxpException(proc.stderr)\n else:\n session_info = proc.stdout[0]\n\n if proc.stderr:\n raise exc.TmuxpException(proc.stderr)\n\n sformats = formats.SESSION_FORMATS\n tmux_formats = ['#{%s}' % format for format in sformats]\n sessions = proc.stdout\n\n # combine format keys with values returned from ``tmux list-windows``\n sessions = [dict(zip(\n sformats, session.split('\\t'))) for session in sessions]\n\n # clear up empty dict\n sessions = [\n dict((k, v) for k, v in session.items() if v)\n for session in sessions\n ]\n\n return sessions", "metadata": "root.Server._list_sessions", "header": "['class', 'Server', '(', 'TmuxRelationalObject', ',', 'EnvironmentMixin', ')', ':', '___EOS___']", "index": 100 } ]
[ { "span": "session_info ", "start_line": 127, "start_column": 12, "end_line": 127, "end_column": 24 }, { "span": "tmux_formats ", "start_line": 133, "start_column": 8, "end_line": 133, "end_column": 20 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Server_", "(_", "Tm", "ux", "Relation", "al", "Object_", ",_", "Environ", "ment", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "list", "\\u", "sessions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "list", " ", "of", " ", "session", "s", " ", "in", " ", ":", "py", ":", "obj", ":`", "dict", "`", " ", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Retrieve", "d", " ", "from", " ", "``", "$", " ", "tm", "ux", "(", "1", ")", " ", "list", "-", "session", "s", "``", " ", "stdout", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", ":", "py", ":", "obj", ":`", "list", "`", " ", "is", " ", "derive", "d", " ", "from", " ", "``", "stdout", "``", " ", "in", " ", ":", "class", ":`", "util", ".", "tm", "ux", "\\u", "cmd", "`", "\\", "10", ";", " ", " ", " ", " ", "whi", "ch", " ", "wrap", "s", " ", ":", "py", ":", "class", ":`", "subproc", "ess", ".", "Pop", "en", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "py", ":", "obj", ":`", "list", "`", " ", "of", " ", ":", "py", ":", "obj", ":`", "dict", "`", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sfo", "rmat", "s_", "=_", "formats_", "._", "SES", "SION", "\\u", "FORMATS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tm", "ux", "\\u", "formats_", "=_", "[_", "'#", "{%", "s", "}'_", "%_", "f_", "for_", "f_", "in_", "sfo", "rmat", "s_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tm", "ux", "\\u", "args_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "F", "%", "s", "'_", "%_", "'\\\\", "t", "'_", "._", "join_", "(_", "tm", "ux", "\\u", "formats_", ")_", ",_", "#", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "proc_", "=_", "self_", "._", "cmd_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "list", "-", "session", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "tm", "ux", "\\u", "args_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "proc_", "._", "stderr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "exc_", "._", "Tm", "ux", "p", "Exception_", "(_", "proc_", "._", "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 ", " _", "session", "\\u", "info_", "=_", "proc_", "._", "stdout_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "proc_", "._", "stderr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "exc_", "._", "Tm", "ux", "p", "Exception_", "(_", "proc_", "._", "stderr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sfo", "rmat", "s_", "=_", "formats_", "._", "SES", "SION", "\\u", "FORMATS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tm", "ux", "\\u", "formats_", "=_", "[_", "'#", "{%", "s", "}'_", "%_", "format_", "for_", "format_", "in_", "sfo", "rmat", "s_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sessions_", "=_", "proc_", "._", "stdout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "combin", "e", " ", "format", " ", "keys", " ", "with", " ", "values", " ", "return", "ed", " ", "from", " ", "``", "tm", "ux", " ", "list", "-", "windows", "``", "_", "\\u\\u\\uNL\\u\\u\\u_", "sessions_", "=_", "[_", "dict_", "(_", "zip_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "sfo", "rmat", "s_", ",_", "session_", "._", "split_", "(_", "'\\\\", "t", "'_", ")_", ")_", ")_", "for_", "session_", "in_", "sessions_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "clear", " ", "up", " ", "empty", " ", "dict_", "\\u\\u\\uNL\\u\\u\\u_", "sessions_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "session_", "._", "items_", "(_", ")_", "if_", "v_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "session_", "in_", "sessions_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "sessions_", "\\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, 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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 ]
Unused import
caseywstark/colab/colab/apps/voting/views.py
[ { "content": "from django.contrib.contenttypes.models import ContentType\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom django.http import Http404, HttpResponse, HttpResponseRedirect\nfrom django.contrib.auth.views import redirect_to_login\nfrom django.template import loader, RequestContext\nfrom django.utils import simplejson\n\nfrom voting.models import Vote\n\nVOTE_DIRECTIONS = (('up', 1), ('down', -1), ('clear', 0))\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def vote_on_object(request, model, direction, post_vote_redirect=None,\n object_id=None, slug=None, slug_field=None, template_name=None,\n template_loader=loader, extra_context=None, context_processors=None,\n template_object_name='object', allow_xmlhttprequest=False, confirm_vote=True):\n \"\"\"\n Generic object vote function.\n\n The given template will be used to confirm the vote if this view is\n fetched using GET; vote registration will only be performed if this\n view is POSTed.\n\n If ``allow_xmlhttprequest`` is ``True`` and an XMLHttpRequest is\n detected by examining the ``HTTP_X_REQUESTED_WITH`` header, the\n ``xmlhttp_vote_on_object`` view will be used to process the\n request - this makes it trivial to implement voting via\n XMLHttpRequest with a fallback for users who don't have JavaScript\n enabled.\n\n Templates:``<app_label>/<model_name>_confirm_vote.html``\n Context:\n object\n The object being voted on.\n direction\n The type of vote which will be registered for the object.\n \"\"\"\n if allow_xmlhttprequest and request.is_ajax():\n return xmlhttprequest_vote_on_object(request, model, direction,\n object_id=object_id, slug=slug,\n slug_field=slug_field)\n\n if extra_context is None: extra_context = {}\n if not request.user.is_authenticated():\n return redirect_to_login(request.path)\n\n try:\n vote = dict(VOTE_DIRECTIONS)[direction]\n except KeyError:\n raise AttributeError(\"'%s' is not a valid vote type.\" % vote_type)\n\n # Look up the object to be voted on\n lookup_kwargs = {}\n if object_id:\n lookup_kwargs['%s__exact' % model._meta.pk.name] = object_id\n elif slug and slug_field:\n lookup_kwargs['%s__exact' % slug_field] = slug\n else:\n raise AttributeError('Generic vote view must be called with either '\n 'object_id or slug and slug_field.')\n try:\n obj = model._default_manager.get(**lookup_kwargs)\n except ObjectDoesNotExist:\n raise Http404, 'No %s found for %s.' % (model._meta.app_label, lookup_kwargs)\n\n if request.method == 'POST' or confirm_vote == False:\n if post_vote_redirect is not None:\n next = post_vote_redirect\n elif request.REQUEST.has_key('next'):\n next = request.REQUEST['next']\n elif hasattr(obj, 'get_absolute_url'):\n if callable(getattr(obj, 'get_absolute_url')):\n next = obj.get_absolute_url()\n else:\n next = obj.get_absolute_url\n else:\n raise AttributeError('Generic vote view must be called with either '\n 'post_vote_redirect, a \"next\" parameter in '\n 'the request, or the object being voted on '\n 'must define a get_absolute_url method or '\n 'property.')\n Vote.objects.record_vote(obj, request.user, vote)\n return HttpResponseRedirect(next)\n else:\n if not template_name:\n template_name = '%s/%s_confirm_vote.html' % (\n model._meta.app_label, model._meta.object_name.lower())\n t = template_loader.get_template(template_name)\n c = RequestContext(request, {\n template_object_name: obj,\n 'direction': direction,\n }, context_processors)\n for key, value in extra_context.items():\n if callable(value):\n c[key] = value()\n else:\n c[key] = value\n response = HttpResponse(t.render(c))\n return response", "metadata": "root.vote_on_object", "header": "['module', '___EOS___']", "index": 11 }, { "content": "def json_error_response(error_message):\n return HttpResponse(simplejson.dumps(dict(success=False,\n error_message=error_message)))", "metadata": "root.json_error_response", "header": "['module', '___EOS___']", "index": 99 }, { "content": "def xmlhttprequest_vote_on_object(request, model, direction,\n object_id=None, slug=None, slug_field=None):\n \"\"\"\n Generic object vote function for use via XMLHttpRequest.\n\n Properties of the resulting JSON object:\n success\n ``true`` if the vote was successfully processed, ``false``\n otherwise.\n score\n The object's updated score and number of votes if the vote\n was successfully processed.\n error_message\n Contains an error message if the vote was not successfully\n processed.\n \"\"\"\n if request.method == 'GET':\n return json_error_response(\n 'XMLHttpRequest votes can only be made using POST.')\n if not request.user.is_authenticated():\n return json_error_response('Not authenticated.')\n\n try:\n vote = dict(VOTE_DIRECTIONS)[direction]\n except KeyError:\n return json_error_response(\n '\\'%s\\' is not a valid vote type.' % direction)\n\n # Look up the object to be voted on\n lookup_kwargs = {}\n if object_id:\n lookup_kwargs['%s__exact' % model._meta.pk.name] = object_id\n elif slug and slug_field:\n lookup_kwargs['%s__exact' % slug_field] = slug\n else:\n return json_error_response('Generic XMLHttpRequest vote view must be '\n 'called with either object_id or slug and '\n 'slug_field.')\n try:\n obj = model._default_manager.get(**lookup_kwargs)\n except ObjectDoesNotExist:\n return json_error_response(\n 'No %s found for %s.' % (model._meta.verbose_name, lookup_kwargs))\n\n # Vote and respond\n Vote.objects.record_vote(obj, request.user, vote)\n return HttpResponse(simplejson.dumps({\n 'success': True,\n 'score': Vote.objects.get_score(obj),\n }))", "metadata": "root.xmlhttprequest_vote_on_object", "header": "['module', '___EOS___']", "index": 103 } ]
[ { "span": "from django.contrib.contenttypes.models import ContentType", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 58 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Object", "Do", "es", "Not", "Exist_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http404_", ",_", "Http", "Response_", ",_", "Http", "Respons", "e", "Redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "views_", "import_", "redirec", "t", "\\u", "to", "\\u", "login_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "import_", "loader_", ",_", "Request", "Context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "simplejson_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "voting", "_", "._", "models_", "import_", "Vote", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "VO", "TE", "\\u", "DIRECTION", "S_", "=_", "(_", "(_", "'", "up", "'_", ",_", "1_", ")_", ",_", "(_", "'", "down", "'_", ",_", "-_", "1_", ")_", ",_", "(_", "'", "clear", "'_", ",_", "0_", ")_", ")_", "\\u\\u\\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_", "vote", "\\u", "on", "\\u", "object_", "(_", "request_", ",_", "model_", ",_", "direction_", ",_", "post", "\\u", "vote", "\\u", "redirect_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "object\\u", "id_", "=_", "None_", ",_", "slug_", "=_", "None_", ",_", "slug", "\\u", "field_", "=_", "None_", ",_", "template", "\\u", "name_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "loader_", "=_", "loader_", ",_", "extra", "\\u", "context_", "=_", "None_", ",_", "context", "\\u", "processors_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", "=_", "'", "object", "'_", ",_", "allow", "\\u", "xml", "http", "request_", "=_", "False_", ",_", "confirm", "\\u", "vote_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Gene", "ric", " ", "object", " ", "vote", " ", "function", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "give", "n", " ", "template", " ", "will", " ", "be", " ", "used", " ", "to", " ", "confirm", " ", "the", " ", "vote", " ", "if", " ", "this", " ", "view", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "fetched", " ", "usi", "ng", " ", "GET", ";", " ", "vote", " ", "registration", " ", "will", " ", "only", " ", "be", " ", "perform", "ed", " ", "if", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "view", " ", "is", " ", "POST", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "``", "allow", "\\u", "xml", "http", "request", "``", " ", "is", " ", "``", "Tru", "e", "``", " ", "and", " ", "an", " ", "XML", "Http", "Request", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "detect", "ed", " ", "by", " ", "exam", "inin", "g", " ", "the", " ", "``", "HTTP", "\\u", "X", "\\u", "REQUEST", "ED", "\\u", "WITH", "``", " ", "header", ",", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "``", "xml", "http", "\\u", "vote", "\\u", "on", "\\u", "object", "``", " ", "view", " ", "will", " ", "be", " ", "used", " ", "to", " ", "process", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "-", " ", "this", " ", "make", "s", " ", "it", " ", "trivial", " ", "to", " ", "implement", " ", "voting", " ", "via", "\\", "10", ";", " ", " ", " ", " ", "XML", "Http", "Request", " ", "with", " ", "a", " ", "fall", "back", " ", "for", " ", "users", " ", "who", " ", "don", "'", "t", " ", "have", " ", "Ja", "va", "Script", "\\", "10", ";", " ", " ", " ", " ", "enable", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tes", ":`", "`", "<", "app", "\\u", "label", ">/", "<", "model", "\\u", "name", ">\\u", "confirm", "\\u", "vote", ".", "html", "``", "\\", "10", ";", " ", " ", " ", " ", "Context", ":", "\\", "10", ";", " ", " ", " ", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "object", " ", "bei", "ng", " ", "vote", "d", " ", "on", ".", "\\", "10", ";", " ", " ", " ", " ", "direction", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "type", " ", "of", " ", "vote", " ", "whi", "ch", " ", "will", " ", "be", " ", "register", "ed", " ", "for", " ", "the", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "allow", "\\u", "xml", "http", "request_", "and_", "request_", "._", "is", "\\u", "ajax_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "xml", "http", "request", "\\u", "vote", "\\u", "on", "\\u", "object_", "(_", "request_", ",_", "model_", ",_", "direction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "object\\u", "id_", "=_", "object\\u", "id_", ",_", "slug_", "=_", "slug_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slug", "\\u", "field_", "=_", "slug", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "extra", "\\u", "context_", "is_", "None_", ":_", "extra", "\\u", "context_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "request_", "._", "user_", "._", "is", "\\u", "authenticated_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "redirec", "t", "\\u", "to", "\\u", "login_", "(_", "request_", "._", "path_", ")_", "\\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 ", " _", "vote_", "=_", "dict_", "(_", "VO", "TE", "\\u", "DIRECTION", "S_", ")_", "[_", "direction_", "]_", "\\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 ", " _", "raise_", "Attribute", "Error_", "(_", "\"'", "%", "s", "'", " ", "is", " ", "not", " ", "a", " ", "valid", " ", "vote", " ", "type", ".\"_", "%_", "vote", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Look", " ", "up", " ", "the", " ", "object", " ", "to", " ", "be", " ", "vote", "d", " ", "on_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "look", "up", "\\u", "kwargs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "object\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "look", "up", "\\u", "kwargs_", "[_", "'%", "s", "\\u\\u", "exact", "'_", "%_", "model_", "._", "\\u", "meta_", "._", "pk_", "._", "name_", "]_", "=_", "object\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "slug_", "and_", "slug", "\\u", "field_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "look", "up", "\\u", "kwargs_", "[_", "'%", "s", "\\u\\u", "exact", "'_", "%_", "slug", "\\u", "field_", "]_", "=_", "slug_", "\\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_", "Attribute", "Error_", "(_", "'", "Gene", "ric", " ", "vote", " ", "view", " ", "must", " ", "be", " ", "call", "ed", " ", "with", " ", "eit", "her", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object\\u", "id", " ", "or", " ", "slug", " ", "and", " ", "slug", "\\u", "field", ".'_", ")_", "\\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 ", " _", "obj_", "=_", "model_", "._", "\\u", "default", "\\u", "manager_", "._", "get_", "(_", "**_", "look", "up", "\\u", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Object", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", ",_", "'", "No", " ", "%", "s", " ", "found", " ", "for", " ", "%", "s", ".'_", "%_", "(_", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "look", "up", "\\u", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", "or_", "confirm", "\\u", "vote_", "==_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "post", "\\u", "vote", "\\u", "redirect_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next_", "=_", "post", "\\u", "vote", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request_", "._", "REQUEST_", "._", "has", "\\u", "key_", "(_", "'", "next", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next_", "=_", "request_", "._", "REQUEST_", "[_", "'", "next", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "hasattr_", "(_", "obj_", ",_", "'", "get", "\\u", "abs", "olute", "\\u", "url", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "callable_", "(_", "getattr_", "(_", "obj_", ",_", "'", "get", "\\u", "abs", "olute", "\\u", "url", "'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next_", "=_", "obj_", "._", "get", "\\u", "abs", "olute", "\\u", "url_", "(_", ")_", "\\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 ", " _", "next_", "=_", "obj_", "._", "get", "\\u", "abs", "olute", "\\u", "url_", "\\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_", "Attribute", "Error_", "(_", "'", "Gene", "ric", " ", "vote", " ", "view", " ", "must", " ", "be", " ", "call", "ed", " ", "with", " ", "eit", "her", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "post", "\\u", "vote", "\\u", "redirec", "t", ",", " ", "a", " ", "\"", "next", "\"", " ", "parameter", " ", "in", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "the", " ", "request", ",", " ", "or", " ", "the", " ", "object", " ", "bei", "ng", " ", "vote", "d", " ", "on", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "must", " ", "defin", "e", " ", "a", " ", "get", "\\u", "abs", "olute", "\\u", "url", " ", "method", " ", "or", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "property", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Vote", "_", "._", "objects_", "._", "record", "\\u", "vote_", "(_", "obj_", ",_", "request_", "._", "user_", ",_", "vote_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "next_", ")_", "\\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_", "not_", "template", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "name_", "=_", "'%", "s", "/", "%", "s", "\\u", "confirm", "\\u", "vote", ".", "html", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "model_", "._", "\\u", "meta_", "._", "object\\u", "name_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "template", "\\u", "loader_", "._", "get", "\\u", "template_", "(_", "template", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Request", "Context_", "(_", "request_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", ":_", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "direction", "'_", ":_", "direction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "context", "\\u", "processors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "extra", "\\u", "context_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "callable_", "(_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "[_", "key_", "]_", "=_", "value_", "(_", ")_", "\\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 ", " _", "c_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "Http", "Response_", "(_", "t_", "._", "render_", "(_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "response_", "\\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_", "json", "\\u", "error", "\\u", "response_", "(_", "error", "\\u", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "simplejson_", "._", "dumps_", "(_", "dict_", "(_", "success_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "error", "\\u", "message_", "=_", "error", "\\u", "message_", ")_", ")_", ")_", "\\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", "http", "request", "\\u", "vote", "\\u", "on", "\\u", "object_", "(_", "request_", ",_", "model_", ",_", "direction_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "object\\u", "id_", "=_", "None_", ",_", "slug_", "=_", "None_", ",_", "slug", "\\u", "field_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Gene", "ric", " ", "object", " ", "vote", " ", "function", " ", "for", " ", "use", " ", "via", " ", "XML", "Http", "Request", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Proper", "ties", " ", "of", " ", "the", " ", "result", "ing", " ", "JSO", "N", " ", "object", ":", "\\", "10", ";", " ", " ", " ", " ", "success", "\\", "10", ";", " ", " ", " ", " ", "``", "true", "``", " ", "if", " ", "the", " ", "vote", " ", "was", " ", "success", "full", "y", " ", "process", "ed", ",", " ", "``", "fal", "se", "``", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", ".", "\\", "10", ";", " ", " ", " ", " ", "score", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "object", "'", "s", " ", "update", "d", " ", "score", " ", "and", " ", "number", " ", "of", " ", "vote", "s", " ", "if", " ", "the", " ", "vote", "\\", "10", ";", " ", " ", " ", " ", "was", " ", "success", "full", "y", " ", "process", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "error", "\\u", "message", "\\", "10", ";", " ", " ", " ", " ", "Contain", "s", " ", "an", " ", "error", " ", "message", " ", "if", " ", "the", " ", "vote", " ", "was", " ", "not", " ", "success", "full", "y", "\\", "10", ";", " ", " ", " ", " ", "process", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "'", "GET", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json", "\\u", "error", "\\u", "response_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "XML", "Http", "Request", " ", "vote", "s", " ", "can", " ", "only", " ", "be", " ", "made", " ", "usi", "ng", " ", "POST", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "request_", "._", "user_", "._", "is", "\\u", "authenticated_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json", "\\u", "error", "\\u", "response_", "(_", "'", "Not", " ", "authenticat", "ed", ".'_", ")_", "\\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 ", " _", "vote_", "=_", "dict_", "(_", "VO", "TE", "\\u", "DIRECTION", "S_", ")_", "[_", "direction_", "]_", "\\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 ", " _", "return_", "json", "\\u", "error", "\\u", "response_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'\\\\'", "%", "s", "\\\\'", " ", "is", " ", "not", " ", "a", " ", "valid", " ", "vote", " ", "type", ".'_", "%_", "direction_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Look", " ", "up", " ", "the", " ", "object", " ", "to", " ", "be", " ", "vote", "d", " ", "on_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "look", "up", "\\u", "kwargs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "object\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "look", "up", "\\u", "kwargs_", "[_", "'%", "s", "\\u\\u", "exact", "'_", "%_", "model_", "._", "\\u", "meta_", "._", "pk_", "._", "name_", "]_", "=_", "object\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "slug_", "and_", "slug", "\\u", "field_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "look", "up", "\\u", "kwargs_", "[_", "'%", "s", "\\u\\u", "exact", "'_", "%_", "slug", "\\u", "field_", "]_", "=_", "slug_", "\\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_", "json", "\\u", "error", "\\u", "response_", "(_", "'", "Gene", "ric", " ", "XML", "Http", "Request", " ", "vote", " ", "view", " ", "must", " ", "be", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "call", "ed", " ", "with", " ", "eit", "her", " ", "object\\u", "id", " ", "or", " ", "slug", " ", "and", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "\\u", "field", ".'_", ")_", "\\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 ", " _", "obj_", "=_", "model_", "._", "\\u", "default", "\\u", "manager_", "._", "get_", "(_", "**_", "look", "up", "\\u", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Object", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "json", "\\u", "error", "\\u", "response_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "No", " ", "%", "s", " ", "found", " ", "for", " ", "%", "s", ".'_", "%_", "(_", "model_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name_", ",_", "look", "up", "\\u", "kwargs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Vote", " ", "and", " ", "respond_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Vote", "_", "._", "objects_", "._", "record", "\\u", "vote_", "(_", "obj_", ",_", "request_", "._", "user_", ",_", "vote_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "simplejson_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "score", "'_", ":_", "Vote", "_", "._", "objects_", "._", "get", "\\u", "score_", "(_", "obj_", ")_", ",_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
dropbox/questions/questions/migrations/0001_initial.py
[ { "content": "# -*- coding: utf-8 -*-\nimport datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(SchemaMigration):\n\n\n\n\n\n models = {\n 'auth.group': {\n 'Meta': {'object_name': 'Group'},\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\n 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'})\n },\n 'auth.permission': {\n 'Meta': {'ordering': \"('content_type__app_label', 'content_type__model', 'codename')\", 'unique_together': \"(('content_type', 'codename'),)\", 'object_name': 'Permission'},\n 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['contenttypes.ContentType']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n },\n 'auth.user': {\n 'Meta': {'object_name': 'User'},\n 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\n 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Group']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),\n 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n },\n 'contenttypes.contenttype': {\n 'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n },\n 'questions.group': {\n 'Meta': {'object_name': 'Group'},\n 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '60'})\n },\n 'questions.question': {\n 'Meta': {'object_name': 'Question'},\n 'added_by': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\"}),\n 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'difficulty': ('django.db.models.fields.CharField', [], {'default': \"'Easy'\", 'max_length': '20'}),\n 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['questions.Group']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'status': ('django.db.models.fields.CharField', [], {'default': \"'Pending'\", 'max_length': '30'}),\n 'tags': ('tagging.fields.TagField', [], {'null': 'True'}),\n 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})\n },\n 'questions.questionrevision': {\n 'Meta': {'object_name': 'QuestionRevision'},\n 'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'date_added': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'question': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['questions.Question']\"}),\n 'text': ('django.db.models.fields.TextField', [], {}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\"})\n },\n 'questions.settings': {\n 'Meta': {'object_name': 'Settings'},\n 'group': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['questions.Group']\", 'null': 'True', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['auth.User']\"})\n }\n }\n\n complete_apps = ['questions']", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 7 }, { "content": " def forwards(self, orm):\n # Adding model 'Group'\n db.create_table('questions_group', (\n ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\n ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=60)),\n ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),\n ))\n db.send_create_signal('questions', ['Group'])\n\n # Adding model 'Settings'\n db.create_table('questions_settings', (\n ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\n ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),\n ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.Group'], null=True, blank=True)),\n ))\n db.send_create_signal('questions', ['Settings'])\n\n # Adding model 'Question'\n db.create_table('questions_question', (\n ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\n ('title', self.gf('django.db.models.fields.CharField')(max_length=255)),\n ('status', self.gf('django.db.models.fields.CharField')(default='Pending', max_length=30)),\n ('tags', self.gf('tagging.fields.TagField')(null=True)),\n ('difficulty', self.gf('django.db.models.fields.CharField')(default='Easy', max_length=20)),\n ('group', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.Group'])),\n ('date_added', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),\n ('added_by', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),\n ))\n db.send_create_signal('questions', ['Question'])\n\n # Adding model 'QuestionRevision'\n db.create_table('questions_questionrevision', (\n ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),\n ('question', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.Question'])),\n ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])),\n ('text', self.gf('django.db.models.fields.TextField')()),\n ('active', self.gf('django.db.models.fields.BooleanField')(default=False)),\n ('date_added', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),\n ))\n db.send_create_signal('questions', ['QuestionRevision'])", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 9 }, { "content": " def backwards(self, orm):\n # Deleting model 'Group'\n db.delete_table('questions_group')\n\n # Deleting model 'Settings'\n db.delete_table('questions_settings')\n\n # Deleting model 'Question'\n db.delete_table('questions_question')\n\n # Deleting model 'QuestionRevision'\n db.delete_table('questions_questionrevision')", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 51 } ]
[ { "span": "import datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "from django.db import models", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "v2_", "import_", "Schema", "Migration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\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_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\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\\uDEDENT\\u\\u\\u_", "models_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "group", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Group", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "80", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "permissi", "on", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "content", "\\u", "type\\u\\u", "app", "\\u", "label", "',", " ", "'", "content", "\\u", "type\\u\\u", "model", "',", " ", "'", "code", "name", "')\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "content", "\\u", "type", "',", " ", "'", "code", "name", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Permi", "ssion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "user", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "User", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "joine", "d", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "email", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Ema", "il", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "7", "5", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "first", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "group", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Group", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "sta", "ff", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "super", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "login", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", ".", "now", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "password", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "128", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "\\u", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contenttype", "s", ".", "contenttype", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "name", "',)\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "app", "\\u", "label", "',", " ", "'", "model", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Conten", "t", "Type", "'_", ",_", "'", "db", "\\u", "table", "'_", ":_", "\"'", "django", "\\u", "content", "\\u", "type", "'\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "label", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "model", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "s", ".", "group", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Group", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "60", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "s", ".", "question", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Quest", "ion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adde", "d\\u", "by", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "adde", "d", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "\\u", "add", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "difficult", "y", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"'", "Eas", "y", "'\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "20", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "group", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "question", "s", ".", "Group", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"'", "Pend", "ing", "'\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tags", "'_", ":_", "(_", "'", "tagging", ".", "fields", ".", "Ta", "g", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "255", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "s", ".", "question", "revis", "ion", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Quest", "ion", "Revi", "sion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "active", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "adde", "d", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "auto", "\\u", "now", "\\u", "add", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "question", "s", ".", "Quest", "ion", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "question", "s", ".", "settings", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Sett", "ings", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "group", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "question", "s", ".", "Group", "']\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "question", "s", "'_", "]_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "forwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Group", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "create", "\\u", "table_", "(_", "'", "question", "s", "\\u", "group", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ")_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "name", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "unique_", "=_", "True_", ",_", "max", "\\u", "length_", "=_", "60_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "description", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ")_", "(_", "null_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "question", "s", "'_", ",_", "[_", "'", "Group", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Sett", "ings", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "create", "\\u", "table_", "(_", "'", "question", "s", "\\u", "settings", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ")_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "user", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "auth", ".", "User", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "group", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "question", "s", ".", "Group", "'_", "]_", ",_", "null_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "question", "s", "'_", ",_", "[_", "'", "Sett", "ings", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Quest", "ion", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "create", "\\u", "table_", "(_", "'", "question", "s", "\\u", "question", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ")_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "title", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "max", "\\u", "length_", "=_", "255_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "status", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "default_", "=_", "'", "Pend", "ing", "'_", ",_", "max", "\\u", "length_", "=_", "30_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "tags", "'_", ",_", "self_", "._", "gf_", "(_", "'", "tagging", ".", "fields", ".", "Ta", "g", "Field", "'_", ")_", "(_", "null_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "difficult", "y", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ")_", "(_", "default_", "=_", "'", "Eas", "y", "'_", ",_", "max", "\\u", "length_", "=_", "20_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "group", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "question", "s", ".", "Group", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "date", "\\u", "adde", "d", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ")_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "adde", "d\\u", "by", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "auth", ".", "User", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "question", "s", "'_", ",_", "[_", "'", "Quest", "ion", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "model", " ", "'", "Quest", "ion", "Revi", "sion", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "create", "\\u", "table_", "(_", "'", "question", "s", "\\u", "question", "revis", "ion", "'_", ",_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "id", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ")_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "question", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "question", "s", ".", "Quest", "ion", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "user", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "auth", ".", "User", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "text", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ")_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "active", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ")_", "(_", "default_", "=_", "False_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "date", "\\u", "adde", "d", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ")_", "(_", "auto", "\\u", "now", "\\u", "add_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "._", "send", "\\u", "create", "\\u", "signal_", "(_", "'", "question", "s", "'_", ",_", "[_", "'", "Quest", "ion", "Revi", "sion", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "backwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "model", " ", "'", "Group", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "delete", "\\u", "table_", "(_", "'", "question", "s", "\\u", "group", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "model", " ", "'", "Sett", "ings", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "delete", "\\u", "table_", "(_", "'", "question", "s", "\\u", "settings", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "model", " ", "'", "Quest", "ion", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "delete", "\\u", "table_", "(_", "'", "question", "s", "\\u", "question", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "model", " ", "'", "Quest", "ion", "Revi", "sion", "'_", "\\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 ]
Unused import
Piratenfraktion-Berlin/OwnTube/livestream/views.py
[ { "content": "from django.shortcuts import render_to_response, get_object_or_404, redirect\nfrom django import forms\nfrom django.template import RequestContext\nfrom django.http import HttpResponseRedirect, HttpResponse\nfrom django.core.urlresolvers import reverse\n\nfrom livestream.models import Stream\n\nimport datetime\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def current(request):\n ''' This view gets all streams that are scheduled to be live right now\n if there are no streams it redirects to the liste view. The upcoming_streams_list\n is used to show upcoming events in a side bar (see the template)'''\n stream_list = Stream.objects.filter(published=True,startDate__lt=datetime.datetime.now, endDate__gt=datetime.datetime.now).order_by('-startDate')\n upcoming_streams_list = Stream.objects.filter(published=True,endDate__gt=datetime.datetime.now).order_by('-startDate')[:5]\n if not stream_list:\n return redirect(list)\n else:\n return render_to_response('livestream/current.html', {'stream_list': stream_list, 'upcoming_streams_list': upcoming_streams_list},\n context_instance=RequestContext(request))", "metadata": "root.current", "header": "['module', '___EOS___']", "index": 11 }, { "content": "def list(request):\n ''' This view shows gets all upcoming streaming events\n and forwards them to our template '''\n stream_list = Stream.objects.filter(published=True,endDate__gt=datetime.datetime.now).order_by('-startDate')\n return render_to_response('livestream/list.html', {'stream_list': stream_list},\n context_instance=RequestContext(request))", "metadata": "root.list", "header": "['module', '___EOS___']", "index": 24 }, { "content": "def detail(request, slug):\n ''' This view shows the detail of a stream, it is used to\n show the user more information on one event but not\n for showing the player'''\n stream = get_object_or_404(Stream, slug=slug)\n upcoming_streams_list = Stream.objects.filter(published=True,endDate__gt=datetime.datetime.now).order_by('-startDate')[:5]\n return render_to_response('livestream/detail.html', {'stream': stream, 'upcoming_streams_list': upcoming_streams_list},\n context_instance=RequestContext(request))", "metadata": "root.detail", "header": "['module', '___EOS___']", "index": 31 } ]
[ { "span": "from django import forms", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 24 }, { "span": "from django.http import HttpResponseRedirect, HttpResponse", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 58 }, { "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_", "django_", "._", "shortcuts_", "import_", "render", "\\u", "to", "\\u", "response_", ",_", "get", "\\u", "object\\u", "or", "\\u", "404_", ",_", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "import_", "forms_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "import_", "Request", "Context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Respons", "e", "Redirect_", ",_", "Http", "Response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lives", "tream_", "._", "models_", "import_", "Stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "current_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Thi", "s", " ", "view", " ", "gets", " ", "all", " ", "stream", "s", " ", "tha", "t", " ", "are", " ", "schedule", "d", " ", "to", " ", "be", " ", "live", " ", "right", " ", "now", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "there", " ", "are", " ", "no", " ", "stream", "s", " ", "it", " ", "redirec", "ts", " ", "to", " ", "the", " ", "liste", " ", "view", ".", " ", "The", " ", "upcom", "ing", "\\u", "stream", "s", "\\u", "list", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "used", " ", "to", " ", "show", " ", "upcom", "ing", " ", "events", " ", "in", " ", "a", " ", "side", " ", "bar", " ", "(", "see", " ", "the", " ", "template", ")'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stream", "\\u", "list_", "=_", "Stream_", "._", "objects_", "._", "filter_", "(_", "published_", "=_", "True_", ",_", "start", "Date", "\\u\\u", "lt_", "=_", "datetime_", "._", "datetime_", "._", "now_", ",_", "end", "Date", "\\u\\u", "gt_", "=_", "datetime_", "._", "datetime_", "._", "now_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "start", "Date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upcom", "ing", "\\u", "stream", "s", "\\u", "list_", "=_", "Stream_", "._", "objects_", "._", "filter_", "(_", "published_", "=_", "True_", ",_", "end", "Date", "\\u\\u", "gt_", "=_", "datetime_", "._", "datetime_", "._", "now_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "start", "Date", "'_", ")_", "[_", ":_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "stream", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "redirect_", "(_", "list_", ")_", "\\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_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "lives", "tream", "/", "current", ".", "html", "'_", ",_", "{_", "'", "stream", "\\u", "list", "'_", ":_", "stream", "\\u", "list_", ",_", "'", "upcom", "ing", "\\u", "stream", "s", "\\u", "list", "'_", ":_", "upcom", "ing", "\\u", "stream", "s", "\\u", "list_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Thi", "s", " ", "view", " ", "show", "s", " ", "gets", " ", "all", " ", "upcom", "ing", " ", "stream", "ing", " ", "events", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "forward", "s", " ", "them", " ", "to", " ", "our", " ", "template", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stream", "\\u", "list_", "=_", "Stream_", "._", "objects_", "._", "filter_", "(_", "published_", "=_", "True_", ",_", "end", "Date", "\\u\\u", "gt_", "=_", "datetime_", "._", "datetime_", "._", "now_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "start", "Date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "lives", "tream", "/", "list", ".", "html", "'_", ",_", "{_", "'", "stream", "\\u", "list", "'_", ":_", "stream", "\\u", "list_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "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_", "detail_", "(_", "request_", ",_", "slug_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Thi", "s", " ", "view", " ", "show", "s", " ", "the", " ", "deta", "il", " ", "of", " ", "a", " ", "stream", ",", " ", "it", " ", "is", " ", "used", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "show", " ", "the", " ", "user", " ", "more", " ", "informati", "on", " ", "on", " ", "one", " ", "event", " ", "but", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "showin", "g", " ", "the", " ", "player", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stream_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Stream_", ",_", "slug_", "=_", "slug_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upcom", "ing", "\\u", "stream", "s", "\\u", "list_", "=_", "Stream_", "._", "objects_", "._", "filter_", "(_", "published_", "=_", "True_", ",_", "end", "Date", "\\u\\u", "gt_", "=_", "datetime_", "._", "datetime_", "._", "now_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "start", "Date", "'_", ")_", "[_", ":_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "lives", "tream", "/", "deta", "il", ".", "html", "'_", ",_", "{_", "'", "stream", "'_", ":_", "stream_", ",_", "'", "upcom", "ing", "\\u", "stream", "s", "\\u", "list", "'_", ":_", "upcom", "ing", "\\u", "stream", "s", "\\u", "list_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ")_" ]
[ 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, 2, 2, 2, 2, 2, 2, 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py
[ { "content": "def _gen_cluster_mock_resp(r, response):\n mock_connection_pool = Mock()\n connection = Mock()\n response = response\n connection.read_response.return_value = response\n mock_connection_pool.get_connection.return_value = connection\n r.connection_pool = mock_connection_pool\n return r", "metadata": "root._gen_cluster_mock_resp", "header": "['module', '___EOS___']", "index": 49 } ]
[ { "span": "response = response", "start_line": 52, "start_column": 4, "end_line": 52, "end_column": 23 } ]
[]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "assignment_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gen", "\\u", "cluster", "\\u", "mock", "\\u", "resp_", "(_", "r_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "connecti", "on", "\\u", "pool_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "._", "read", "\\u", "response_", "._", "return", "\\u", "value_", "=_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mock", "\\u", "connecti", "on", "\\u", "pool_", "._", "get", "\\u", "connection_", "._", "return", "\\u", "value_", "=_", "connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "connecti", "on", "\\u", "pool_", "=_", "mock", "\\u", "connecti", "on", "\\u", "pool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "r_", "\\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, 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 ]
Unused import
saltstack/salt/salt/modules/etcd_mod.py
[ { "content": "# -*- coding: utf-8 -*-\n'''\nExecution module to work with etcd\n\n:depends: - python-etcd\n\nIn order to use an etcd server, a profile should be created in the master\nconfiguration file:\n\n.. code-block:: yaml\n\n my_etd_config:\n etcd.host: 127.0.0.1\n etcd.port: 4001\n\nIt is technically possible to configure etcd without using a profile, but this\nis not considered to be a best practice, especially when multiple etcd servers\nor clusters are available.\n\n.. code-block:: yaml\n\n etcd.host: 127.0.0.1\n etcd.port: 4001\n'''\nfrom __future__ import absolute_import\n\n# Import python libs\nimport logging\n\n# Import third party libs\ntry:\n import salt.utils.etcd_util # pylint: disable=W0611\n HAS_LIBS = True\nexcept ImportError:\n HAS_LIBS = False\n\n__virtualname__ = 'etcd'\n\n# Set up logging\nlog = logging.getLogger(__name__)\n\n\n# Define a function alias in order not to shadow built-in's\n__func_alias__ = {\n 'get_': 'get',\n 'set_': 'set',\n 'rm_': 'rm',\n 'ls_': 'ls'\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 __virtual__():\n '''\n Only return if python-etcd is installed\n '''\n if HAS_LIBS:\n return __virtualname__\n return (False, 'The etcd_mod execution module cannot be loaded: '\n 'python etcd library not available.')", "metadata": "root.__virtual__", "header": "['module', '___EOS___']", "index": 51 }, { "content": "def get_(key, recurse=False, profile=None):\n '''\n .. versionadded:: 2014.7.0\n\n Get a value from etcd, by direct path. Returns None on failure.\n\n CLI Examples:\n\n .. code-block:: bash\n\n salt myminion etcd.get /path/to/key\n salt myminion etcd.get /path/to/key profile=my_etcd_config\n salt myminion etcd.get /path/to/key recurse=True profile=my_etcd_config\n '''\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n if recurse:\n return client.tree(key)\n else:\n return client.get(key, recurse=recurse)", "metadata": "root.get_", "header": "['module', '___EOS___']", "index": 61 }, { "content": "def set_(key, value, profile=None, ttl=None, directory=False):\n '''\n .. versionadded:: 2014.7.0\n\n Set a key in etcd by direct path. Optionally, create a directory\n or set a TTL on the key. Returns None on failure.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt myminion etcd.set /path/to/key value\n salt myminion etcd.set /path/to/key value profile=my_etcd_config\n salt myminion etcd.set /path/to/dir '' directory=True\n salt myminion etcd.set /path/to/key value ttl=5\n '''\n\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.set(key, value, ttl=ttl, directory=directory)", "metadata": "root.set_", "header": "['module', '___EOS___']", "index": 82 }, { "content": "def update(fields, path='', profile=None):\n '''\n .. versionadded:: 2016.3.0\n\n Sets a dictionary of values in one call. Useful for large updates\n in syndic environments. The dictionary can contain a mix of formats\n such as:\n\n .. code-block:: python\n\n {\n '/some/example/key': 'bar',\n '/another/example/key': 'baz'\n }\n\n Or it may be a straight dictionary, which will be flattened to look\n like the above format:\n\n .. code-block:: python\n\n {\n 'some': {\n 'example': {\n 'key': 'bar'\n }\n },\n 'another': {\n 'example': {\n 'key': 'baz'\n }\n }\n }\n\n You can even mix the two formats and it will be flattened to the first\n format. Leading and trailing '/' will be removed.\n\n Empty directories can be created by setting the value of the key to an\n empty dictionary.\n\n The 'path' parameter will optionally set the root of the path to use.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt myminion etcd.update \"{'/path/to/key': 'baz', '/another/key': 'bar'}\"\n salt myminion etcd.update \"{'/path/to/key': 'baz', '/another/key': 'bar'}\" profile=my_etcd_config\n salt myminion etcd.update \"{'/path/to/key': 'baz', '/another/key': 'bar'}\" path='/some/root'\n '''\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.update(fields, path)", "metadata": "root.update", "header": "['module', '___EOS___']", "index": 103 }, { "content": "def watch(key, recurse=False, profile=None, timeout=0, index=None):\n '''\n .. versionadded:: 2016.3.0\n\n Makes a best effort to watch for a key or tree change in etcd.\n Returns a dict containing the new key value ( or None if the key was\n deleted ), the modifiedIndex of the key, whether the key changed or\n not, the path to the key that changed and whether it is a directory or not.\n\n If something catastrophic happens, returns {}\n\n CLI Example:\n\n .. code-block:: bash\n\n salt myminion etcd.watch /path/to/key\n salt myminion etcd.watch /path/to/key timeout=10\n salt myminion etcd.watch /patch/to/key profile=my_etcd_config index=10\n '''\n\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.watch(key, recurse=recurse, timeout=timeout, index=index)", "metadata": "root.watch", "header": "['module', '___EOS___']", "index": 156 }, { "content": "def ls_(path='/', profile=None):\n '''\n .. versionadded:: 2014.7.0\n\n Return all keys and dirs inside a specific path. Returns an empty dict on\n failure.\n\n CLI Example:\n\n\n .. code-block:: bash\n\n salt myminion etcd.ls /path/to/dir/\n salt myminion etcd.ls /path/to/dir/ profile=my_etcd_config\n '''\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.ls(path)", "metadata": "root.ls_", "header": "['module', '___EOS___']", "index": 180 }, { "content": "def rm_(key, recurse=False, profile=None):\n '''\n .. versionadded:: 2014.7.0\n\n Delete a key from etcd. Returns True if the key was deleted, False if it wasn\n not and None if there was a failure.\n\n CLI Example:\n\n\n .. code-block:: bash\n\n salt myminion etcd.rm /path/to/key\n salt myminion etcd.rm /path/to/key profile=my_etcd_config\n salt myminion etcd.rm /path/to/dir recurse=True profile=my_etcd_config\n '''\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.rm(key, recurse=recurse)", "metadata": "root.rm_", "header": "['module', '___EOS___']", "index": 199 }, { "content": "def tree(path='/', profile=None):\n '''\n .. versionadded:: 2014.7.0\n\n Recurse through etcd and return all values. Returns None on failure.\n\n CLI Example:\n\n\n .. code-block:: bash\n\n salt myminion etcd.tree\n salt myminion etcd.tree profile=my_etcd_config\n salt myminion etcd.tree /path/to/keys profile=my_etcd_config\n '''\n client = __utils__['etcd_util.get_conn'](__opts__, profile)\n return client.tree(path)", "metadata": "root.tree", "header": "['module', '___EOS___']", "index": 219 } ]
[ { "span": "import salt.utils.etcd_util ", "start_line": 31, "start_column": 4, "end_line": 31, "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_", "'''", "\\", "10", ";", "Execut", "ion", " ", "module", " ", "to", " ", "work", " ", "with", " ", "etcd", "\\", "10", ";", "\\", "10", ";", ":", "depend", "s", ":", " ", " ", "-", " ", "python", "-", "etcd", "\\", "10", ";", "\\", "10", ";", "In", " ", "order", " ", "to", " ", "use", " ", "an", " ", "etcd", " ", "server", ",", " ", "a", " ", "profile", " ", "shou", "ld", " ", "be", " ", "created", " ", "in", " ", "the", " ", "master", "\\", "10", ";", "configura", "tion", " ", "file", ":", "\\", "10", ";", "\\", "10", ";", "..", " ", "code", "-", "block", "::", " ", "yaml", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "my", "\\u", "et", "d\\u", "config", ":", "\\", "10", ";", " ", " ", "etcd", ".", "host", ":", " ", "127", ".0", ".0", ".1", "\\", "10", ";", " ", " ", "etcd", ".", "port", ":", " ", "400", "1", "\\", "10", ";", "\\", "10", ";", "It", " ", "is", " ", "technical", "ly", " ", "possib", "le", " ", "to", " ", "configur", "e", " ", "etcd", " ", "with", "out", " ", "usi", "ng", " ", "a", " ", "profile", ",", " ", "but", " ", "this", "\\", "10", ";", "is", " ", "not", " ", "consider", "ed", " ", "to", " ", "be", " ", "a", " ", "best", " ", "practic", "e", ",", " ", "especial", "ly", " ", "whe", "n", " ", "multiple", " ", "etcd", " ", "server", "s", "\\", "10", ";", "or", " ", "cluster", "s", " ", "are", " ", "avail", "able", ".", "\\", "10", ";", "\\", "10", ";", "..", " ", "code", "-", "block", "::", " ", "yaml", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "etcd", ".", "host", ":", " ", "127", ".0", ".0", ".1", "\\", "10", ";", " ", " ", " ", " ", "etcd", ".", "port", ":", " ", "400", "1", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "python", " ", "libs_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "third", " ", "part", "y", " ", "libs_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "salt_", "._", "utils_", "._", "etcd", "\\u", "util_", "#", " ", "pylint", ":", " ", "disable", "=", "W", "061", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "HAS", "\\u", "LIBS", "_", "=_", "True_", "\\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 ", " _", "HAS", "\\u", "LIBS", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u", "virtual", "name\\u\\u_", "=_", "'", "etcd", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "up", " ", "logging_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Define", " ", "a", " ", "function", " ", "alias", " ", "in", " ", "order", " ", "not", " ", "to", " ", "shadow", " ", "bui", "lt", "-", "in", "'", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "func", "\\u", "alias", "\\u\\u_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "get", "\\u'_", ":_", "'", "get", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "set\\u", "'_", ":_", "'", "set", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rm", "\\u'_", ":_", "'", "rm", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ls", "\\u'_", ":_", "'", "ls", "'_", "\\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_", "\\u\\u", "virtual", "\\u\\u_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "On", "ly", " ", "return", " ", "if", " ", "python", "-", "etcd", " ", "is", " ", "install", "ed", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "HAS", "\\u", "LIBS", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u", "virtual", "name\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "False_", ",_", "'", "The", " ", "etcd", "\\u", "mod", " ", "executi", "on", " ", "module", " ", "cann", "ot", " ", "be", " ", "load", "ed", ":", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "python", " ", "etcd", " ", "librar", "y", " ", "not", " ", "avail", "able", ".'_", ")_", "\\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", "\\u_", "(_", "key_", ",_", "recurse_", "=_", "False_", ",_", "profile_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2014", ".7", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "a", " ", "value", " ", "from", " ", "etcd", ",", " ", "by", " ", "direct", " ", "path", ".", " ", " ", "Return", "s", " ", "Non", "e", " ", "on", " ", "fail", "ure", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ples", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "get", " ", "/", "path", "/", "to", "/", "key", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "get", " ", "/", "path", "/", "to", "/", "key", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "get", " ", "/", "path", "/", "to", "/", "key", " ", "recurse", "=", "Tru", "e", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "recurse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "client_", "._", "tree_", "(_", "key_", ")_", "\\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_", "client_", "._", "get_", "(_", "key_", ",_", "recurse_", "=_", "recurse_", ")_", "\\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_", "set\\u", "_", "(_", "key_", ",_", "value_", ",_", "profile_", "=_", "None_", ",_", "ttl_", "=_", "None_", ",_", "directory_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2014", ".7", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "a", " ", "key", " ", "in", " ", "etcd", " ", "by", " ", "direct", " ", "path", ".", " ", "Optio", "nal", "ly", ",", " ", "create", " ", "a", " ", "director", "y", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "set", " ", "a", " ", "TTL", " ", "on", " ", "the", " ", "key", ".", " ", " ", "Return", "s", " ", "Non", "e", " ", "on", " ", "fail", "ure", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "set", " ", "/", "path", "/", "to", "/", "key", " ", "value", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "set", " ", "/", "path", "/", "to", "/", "key", " ", "value", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "set", " ", "/", "path", "/", "to", "/", "dir", " ", "''", " ", "director", "y", "=", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "set", " ", "/", "path", "/", "to", "/", "key", " ", "value", " ", "ttl", "=", "5", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "set_", "(_", "key_", ",_", "value_", ",_", "ttl_", "=_", "ttl_", ",_", "directory_", "=_", "directory_", ")_", "\\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_", "update_", "(_", "fields_", ",_", "path_", "=_", "''_", ",_", "profile_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2016", ".3", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Set", "s", " ", "a", " ", "dictionar", "y", " ", "of", " ", "values", " ", "in", " ", "one", " ", "call", ".", " ", " ", "Us", "efu", "l", " ", "for", " ", "large", " ", "update", "s", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "syn", "dic", " ", "environ", "ment", "s", ".", " ", " ", "The", " ", "dictionar", "y", " ", "can", " ", "contain", " ", "a", " ", "mix", " ", "of", " ", "formats", "\\", "10", ";", " ", " ", " ", " ", "suc", "h", " ", "as", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", "'/", "some", "/", "example", "/", "key", "':", " ", "'", "bar", "',", "\\", "10", ";", " ", " ", "'/", "anot", "her", "/", "example", "/", "key", "':", " ", "'", "ba", "z", "'", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Or", " ", "it", " ", "may", " ", "be", " ", "a", " ", "straight", " ", "dictionar", "y", ",", " ", "whi", "ch", " ", "will", " ", "be", " ", "flattened", " ", "to", " ", "look", "\\", "10", ";", " ", " ", " ", " ", "like", " ", "the", " ", "above", " ", "format", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "'", "some", "':", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "'", "example", "':", " ", "{", "\\", "10", ";", " ", " ", "'", "key", "':", " ", "'", "bar", "'", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "},", "\\", "10", ";", " ", " ", " ", " ", "'", "anot", "her", "':", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "'", "example", "':", " ", "{", "\\", "10", ";", " ", " ", "'", "key", "':", " ", "'", "ba", "z", "'", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "You", " ", "can", " ", "even", " ", "mix", " ", "the", " ", "two", " ", "formats", " ", "and", " ", "it", " ", "will", " ", "be", " ", "flattened", " ", "to", " ", "the", " ", "first", "\\", "10", ";", " ", " ", " ", " ", "format", ".", " ", " ", "Lead", "ing", " ", "and", " ", "trail", "ing", " ", "'/'", " ", "will", " ", "be", " ", "remove", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Emp", "ty", " ", "director", "ies", " ", "can", " ", "be", " ", "created", " ", "by", " ", "setti", "ng", " ", "the", " ", "value", " ", "of", " ", "the", " ", "key", " ", "to", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "empty", " ", "dictionar", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "'", "path", "'", " ", "parameter", " ", "will", " ", "option", "ally", " ", "set", " ", "the", " ", "root", " ", "of", " ", "the", " ", "path", " ", "to", " ", "use", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "update", " ", "\"{", "'/", "path", "/", "to", "/", "key", "':", " ", "'", "ba", "z", "',", " ", "'/", "anot", "her", "/", "key", "':", " ", "'", "bar", "'}", "\"", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "update", " ", "\"{", "'/", "path", "/", "to", "/", "key", "':", " ", "'", "ba", "z", "',", " ", "'/", "anot", "her", "/", "key", "':", " ", "'", "bar", "'}", "\"", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "update", " ", "\"{", "'/", "path", "/", "to", "/", "key", "':", " ", "'", "ba", "z", "',", " ", "'/", "anot", "her", "/", "key", "':", " ", "'", "bar", "'}", "\"", " ", "path", "='", "/", "some", "/", "root", "'", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "update_", "(_", "fields_", ",_", "path_", ")_", "\\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_", "watch_", "(_", "key_", ",_", "recurse_", "=_", "False_", ",_", "profile_", "=_", "None_", ",_", "timeout_", "=_", "0_", ",_", "index_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2016", ".3", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Make", "s", " ", "a", " ", "best", " ", "effort", " ", "to", " ", "watch", " ", "for", " ", "a", " ", "key", " ", "or", " ", "tree", " ", "change", " ", "in", " ", "etcd", ".", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "dict", " ", "contain", "ing", " ", "the", " ", "new", " ", "key", " ", "value", " ", "(", " ", "or", " ", "Non", "e", " ", "if", " ", "the", " ", "key", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "delete", "d", " ", "),", " ", "the", " ", "modifi", "ed", "Index", " ", "of", " ", "the", " ", "key", ",", " ", "whe", "ther", " ", "the", " ", "key", " ", "change", "d", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "not", ",", " ", "the", " ", "path", " ", "to", " ", "the", " ", "key", " ", "tha", "t", " ", "change", "d", " ", "and", " ", "whe", "ther", " ", "it", " ", "is", " ", "a", " ", "director", "y", " ", "or", " ", "not", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "somet", "hing", " ", "cata", "stro", "phi", "c", " ", "happ", "ens", ",", " ", "return", "s", " ", "{}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "watch", " ", "/", "path", "/", "to", "/", "key", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "watch", " ", "/", "path", "/", "to", "/", "key", " ", "timeo", "ut", "=", "10", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "watch", " ", "/", "patch", "/", "to", "/", "key", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", " ", "index", "=", "10", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "watch_", "(_", "key_", ",_", "recurse_", "=_", "recurse_", ",_", "timeout_", "=_", "timeout_", ",_", "index_", "=_", "index_", ")_", "\\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_", "ls", "\\u_", "(_", "path_", "=_", "'/'_", ",_", "profile_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2014", ".7", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "all", " ", "keys", " ", "and", " ", "dirs", " ", "insi", "de", " ", "a", " ", "specific", " ", "path", ".", " ", "Return", "s", " ", "an", " ", "empty", " ", "dict", " ", "on", "\\", "10", ";", " ", " ", " ", " ", "fail", "ure", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "ls", " ", "/", "path", "/", "to", "/", "dir", "/", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "ls", " ", "/", "path", "/", "to", "/", "dir", "/", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "ls_", "(_", "path_", ")_", "\\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_", "rm", "\\u_", "(_", "key_", ",_", "recurse_", "=_", "False_", ",_", "profile_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2014", ".7", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Delete", " ", "a", " ", "key", " ", "from", " ", "etcd", ".", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "key", " ", "was", " ", "delete", "d", ",", " ", "Fal", "se", " ", "if", " ", "it", " ", "was", "n", "\\", "10", ";", " ", " ", " ", " ", "not", " ", "and", " ", "Non", "e", " ", "if", " ", "there", " ", "was", " ", "a", " ", "fail", "ure", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "rm", " ", "/", "path", "/", "to", "/", "key", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "rm", " ", "/", "path", "/", "to", "/", "key", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "rm", " ", "/", "path", "/", "to", "/", "dir", " ", "recurse", "=", "Tru", "e", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "rm_", "(_", "key_", ",_", "recurse_", "=_", "recurse_", ")_", "\\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_", "tree_", "(_", "path_", "=_", "'/'_", ",_", "profile_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "version", "adde", "d", "::", " ", "2014", ".7", ".0", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Recurs", "e", " ", "through", " ", "etcd", " ", "and", " ", "return", " ", "all", " ", "values", ".", " ", " ", "Return", "s", " ", "Non", "e", " ", "on", " ", "fail", "ure", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "CLI", " ", "Exam", "ple", ":", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "bash", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "tree", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "tree", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "salt", " ", "mym", "ini", "on", " ", "etcd", ".", "tree", " ", "/", "path", "/", "to", "/", "keys", " ", "profile", "=", "my", "\\u", "etcd", "\\u", "config", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u\\u", "util", "s\\u\\u_", "[_", "'", "etcd", "\\u", "util", ".", "get", "\\u", "conn", "'_", "]_", "(_", "\\u\\u", "opts", "\\u\\u_", ",_", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "client_", "._", "tree_", "(_", "path_", ")_" ]
[ 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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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, 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 ]
Unused local variable
apiaryio/api-blueprint-sublime-plugin/linter.py
[ { "content": "def ApiBlueprintFactory():\n \"\"\" Define API Blueprint Linter Class\"\"\"\n\n class ApiBlueprint(Linter):\n \"\"\"Provides an interface to apiblueprint.\"\"\"\n\n syntax = 'apiblueprint'\n cmd = 'drafter --validate'\n executable = 'drafter'\n executable = None\n regex = (\n r'(?:(?P<warning>warning)|(?P<error>error)):\\s*\\((?P<code>\\d+)\\)'\n r'(?P<message>.+?)(?::|$)'\n r'(?P<line>\\d+):(?P<col>\\d+)(?:.*)'\n )\n multiline = False\n line_col_base = (0, 0)\n tempfile_suffix = None\n error_stream = util.STREAM_BOTH\n selectors = {}\n word_re = None\n defaults = {}\n inline_settings = None\n inline_overrides = None\n comment_re = None\n\n def split_match(self, match):\n \"\"\"\n Run default match. If match is found, convert line variable to line number\n and adjust col.\n \"\"\"\n match, line, col, error, warning, message, near = super().split_match(match)\n\n if line is not None:\n line, col = self.view.rowcol((int(line)))\n line = int(line) - self.line_col_base[0]\n\n return match, line, col, error, warning, message, near", "metadata": "root.ApiBlueprintFactory", "header": "['module', '___EOS___']", "index": 15 } ]
[ { "span": "ApiBlueprint(", "start_line": 18, "start_column": 10, "end_line": 18, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Ap", "i", "Blue", "print", "Factory_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Define", " ", "API", " ", "Blue", "print", " ", "Lin", "ter", " ", "Class", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Ap", "i", "Blueprint_", "(_", "Lin", "ter_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Prov", "ides", " ", "an", " ", "interface", " ", "to", " ", "api", "blue", "print", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "syntax_", "=_", "'", "api", "blue", "print", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "'", "draft", "er", " ", "--", "validat", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "executable_", "=_", "'", "draft", "er", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "executable_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "regex_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "r", "'(?:", "(?", "P", "<", "warn", "ing", ">", "warn", "ing", ")|(", "?", "P", "<", "error", ">", "error", "))", ":\\\\", "s", "*\\\\", "((", "?", "P", "<", "code", ">\\\\", "d", "+)\\\\", ")'_", "\\u\\u\\uNL\\u\\u\\u_", "r", "'(", "?", "P", "<", "message", ">.+?)", "(?:", ":|", "$)", "'_", "\\u\\u\\uNL\\u\\u\\u_", "r", "'(", "?", "P", "<", "line", ">\\\\", "d", "+)", ":(?", "P", "<", "col", ">\\\\", "d", "+)(", "?:", ".*)", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "multiline", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "col", "\\u", "base_", "=_", "(_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tempfile", "\\u", "suffix_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error", "\\u", "stream_", "=_", "util_", "._", "STRE", "AM", "\\u", "BOTH_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selectors_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "word", "\\u", "re_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "defaults_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inline", "\\u", "settings_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inline", "\\u", "overrides_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment", "\\u", "re_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "split", "\\u", "match_", "(_", "self_", ",_", "match_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "default", " ", "match", ".", " ", " ", "If", " ", "match", " ", "is", " ", "found", ",", " ", "convert", " ", "line", " ", "variab", "le", " ", "to", " ", "line", " ", "number", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "adjust", " ", "col", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match_", ",_", "line_", ",_", "col_", ",_", "error_", ",_", "warning_", ",_", "message_", ",_", "near_", "=_", "super_", "(_", ")_", "._", "split", "\\u", "match_", "(_", "match_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "line_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", ",_", "col_", "=_", "self_", "._", "view_", "._", "rowco", "l_", "(_", "(_", "int_", "(_", "line_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "=_", "int_", "(_", "line_", ")_", "-_", "self_", "._", "line", "\\u", "col", "\\u", "base_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "match_", ",_", "line_", ",_", "col_", ",_", "error_", ",_", "warning_", ",_", "message_", ",_", "near_", "\\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, 0, 1, 1, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
redapple/parslepy/tests/tools.py
[ { "content": "# borrowed from python-github2/tests/test_request.py\ntry:\n from nose.tools import assert_dict_equal\nexcept ImportError: # for Python < 2.7\n try:\n import unittest2\n _binding = unittest2.TestCase('run')\n assert_dict_equal = _binding.assertDictEqual\n assert_is_instance = _binding.assertIsInstance\n assert_tuple_equal = _binding.assertTupleEqual\n except:\n raise\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from nose.tools import assert_dict_equal", "start_line": 2, "start_column": 4, "end_line": 2, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "borrow", "ed", " ", "from", " ", "python", "-", "git", "hub", "2", "/", "tests", "/", "test\\u", "request", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "nose_", "._", "tools_", "import_", "assert", "\\u", "dict", "\\u", "equal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "#", " ", "for", " ", "Pyth", "on", " ", "<", " ", "2.7", "_", "\\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_", "unittest2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "binding_", "=_", "unittest2_", "._", "Test", "Case_", "(_", "'", "run", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "dict", "\\u", "equal_", "=_", "\\u", "binding_", "._", "assert", "Dict", "Equal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "is", "\\u", "instance_", "=_", "\\u", "binding_", "._", "assert", "Is", "Instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "tuple", "\\u", "equal_", "=_", "\\u", "binding_", "._", "assert", "Tup", "le", "Equal_", "\\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 ", " _", "raise_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]